add commit ref (#1)

* add commit ref

Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>

* update to RefSpec

Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
This commit is contained in:
Bo-Yi Wu
2017-06-17 02:42:05 -05:00
committed by GitHub
parent a1ccf186fd
commit cad7d92b58
2 changed files with 14 additions and 1 deletions
+6
View File
@@ -85,6 +85,11 @@ func main() {
Usage: "git commit sha",
EnvVar: "DRONE_COMMIT_SHA",
},
cli.StringFlag{
Name: "commit.refspec",
Usage: "git commit ref spec",
EnvVar: "DRONE_COMMIT_REFSPEC",
},
cli.StringFlag{
Name: "commit.branch",
Value: "master",
@@ -173,6 +178,7 @@ func run(c *cli.Context) error {
Event: c.String("build.event"),
Status: c.String("build.status"),
Commit: c.String("commit.sha"),
RefSpec: c.String("commit.refspec"),
Branch: c.String("commit.branch"),
Author: c.String("commit.author"),
Email: c.String("commit.author.email"),
+8 -1
View File
@@ -26,6 +26,7 @@ type (
Event string
Number int
Commit string
RefSpec string
Branch string
Author string
Avatar string
@@ -171,7 +172,13 @@ func (p *Plugin) DroneTemplate() EmbedObject {
case "push":
description = fmt.Sprintf("%s pushed to %s", p.Build.Author, p.Build.Branch)
case "pull_request":
description = fmt.Sprintf("%s created pull request %s", p.Build.Author, p.Build.Branch)
branch := ""
if p.Build.RefSpec != "" {
branch = p.Build.RefSpec
} else {
branch = p.Build.Branch
}
description = fmt.Sprintf("%s updated pull request %s", p.Build.Author, branch)
case "tag":
description = fmt.Sprintf("%s pushed tag %s", p.Build.Author, p.Build.Branch)
}