kou commented on code in PR #14033:
URL: https://github.com/apache/arrow/pull/14033#discussion_r1001111400
##########
.github/workflows/integration.yml:
##########
@@ -85,7 +85,10 @@ jobs:
env:
ARCHERY_DOCKER_USER: ${{ secrets.DOCKERHUB_USER }}
ARCHERY_DOCKER_PASSWORD: ${{ secrets.DOCKERHUB_TOKEN }}
- run: archery docker run -e ARCHERY_INTEGRATION_WITH_RUST=1
conda-integration
+ run: >
+ archery docker run -e ARCHERY_INTEGRATION_WITH_RUST=1 -e
+ ARCHERY_DEFAULT_BRANCH=${{ github.event.repository.default_branch }}
+ conda-integration
Review Comment:
How about indenting/formatting for easy to read?
```suggestion
archery docker run
-e ARCHERY_DEFAULT_BRANCH=${{
github.event.repository.default_branch }}
-e ARCHERY_INTEGRATION_WITH_RUST=1
conda-integration
```
##########
dev/archery/archery/crossbow/core.py:
##########
@@ -361,6 +362,29 @@ 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("ARCHERY_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:
+ # TODO: ARROW-18011 to track changing the hard coded default
+ # value from "master" to "main".
+ default_branch_name = "master"
+ warnings.warn('Unable to determine default branch name: '
+ 'ARCHERY_DEFAULT_BRANCH environment variable is '
+ 'not set. Git repository does not contain a '
+ '\'refs/remotes/origin/HEAD\'reference. Setting '
+ 'the default branch name to' +
Review Comment:
```suggestion
'the default branch name to ' +
```
##########
dev/archery/archery/crossbow/core.py:
##########
@@ -546,8 +570,10 @@ def github_overwrite_release_assets(self, tag_name,
target_commitish,
'Unsupported upload method {}'.format(method)
)
- def github_pr(self, title, head=None, base="master", body=None,
+ def github_pr(self, title, head=None, base=None, body=None,
github_token=None, create=False):
+ # Default value for base is the default_branch name()
+ base = self.default_branch_name() if base is None else base
Review Comment:
Do we need `()` here?
##########
dev/archery/archery/release/core.py:
##########
@@ -361,6 +362,45 @@ 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("ARCHERY_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]
+ except KeyError:
+ # TODO: ARROW-18011 to track changing the hard coded default
+ # value from "master" to "main".
+ default_branch_name = "master"
+ warnings.warn('Unable to determine default branch name: '
+ 'ARCHERY_DEFAULT_BRANCH environment variable is '
+ 'not set. Git repository does not contain a '
+ '\'refs/remotes/origin/HEAD\'reference. Setting '
+ 'the default branch name to' +
Review Comment:
```suggestion
'the default branch name to ' +
```
--
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]