mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-10 15:35:49 +01:00
post all changesets to hooks
This commit is contained in:
@@ -36,6 +36,7 @@ package sonia.scm.web;
|
|||||||
//~--- non-JDK imports --------------------------------------------------------
|
//~--- non-JDK imports --------------------------------------------------------
|
||||||
|
|
||||||
import org.eclipse.jgit.revwalk.RevCommit;
|
import org.eclipse.jgit.revwalk.RevCommit;
|
||||||
|
import org.eclipse.jgit.revwalk.RevSort;
|
||||||
import org.eclipse.jgit.revwalk.RevWalk;
|
import org.eclipse.jgit.revwalk.RevWalk;
|
||||||
import org.eclipse.jgit.transport.PostReceiveHook;
|
import org.eclipse.jgit.transport.PostReceiveHook;
|
||||||
import org.eclipse.jgit.transport.ReceiveCommand;
|
import org.eclipse.jgit.transport.ReceiveCommand;
|
||||||
@@ -109,13 +110,23 @@ public class GitPostReceiveHook implements PostReceiveHook
|
|||||||
|
|
||||||
for (ReceiveCommand rc : receiveCommands)
|
for (ReceiveCommand rc : receiveCommands)
|
||||||
{
|
{
|
||||||
if (isCreateOrUpdateCommand(rc))
|
if (rc.getResult() == ReceiveCommand.Result.OK)
|
||||||
{
|
{
|
||||||
RevCommit commit = walk.parseCommit(rc.getNewId());
|
walk.reset();
|
||||||
|
walk.sort(RevSort.NONE);
|
||||||
|
walk.markStart(walk.parseCommit(rc.getNewId()));
|
||||||
|
|
||||||
if (commit != null)
|
if (isUpdateCommand(rc))
|
||||||
|
{
|
||||||
|
walk.markUninteresting(walk.parseCommit(rc.getOldId()));
|
||||||
|
}
|
||||||
|
|
||||||
|
RevCommit commit = walk.next();
|
||||||
|
|
||||||
|
while (commit != null)
|
||||||
{
|
{
|
||||||
changesets.add(converter.createChangeset(commit));
|
changesets.add(converter.createChangeset(commit));
|
||||||
|
commit = walk.next();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -150,12 +161,10 @@ public class GitPostReceiveHook implements PostReceiveHook
|
|||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
private boolean isCreateOrUpdateCommand(ReceiveCommand rc)
|
private boolean isUpdateCommand(ReceiveCommand rc)
|
||||||
{
|
{
|
||||||
return (rc.getResult() == ReceiveCommand.Result.OK)
|
return (rc.getType() == ReceiveCommand.Type.UPDATE)
|
||||||
&& ((rc.getType() == ReceiveCommand.Type.CREATE)
|
|| (rc.getType() == ReceiveCommand.Type.UPDATE_NONFASTFORWARD);
|
||||||
|| (rc.getType() == ReceiveCommand.Type.UPDATE)
|
|
||||||
|| (rc.getType() == ReceiveCommand.Type.UPDATE_NONFASTFORWARD));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//~--- fields ---------------------------------------------------------------
|
//~--- fields ---------------------------------------------------------------
|
||||||
|
|||||||
Reference in New Issue
Block a user