ePages 7.23.0 - DE_EPAGES/Core/API/Git.pm

Package DE_EPAGES::Core::API::Git

This module provides Git commands.

Example
my $Git = DE_EPAGES::Core::API::Git->new();
$Git->CloneRepository($RepoUrl);
@EXPORT_OK
CloneRepository
GetPatchCartridge
GitExportRepo
Add
Commit
Checkout
CreateBranch
ExistsRemoteBranch
ExistsLocalBranch
Merge
Push
MapGitToPath
ProjectUpdates4GitFingerprint

Functions

Add
Checkout
CloneRepository
Commit
CreateBranch
ExistsLocalBranch
ExistsRemoteBranch
GetCommitId
GetPatchCartridge
GitExportRepo
MapGitToPath
Merge
ProjectUpdates4GitFingerprint
Push
Remove
new

Add

Add a file or directory for the next commit.

Syntax
$self->Add($FileOrDirectory);
Input
$FileOrDirectory (string)
file or directory to add for commit
$aArguments (ref.array.string)
git add arguments

Checkout

Checkout a branch.

Syntax
$self->Checkout($Branch, $aArguments);
Input
$Branch (string)
name of the branch
$aArguments (ref.array.string)
git checkout arguments

CloneRepository

Clone a Git Repository.

Syntax
$self->CloneRepository($RepoUrl, $TargetDir, $aArguments);
Input
$RepoUrl (string)
url of a GitHub repository
$TargetDir (string)
target directory to clone files to
$aArguments (ref.array.string)
git clone arguments

Commit

Commit changes to current branch.

Syntax
$self->Commit($CommitString, $aArguments);
Input
$CommitString (string)
commit message
$aArguments (ref.array.string)
git commit arguments,
e.g. '-a' to directly add and commit a modified file

CreateBranch

Create a branch.

Syntax
$self->CreateBranch($Branch, $aArguments);
Input
$Branch (string)
name of the branch
$aArguments (ref.array.string)
git checkout arguments

ExistsLocalBranch

Check if a branch already exists local.

Syntax
$self->ExistsLocalBranch($Branch);
Input
$Branch (string)
name of the branch
Return
(bool)
1, if branch already exists local, 0 otherwise

ExistsRemoteBranch

Check if a branch already exists on remote.

Syntax
$self->ExistsRemoteBranch($Branch);
Input
$Branch (string)
name of the branch
Return
(bool)
1, if branch already exists on remote, 0 otherwise

GetCommitId

Get the commit ID (SHA-1) of given commit (i.e. HEAD). Based on the git command rev-parse.

Syntax
$self->GetCommitId($Commit, $aArguments);
Input
$Commit (string)
tag to identify a commit (i.e 'HEAD')
$aArguments (ref.array.string)
git rev-parse arguments (i.e. '--short')

GetPatchCartridge

Get an extracted archive of the Cartridge repository (or specified Cartridge) for specified tag/branch.

Syntax
$self->GetPatchCartridge($Tag, $TargetDir);
Input
$Version (string)
version to create tmp folder in Patches/PatchTemp/release_$Version
$BranchOrTag (string)
branch to get latest commit point or specified tag point from
$CartridgePath (string)
path to cartridge, e.g. /srv/epages/eproot/Cartridges/FlexProvider
$TargetDir (string)
target directory to extract files to

GitExportRepo

Get an extracted archive of the Cartridge repository (or specified Cartridge) for specified tag/branch.

Syntax
$self->GitExportRepo($BranchOrTag, $RepoTarget, $TargetDir, $TarFile, $CartridgePath);
Input
$BranchOrTag (string)
branch to get latest commit point or specified tag point from
$RepoSource (string)
folder where your .git folder is. Files will be exported from here.
$TargetDir (string)
target directory to extract files to
$TarFile (string)
name of the tar file
$CartridgePath (string)
path to cartridge, e.g. /srv/epages/eproot/Cartridges/FlexProvider

MapGitToPath

Returns hash with absolute paths in file system as key and role as value for $File in $GitRepo. $GitRepo must be one of following repositories:

Syntax
$PathList = MapGitToPath($GitRepo, $File)
Example
{'/srv/epages/eproot/Cartridges/Cartridges.xml' => 'local'} = MapGitToPath('ePages-de/Cartridges', 'Cartridges.xml')
Input
$GitRepo (string)
GIT repository
$File (string)
file in GIT repository
Return
$PathList (ref.hash)
hash with absolute paths as key and role as value, role is one of:
  • common
  • apache
  • appsrv
  • ascsrv
  • reqsrv
  • unity
  • am-yum

Merge

Merge changes from $FeatureBranch to $MergeBranch.

Syntax
$self->Merge($MergeBranch, $FeatureBranch, $aArguments);
Input
$MergeBranch (string)
name of the branch to merge into
$FeatureBranch (string)
name of the branch to merge from
$aArguments (ref.array.string)
git merge arguments

ProjectUpdates4GitFingerprint

Changes hash $Fingerprint according to $System, $Roles, $Node, $Dir in $Branch of $GitRepo.

Syntax
ProjectUpdates4GitFingerprint($GitRepo, $Branch, $Fingerprint, $System, $Roles, $Node, $Dir)
Example
ProjectUpdates4GitFingerprint($GitRepo, \%Fingerprint, 'live', [qw(common appsrv)],
                              'my.host.com', "~/my-git/repo");
Input
$GitRepo (ref.object)
Git repository object
$Branch (string)
Git branch like 'origin/release/7.11.0'
$Fingerprint (ref.hash)
hash to change
$Node (ref.hash)
hash with keys host, roles and system
$Dir (string)
Git directory containing .git
$Quiet (boolean)
no output if set

Push

Push current changes (file or directory) to remote.

Syntax
$self->Push($Remote, $aArguments);
Input
$Remote (string)
remote the changes will be pushed to
$Branch (string)
branch to be pushed
$aArguments (ref.array.string)
git push arguments

Remove

Remove a file or directory for the next commit.

Syntax
$self->Remove($FileOrDirectory);
Input
$FileOrDirectory (string)
file or directory to remove for commit
$aArguments (ref.array.string)
git rm arguments

new

Create a Git object.

Syntax
$Git = DE_EPAGES::Core::API::Git->new($hOptions);
Return
$Git (object)
Git object