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

fix(pullrequests) Do not mention a pull request in dry run when there are no changes #496

Merged
merged 1 commit into from
Feb 1, 2022

Conversation

olblak
Copy link
Member

@olblak olblak commented Jan 30, 2022

An expected pull request is mentioned in dry run logs even if there is no change

Fix #484
Fix #440
In the current state, this PR fix two bugs which by the way could be split into two Pull requests :)

  1. In Dry mode, don't mention that a PR will be open if it's not the case (An expected pull request is mentioned in dry run logs even if there is no change #484 )
  2. Pull request object correctly using the updated configuration. This avoids open pull requests with a message containing templating instruction such as Bump app to {{ source "source" }}

Test

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

  1. Run updatecli in dry mode and debug enable, with a updatecli configuration that shouldn't open a pullrequest. We shouldn't have pull request message
  2. Run updatecli in dry mode and debug enable, with a updatecli configuration that should open a pull request and where the title contains templating instruction. We should have pull request message with the correct title

Additional Information

Tradeoff

Potential improvement

While working on this PR, I realize that we have confusion about what a pull request title should be. The title should be configured in the spec level and not at the pull request level.

pullrequestID:
  kind: github
  title: my title
  spec:
     label: 
        - dependencies

or

pullrequestID:
  kind: github
  spec:
    title: my title 
    label: 
        - dependencies

At the moment the latter example, is implement in the code in a way that it's totally useless.
I also realize that the way to generate a pullrequest title is overly complicated and could drastically simplified by just having the two following cases
1 A title is specified in the spec, then we use that value
2. No title specified so we let GitHub should, which will be the first commit title

@olblak olblak added bug Something isn't working pullrequest-github labels Jan 30, 2022
@@ -70,7 +70,7 @@ func New(config *Config, sourceControlManager *scm.Scm) (PullRequest, error) {

p := PullRequest{
Title: config.Title,
Config: config,
Config: *config,
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm wondering how this change could help?

The type passed to the object was already a *Config(e.g. a pointer) so the calling method on the PullRequest were already able to change its pointer reference.

Did I miss something?

Copy link
Member Author

Choose a reason for hiding this comment

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

That was my understanding as well but it doesn't seem to work. I think that part would benefit from so refactoring. But I first needs to master the debugger :p

Copy link
Contributor

Choose a reason for hiding this comment

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

Given this consideration + the fact that the updatecli compiled from this PR stills creates PR with the litteral {{ source ...}}, do you mind removing this commit, so we can proceed on the rest of the code changes (eg fixing #484) ?

Many thanks for taking time for this!

Copy link
Contributor

Choose a reason for hiding this comment

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

For info, since this is only a "bugfix", I'm rebasing this PR to update it + remove the "PR title templating" tentative fix that would be a subsequent PR, so we can merge the initial fix.

@dduportal
Copy link
Contributor

At the moment the latter example, is implement in the code in a way that it's totally useless.
I also realize that the way to generate a pullrequest title is overly complicated and could drastically simplified by just having the two following cases
1 A title is specified in the spec, then we use that value

  1. No title specified so we let GitHub should, which will be the first commit title

@olblak do you mind opening an issue describing this thought process and pointing some code elements? That would allow us to discuss the subject, reach a consensus and then implement it in async :)

@olblak
Copy link
Member Author

olblak commented Jan 31, 2022

@olblak do you mind opening an issue describing this thought process and pointing some code elements? That would allow us to discuss the subject, reach a consensus and then implement it in async :)

Yep, yep, which is why I mentioned it in "Potential Improvement" section

Signed-off-by: Olblak <me@olblak.com>
@dduportal dduportal changed the title An expected pull request is mentioned in dry run logs even if there is no change fix(pullrequests) An expected pull request is mentioned in dry run logs even if there is no change Feb 1, 2022
@dduportal dduportal changed the title fix(pullrequests) An expected pull request is mentioned in dry run logs even if there is no change fix(pullrequests) Do not mention a pull request in dry run whenthere are no changes Feb 1, 2022
@dduportal dduportal changed the title fix(pullrequests) Do not mention a pull request in dry run whenthere are no changes fix(pullrequests) Do not mention a pull request in dry run when there are no changes Feb 1, 2022
@dduportal dduportal enabled auto-merge (squash) February 1, 2022 14:37
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
Projects
None yet
3 participants