Skip to content
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

Bugfix: Don't try to open a pullrequest when not needed #436

Merged
merged 13 commits into from
Jan 3, 2022

Conversation

olblak
Copy link
Member

@olblak olblak commented Dec 31, 2021

Signed-off-by: Olblak me@olblak.com

Don't try to open a pullrequest when not needed

Fix #431

Add a function to test if the latest commits of two branches are similar. The intend of this approach is to only try to create a pullrequest when two branch content mismatch

Test

To test this pull request, you can run the following commands:

cp pkg/plugins/git/generic
go test

Additional Information

Tradeoff

Potential improvement

I am planning to also look at a way to test if two git tags are similar

Signed-off-by: Olblak <me@olblak.com>
@olblak olblak added scm-git SCM of kind "Git" pullrequest-github labels Dec 31, 2021
@olblak olblak marked this pull request as draft December 31, 2021 15:23
@olblak olblak changed the title Add diffbranch function Don't try to open a pullrequest when not needed Dec 31, 2021
Signed-off-by: Olblak <me@olblak.com>
Signed-off-by: Olblak <me@olblak.com>
Signed-off-by: Olblak <me@olblak.com>
@olblak olblak marked this pull request as ready for review January 1, 2022 17:05
Signed-off-by: Olblak <me@olblak.com>
@olblak olblak requested a review from dduportal January 1, 2022 17:33
@olblak
Copy link
Member Author

olblak commented Jan 1, 2022

Well for some reason the github action doesn't find the branch "main"

Signed-off-by: Olblak <me@olblak.com>
Signed-off-by: Olblak <me@olblak.com>
@olblak
Copy link
Member Author

olblak commented Jan 1, 2022

I successfully tested this PR with jenkins-infra/kubernetes-management#1879
But I can't figure out why the test is not working from Github Action

@dduportal
Copy link
Contributor

The error also appears on my machine (macOS 12.1, MBP 16" Intel, go1.17.5):

$ gh pr checkout 436
$ make test-short    
go test ./... -short
# ...
time="2022-01-02T09:27:53+01:00" level=error msg="reference \"main\" - reference not found"
time="2022-01-02T09:27:53+01:00" level=error msg="reference \"main\" - reference not found"
time="2022-01-02T09:27:53+01:00" level=error msg="reference \"main\" - reference not found"
--- FAIL: TestIsSimilarBranch (0.00s)
    main_test.go:54: 
                Error Trace:    main_test.go:54
                Error:          Not equal: 
                                expected: *errors.errorString(&errors.errorString{s:"reference not found"})
                                actual  : <nil>(<nil>)
                Test:           TestIsSimilarBranch
    main_test.go:55: [0] Expected error '<nil>' but got 'reference not found'
    main_test.go:54: 
                Error Trace:    main_test.go:54
                Error:          Not equal: 
                                expected: *errors.errorString(&errors.errorString{s:"reference not found"})
                                actual  : <nil>(<nil>)
                Test:           TestIsSimilarBranch
    main_test.go:55: [1] Expected error '<nil>' but got 'reference not found'
    main_test.go:61: 
                Error Trace:    main_test.go:61
                Error:          Not equal: 
                                expected: false
                                actual  : true
                Test:           TestIsSimilarBranch
    main_test.go:62: [1] Expected result 'true' but got 'false'
FAIL
FAIL    github.com/updatecli/updatecli/pkg/plugins/git/generic  7.026s
#...

=> I'm trying to debug it since it appears locally.

pkg/plugins/git/generic/main_test.go Outdated Show resolved Hide resolved
@dduportal
Copy link
Contributor

The fix is working for me on both the asciidoctor/docker-asciidoctor and jenkins-infra/* repositories on my manual tests ✅ .

Many thanks for this huge work to start 2022 🍾

olblak and others added 3 commits January 3, 2022 09:37
Co-authored-by: Damien Duportal <damien.duportal@gmail.com>
Signed-off-by: Olblak <me@olblak.com>
@olblak olblak enabled auto-merge (squash) January 3, 2022 08:45
@olblak olblak disabled auto-merge January 3, 2022 08:45
@olblak olblak enabled auto-merge (squash) January 3, 2022 08:45
Copy link
Contributor

@dduportal dduportal left a comment

Choose a reason for hiding this comment

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

🚀

@olblak olblak merged commit 26d1382 into updatecli:main Jan 3, 2022
@dduportal dduportal added the bug Something isn't working label Jan 3, 2022
@dduportal dduportal changed the title Don't try to open a pullrequest when not needed Bugfix: Don't try to open a pullrequest when not needed Jan 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working pullrequest-github scm-git SCM of kind "Git"
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Updatecli tries to open a pullrequest even if nothing changed
2 participants