public class JGitSource extends Object implements Source
Source
that gets file from a Git repository. There
are several ways of authenticating access to git.
setUserPassword(String, String)
or
setUserPassword(String)
to pass username and password to
the instance.setSshIdentity(String)
or
setSshIdentityFile(File)
setBuildInSshIdentityUsed(boolean)
with true or
setSshIdentity(String)
with buildin tells the
class to use the build-in private key. Beaware that since everyone can get
this build-in private key from Gitcon jar file, exposing your Git repo to
user gitconreader is equivalent to exposing it to public.Constructor and Description |
---|
JGitSource(String repoUri)
Constructor that uses a working directory under system temporary
directory
|
Modifier and Type | Method and Description |
---|---|
String |
getBranchOrCommmit() |
File |
initWorkingDirectory(File workingDirectory)
Get files from logical source into local working directory when
application starts
|
void |
setBranchOrCommit(String branch)
Caller sets branchOrCommit in order to checkout files from a non-default
branch or specified commit.
|
void |
setBuildInSshIdentityUsed(boolean buildInSshIdentityUsed)
Gitcon jar file comes with a build-in SSH private key for user
gitconreader in both Github and BitBucket.
|
void |
setSshIdentity(String privateKeyPath)
Use specified SSH private key for authentication
|
void |
setSshIdentityFile(File privateKeyFile)
An alternative of
setSshIdentity(String) that takes a
File instead of file path. |
void |
setUserPassword(String userAndPassword)
An alternative method of
setUserPassword(String, String) which
takes parameters from one single string |
void |
setUserPassword(String user,
String password)
Set user and password used to authenticate access to Git repository.
|
void |
updateWorkingDirectory(File workingDirectory)
Update local repository by running a git pull command
|
public JGitSource(String repoUri)
repoUri
- Git repository URIpublic String getBranchOrCommmit()
public File initWorkingDirectory(File workingDirectory) throws org.eclipse.jgit.api.errors.GitAPIException, IOException
Source
initWorkingDirectory
in interface Source
workingDirectory
- Local working directory, the root of local
repositorySource
may choose to download
remote files into a subdirectory under working directory, in
which case the subdirectory is returned.org.eclipse.jgit.api.errors.GitAPIException
IOException
public void setBranchOrCommit(String branch)
branch
- Branch or commit in Git repositorypublic void setBuildInSshIdentityUsed(boolean buildInSshIdentityUsed)
JGitSource
to use the build-in SSH key.buildInSshIdentityUsed
- True to use the build-in SSH priavate keypublic void setSshIdentity(String privateKeyPath)
privateKeyPath
- Path to SSH private key. However if value is
default, the default OS SSH key will be used. If
value is buildin, a build-in SSH private key, which
is registered for user gitconreader in Github and
BitBucket will be used.setBuildInSshIdentityUsed(boolean)
public void setSshIdentityFile(File privateKeyFile)
setSshIdentity(String)
that takes a
File
instead of file path.privateKeyFile
- SSH private key file objectpublic void setUserPassword(String userAndPassword)
setUserPassword(String, String)
which
takes parameters from one single stringuserAndPassword
- One string in form of <user>:<password>public void setUserPassword(String user, String password)
user
- Login user namepassword
- Login passwordpublic void updateWorkingDirectory(File workingDirectory) throws org.eclipse.jgit.api.errors.GitAPIException
updateWorkingDirectory
in interface Source
workingDirectory
- Local working directoryorg.eclipse.jgit.api.errors.GitAPIException
- Allows JGit exceptionsCopyright © 2009–2014. All rights reserved.