From b7403152813c7fee783e3c999c7f7ae9fbaacce0 Mon Sep 17 00:00:00 2001 From: James Moger <james.moger@gitblit.com> Date: Fri, 03 Feb 2012 18:16:16 -0500 Subject: [PATCH] Block pushes to a repository with a working copy (issue 49) --- tests/com/gitblit/tests/JGitUtilsTest.java | 22 ++++++++++++++++++++++ 1 files changed, 22 insertions(+), 0 deletions(-) diff --git a/tests/com/gitblit/tests/JGitUtilsTest.java b/tests/com/gitblit/tests/JGitUtilsTest.java index 7c3f8ab..8d70d2f 100644 --- a/tests/com/gitblit/tests/JGitUtilsTest.java +++ b/tests/com/gitblit/tests/JGitUtilsTest.java @@ -212,6 +212,28 @@ assertEquals("183474d554e6f68478a02d9d7888b67a9338cdff", list.get(0).notesRef .getReferencedObjectId().getName()); } + + @Test + public void testRelinkHEAD() throws Exception { + Repository repository = GitBlitSuite.getJGitRepository(); + // confirm HEAD is master + String currentRef = JGitUtils.getHEADRef(repository); + assertEquals("refs/heads/master", currentRef); + List<String> availableHeads = JGitUtils.getAvailableHeadTargets(repository); + assertTrue(availableHeads.size() > 0); + + // set HEAD to stable-1.2 + JGitUtils.setHEADtoRef(repository, "refs/heads/stable-1.2"); + currentRef = JGitUtils.getHEADRef(repository); + assertEquals("refs/heads/stable-1.2", currentRef); + + // restore HEAD to master + JGitUtils.setHEADtoRef(repository, "refs/heads/master"); + currentRef = JGitUtils.getHEADRef(repository); + assertEquals("refs/heads/master", currentRef); + + repository.close(); + } @Test public void testCreateOrphanedBranch() throws Exception { -- Gitblit v1.9.1