{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
{-# OPTIONS_GHC -fno-warn-unused-matches #-}

-- Derived from AWS service descriptions, licensed under Apache 2.0.

-- |
-- Module      : Amazonka.CodeCommit.Types.Commit
-- Copyright   : (c) 2013-2021 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay <brendan.g.hay+amazonka@gmail.com>
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.CodeCommit.Types.Commit where

import Amazonka.CodeCommit.Types.UserInfo
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Returns information about a specific commit.
--
-- /See:/ 'newCommit' smart constructor.
data Commit = Commit'
  { -- | The full SHA ID of the specified commit.
    Commit -> Maybe Text
commitId :: Prelude.Maybe Prelude.Text,
    -- | Information about the person who committed the specified commit, also
    -- known as the committer. Information includes the date in timestamp
    -- format with GMT offset, the name of the committer, and the email address
    -- for the committer, as configured in Git.
    --
    -- For more information about the difference between an author and a
    -- committer in Git, see
    -- <http://git-scm.com/book/ch2-3.html Viewing the Commit History> in Pro
    -- Git by Scott Chacon and Ben Straub.
    Commit -> Maybe UserInfo
committer :: Prelude.Maybe UserInfo,
    -- | Tree information for the specified commit.
    Commit -> Maybe Text
treeId :: Prelude.Maybe Prelude.Text,
    -- | Any other data associated with the specified commit.
    Commit -> Maybe Text
additionalData :: Prelude.Maybe Prelude.Text,
    -- | A list of parent commits for the specified commit. Each parent commit ID
    -- is the full commit ID.
    Commit -> Maybe [Text]
parents :: Prelude.Maybe [Prelude.Text],
    -- | Information about the author of the specified commit. Information
    -- includes the date in timestamp format with GMT offset, the name of the
    -- author, and the email address for the author, as configured in Git.
    Commit -> Maybe UserInfo
author :: Prelude.Maybe UserInfo,
    -- | The commit message associated with the specified commit.
    Commit -> Maybe Text
message :: Prelude.Maybe Prelude.Text
  }
  deriving (Commit -> Commit -> Bool
(Commit -> Commit -> Bool)
-> (Commit -> Commit -> Bool) -> Eq Commit
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Commit -> Commit -> Bool
$c/= :: Commit -> Commit -> Bool
== :: Commit -> Commit -> Bool
$c== :: Commit -> Commit -> Bool
Prelude.Eq, ReadPrec [Commit]
ReadPrec Commit
Int -> ReadS Commit
ReadS [Commit]
(Int -> ReadS Commit)
-> ReadS [Commit]
-> ReadPrec Commit
-> ReadPrec [Commit]
-> Read Commit
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Commit]
$creadListPrec :: ReadPrec [Commit]
readPrec :: ReadPrec Commit
$creadPrec :: ReadPrec Commit
readList :: ReadS [Commit]
$creadList :: ReadS [Commit]
readsPrec :: Int -> ReadS Commit
$creadsPrec :: Int -> ReadS Commit
Prelude.Read, Int -> Commit -> ShowS
[Commit] -> ShowS
Commit -> String
(Int -> Commit -> ShowS)
-> (Commit -> String) -> ([Commit] -> ShowS) -> Show Commit
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Commit] -> ShowS
$cshowList :: [Commit] -> ShowS
show :: Commit -> String
$cshow :: Commit -> String
showsPrec :: Int -> Commit -> ShowS
$cshowsPrec :: Int -> Commit -> ShowS
Prelude.Show, (forall x. Commit -> Rep Commit x)
-> (forall x. Rep Commit x -> Commit) -> Generic Commit
forall x. Rep Commit x -> Commit
forall x. Commit -> Rep Commit x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Commit x -> Commit
$cfrom :: forall x. Commit -> Rep Commit x
Prelude.Generic)

-- |
-- Create a value of 'Commit' with all optional fields omitted.
--
-- Use <https://hackage.haskell.org/package/generic-lens generic-lens> or <https://hackage.haskell.org/package/optics optics> to modify other optional fields.
--
-- The following record fields are available, with the corresponding lenses provided
-- for backwards compatibility:
--
-- 'commitId', 'commit_commitId' - The full SHA ID of the specified commit.
--
-- 'committer', 'commit_committer' - Information about the person who committed the specified commit, also
-- known as the committer. Information includes the date in timestamp
-- format with GMT offset, the name of the committer, and the email address
-- for the committer, as configured in Git.
--
-- For more information about the difference between an author and a
-- committer in Git, see
-- <http://git-scm.com/book/ch2-3.html Viewing the Commit History> in Pro
-- Git by Scott Chacon and Ben Straub.
--
-- 'treeId', 'commit_treeId' - Tree information for the specified commit.
--
-- 'additionalData', 'commit_additionalData' - Any other data associated with the specified commit.
--
-- 'parents', 'commit_parents' - A list of parent commits for the specified commit. Each parent commit ID
-- is the full commit ID.
--
-- 'author', 'commit_author' - Information about the author of the specified commit. Information
-- includes the date in timestamp format with GMT offset, the name of the
-- author, and the email address for the author, as configured in Git.
--
-- 'message', 'commit_message' - The commit message associated with the specified commit.
newCommit ::
  Commit
