public class GitFacade extends GitFacadeSupport
| Constructor and Description |
|---|
GitFacade() |
| Modifier and Type | Method and Description |
|---|---|
List<String> |
branches()
Returns all the branch names we can use in the local repo
|
protected void |
checkoutBranch(org.eclipse.jgit.api.Git git,
String branch) |
List<String> |
completePath(String branch,
String completionText,
boolean directoriesOnly)
Provides a file/path completion hook so we can start typing the name of a file or directory
|
protected void |
configureBranch(String branch) |
void |
createBranch(String fromBranch,
String newBranch)
Creates a new branch from the given branch
|
CommitInfo |
createDirectory(String branch,
String path,
String commitMessage,
String authorName,
String authorEmail)
Creates a new file if it doesn't already exist
|
String |
currentBranch() |
void |
destroy() |
String |
diff(String objectId,
String baseObjectId,
String path)
Performs a diff of the latest or a specifc version of the given blobPath
against either the previous or a given baseObjectId
|
protected void |
doPull() |
protected Iterable<org.eclipse.jgit.transport.PushResult> |
doPush(org.eclipse.jgit.api.Git git) |
FileInfo |
exists(String branch,
String pathOrEmpty)
Checks if the file exists and if so what its file metadata is.
|
static Date |
getCommitDate(org.eclipse.jgit.revwalk.RevCommit commit)
Retrieves a Java Date from a Git commit.
|
CommitInfo |
getCommitInfo(String commitId)
Returns details about the commit, such as its message etc
|
List<CommitTreeInfo> |
getCommitTree(String commitId)
Returns the commit tree for the given commit id
|
String |
getConfigDirName() |
String |
getContent(String objectId,
String blobPath)
Get the contents of a blobPath for a given commit objectId
|
org.eclipse.jgit.transport.CredentialsProvider |
getCredentials() |
String |
getDefaultBranch()
Defaults to the current branch on disk if not explicitly configured
|
String |
getDefaultGitAttributes() |
String |
getDefaultRemoteRepository() |
String |
getHEAD() |
String |
getInitialImportURLs() |
long |
getPullTimePeriod() |
String |
getRemote() |
String |
getRemoteRepository() |
File |
getRootGitDirectory() |
static GitFacade |
getSingleton() |
org.eclipse.jgit.lib.PersonIdent |
getStashPersonIdent() |
Timer |
getTimer() |
protected <T> T |
gitOperation(org.eclipse.jgit.lib.PersonIdent personIdent,
Callable<T> callable)
Performs the given operations on a clean git repository
|
List<CommitInfo> |
history(String branch,
String objectId,
String path,
int limit)
Return the history of the repository or a specific directory or file path
|
protected void |
importInitialContent(org.eclipse.jgit.api.Git git,
File rootFolder,
String branch)
When creating an empty initial git repository lets see if there are a list of URLs for zips
of content to include
|
void |
init() |
void |
initialiseGitRepo() |
boolean |
isCloneAllBranches() |
boolean |
isCloneRemoteRepoOnStartup() |
boolean |
isPullBeforeOperation() |
boolean |
isPullOnStartup() |
boolean |
isPushOnCommit() |
protected boolean |
localBranchExists(String branch) |
protected void |
logPull(String message) |
FileContents |
read(String branch,
String pathOrEmpty)
Reads the contents of a file or a directory
|
<T> T |
readFile(String branch,
String pathOrEmpty,
Function<File,T> callback) |
String |
readJsonChildContent(String branch,
String path,
String fileNameWildcardOrBlank,
String search)
Reads the child JSON file contents which match the given search string (if specified) and which match the given file name wildcard (using * to match any characters in the name).
|
void |
remove(String branch,
String path,
String commitMessage,
String authorName,
String authorEmail) |
void |
rename(String branch,
String oldPath,
String newPath,
String commitMessage,
String authorName,
String authorEmail)
Renames the given oldPath to the newPath location for the given branch, commit message and user
|
void |
revertTo(String branch,
String objectId,
String blobPath,
String commitMessage,
String authorName,
String authorEmail)
Reverts the file to a previous value
|
void |
setCloneAllBranches(boolean cloneAllBranches) |
void |
setCloneRemoteRepoOnStartup(boolean cloneRemoteRepoOnStartup) |
void |
setConfigDirectory(File configDirectory) |
void |
setConfigDirName(String configDirName) |
void |
setCredentials(org.eclipse.jgit.transport.CredentialsProvider credentials) |
void |
setDefaultBranch(String defaultBranch) |
void |
setDefaultGitAttributes(String defaultGitAttributes) |
void |
setDefaultRemoteRepository(String defaultRemoteRepository) |
void |
setInitialImportURLs(String initialImportURLs)
Sets the URLs which are used to import content in a newly created git repository
|
void |
setPullBeforeOperation(boolean pullBeforeOperation) |
void |
setPullOnStartup(boolean pullOnStartup) |
void |
setPullTimePeriod(long pullTimePeriod) |
void |
setPushOnCommit(boolean pushOnCommit) |
void |
setRemote(String remote) |
void |
setRemoteRepository(String remoteRepository) |
void |
setStashPersonIdent(org.eclipse.jgit.lib.PersonIdent stashPersonIdent) |
void |
setTimer(Timer timer) |
org.eclipse.jgit.api.Status |
status() |
static String |
trimLeadingSlash(String path) |
void |
uploadFile(String branch,
String path,
boolean unzip,
String sourceFileName,
String destName)
Uploads the given local file name to the given branch and path; unzipping any zips if the flag is true
|
void |
uploadFiles(String branch,
String path,
boolean unzip,
Map<String,File> uploadFiles)
Uploads a list of files to the given branch and path
|
CommitInfo |
write(String branch,
String path,
String commitMessage,
String authorName,
String authorEmail,
String contents) |
CommitInfo |
writeBase64(String branch,
String path,
String commitMessage,
String authorName,
String authorEmail,
String contentsBase64) |
<T> T |
writeFile(String branch,
String pathOrEmpty,
WriteCallback<T> callback) |
commitThenPush, createCommitInfo, defaultObjectId, doCompletePath, doCreateBranch, doCreateDirectory, doDiff, doExists, doExists, doGetCommitInfo, doGetCommitTree, doGetContent, doGetHead, doHistory, doListBranches, doRead, doReadFile, doReadJsonChildContent, doRemove, doRename, doRevert, doWrite, doWriteFile, getBranchObjectId, getDefaultObjectName, getFile, getFilePattern, getRepositoryLabel, getShortCommitHash, isIgnoreFile, removeLeadingSlash, setRepositoryLabel, toStringgetMBeanServer, getObjectName, setMBeanServer, setObjectNamepublic static GitFacade getSingleton()
public void init()
throws Exception
init in class MBeanSupportExceptionpublic void destroy()
throws Exception
destroy in class MBeanSupportExceptionpublic org.eclipse.jgit.lib.PersonIdent getStashPersonIdent()
public void setStashPersonIdent(org.eclipse.jgit.lib.PersonIdent stashPersonIdent)
public String getRemoteRepository()
public void setRemoteRepository(String remoteRepository)
public String getRemote()
public void setRemote(String remote)
public String getConfigDirName()
public void setConfigDirName(String configDirName)
public String getDefaultRemoteRepository()
public void setDefaultRemoteRepository(String defaultRemoteRepository)
public boolean isPullOnStartup()
public void setPullOnStartup(boolean pullOnStartup)
public boolean isCloneAllBranches()
public void setCloneAllBranches(boolean cloneAllBranches)
public boolean isPushOnCommit()
isPushOnCommit in class GitFacadeSupportpublic void setPushOnCommit(boolean pushOnCommit)
public boolean isPullBeforeOperation()
public void setPullBeforeOperation(boolean pullBeforeOperation)
public boolean isCloneRemoteRepoOnStartup()
public void setCloneRemoteRepoOnStartup(boolean cloneRemoteRepoOnStartup)
public org.eclipse.jgit.transport.CredentialsProvider getCredentials()
public void setCredentials(org.eclipse.jgit.transport.CredentialsProvider credentials)
public long getPullTimePeriod()
public void setPullTimePeriod(long pullTimePeriod)
public Timer getTimer()
public void setTimer(Timer timer)
public String getDefaultBranch()
public void setDefaultBranch(String defaultBranch)
public String getInitialImportURLs()
public void setInitialImportURLs(String initialImportURLs)
public String getContent(String objectId, String blobPath)
GitFacadeMXBeanpublic FileContents read(String branch, String pathOrEmpty) throws IOException, org.eclipse.jgit.api.errors.GitAPIException
GitFacadeMXBeanIOExceptionorg.eclipse.jgit.api.errors.GitAPIExceptionpublic <T> T readFile(String branch, String pathOrEmpty, Function<File,T> callback) throws IOException, org.eclipse.jgit.api.errors.GitAPIException
IOExceptionorg.eclipse.jgit.api.errors.GitAPIExceptionpublic <T> T writeFile(String branch, String pathOrEmpty, WriteCallback<T> callback) throws IOException, org.eclipse.jgit.api.errors.GitAPIException
IOExceptionorg.eclipse.jgit.api.errors.GitAPIExceptionpublic FileInfo exists(String branch, String pathOrEmpty) throws IOException, org.eclipse.jgit.api.errors.GitAPIException
GitFacadeMXBeanIOExceptionorg.eclipse.jgit.api.errors.GitAPIExceptionpublic List<String> completePath(String branch, String completionText, boolean directoriesOnly)
GitFacadeMXBeanpublic String readJsonChildContent(String branch, String path, String fileNameWildcardOrBlank, String search) throws IOException
GitFacadeMXBeanIOExceptionpublic CommitInfo writeBase64(String branch, String path, String commitMessage, String authorName, String authorEmail, String contentsBase64)
public CommitInfo write(String branch, String path, String commitMessage, String authorName, String authorEmail, String contents)
public CommitInfo createDirectory(String branch, String path, String commitMessage, String authorName, String authorEmail)
GitFacadeMXBeanpublic void createBranch(String fromBranch, String newBranch)
GitFacadeMXBeanpublic List<CommitTreeInfo> getCommitTree(String commitId)
GitFacadeMXBeanpublic CommitInfo getCommitInfo(String commitId)
GitFacadeMXBeanpublic void revertTo(String branch, String objectId, String blobPath, String commitMessage, String authorName, String authorEmail)
GitFacadeMXBeanpublic void rename(String branch, String oldPath, String newPath, String commitMessage, String authorName, String authorEmail)
GitFacadeMXBeanpublic void remove(String branch, String path, String commitMessage, String authorName, String authorEmail)
public List<String> branches()
GitFacadeMXBeanprotected Iterable<org.eclipse.jgit.transport.PushResult> doPush(org.eclipse.jgit.api.Git git) throws Exception
doPush in class GitFacadeSupportExceptionpublic String getHEAD()
public String getDefaultGitAttributes()
public void setDefaultGitAttributes(String defaultGitAttributes)
public List<CommitInfo> history(String branch, String objectId, String path, int limit)
GitFacadeMXBeanpublic static Date getCommitDate(org.eclipse.jgit.revwalk.RevCommit commit)
commit - the commitpublic String diff(String objectId, String baseObjectId, String path)
GitFacadeMXBeanpublic void uploadFile(String branch, String path, boolean unzip, String sourceFileName, String destName) throws IOException, org.eclipse.jgit.api.errors.GitAPIException
IOExceptionorg.eclipse.jgit.api.errors.GitAPIExceptionpublic void uploadFiles(String branch, String path, boolean unzip, Map<String,File> uploadFiles) throws IOException, org.eclipse.jgit.api.errors.GitAPIException
IOExceptionorg.eclipse.jgit.api.errors.GitAPIExceptionpublic File getRootGitDirectory()
public void setConfigDirectory(File configDirectory)
public void initialiseGitRepo()
throws IOException,
org.eclipse.jgit.api.errors.GitAPIException
IOExceptionorg.eclipse.jgit.api.errors.GitAPIExceptionprotected void importInitialContent(org.eclipse.jgit.api.Git git,
File rootFolder,
String branch)
git - branch - protected void doPull()
protected void logPull(String message)
public org.eclipse.jgit.api.Status status()
protected <T> T gitOperation(org.eclipse.jgit.lib.PersonIdent personIdent,
Callable<T> callable)
public String currentBranch()
protected void checkoutBranch(org.eclipse.jgit.api.Git git,
String branch)
throws org.eclipse.jgit.api.errors.GitAPIException
checkoutBranch in class GitFacadeSupportorg.eclipse.jgit.api.errors.GitAPIExceptionprotected void configureBranch(String branch)
protected boolean localBranchExists(String branch) throws org.eclipse.jgit.api.errors.GitAPIException
org.eclipse.jgit.api.errors.GitAPIExceptionCopyright © 2020 JBoss by Red Hat. All rights reserved.