Skip to content

Commit

Permalink
Get default branch and show message in pipeline list (woodpecker-ci#3867
Browse files Browse the repository at this point in the history
)
  • Loading branch information
anbraten authored and 6543 committed Sep 5, 2024
1 parent c7fef8e commit bc786b3
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 11 deletions.
12 changes: 10 additions & 2 deletions cli/deploy/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,14 @@ import (
// Command exports the deploy command.
var Command = &cli.Command{
Name: "deploy",
Usage: "deploy code",
Usage: "trigger a pipeline with the 'deployment' event",
ArgsUsage: "<repo-id|repo-full-name> <pipeline> <environment>",
Action: deploy,
Flags: []cli.Flag{
common.FormatFlag(tmplDeployInfo),
&cli.StringFlag{
Name: "branch",
Usage: "branch filter",
Value: "main",
},
&cli.StringFlag{
Name: "event",
Expand Down Expand Up @@ -74,6 +73,15 @@ func deploy(c *cli.Context) error {
event := c.String("event")
status := c.String("status")

if branch == "" {
repo, err := client.Repo(repoID)
if err != nil {
return err
}

branch = repo.DefaultBranch
}

pipelineArg := c.Args().Get(1)
var number int64
if pipelineArg == "last" {
Expand Down
2 changes: 1 addition & 1 deletion cli/pipeline/pipeline.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ func pipelineOutput(c *cli.Context, resources []woodpecker.Pipeline, fd ...io.Wr
fallthrough
default:
table := output.NewTable(out)
cols := []string{"Number", "Status", "Event", "Branch", "Commit", "Author"}
cols := []string{"Number", "Status", "Event", "Branch", "Message", "Author"}

if len(outOpt) > 0 {
cols = outOpt
Expand Down
16 changes: 8 additions & 8 deletions cli/pipeline/pipeline_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ func TestPipelineOutput(t *testing.T) {
{
name: "table output with default columns",
args: []string{},
expected: "NUMBER STATUS EVENT BRANCH COMMIT AUTHOR\n1 success push main abcdef John Doe\n",
expected: "NUMBER STATUS EVENT BRANCH MESSAGE AUTHOR\n1 success push main message John Doe\n",
},
{
name: "table output with custom columns",
Expand All @@ -32,7 +32,7 @@ func TestPipelineOutput(t *testing.T) {
{
name: "table output with no header",
args: []string{"output", "--output-no-headers"},
expected: "1 success push main abcdef John Doe\n",
expected: "1 success push main message John Doe\n",
},
{
name: "go-template output",
Expand All @@ -48,12 +48,12 @@ func TestPipelineOutput(t *testing.T) {

pipelines := []woodpecker.Pipeline{
{
Number: 1,
Status: "success",
Event: "push",
Branch: "main",
Commit: "abcdef",
Author: "John Doe",
Number: 1,
Status: "success",
Event: "push",
Branch: "main",
Message: "message",
Author: "John Doe",
},
}

Expand Down

0 comments on commit bc786b3

Please sign in to comment.