Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add repo directory env var #147

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
3 changes: 2 additions & 1 deletion data/test/_testscripts/test-env-vars.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
echo "XARGS_REPO_OWNER=$XARGS_REPO_OWNER"
echo "XARGS_REPO_DIRECTORY=$XARGS_REPO_DIRECTORY"
1 change: 1 addition & 0 deletions repository/repo-operations.go
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down