Package org.eclipse.jgit.lfs
Class LfsPrePushHook
- java.lang.Object
-
- org.eclipse.jgit.hooks.GitHook<java.lang.String>
-
- org.eclipse.jgit.hooks.PrePushHook
-
- org.eclipse.jgit.lfs.LfsPrePushHook
-
- All Implemented Interfaces:
java.util.concurrent.Callable<java.lang.String>
public class LfsPrePushHook extends PrePushHook
Pre-push hook that handles uploading LFS artefacts.- Since:
- 4.11
-
-
Field Summary
Fields Modifier and Type Field Description private static java.lang.String
EMPTY
private java.util.Collection<RemoteRefUpdate>
refs
-
Fields inherited from class org.eclipse.jgit.hooks.PrePushHook
NAME
-
Fields inherited from class org.eclipse.jgit.hooks.GitHook
errorStream, outputStream
-
-
Constructor Summary
Constructors Constructor Description LfsPrePushHook(Repository repo, java.io.PrintStream outputStream)
LfsPrePushHook(Repository repo, java.io.PrintStream outputStream, java.io.PrintStream errorStream)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.String
call()
private void
excludeRemoteRefs(ObjectWalk walk)
private static void
findLfsPointers(java.util.Set<LfsPointer> toPush, ObjectWalk walk)
private java.util.Set<LfsPointer>
findObjectsToPush()
private static long
getObjectSize(ObjectReader r, RevObject obj)
private static LfsPointer
loadLfsPointer(ObjectReader r, AnyObjectId obj)
private java.util.List<Protocol.ObjectInfo>
parseObjects(com.google.gson.stream.JsonReader reader)
private java.lang.String
remote()
private java.util.Map<java.lang.String,LfsPointer>
requestBatchUpload(HttpConnection api, java.util.Set<LfsPointer> toPush)
void
setRefs(java.util.Collection<RemoteRefUpdate> toRefs)
Set Refsprivate void
uploadContents(HttpConnection api, java.util.Map<java.lang.String,LfsPointer> oid2ptr)
private void
uploadFile(Protocol.ObjectInfo o, Protocol.Action uploadAction, java.nio.file.Path path)
-
Methods inherited from class org.eclipse.jgit.hooks.PrePushHook
getHookName, getParameters, getRemoteName, getStdinArgs, setRemoteLocation, setRemoteName
-
Methods inherited from class org.eclipse.jgit.hooks.GitHook
doRun, getErrorStream, getOutputStream, getRepository, isNativeHookPresent
-
-
-
-
Field Detail
-
EMPTY
private static final java.lang.String EMPTY
- See Also:
- Constant Field Values
-
refs
private java.util.Collection<RemoteRefUpdate> refs
-
-
Constructor Detail
-
LfsPrePushHook
public LfsPrePushHook(Repository repo, java.io.PrintStream outputStream)
- Parameters:
repo
- the repositoryoutputStream
- not used by this implementation
-
LfsPrePushHook
public LfsPrePushHook(Repository repo, java.io.PrintStream outputStream, java.io.PrintStream errorStream)
- Parameters:
repo
- the repositoryoutputStream
- not used by this implementationerrorStream
- not used by this implementation- Since:
- 5.6
-
-
Method Detail
-
setRefs
public void setRefs(java.util.Collection<RemoteRefUpdate> toRefs)
Description copied from class:PrePushHook
Set Refs- Overrides:
setRefs
in classPrePushHook
- Parameters:
toRefs
- a collection ofRemoteRefUpdate
s
-
call
public java.lang.String call() throws java.io.IOException, AbortedByHookException
Description copied from class:PrePushHook
Run the hook.
- Specified by:
call
in interfacejava.util.concurrent.Callable<java.lang.String>
- Overrides:
call
in classPrePushHook
- Throws:
java.io.IOException
AbortedByHookException
-
findObjectsToPush
private java.util.Set<LfsPointer> findObjectsToPush() throws java.io.IOException, MissingObjectException, IncorrectObjectTypeException
- Throws:
java.io.IOException
MissingObjectException
IncorrectObjectTypeException
-
findLfsPointers
private static void findLfsPointers(java.util.Set<LfsPointer> toPush, ObjectWalk walk) throws MissingObjectException, IncorrectObjectTypeException, java.io.IOException
- Throws:
MissingObjectException
IncorrectObjectTypeException
java.io.IOException
-
getObjectSize
private static long getObjectSize(ObjectReader r, RevObject obj) throws java.io.IOException
- Throws:
java.io.IOException
-
loadLfsPointer
private static LfsPointer loadLfsPointer(ObjectReader r, AnyObjectId obj) throws java.io.IOException
- Throws:
java.io.IOException
-
excludeRemoteRefs
private void excludeRemoteRefs(ObjectWalk walk) throws java.io.IOException
- Throws:
java.io.IOException
-
remote
private java.lang.String remote()
-
requestBatchUpload
private java.util.Map<java.lang.String,LfsPointer> requestBatchUpload(HttpConnection api, java.util.Set<LfsPointer> toPush) throws java.io.IOException
- Throws:
java.io.IOException
-
uploadContents
private void uploadContents(HttpConnection api, java.util.Map<java.lang.String,LfsPointer> oid2ptr) throws java.io.IOException
- Throws:
java.io.IOException
-
parseObjects
private java.util.List<Protocol.ObjectInfo> parseObjects(com.google.gson.stream.JsonReader reader)
-
uploadFile
private void uploadFile(Protocol.ObjectInfo o, Protocol.Action uploadAction, java.nio.file.Path path) throws java.io.IOException, CorruptMediaFile
- Throws:
java.io.IOException
CorruptMediaFile
-
-