public class GitOperations extends Object
Constructor and Description |
---|
GitOperations() |
Modifier and Type | Method and Description |
---|---|
org.eclipse.jgit.revwalk.RevCommit |
addAndCommit(org.eclipse.jgit.api.Git git,
String message)
Add all files and commit them with given message.
|
org.eclipse.jgit.revwalk.RevCommit |
addAndCommit(org.eclipse.jgit.api.Git git,
String message,
String author,
String email)
Add all files and commit them with given message.
|
org.eclipse.jgit.lib.Ref |
checkoutBranch(org.eclipse.jgit.api.Git git,
String branch)
Checkout existing branch.
|
org.eclipse.jgit.lib.Ref |
checkoutBranch(org.eclipse.jgit.api.Git git,
String branch,
String remote)
Checkout existing branch.
|
org.eclipse.jgit.lib.Ref |
checkoutTag(org.eclipse.jgit.api.Git git,
String tag)
Checkout existing tag.
|
org.eclipse.jgit.api.Git |
cloneRepository(String remoteUrl,
Path localPath)
Clones a public remote git repository.
|
org.eclipse.jgit.api.Git |
cloneRepository(String remoteUrl,
Path localPath,
String passphrase,
Path privateKey)
Clones a private remote git repository.
|
org.eclipse.jgit.api.Git |
cloneRepository(String remoteUrl,
Path localPath,
String username,
String password)
Clones a private remote git repository.
|
org.eclipse.jgit.lib.Ref |
createBranchAndCheckout(org.eclipse.jgit.api.Git git,
String branch)
Executes a checkout -b command using given branch.
|
org.eclipse.jgit.lib.Ref |
createTag(org.eclipse.jgit.api.Git git,
String name)
Creates a tag.
|
boolean |
hasAtLeastOneReference(org.eclipse.jgit.lib.Repository repo)
Checks if a repo has been cloned correctly.
|
boolean |
isLocalBranch(org.eclipse.jgit.api.Git git,
String branch)
Checks if given branch has been checkedout locally too.
|
boolean |
isRemoteBranch(org.eclipse.jgit.api.Git git,
String branch,
String remote)
Checks if given branch is remote.
|
boolean |
isValidGitRepository(Path folder)
Checks if given folder is a git repository
|
org.eclipse.jgit.api.Git |
openGitRepository(Path path)
Opens local git repository.
|
org.eclipse.jgit.api.PullResult |
pullFromRepository(org.eclipse.jgit.api.Git git,
String remote,
String remoteBranch)
Pull repository from current branch and remote branch with same name as current
|
org.eclipse.jgit.api.PullResult |
pullFromRepository(org.eclipse.jgit.api.Git git,
String remote,
String remoteBranch,
String passphrase,
Path privateKey)
Pull repository from current branch and remote branch with same name as current
|
org.eclipse.jgit.api.PullResult |
pullFromRepository(org.eclipse.jgit.api.Git git,
String remote,
String remoteBranch,
String username,
String password)
Pull repository from current branch and remote branch with same name as current
|
Iterable<org.eclipse.jgit.transport.PushResult> |
pushToRepository(org.eclipse.jgit.api.Git git,
String remote)
Push all changes and tags to given remote.
|
Iterable<org.eclipse.jgit.transport.PushResult> |
pushToRepository(org.eclipse.jgit.api.Git git,
String remote,
String passphrase,
Path privateKey)
Push all changes and tags to given remote.
|
Iterable<org.eclipse.jgit.transport.PushResult> |
pushToRepository(org.eclipse.jgit.api.Git git,
String remote,
String username,
String password)
Push all changes and tags to given remote.
|
public boolean isValidGitRepository(Path folder)
folder
- to checkpublic org.eclipse.jgit.api.Git openGitRepository(Path path) throws IOException
path
- of git repositoryIOException
public org.eclipse.jgit.lib.Ref checkoutTag(org.eclipse.jgit.api.Git git, String tag)
git
- instance.tag
- to movepublic boolean isLocalBranch(org.eclipse.jgit.api.Git git, String branch)
git
- instance.branch
- to check.public boolean isRemoteBranch(org.eclipse.jgit.api.Git git, String branch, String remote)
git
- instance.branch
- to check.remote
- name.public org.eclipse.jgit.lib.Ref checkoutBranch(org.eclipse.jgit.api.Git git, String branch)
git
- instance.branch
- to movepublic org.eclipse.jgit.lib.Ref checkoutBranch(org.eclipse.jgit.api.Git git, String branch, String remote)
git
- instance.branch
- to moveremote
- repository namepublic org.eclipse.jgit.lib.Ref createBranchAndCheckout(org.eclipse.jgit.api.Git git, String branch)
git
- instance.branch
- to create and checkout.public org.eclipse.jgit.revwalk.RevCommit addAndCommit(org.eclipse.jgit.api.Git git, String message)
git
- instance.message
- of the commit.public org.eclipse.jgit.revwalk.RevCommit addAndCommit(org.eclipse.jgit.api.Git git, String message, String author, String email)
git
- instance.message
- of the commit.author
- of the commit.email
- of author of the commit.public org.eclipse.jgit.api.PullResult pullFromRepository(org.eclipse.jgit.api.Git git, String remote, String remoteBranch)
git
- instance.remote
- to be used.remoteBranch
- to use.public Iterable<org.eclipse.jgit.transport.PushResult> pushToRepository(org.eclipse.jgit.api.Git git, String remote)
git
- instance.remote
- to be used.public Iterable<org.eclipse.jgit.transport.PushResult> pushToRepository(org.eclipse.jgit.api.Git git, String remote, String username, String password)
git
- instance.remote
- to be used.username
- to login.password
- to login.public org.eclipse.jgit.lib.Ref createTag(org.eclipse.jgit.api.Git git, String name)
git
- instance.name
- of the tag.public Iterable<org.eclipse.jgit.transport.PushResult> pushToRepository(org.eclipse.jgit.api.Git git, String remote, String passphrase, Path privateKey)
git
- instance.remote
- to be used.passphrase
- to access private key.privateKey
- file location.public org.eclipse.jgit.api.PullResult pullFromRepository(org.eclipse.jgit.api.Git git, String remote, String remoteBranch, String username, String password)
git
- instance.remote
- to be used.remoteBranch
- to use.username
- to connectpassword
- to connectpublic org.eclipse.jgit.api.PullResult pullFromRepository(org.eclipse.jgit.api.Git git, String remote, String remoteBranch, String passphrase, Path privateKey)
git
- instance.remote
- to be used.remoteBranch
- to use.passphrase
- to access private key.privateKey
- file location.public org.eclipse.jgit.api.Git cloneRepository(String remoteUrl, Path localPath)
remoteUrl
- to connect.localPath
- where to clone the repo.public org.eclipse.jgit.api.Git cloneRepository(String remoteUrl, Path localPath, String username, String password)
remoteUrl
- to connect.localPath
- where to clone the repo.username
- to connectpassword
- to connectpublic org.eclipse.jgit.api.Git cloneRepository(String remoteUrl, Path localPath, String passphrase, Path privateKey)
remoteUrl
- to connect.localPath
- where to clone the repo.passphrase
- to access private key.privateKey
- file location. If null default (~.ssh/id_rsa) location is used.public boolean hasAtLeastOneReference(org.eclipse.jgit.lib.Repository repo)
repo
- to checkCopyright © 2017 JBoss by Red Hat. All rights reserved.