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


##########
dev/archery/archery/crossbow/core.py:
##########
@@ -361,6 +361,24 @@ def signature(self):
         return pygit2.Signature(self.user_name, self.user_email,
                                 int(time.time()))
 
+    @property
+    def default_branch_name(self):
+        default_branch_name = os.getenv("DEFAULT_BRANCH")
+
+        if default_branch_name is None:
+            try:
+                ref_obj = self.repo.references["refs/remotes/origin/HEAD"]
+                target_name = ref_obj.target
+                target_name_tokenized = target_name.split("/")
+                default_branch_name = target_name_tokenized[-1]
+            except KeyError:
+                raise RuntimeError(
+                    'Unable to determine default branch name: DEFAULT_BRANCH '
+                    'environment variable is not set. Git repository does not '
+                    'contain a \'refs/remotes/origin/HEAD\' reference.')

Review Comment:
   Thanks for this suggestion, instead of erroring, I will set the default to 
"master" while printing a warning containing the same details as the error 
message above. It could be helpful for the user to know that the two heuristics 
that we're using are not working in their environment and it is falling back to 
a hard-coded default. We've also added a Jira ticket (ARROW-18011) to modify 
the default value from "master" to "main" after the migration. 



-- 
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