From 4d81463858b6cc04f9bcf27eb7e2b8238d4e59b8 Mon Sep 17 00:00:00 2001 From: jeff350 <10672501+jeff350@users.noreply.github.com> Date: Mon, 12 Feb 2024 22:15:54 -0600 Subject: [PATCH] feat: add repo directory env var --- README.md | 11 ++++++----- data/test/_testscripts/test-env-vars.sh | 3 ++- repository/repo-operations.go | 1 + 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 7b05599..0d3aaa3 100644 --- a/README.md +++ b/README.md @@ -247,11 +247,12 @@ git-xargs --github-org my-github-org \ When executing commands or scripts, `git-xargs` will register the following environment variables for use by commands or scripts based on the arguments and flags provided: -| Env var | Value -| ------------------ | --------------------------- -| `XARGS_DRY_RUN` | Whether the `--dry-run` flag was provided to `git-xargs`; options are `true`, `false` -| `XARGS_REPO_NAME` | Name of the target repository being processed -| `XARGS_REPO_OWNER` | Owner of the target repository being processed +| Env var | Value +| ---------------------- | --------------------------- +| `XARGS_DRY_RUN` | Whether the `--dry-run` flag was provided to `git-xargs`; options are `true`, `false` +| `XARGS_REPO_NAME` | Name of the target repository being processed +| `XARGS_REPO_OWNER` | Owner of the target repository being processed +| `XARGS_REPO_DIRECTORY` | Directory of the target repository being processed ## Debugging runtime errors diff --git a/data/test/_testscripts/test-env-vars.sh b/data/test/_testscripts/test-env-vars.sh index 108e2e9..31ca2c9 100755 --- a/data/test/_testscripts/test-env-vars.sh +++ b/data/test/_testscripts/test-env-vars.sh @@ -4,4 +4,5 @@ echo "XARGS_DRY_RUN=$XARGS_DRY_RUN" echo "XARGS_REPO_NAME=$XARGS_REPO_NAME" -echo "XARGS_REPO_OWNER=$XARGS_REPO_OWNER" \ No newline at end of file +echo "XARGS_REPO_OWNER=$XARGS_REPO_OWNER" +echo "XARGS_REPO_DIRECTORY=$XARGS_REPO_DIRECTORY" diff --git a/repository/repo-operations.go b/repository/repo-operations.go index d1f3761..627c315 100644 --- a/repository/repo-operations.go +++ b/repository/repo-operations.go @@ -114,6 +114,7 @@ func executeCommandWithLogger(config *config.GitXargsConfig, repositoryDir strin cmd.Env = append(cmd.Env, fmt.Sprintf("XARGS_DRY_RUN=%t", config.DryRun)) cmd.Env = append(cmd.Env, fmt.Sprintf("XARGS_REPO_NAME=%s", repo.GetName())) cmd.Env = append(cmd.Env, fmt.Sprintf("XARGS_REPO_OWNER=%s", repo.GetOwner().GetLogin())) + cmd.Env = append(cmd.Env, fmt.Sprintf("XARGS_REPO_DIRECTORY=%s", repositoryDir)) logger.WithFields(logrus.Fields{ "Repo": repo.GetName(),