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
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddFilesIn(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.voidaddFilesIn(String sourceFolder, String destinationFolder) Copies all files of the specified directory to thedestinationFolderof this git repository and adds the copied files using git add.voidaddFilesIn(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.voidaddFilesIn(URL sourceFolder, Path destinationFolder) Copies all files of the specified directory to thedestinationFolderof this git repository and adds the copied files using git add.addSubmodule(String submoduleName) Add a submodule to the main repository.voidchangeAndCommitFile(String fileName, String fileContent, String message) Append the specified content at the end of the given file and commit the file.voidchangeAndCommitFoo(String message) Appends the string "more" to the file "foo", adds it to the repository and commits it.voidvoidclose()voidRecords all changes to the repository.voidcreateBranch(String name) Creates the specified branch in this repository.Get sha1 hash of the most recent commit.Execute git command in specified directory.voidsetIdentity(String userName, String userMail) Sets the identity to be used when committing files.voidvoidtransferToDockerContainer(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:
closein interfaceAutoCloseable- Specified by:
closein 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 thedestinationFolderof 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 thedestinationFolderof 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
-