From cd79be8ddb7432d4926756a05455d52153b26e5b Mon Sep 17 00:00:00 2001 From: Olivier Ramonat Date: Tue, 26 Mar 2024 14:05:49 +0100 Subject: [PATCH] Do not assume Git default branch is called "master" Running git init won't always create a "master" branch. More and more configurations creates a branch named "main", and the name of the initial branch can be changed using: [init] defaultBranch = nameofbranch To get the first branch created by git init, run: git branch --show-current --- tests/tests_e3/vcs/git/main_test.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tests/tests_e3/vcs/git/main_test.py b/tests/tests_e3/vcs/git/main_test.py index cc143c1e..4df562ce 100644 --- a/tests/tests_e3/vcs/git/main_test.py +++ b/tests/tests_e3/vcs/git/main_test.py @@ -69,6 +69,9 @@ def test_git_repo(): repo.git_cmd(["config", "user.email", "e3-core@example.net"]) repo.git_cmd(["config", "user.name", "e3 core"]) repo.git_cmd(["commit", "-m", "new file"]) + + main_branch = repo.git_cmd(["branch", "--show-current"]).out + repo.git_cmd(["tag", "-a", "-m", "new tag", "20.0855369232"]) repo.git_cmd(["notes", "--ref", "review", "add", "HEAD", "-F", commit_note]) @@ -130,7 +133,7 @@ def test_git_repo(): repo2 = GitRepository(working_tree2) giturl = "file://%s" % working_tree.replace("\\", "/") repo2.init(url=giturl, remote="tree1") - repo2.update(url=giturl, refspec="master") + repo2.update(url=giturl, refspec=main_branch) assert repo2.rev_parse() == repo.rev_parse() repo2.fetch_gerrit_notes(url=giturl)