lafiona commented on code in PR #14033:
URL: https://github.com/apache/arrow/pull/14033#discussion_r995048416


##########
dev/archery/archery/release/core.py:
##########
@@ -361,6 +362,40 @@ def commits(self):
         commit_range = f"{lower}..{upper}"
         return list(map(Commit, self.repo.iter_commits(commit_range)))
 
+    @cached_property
+    def default_branch(self):
+        default_branch_name = os.getenv("DEFAULT_BRANCH")
+
+        if default_branch_name is None:
+            try:
+                # Set up repo object
+                arrow = ArrowSources.find()
+                repo = Repo(arrow.path)
+                origin = repo.remotes["origin"]
+                origin_refs = origin.refs
+
+                # Get git.RemoteReference object to origin/HEAD
+                origin_head = origin_refs["HEAD"]
+
+                # Get git.RemoteReference object to origin/main or
+                # origin/master
+                origin_head_reference = origin_head.reference
+
+                # Get string value of remote head reference, should return
+                # "origin/main" or "origin/master"
+                origin_head_name = origin_head_reference.name
+                origin_head_name_tokenized = origin_head_name.split("/")
+
+                # The last token is the default branch name
+                default_branch_name = origin_head_name_tokenized[-1]

Review Comment:
   Thanks for creating this Jira ticket



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to