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

feat: when using replace strategy also update PR #368

Merged
merged 5 commits into from
Feb 3, 2024

Conversation

dnwe
Copy link
Contributor

@dnwe dnwe commented Jul 6, 2023

What does this change

Previous when using --conflict-strategy replace multi-gitter would replace all of the commits, but would leave the pull request itself untouched if it was already open.

Now if multi-gitter is re-run and (e.g.,) the pr-title, pr-body or labels are changed, then the existing PR will be edited and updated to use their new values

Checklist

  • Made sure the PR follows the CONTRIBUTING.md guidelines
  • Tests if something new is added

Copy link
Owner

@lindell lindell left a comment

Choose a reason for hiding this comment

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

Thanks for the PR!

The code looks really good! I don't really have any code comments other than that we might be able to share some code between the Create and Update functions. But it is probably also as much of premature optimization, so I did not actually put in any comments on it.


The thing that needs to be discussed is what should happen to fields such as reviewers/labels/etc.

It seems that the behavior differs between SCMs (and for Giteas case, per field type). In some cases, the fields are updated to the list of the values provided to multi-gitter, while in other cases, the new values are added to any existing ones.

I think the replacement approach seems more logical. But I'm happy to discuss which one should be used. Either way, it should be the same no matter of SCM/field type.

Comment on lines +337 to +370
Reviewers: getReviewers(r.Reviewers, r.MaxReviewers),
TeamReviewers: getReviewers(r.TeamReviewers, r.MaxTeamReviewers),
Copy link
Owner

Choose a reason for hiding this comment

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

Thought/Discussion: If max-reviewers is less than the reviewers provided, the reviewers used will be randomized. Do we want this to happen in the case of an update or not? 🤔 I have no real opinion here, but a conscious decision has to be made.

@lindell lindell force-pushed the master branch 2 times, most recently from de07efa to 2e9b182 Compare July 15, 2023 19:12
@jamestelfer
Copy link
Contributor

This is a pretty useful PR that would help me out -- what is needed to get it over the finish line? Could I resurrect it to get that last bit done?

@dnwe
Copy link
Contributor Author

dnwe commented Nov 7, 2023

@jamestelfer thanks for the prod, I'd forgotten to revisit this PR after the review from @lindell — let me do a quick rebase and then take a look at addressing the comments

@lindell
Copy link
Owner

lindell commented Feb 1, 2024

I now commit a change for the "update instead of add" change for github. I think that only Gitea reviewers are left now.

@dnwe
Copy link
Contributor Author

dnwe commented Feb 1, 2024

@lindell thanks! I'll take a look at porting your github changes to the gitea pkg

@dnwe dnwe force-pushed the replace-also-updates-pr branch 4 times, most recently from 7e8cdd8 to 926bde8 Compare February 1, 2024 12:22
@dnwe
Copy link
Contributor Author

dnwe commented Feb 1, 2024

@lindell I've rebased on later master and I think this PR should be ready for a re-review now

@dnwe
Copy link
Contributor Author

dnwe commented Feb 1, 2024

Note: for gitea, I spun up a docker image with an install and configured three sample users and tested that the replace of review requests was working

image

Copy link
Owner

@lindell lindell left a comment

Choose a reason for hiding this comment

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

Just some minor comments and this should be ready to me merged 😄

internal/scm/gitea/gitea.go Outdated Show resolved Hide resolved
internal/scm/gitea/gitea.go Outdated Show resolved Hide resolved
internal/scm/gitea/gitea.go Outdated Show resolved Hide resolved
Previous when using `--conflict-strategy replace` multi-gitter would
replace all of the commits, but would leave the pull request itself
untouched if it was already open.

Now if multi-gitter is re-run and (e.g.,) the pr-title, pr-body or
labels are changed, then the existing PR will be edited and updated to
use their new values
@dnwe dnwe force-pushed the replace-also-updates-pr branch from aa04e9d to fe9adb2 Compare February 2, 2024 10:48
lindell and others added 4 commits February 2, 2024 10:49
…bels

Instead of just adding them, the replace strategy will now overwrite
them by doing any necessary add and removes
When using replace strategy, replace the review requests where they
differ and remove any that should no longer apply
Now that multi-gitter has a baseline of Go 1.21 we can switch to using
stdlib for the slices package.

Note: we still need golang.org/x/exp/maps for maps.Values, which is not
yet available in the equivalent stdlib maps package and likely won't be
until Go 1.23
If no new reviewers were passed as arguments then we just leave the
existing ones alone.

Also simplify by switching to using non-interface repository for
the param as setReviewers is an internal func to this package.
@dnwe dnwe force-pushed the replace-also-updates-pr branch from fe9adb2 to 93f28c4 Compare February 2, 2024 10:51
Copy link
Owner

@lindell lindell left a comment

Choose a reason for hiding this comment

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

LGTM 👍

Thanks for the contribution!

@lindell lindell merged commit 3f2d821 into lindell:master Feb 3, 2024
9 checks passed
Copy link
Contributor

github-actions bot commented Feb 3, 2024

Included in release v0.50.0 🎉

@dnwe dnwe deleted the replace-also-updates-pr branch February 5, 2024 11:31
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