newCommit :: Commit
newCommit =
  Commit' :: Maybe Text
-> Maybe UserInfo
-> Maybe Text
-> Maybe Text
-> Maybe [Text]
-> Maybe UserInfo
-> Maybe Text
-> Commit
Commit'
    { $sel:commitId:Commit' :: Maybe Text
commitId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:committer:Commit' :: Maybe UserInfo
committer = Maybe UserInfo
forall a. Maybe a
Prelude.Nothing,
      $sel:treeId:Commit' :: Maybe Text
treeId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:additionalData:Commit' :: Maybe Text
additionalData = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:parents:Commit' :: Maybe [Text]
parents = Maybe [Text]
forall a. Maybe a
Prelude.Nothing,
      $sel:author:Commit' :: Maybe UserInfo
author = Maybe UserInfo
forall a. Maybe a
Prelude.Nothing,
      $sel:message:Commit' :: Maybe Text
message = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The full SHA ID of the specified commit.
commit_commitId :: Lens.Lens' Commit (Prelude.Maybe Prelude.Text)
commit_commitId :: (Maybe Text -> f (Maybe Text)) -> Commit -> f Commit
commit_commitId = (Commit -> Maybe Text)
-> (Commit -> Maybe Text -> Commit)
-> Lens Commit Commit (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Commit' {Maybe Text
commitId :: Maybe Text
$sel:commitId:Commit' :: Commit -> Maybe Text
commitId} -> Maybe Text
commitId) (\s :: Commit
s@Commit' {} Maybe Text
a -> Commit
s {$sel:commitId:Commit' :: Maybe Text
commitId = Maybe Text
a} :: Commit)

-- | Information about the person who committed the specified commit, also
-- known as the committer. Information includes the date in timestamp
-- format with GMT offset, the name of the committer, and the email address
-- for the committer, as configured in Git.
--
-- For more information about the difference between an author and a
-- committer in Git, see
-- <http://git-scm.com/book/ch2-3.html Viewing the Commit History> in Pro
-- Git by Scott Chacon and Ben Straub.
commit_committer :: Lens.Lens' Commit (Prelude.Maybe UserInfo)
commit_committer :: (Maybe UserInfo -> f (Maybe UserInfo)) -> Commit -> f Commit
commit_committer = (Commit -> Maybe UserInfo)
-> (Commit -> Maybe UserInfo -> Commit)
-> Lens Commit Commit (Maybe UserInfo) (Maybe UserInfo)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Commit' {Maybe UserInfo
committer :: Maybe UserInfo
$sel:committer:Commit' :: Commit -> Maybe UserInfo
committer} -> Maybe UserInfo
committer) (\s :: Commit
s@Commit' {} Maybe UserInfo
a -> Commit
s {$sel:committer:Commit' :: Maybe UserInfo
committer = Maybe UserInfo
a} :: Commit)

-- | Tree information for the specified commit.
commit_treeId :: Lens.Lens' Commit (Prelude.Maybe Prelude.Text)
commit_treeId :: (Maybe Text -> f (Maybe Text)) -> Commit -> f Commit
commit_treeId = (Commit -> Maybe Text)
-> (Commit -> Maybe Text -> Commit)
-> Lens Commit Commit (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Commit' {Maybe Text
treeId :: Maybe Text
$sel:treeId:Commit' :: Commit -> Maybe Text
treeId} -> Maybe Text
treeId) (\s :: Commit
s@Commit' {} Maybe Text
a -> Commit
s {$sel:treeId:Commit' :: Maybe Text
treeId = Maybe Text
a} :: Commit)

-- | Any other data associated with the specified commit.
commit_additionalData :: Lens.Lens' Commit (Prelude.Maybe Prelude.Text)
commit_additionalData :: (Maybe Text -> f (Maybe Text)) -> Commit -> f Commit
commit_additionalData = (Commit -> Maybe Text)
-> (Commit -> Maybe Text -> Commit)
-> Lens Commit Commit (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Commit' {Maybe Text
additionalData :: Maybe Text
$sel:additionalData:Commit' :: Commit -> Maybe Text
additionalData} -> Maybe Text
additionalData) (\s :: Commit
s@Commit' {} Maybe Text
a -> Commit
s {$sel:additionalData:Commit' :: Maybe Text
additionalData = Maybe Text
a} :: Commit)

