Class GitRepo
java.lang.Object
org.jenkinsci.test.acceptance.plugins.git.GitRepo
- All Implemented Interfaces:
Closeable
,AutoCloseable
Manipulates git repository locally.
- Author:
- Kohsuke Kawaguchi
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addFilesIn
(String sourceFolder) Copies all files of the specified folder to the root folder of this git repository and adds the copied files using 'git add.void
addFilesIn
(String sourceFolder, String destinationFolder) Copies all files of the specified directory to thedestinationFolder
of this git repository and adds the copied files using git add.void
addFilesIn
(URL sourceFolder) Copies all files of the specified folder to the root folder of this git repository and adds the copied files using 'git add.void
addFilesIn
(URL sourceFolder, Path destinationFolder) Copies all files of the specified directory to thedestinationFolder
of this git repository and adds the copied files using git add.addSubmodule
(String submoduleName) Add a submodule to the main repository.void
changeAndCommitFile
(String fileName, String fileContent, String message) Append the specified content at the end of the given file and commit the file.void
changeAndCommitFoo
(String message) Appends the string "more" to the file "foo", adds it to the repository and commits it.void
void
close()
void
Records all changes to the repository.void
createBranch
(String name) Creates the specified branch in this repository.Get sha1 hash of the most recent commit.Execute git command in specified directory.void
setIdentity
(String userName, String userMail) Sets the identity to be used when committing files.void
void
transferToDockerContainer
(String host, int port) Zip bare repository, copy to Docker container using sftp, then unzip.
-
Field Details
-
dir
-
-
Constructor Details
-
GitRepo
public GitRepo() -
GitRepo
Creates a new repo by cloning the given URL.
-
-
Method Details
-
setIdentity
Sets the identity to be used when committing files.- Parameters:
userName
- the name of the useruserMail
- the email of the user
-
git
-
gitDir
Execute git command in specified directory. -
changeAndCommitFile
Append the specified content at the end of the given file and commit the file.- Parameters:
fileName
- the name of the filefileContent
- the new content of the filemessage
- the commit message to ue
-
changeAndCommitFoo
Appends the string "more" to the file "foo", adds it to the repository and commits it.- Parameters:
message
- commit message
-
commit
Records all changes to the repository.- Parameters:
message
- commit message
-
touch
-
getLastSha1
Get sha1 hash of the most recent commit.- Returns:
- Hash value
-
checkout
-
close
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Throws:
IOException
-
addSubmodule
Add a submodule to the main repository.- Parameters:
submoduleName
- name of the submodule
-
transferToDockerContainer
Zip bare repository, copy to Docker container using sftp, then unzip. The repo is now accessible over "ssh://git@ip:port/home/git/gitRepo.git"- Parameters:
host
- IP of Docker containerport
- SSH port of Docker container
-
addFilesIn
Copies all files of the specified folder to the root folder of this git repository and adds the copied files using 'git add.- Parameters:
sourceFolder
- the folder with the files to copy
-
addFilesIn
Copies all files of the specified directory to thedestinationFolder
of this git repository and adds the copied files using git add.- Parameters:
sourceFolder
- the folder with the files to copydestinationFolder
- the destination folder for the copied files
-
addFilesIn
Copies all files of the specified folder to the root folder of this git repository and adds the copied files using 'git add.- Parameters:
sourceFolder
- the folder with the files to copy
-
addFilesIn
Copies all files of the specified directory to thedestinationFolder
of this git repository and adds the copied files using git add.- Parameters:
sourceFolder
- the folder with the files to copydestinationFolder
- the destination folder for the copied files
-
createBranch
Creates the specified branch in this repository.- Parameters:
name
- the name of the branch
-
mkdir
-