Skip to content

Commit

Permalink
feat: added env var REPOSITORY_NAME to script runs
Browse files Browse the repository at this point in the history
  • Loading branch information
lindell committed Jun 28, 2020
1 parent f4a05f4 commit 4a72ee6
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
8 changes: 7 additions & 1 deletion cmd/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,17 @@ import (
"github.com/spf13/cobra"
)

const runHelp = `
This command will clone down multiple repositories. For each of those repositories, the script will be run in the context of that repository. If the script finished with a zero exit code, and the script resulted in file changes, a pull request will be created with.
The environment variable REPOSITORY_NAME will be set to the name of the repository currently being executed by the script.
`

// RunCmd is the main command that runs a script for multiple repositories and creates PRs with the changes made
var RunCmd = &cobra.Command{
Use: "run [script path]",
Short: "Clones multiple repostories, run a script in that directory, and creates a PR with those changes.",
Long: "Run will clone down multiple repositories. For each of those repositories, the script will be run. If the script finished with a zero exit code, and the script resulted in file changes, a pull request will be created with.",
Long: runHelp,
Args: cobra.ExactArgs(1),
RunE: run,
}
Expand Down
3 changes: 3 additions & 0 deletions internal/multigitter/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,9 @@ func (r Runner) runSingleRepo(ctx context.Context, repo domain.Repository) error
// If the command return a non zero exit code, abort.
cmd := exec.Command(r.ScriptPath)
cmd.Dir = tmpDir
cmd.Env = append(os.Environ(),
fmt.Sprintf("REPOSITORY_NAME=%s", repo.Name),
)

writer := newLogger()
defer writer.Close()
Expand Down

0 comments on commit 4a72ee6

Please sign in to comment.