-- | A list of parent commits for the specified commit. Each parent commit ID
-- is the full commit ID.
commit_parents :: Lens.Lens' Commit (Prelude.Maybe [Prelude.Text])
commit_parents :: (Maybe [Text] -> f (Maybe [Text])) -> Commit -> f Commit
commit_parents = (Commit -> Maybe [Text])
-> (Commit -> Maybe [Text] -> Commit)
-> Lens Commit Commit (Maybe [Text]) (Maybe [Text])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Commit' {Maybe [Text]
parents :: Maybe [Text]
$sel:parents:Commit' :: Commit -> Maybe [Text]
parents} -> Maybe [Text]
parents) (\s :: Commit
s@Commit' {} Maybe [Text]
a -> Commit
s {$sel:parents:Commit' :: Maybe [Text]
parents = Maybe [Text]
a} :: Commit) ((Maybe [Text] -> f (Maybe [Text])) -> Commit -> f Commit)
-> ((Maybe [Text] -> f (Maybe [Text]))
    -> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> Commit
-> f Commit
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Text] [Text] [Text] [Text]
-> Iso (Maybe [Text]) (Maybe [Text]) (Maybe [Text]) (Maybe [Text])
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso [Text] [Text] [Text] [Text]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | Information about the author of the specified commit. Information
-- includes the date in timestamp format with GMT offset, the name of the
-- author, and the email address for the author, as configured in Git.
commit_author :: Lens.Lens' Commit (Prelude.Maybe UserInfo)
commit_author :: (Maybe UserInfo -> f (Maybe UserInfo)) -> Commit -> f Commit
commit_author = (Commit -> Maybe UserInfo)
-> (Commit -> Maybe UserInfo -> Commit)
-> Lens Commit Commit (Maybe UserInfo) (Maybe UserInfo)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Commit' {Maybe UserInfo
author :: Maybe UserInfo
$sel:author:Commit' :: Commit -> Maybe UserInfo
author} -> Maybe UserInfo
author) (\s :: Commit
s@Commit' {} Maybe UserInfo
a -> Commit
s {$sel:author:Commit' :: Maybe UserInfo
author = Maybe UserInfo
a} :: Commit)

-- | The commit message associated with the specified commit.
commit_message :: Lens.Lens' Commit (Prelude.Maybe Prelude.Text)
commit_message :: (Maybe Text -> f (Maybe Text)) -> Commit -> f Commit
commit_message = (Commit -> Maybe Text)
-> (Commit -> Maybe Text -> Commit)
-> Lens Commit Commit (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Commit' {Maybe Text
message :: Maybe Text
$sel:message:Commit' :: Commit -> Maybe Text
message} -> Maybe Text
message) (\s :: Commit
s@Commit' {} Maybe Text
a -> Commit
s {$sel:message:Commit' :: Maybe Text
message = Maybe Text
a} :: Commit)

instance Core.FromJSON Commit where
  parseJSON :: Value -> Parser Commit
parseJSON =
    String -> (Object -> Parser Commit) -> Value -> Parser Commit
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"Commit"
      ( \Object
x ->
          Maybe Text
-> Maybe UserInfo
-> Maybe Text
-> Maybe Text
-> Maybe [Text]
-> Maybe UserInfo
-> Maybe Text
-> Commit
Commit'
            (Maybe Text
 -> Maybe UserInfo
 -> Maybe Text
 -> Maybe Text
 -> Maybe [Text]
 -> Maybe UserInfo
 -> Maybe Text
 -> Commit)
-> Parser (Maybe Text)
-> Parser
     (Maybe UserInfo
      -> Maybe Text
      -> Maybe Text
      -> Maybe [Text]
      -> Maybe UserInfo
      -> Maybe Text
      -> Commit)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"commitId")
            Parser
  (Maybe UserInfo
   -> Maybe Text
   -> Maybe Text
   -> Maybe [Text]
   -> Maybe UserInfo
   -> Maybe Text
   -> Commit)
-> Parser (Maybe UserInfo)
-> Parser
     (Maybe Text
      -> Maybe Text
      -> Maybe [Text]
      -> Maybe UserInfo
      -> Maybe Text
      -> Commit)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe UserInfo)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"committer")
            Parser
  (Maybe Text
   -> Maybe Text
   -> Maybe [Text]
   -> Maybe UserInfo
   -> Maybe Text
   -> Commit)
-> Parser (Maybe Text)
-> Parser
     (Maybe Text
      -> Maybe [Text] -> Maybe UserInfo -> Maybe Text -> Commit)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"treeId")
            Parser
  (Maybe Text
   -> Maybe [Text] -> Maybe UserInfo -> Maybe Text -> Commit)
-> Parser (Maybe Text)
-> Parser (Maybe [Text] -> Maybe UserInfo -> Maybe Text -> Commit)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"additionalData")
            Parser (Maybe [Text] -> Maybe UserInfo -> Maybe Text -> Commit)
-> Parser (Maybe [Text])
-> Parser (Maybe UserInfo -> Maybe Text -> Commit)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe (Maybe [Text]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"parents" Parser (Maybe (Maybe [Text]))
-> Maybe [Text] -> Parser (Maybe [Text])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [Text]
forall a. Monoid a => a
Prelude.mempty)
            Parser (Maybe UserInfo -> Maybe Text -> Commit)
-> Parser (Maybe UserInfo) -> Parser (Maybe Text -> Commit)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe UserInfo)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"author")
            Parser (Maybe Text -> Commit)
-> Parser (Maybe Text) -> Parser Commit
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"message")
      )

instance Prelude.Hashable Commit

instance Prelude.NFData Commit