-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
fix: Add skip to test if branch do not exists, instead of failing #9204
fix: Add skip to test if branch do not exists, instead of failing #9204
Conversation
Signed-off-by: rishabh625 <rishabhmishra625@gmail.com>
61ca0bd
to
fc2d87f
Compare
Codecov Report
@@ Coverage Diff @@
## master #9204 +/- ##
==========================================
+ Coverage 45.49% 45.82% +0.32%
==========================================
Files 219 219
Lines 25870 25869 -1
==========================================
+ Hits 11770 11854 +84
+ Misses 12462 12371 -91
- Partials 1638 1644 +6
Continue to review full report at Codecov.
|
Hi @rishabh625,
Just wanted to confirm if this PR is addressing this issue?? |
Signed-off-by: rishabh625 <rishabhmishra625@gmail.com>
Hi @leoluz : yeah this is addressing issue that u mentioned above, wrt gitea failing to list default branch for test-ldap-repos |
@jannfis @leoluz @crenshaw-dev : can u please review? |
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 adding a unit test for this would make sense.
@@ -126,6 +126,9 @@ func getBranches(ctx context.Context, provider SCMProviderService, repos []*Repo | |||
for _, repo := range repos { | |||
reposFilled, err := provider.GetBranches(ctx, repo) | |||
if err != nil { | |||
if checkBranchDoNotExist(err.Error()) { |
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.
Would this hide an error where the repo doesn't exist? Or will it only return true if a branch doesn't exist?
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.
It will only skip errors if branch doesn't exist, i'll add a UT for this
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.
Added Test cases, added with gitea provider only
- branch doesn't exist
- repo doesn't exist
Signed-off-by: rishabh625 <rishabhmishra625@gmail.com>
Signed-off-by: rishabh625 <rishabhmishra625@gmail.com>
Signed-off-by: rishabh625 <rishabhmishra625@gmail.com>
if checkBranchDoNotExist(err) { | ||
continue | ||
} |
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.
After reviewing the test, I don't think this is the correct fix. We're hitting an error because the gitea API is returning main
as the default branch name for this repo. But that repo doesn't have a main
branch. It looks like a bug in the gitea API.
In the case of a 404 we could fall back to listing all branches and then picking the 1st one if there's only one. I'll put up another PR based on this one.
Closing as fixed in #9228 |
Signed-off-by: rishabh625 rishabhmishra625@gmail.com
Note on DCO:
If the DCO action in the integration test fails, one or more of your commits are not signed off. Please click on the Details link next to the DCO action for instructions on how to resolve this.
Checklist:
Fixes:- 9203