mirror of
https://github.com/overleaf/overleaf.git
synced 2024-12-01 20:29:39 -05:00
Iterating over received parent commits.
This commit is contained in:
parent
6d4309267e
commit
ba7d0d318c
1 changed files with 7 additions and 4 deletions
|
@ -21,16 +21,19 @@ public class CheckNonFastForwardHook implements PreReceiveHook {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPreReceive(ReceivePack receivePack, Collection<ReceiveCommand> receiveCommands) {
|
public void onPreReceive(ReceivePack receivePack, Collection<ReceiveCommand> receiveCommands) {
|
||||||
|
System.out.println("There are " + receiveCommands.size() + " receive commands.");
|
||||||
|
System.out.println("All commits: ");
|
||||||
|
System.out.println(receiveCommands);
|
||||||
for (ReceiveCommand receiveCommand : receiveCommands) {
|
for (ReceiveCommand receiveCommand : receiveCommands) {
|
||||||
receiveCommand.setResult(RefUpdate.Result.REJECTED);
|
// receiveCommand.setResult(RefUpdate.Result.REJECTED);
|
||||||
System.out.println(receiveCommand.getRef());
|
|
||||||
try {
|
try {
|
||||||
|
System.out.println("Old: " + receiveCommand.getOldId());
|
||||||
|
System.out.println("New: " + receiveCommand.getNewId());
|
||||||
// a RevWalk allows to walk over commits based on some filtering that is
|
// a RevWalk allows to walk over commits based on some filtering that is
|
||||||
// defined
|
// defined
|
||||||
RevWalk walk = new RevWalk(receivePack.getRepository());
|
RevWalk walk = new RevWalk(receivePack.getRepository());
|
||||||
|
|
||||||
RevCommit commit = walk.parseCommit(receiveCommand.getNewId());
|
RevCommit commit = walk.parseCommit(receiveCommand.getNewId());
|
||||||
|
System.out.println("Parent commit: " + commit.getParents()[0].getId());
|
||||||
RevTree tree = commit.getTree();
|
RevTree tree = commit.getTree();
|
||||||
System.out.println("Having tree: " + tree);
|
System.out.println("Having tree: " + tree);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue