diff --git a/cmd/run.go b/cmd/run.go index 570693d6..c68719ce 100755 --- a/cmd/run.go +++ b/cmd/run.go @@ -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, } diff --git a/internal/multigitter/run.go b/internal/multigitter/run.go index 31b82c2c..56320a29 100755 --- a/internal/multigitter/run.go +++ b/internal/multigitter/run.go @@ -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()