Package org.jenkinsci.plugins.gitserver
Class FileBackedHttpGitRepository
- java.lang.Object
-
- org.jenkinsci.plugins.gitserver.HttpGitRepository
-
- org.jenkinsci.plugins.gitserver.FileBackedHttpGitRepository
-
public abstract class FileBackedHttpGitRepository extends HttpGitRepository
Convenient subtype ofHttpGitRepository
where the repository is non-bare, resides in a directory local to the controller, and you maintain the local up-to-date checkout whenever a change is pushed.- Author:
- Kohsuke Kawaguchi
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
FileBackedHttpGitRepository(File workspace)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract void
checkPushPermission()
Do something likeJenkins.getInstance().checkPermission(Jenkins.ADMINISTER)
to make sure the user has the permission to push.protected void
createInitialRepository(org.eclipse.jgit.lib.Repository r)
Called when there's no .git directory to create one.org.eclipse.jgit.transport.ReceivePack
createReceivePack(javax.servlet.http.HttpServletRequest context, org.eclipse.jgit.lib.Repository db)
Requires the admin access to be able to pushorg.eclipse.jgit.transport.ReceivePack
createReceivePack(org.eclipse.jgit.lib.Repository db)
org.eclipse.jgit.transport.UploadPack
createUploadPack(javax.servlet.http.HttpServletRequest context, org.eclipse.jgit.lib.Repository db)
This default implementation allows read access to anyone who can access the HTTP URL this repository is bound to.org.eclipse.jgit.lib.Repository
openRepository()
Opens the repository this UI-bound object holds on to.protected void
updateWorkspace(org.eclipse.jgit.lib.Repository repo)
Called when new ref is pushed to update the local workspace.-
Methods inherited from class org.jenkinsci.plugins.gitserver.HttpGitRepository
doDynamic, init
-
-
-
-
Field Detail
-
workspace
public final File workspace
Directory of the local workspace on the controller. There will be "./.git" that hosts the actual repository.
-
-
Constructor Detail
-
FileBackedHttpGitRepository
protected FileBackedHttpGitRepository(File workspace)
-
-
Method Detail
-
openRepository
public org.eclipse.jgit.lib.Repository openRepository() throws IOException
Description copied from class:HttpGitRepository
Opens the repository this UI-bound object holds on to.- Specified by:
openRepository
in classHttpGitRepository
- Throws:
IOException
-
createInitialRepository
protected void createInitialRepository(org.eclipse.jgit.lib.Repository r) throws IOException
Called when there's no .git directory to create one. This implementation also imports whatever currently in there into the repository.- Throws:
IOException
-
createUploadPack
public org.eclipse.jgit.transport.UploadPack createUploadPack(javax.servlet.http.HttpServletRequest context, org.eclipse.jgit.lib.Repository db) throws org.eclipse.jgit.transport.resolver.ServiceNotEnabledException, org.eclipse.jgit.transport.resolver.ServiceNotAuthorizedException
This default implementation allows read access to anyone who can access the HTTP URL this repository is bound to. For example, if this object is used as a project action, and the project isn't readable to Alice, then Alice won't be able to pull from this repository (think of a POSIX file system where /foo/bar is rwx------ and /foo/bar/zot is rwxrwxrwx.)- Specified by:
createUploadPack
in classHttpGitRepository
- Throws:
org.eclipse.jgit.transport.resolver.ServiceNotEnabledException
org.eclipse.jgit.transport.resolver.ServiceNotAuthorizedException
- See Also:
UploadPackFactory.create(Object, Repository)
-
createReceivePack
public org.eclipse.jgit.transport.ReceivePack createReceivePack(javax.servlet.http.HttpServletRequest context, org.eclipse.jgit.lib.Repository db) throws org.eclipse.jgit.transport.resolver.ServiceNotEnabledException, org.eclipse.jgit.transport.resolver.ServiceNotAuthorizedException
Requires the admin access to be able to push- Specified by:
createReceivePack
in classHttpGitRepository
- Throws:
org.eclipse.jgit.transport.resolver.ServiceNotEnabledException
org.eclipse.jgit.transport.resolver.ServiceNotAuthorizedException
- See Also:
ReceivePackFactory.create(Object, Repository)
-
createReceivePack
public org.eclipse.jgit.transport.ReceivePack createReceivePack(org.eclipse.jgit.lib.Repository db)
-
updateWorkspace
protected void updateWorkspace(org.eclipse.jgit.lib.Repository repo) throws IOException, org.eclipse.jgit.api.errors.GitAPIException
Called when new ref is pushed to update the local workspace. The default implementation does "git reset --hard main"- Throws:
IOException
org.eclipse.jgit.api.errors.GitAPIException
-
checkPushPermission
protected abstract void checkPushPermission()
Do something likeJenkins.getInstance().checkPermission(Jenkins.ADMINISTER)
to make sure the user has the permission to push.
-
-