mirror of
https://github.com/appleboy/drone-discord.git
synced 2026-06-04 10:23:47 +08:00
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:
@@ -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"),
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user