-
-
Notifications
You must be signed in to change notification settings - Fork 95
fix: handle main/master branch fallback and add branch support in comments #1053
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 1 commit
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is no need to guess user branches at all. If the branch is set, use it in git clone. If the branch is not specified, simply run
git clonewithout the branch.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@llxia This handles the scenario where a Git branch is not explicitly specified. In such cases, the Ruby script defaults to using master. Since most GitHub repositories default to either main or master, the assumption is that one of these branches should be available. Therefore, when a branch is not provided via the comment, the script should attempt to resolve to main or master. Without this fallback logic, the script will fail for repositories that only use main, if master is assumed by default. The core idea is to make the script resilient by defaulting to main or master when no branch is specified.
This approach prevents failures when analyzing repositories like
https://github.com/OpenElements/hiero-enterprise-java, which uses 'main', without requiring users to always specify a branch. By prioritizing 'main' and falling back to 'master', we cover the most common default branch names while maintaining flexibility for user-specified branches.Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the overall logic should be
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
An example of using branch in bugspots is:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@llxia @LongyuZhang this is what I mean. The ruby script defaults master as a branch. Imagine a scennario where we have not specified the branch, that means the repos that default to main as a branch will fail. I will provide examples from the ruby script below.
Note: My assumption is every github repo that is created defaults to main or master but the ruby script only defaults to master which could be wrong on repos that have main as default.
Note: ONLY IMAGINE SCENARIOS WHERE WE DONT SPECIFY THE BRANCH
This error happens because
hiero-enterprise-javadefaults to mainThis one passes because the project defaults to master
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Branch should be set in bugspots. We should not rely on the default in bugspots. See #1053 (comment)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When the
userBranchis not specified, its value can be obtained with git command, e.g.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@llxia @LongyuZhang my bad. It took me long to notice that we are resolving branches using
git rev-parse --abbrev-ref HEAD. I will push a fix