Adding crowdin branch support (#1)

* Adding crowdin branch support

Signed-off-by: Jonas Franz <info@jonasfranz.de>

* Adding documentation for ignore_branche

Signed-off-by: Jonas Franz <info@jonasfranz.de>
development
Jonas Franz 7 years ago committed by GitHub
parent ec3cf3004c
commit 39fb5cfbe0
  1. 1
      DOCS.md
  2. 14
      main.go
  3. 11
      plugin.go

@ -7,6 +7,7 @@ You must provide in your configuration:
* `files` - Map of files to upload to Crowdin
* key: the Crowdin file name
* value: the real path the to file
* `ignore_branch` It will send the Drone branch to Crowdin if it is `false`. (Default: `false`)
Information about API keys: https://support.crowdin.com/api/api-integration-setup/
## Example

@ -33,6 +33,17 @@ func main() {
EnvVar: "PLUGIN_FILES",
Value: &StringMapFlag{},
},
cli.StringFlag{
Name: "commit.branch",
Value: "master",
Usage: "git commit branch",
EnvVar: "DRONE_COMMIT_BRANCH",
},
cli.BoolFlag{
Name: "ignore-branch",
Usage: "if true it will not pass the branch to crowdin",
EnvVar: "PLUGIN_IGNORE_BRANCH",
},
}
if err := app.Run(os.Args); err != nil {
log.Fatal(err)
@ -47,5 +58,8 @@ func run(c *cli.Context) error {
Key: c.String("project-key"),
},
}
if !c.Bool("ignore-branch") {
plugin.Branch = c.String("commit.branch")
}
return plugin.Exec()
}

@ -26,6 +26,7 @@ type (
Plugin struct {
Config Config
Files Files
Branch string
}
)
@ -57,9 +58,13 @@ func (p Plugin) Exec() error {
if _, err = io.Copy(part, file); err != nil {
return err
}
if err = writer.Close(); err != nil {
return err
}
}
// Adding branch if it is not ignored
if p.Branch != "" {
writer.WriteField("branch", p.Branch)
}
if err := writer.Close(); err != nil {
return err
}
var req *http.Request
var err error

Loading…
Cancel
Save