Skip to content

fix: handle main/master branch fallback and add branch support in comments#1053

Merged
LongyuZhang merged 2 commits intoadoptium:masterfrom
Ndacyayisenga-droid:branch-fx
Jun 27, 2025
Merged

fix: handle main/master branch fallback and add branch support in comments#1053
LongyuZhang merged 2 commits intoadoptium:masterfrom
Ndacyayisenga-droid:branch-fx

Conversation

@Ndacyayisenga-droid
Copy link
Contributor

No description provided.

@netlify
Copy link

netlify bot commented Jun 19, 2025

Deploy Preview for eclipsefdn-adoptium-trss ready!

Name Link
🔨 Latest commit 2d321ce
🔍 Latest deploy log https://app.netlify.com/projects/eclipsefdn-adoptium-trss/deploys/685c76ea8b5fae0008b4febe
😎 Deploy Preview https://deploy-preview-1053--eclipsefdn-adoptium-trss.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

BugPredict/gw.sh Outdated
Comment on lines +52 to +53
# Try default branches in order of preference (master first to match bugspots default)
branches=("master" "main")
Copy link
Contributor

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 clone without the branch.

Copy link
Contributor Author

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 clone without the branch.

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

Copy link
Contributor

@llxia llxia Jun 25, 2025

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

if the user provides userBranch
    git clone userRepo userBranch
else
    git clone userRepo
    set userBranch via git cmd (i.e., git rev-parse --abbrev-ref HEAD)

bugspots -b userBranch userRepoDir

Copy link
Contributor

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:

bugspots -b main /root/hiero-enterprise-java
Scanning /root/hiero-enterprise-java repo
	Found 38 bugfix commits, with 109 hotspots

Copy link
Contributor Author

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:

bugspots -b main /root/hiero-enterprise-java
Scanning /root/hiero-enterprise-java repo
	Found 38 bugfix commits, with 109 hotspots

@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-java defaults to main

bugspots /Users/mac/Hiero/hiero-enterprise-java              
Scanning /Users/mac/Hiero/hiero-enterprise-java repo
/Users/mac/.rvm/gems/ruby-3.0.0/gems/bugspots-0.2.2/lib/bugspots/scanner.rb:13:in `scan': no such branch in the repo: master (ArgumentError)
	from /Users/mac/.rvm/gems/ruby-3.0.0/gems/bugspots-0.2.2/bin/bugspots:49:in `<top (required)>'
	from /Users/mac/.rvm/gems/ruby-3.0.0/bin/bugspots:23:in `load'
	from /Users/mac/.rvm/gems/ruby-3.0.0/bin/bugspots:23:in `<main>'

This one passes because the project defaults to master

bugspots /Users/mac/maven/maven-dependency-plugin                        
Scanning /Users/mac/maven/maven-dependency-plugin repo
	Found 186 bugfix commits, with 418 hotspots:

	Fixes:
		- fix: remove duplicate maven-resolver-api and maven-resolver-util dependencies in pom.xml (#526)
		- Fix broken link on analyze-exclusions-mojo (#521)
		- Bump org.apache.maven.plugins:maven-plugins from 43 to 44 (#516)
		- Fix broken link for dependency:collect
		- [MDEP-689] Fixes ignored dependency filtering in go-offline goal (#417)
		- [MDEP-960] Repair silent logging (#447)
		- [MNG-2961] Remove workaround for fixed bug (#441)
		- Fix SCM tag
		- Delete obsolete commented code for issue that was won't fixed 10 years ago (#446)
		- [MDEP-903] Upgrade to Doxia 2.0.0 Milestone Stack
		

	Hotspots:
		3.3144 - pom.xml
		1.4030 - src/site/apt/index.apt.vm
		1.2976 - src/main/java/org/apache/maven/plugins/dependency/resolvers/ResolveDependencySourcesMojo.java
		1.1938 - src/test/java/org/apache/maven/plugins/dependency/TestCollectMojo.java
		1.1415 - src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestUnpackDependenciesMojo.java
		1.0123 - src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestCopyDependenciesMojo.java
		0.9551 - src/test/java/org/apache/maven/plugins/dependency/fromConfiguration/TestIncludeExcludeUnpackMojo.java
		0.9485 - src/it/projects/sources/pom.xml
		0.8771 - src/test/java/org/apache/maven/plugins/dependency/resolvers/GoOfflineMojoTest.java
		0.8608 - src/main/java/org/apache/maven/plugins/dependency/analyze/AbstractAnalyzeMojo.java
		0.7905 - src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestIncludeExcludeUnpackDependenciesMojo.java

Copy link
Contributor

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)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When the userBranch is not specified, its value can be obtained with git command, e.g.

cd hiero-enterprise-java; git rev-parse --abbrev-ref HEAD
main

Copy link
Contributor Author

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)

@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

@karianna karianna requested a review from llxia June 25, 2025 02:58
Copy link
Contributor

@LongyuZhang LongyuZhang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@LongyuZhang LongyuZhang merged commit febb4c4 into adoptium:master Jun 27, 2025
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants