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

Add missing base_branch parameter to planpreview request #2130

Merged
merged 1 commit into from
Jun 25, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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