diff --git a/pom.xml b/pom.xml index f84aa20..b121acd 100644 --- a/pom.xml +++ b/pom.xml @@ -29,7 +29,7 @@ UTF-8 2.4.1 2.4.1 - 4.2.0 + 4.2.3 1.1.1 4.10 diff --git a/src/main/java/com/englishtown/stash/hook/MirrorRepositoryHook.java b/src/main/java/com/englishtown/stash/hook/MirrorRepositoryHook.java index 7cd9636..19b2fa1 100644 --- a/src/main/java/com/englishtown/stash/hook/MirrorRepositoryHook.java +++ b/src/main/java/com/englishtown/stash/hook/MirrorRepositoryHook.java @@ -114,11 +114,14 @@ public class MirrorRepositoryHook implements AsyncPostReceiveRepositoryHook, Rep CommandExitHandler exitHandler = new GitCommandExitHandler(i18nService, repository); PasswordHandler passwordHandler = new PasswordHandler(password, exitHandler); - // Call push command with the mirror flag set + // Call push command with the prune flag and refspecs for heads and tags + // Do not use the mirror flag as pull-request refs are included String result = builder .command("push") - .argument("--mirror") + .argument("--prune") // this deletes locally deleted branches .argument(authenticatedUrl.toString()) + .argument("+refs/heads/*:refs/heads/*") // Only mirror heads + .argument("+refs/tags/*:refs/tags/*") // and tags .errorHandler(passwordHandler) .exitHandler(passwordHandler) .build(passwordHandler) diff --git a/src/test/java/com/englishtown/stash/hook/MirrorRepositoryHookTest.java b/src/test/java/com/englishtown/stash/hook/MirrorRepositoryHookTest.java index 1a4bdb6..7683de6 100644 --- a/src/test/java/com/englishtown/stash/hook/MirrorRepositoryHookTest.java +++ b/src/test/java/com/englishtown/stash/hook/MirrorRepositoryHookTest.java @@ -164,8 +164,10 @@ public class MirrorRepositoryHookTest { callable.call(); verify(builder, times(1)).command(eq("push")); - verify(builder, times(1)).argument(eq("--mirror")); + verify(builder, times(1)).argument(eq("--prune")); verify(builder, times(1)).argument(eq(repository)); + verify(builder, times(1)).argument(eq("+refs/heads/*:refs/heads/*")); + verify(builder, times(1)).argument(eq("+refs/tags/*:refs/tags/*")); verify(cmd, times(1)).call(); }