From ba7d0d318c88e7eee65967e0669fd55797c88c50 Mon Sep 17 00:00:00 2001 From: Winston Li Date: Sat, 15 Nov 2014 17:37:11 +0000 Subject: [PATCH] Iterating over received parent commits. --- .../git/handler/hook/CheckNonFastForwardHook.java | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/services/git-bridge/src/uk/ac/ic/wlgitbridge/git/handler/hook/CheckNonFastForwardHook.java b/services/git-bridge/src/uk/ac/ic/wlgitbridge/git/handler/hook/CheckNonFastForwardHook.java index b9e2ad0de0..de4ac18a4c 100644 --- a/services/git-bridge/src/uk/ac/ic/wlgitbridge/git/handler/hook/CheckNonFastForwardHook.java +++ b/services/git-bridge/src/uk/ac/ic/wlgitbridge/git/handler/hook/CheckNonFastForwardHook.java @@ -21,16 +21,19 @@ public class CheckNonFastForwardHook implements PreReceiveHook { @Override public void onPreReceive(ReceivePack receivePack, Collection receiveCommands) { + System.out.println("There are " + receiveCommands.size() + " receive commands."); + System.out.println("All commits: "); + System.out.println(receiveCommands); for (ReceiveCommand receiveCommand : receiveCommands) { - receiveCommand.setResult(RefUpdate.Result.REJECTED); - System.out.println(receiveCommand.getRef()); +// receiveCommand.setResult(RefUpdate.Result.REJECTED); 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 // defined RevWalk walk = new RevWalk(receivePack.getRepository()); - RevCommit commit = walk.parseCommit(receiveCommand.getNewId()); + System.out.println("Parent commit: " + commit.getParents()[0].getId()); RevTree tree = commit.getTree(); System.out.println("Having tree: " + tree);