Skip to content

Commit

Permalink
Add missing base_branch parameter to planpreview request (#2130)
Browse files Browse the repository at this point in the history
**What this PR does / why we need it**:

**Which issue(s) this PR fixes**:

Fixes #

**Does this PR introduce a user-facing change?**:
<!--
If no, just write "NONE" in the release-note block below.
-->
```release-note
NONE
```

This PR was merged by Kapetanios.
  • Loading branch information
nghialv committed Jun 25, 2021
1 parent 849c28f commit 1becbe1
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 8 deletions.
5 changes: 3 additions & 2 deletions pkg/app/api/grpcapi/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@ func (a *API) RequestPlanPreview(ctx context.Context, req *apiservice.RequestPla
repositories := make(map[string]string, len(pipeds))
for _, p := range pipeds {
for _, r := range p.Repositories {
if r.Remote == req.RepoRemoteUrl {
if r.Remote == req.RepoRemoteUrl && r.Branch == req.BaseBranch {
repositories[p.Id] = r.Id
break
}
Expand All @@ -415,8 +415,9 @@ func (a *API) RequestPlanPreview(ctx context.Context, req *apiservice.RequestPla
Commander: commander,
BuildPlanPreview: &model.Command_BuildPlanPreview{
RepositoryId: repositoryID,
Branch: req.Branch,
HeadBranch: req.HeadBranch,
HeadCommit: req.HeadCommit,
BaseBranch: req.BaseBranch,
},
}
if err := addCommand(ctx, a.commandStore, &cmd, a.logger); err != nil {
Expand Down
3 changes: 2 additions & 1 deletion pkg/app/api/service/apiservice/service.proto
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,9 @@ message RegisterEventResponse {

message RequestPlanPreviewRequest {
string repo_remote_url = 1 [(validate.rules).string.min_len = 1];
string branch = 2 [(validate.rules).string.min_len = 1];
string head_branch = 2 [(validate.rules).string.min_len = 1];
string head_commit = 3 [(validate.rules).string.min_len = 1];
string base_branch = 4 [(validate.rules).string.min_len = 1];
}

message RequestPlanPreviewResponse {
Expand Down
12 changes: 8 additions & 4 deletions pkg/app/pipectl/cmd/planpreview/planpreview.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,9 @@ import (

type command struct {
repoRemoteURL string
branch string
headBranch string
headCommit string
baseBranch string
timeout time.Duration
checkInterval time.Duration

Expand All @@ -56,12 +57,14 @@ func NewCommand() *cobra.Command {
c.clientOptions.RegisterPersistentFlags(cmd)

cmd.Flags().StringVar(&c.repoRemoteURL, "repo-remote-url", c.repoRemoteURL, "The remote URL of Git repository.")
cmd.Flags().StringVar(&c.branch, "branch", c.branch, "The branch of the target commit.")
cmd.Flags().StringVar(&c.headBranch, "head-branch", c.headBranch, "The head branch of the change.")
cmd.Flags().StringVar(&c.headCommit, "head-commit", c.headCommit, "The SHA of the head commit.")
cmd.Flags().StringVar(&c.baseBranch, "base-branch", c.baseBranch, "The base branch of the change.")

cmd.MarkFlagRequired("repo-remote-url")
cmd.MarkFlagRequired("branch")
cmd.MarkFlagRequired("head-branch")
cmd.MarkFlagRequired("head-commit")
cmd.MarkFlagRequired("base-branch")

return cmd
}
Expand All @@ -78,8 +81,9 @@ func (c *command) run(ctx context.Context, _ cli.Telemetry) error {

req := &apiservice.RequestPlanPreviewRequest{
RepoRemoteUrl: c.repoRemoteURL,
Branch: c.branch,
HeadBranch: c.headBranch,
HeadCommit: c.headCommit,
BaseBranch: c.baseBranch,
}

resp, err := cli.RequestPlanPreview(ctx, req)
Expand Down
3 changes: 2 additions & 1 deletion pkg/model/command.proto
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,9 @@ message Command {

message BuildPlanPreview {
string repository_id = 1 [(validate.rules).string.min_len = 1];
string branch = 2 [(validate.rules).string.min_len = 1];
string head_branch = 2 [(validate.rules).string.min_len = 1];
string head_commit = 3 [(validate.rules).string.min_len = 1];
string base_branch = 4 [(validate.rules).string.min_len = 1];
}

// The generated unique identifier.
Expand Down

0 comments on commit 1becbe1

Please sign in to comment.