mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2024-11-26 03:41:01 +00:00
Get default branch and show message in pipeline list (#3867)
This commit is contained in:
parent
28e982fffb
commit
38b8a55714
3 changed files with 19 additions and 11 deletions
|
@ -30,7 +30,7 @@ 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{
|
||||
|
@ -38,7 +38,6 @@ var Command = &cli.Command{
|
|||
&cli.StringFlag{
|
||||
Name: "branch",
|
||||
Usage: "branch filter",
|
||||
Value: "main",
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "event",
|
||||
|
@ -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" {
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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",
|
||||
|
@ -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",
|
||||
|
@ -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",
|
||||
},
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue