From fd8a21db04d9f4b31afbc23360a4a46f2051bd19 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Bouchex=20Bellomi=C3=A9?= Date: Thu, 3 Oct 2024 15:46:02 +0200 Subject: [PATCH] #1967 Adding rename method test --- .../java/org/kohsuke/github/GHBranchTest.java | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/src/test/java/org/kohsuke/github/GHBranchTest.java b/src/test/java/org/kohsuke/github/GHBranchTest.java index 117da049f7..b9b6270cd4 100644 --- a/src/test/java/org/kohsuke/github/GHBranchTest.java +++ b/src/test/java/org/kohsuke/github/GHBranchTest.java @@ -18,6 +18,7 @@ public GHBranchTest() { private static final String BRANCH_1 = "testBranch1"; private static final String BRANCH_2 = "testBranch2"; + private static final String BRANCH_3 = "testBranch3"; private GHRepository repository; @@ -74,4 +75,31 @@ public void testMergeBranch() throws Exception { // Should be null since all changes already merged assertThat(mergeCommit, nullValue()); } + + /** + * Test merge rename. + * + * @throws Exception + * the exception + */ + @Test + public void testBranchRename() throws Exception { + repository = getTempRepository(); + String mainHead = repository.getRef("heads/main").getObject().getSha(); + + String branchName = "refs/heads/" + BRANCH_3; + repository.createRef(branchName, mainHead); + repository.createContent() + .content(branchName) + .message(branchName) + .path(branchName) + .branch(branchName) + .commit(); + + GHBranch otherBranch = repository.getBranch(BRANCH_3); + otherBranch.rename(BRANCH_3+"_renamed"); + GHBranch otherBranchRenamed = repository.getBranch(BRANCH_3+"_renamed"); + assertThat(otherBranchRenamed, notNullValue()); + assertThat(otherBranchRenamed.getName(), equalTo(BRANCH_3+"_renamed")); + } }