Skip to content

Commit 8e54f78

Browse files
authored
Merge pull request #32 from hushsecurity/rbk_add_reviewers
create: allow adding reviewers
2 parents bc99ffd + 8c31877 commit 8e54f78

File tree

4 files changed

+29
-3
lines changed

4 files changed

+29
-3
lines changed

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,15 @@ All notable changes to this project will be documented in this file.
77
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
88
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
99

10+
## [0.6.0] - 2024-12-16
11+
12+
### Added
13+
14+
- add `create -r <user-reviewer> -t <team-reviewer>` cli args to add reviewers at
15+
revision creation time. This is especially handy at creation of the first revision
16+
because one can omit the reviewers at PR creation and specify them only when
17+
first revision is published.
18+
1019
## [0.5.0] - 2024-12-09
1120

1221
### Added
@@ -75,3 +84,4 @@ Initial release.
7584
[0.3.0]: https://github.com/hushsecurity/gh-pr-revision/compare/v0.2.0...v0.3.0
7685
[0.4.0]: https://github.com/hushsecurity/gh-pr-revision/compare/v0.3.0...v0.4.0
7786
[0.5.0]: https://github.com/hushsecurity/gh-pr-revision/compare/v0.4.0...v0.5.0
87+
[0.6.0]: https://github.com/hushsecurity/gh-pr-revision/compare/v0.5.0...v0.6.0

create.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,8 @@ func createRevision(args CreateArgs) error {
220220

221221
newRev.ExtendReviewers(revisions...)
222222
newRev.ExtendReviewersFromApi(apiPr)
223+
newRev.ExtendUserReviewers(args.UserReviewer...)
224+
newRev.ExtendTeamReviewers(args.TeamReviewer...)
223225

224226
path, err := newPrComment(newRev, revisions)
225227
if err != nil {

main.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,11 @@ import (
1212
var version string
1313

1414
type CreateArgs struct {
15-
Commitish string `arg:"-c, --commitish" help:"a commitish to associate the revision with (HEAD if omitted)"`
16-
Edit bool `arg:"-e, --editor" help:"open an editor to add revision comment"`
17-
Message string `arg:"-m, --message" help:"add this as revision comment"`
15+
Commitish string `arg:"-c, --commitish" help:"a commitish to associate the revision with (HEAD if omitted)"`
16+
Edit bool `arg:"-e, --editor" help:"open an editor to add revision comment"`
17+
Message string `arg:"-m, --message" help:"add this as revision comment"`
18+
UserReviewer []string `arg:"-r, --reviewer,separate" help:"add a user reviewer to the pull-request"`
19+
TeamReviewer []string `arg:"-t, --team-reviewer,separate" help:"add a team reviewer to the pull-request"`
1820
}
1921

2022
type DiffArgs struct {

revision.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,18 @@ func (r *Revision) AddTeamReviewer(slug string) {
6161
r.TeamReviewers = append(r.TeamReviewers, slug)
6262
}
6363

64+
func (r *Revision) ExtendUserReviewers(reviewers ...string) {
65+
for _, login := range reviewers {
66+
r.AddUserReviewer(login)
67+
}
68+
}
69+
70+
func (r *Revision) ExtendTeamReviewers(reviewers ...string) {
71+
for _, slug := range reviewers {
72+
r.AddTeamReviewer(slug)
73+
}
74+
}
75+
6476
func (r *Revision) ExtendReviewers(revisions ...Revision) {
6577
for _, other := range revisions {
6678
for _, login := range other.UserReviewers {

0 commit comments

Comments
 (0)