-
-
Notifications
You must be signed in to change notification settings - Fork 61
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
Add support for git-xargs registered environment variables based on arguments and flags #127
Add support for git-xargs registered environment variables based on arguments and flags #127
Conversation
Closes gruntwork-io#115 These changes add support for git-xargs registered environment variables based on arguments and flags intended for use by the commands and scripts called by git-xargs. These environment variables start with `XARGS_` to avoid collision with other use cases and include: - `XARGS_REPO_NAME`: the name of the repository targeted - `XARGS_DRY_RUN`: whether `--dry-run` flag was provided Additionally, these changes contain a basic test to ensure this feature works as expected going forward.
While updating documentation, I realized that the original intent of issue 115 might require the repository owner information as well as the repository name. This expands the initial changes and performs some minor refactoring.
This would address my use-case. Very much appreciated |
cc: @karlwithak1 |
@andyfeller Thanks for your PR! Your changes LGTM, so I've kicked off tests |
@andyfeller would you kindly |
@zackproser : I'm currently working on my personal laptop being out of office, the script appears to match the permissions of the others on WSL: andyfeller@WIN-29L6KJF8DED:/mnt/c/Users/andre/Documents/Workspace/andyfeller/git-xargs/data/test/_testscripts$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 20.04.3 LTS
Release: 20.04
Codename: focal
andyfeller@WIN-29L6KJF8DED:/mnt/c/Users/andre/Documents/Workspace/andyfeller/git-xargs/data/test/_testscripts$ ls -l
total 4
-rwxrwxrwx 1 andyfeller andyfeller 1249 Jun 28 08:29 add-license.sh
-rwxrwxrwx 1 andyfeller andyfeller 83 Jun 28 08:29 bad-perm.sh
-rwxrwxrwx 1 andyfeller andyfeller 306 Jun 28 09:30 test-env-vars.sh
-rwxrwxrwx 1 andyfeller andyfeller 59 Jun 28 08:29 test-python.py
-rwxrwxrwx 1 andyfeller andyfeller 55 Jun 28 08:29 test-ruby.rb
-rwxrwxrwx 1 andyfeller andyfeller 293 Jun 28 08:29 test-stdout-stderr.sh This appears to differ on Git Bash for Windows: andre@WIN-29L6KJF8DED MINGW64 ~/Documents/Workspace/andyfeller/git-xargs/data/test/_testscripts (issue-115-env-vars)
$ ll
total 9
-rwxr-xr-x 1 andre 197609 1249 Jun 28 08:29 add-license.sh*
-rwxr-xr-x 1 andre 197609 83 Jun 28 08:29 bad-perm.sh*
-rwxr-xr-x 1 andre 197609 306 Jun 28 09:30 test-env-vars.sh*
-rwxr-xr-x 1 andre 197609 59 Jun 28 08:29 test-python.py*
-rwxr-xr-x 1 andre 197609 55 Jun 28 08:29 test-ruby.rb*
-rwxr-xr-x 1 andre 197609 293 Jun 28 08:29 test-stdout-stderr.sh* When trying to change the mode of the file, |
Trying to utilize $ git update-index --chmod=+x test-env-vars.sh |
Thanks, Andy! LGTM, so approving and merging. |
@andyfeller Thanks again - https://github.com/gruntwork-io/git-xargs/releases/tag/v0.1.9 is the latest release that will have your changes. v0.1.8 had a build issue related to the Go version, which I bumped in a subsequent release. |
@zackproser : thank you and thank you for OSSing your work for others ✨ I hope to contribute back more, an example of a wrapper script that will demonstrate calling multiple commands and scripts. In my use case, I have repositories created from a template, which has been updated with new files that the children should get. Additionally, there have been new issue / PR labels I want to push out, which is was somewhat difficult without this PR due to knowing if |
@andyfeller Thanks so much for your kind words. It is my sincere pleasure. That sounds terrific and I'd bet many others would benefit from that as well. I initially had this scripts folder here thinking it might be a decent place for the community to compile such scripts / examples - but perhaps those belong in a separate repo? Not sure. |
@zackproser : finally finished refactoring my initial prototype wrapping around git-xargs and released it as a GitHub CLI extension: https://github.com/andyfeller/gh-publicize I'd love to chat a bit regarding your thoughts, can open an issue or discussion. |
@andyfeller Wow! This looks super cool - I especially love the fact you made it a gh extension - I've found those to work really well in the past. I love the proposed use cases you have as well - they all make a ton of sense and were part of what originally urged us on to write git-xargs. Speaking of which - one other idea I always thought would be awesome in conjunction with this stuff is some kind of light engine that could provide the git diff between some desired state and the current state of a given repo - which could output git-xargs or gh-publicize instructions / API calls - to essentially open the PRs which would get your repos all up to date and compliant with what you've set as your template repo - if I'm making sense. One logistical note - I'm no longer working at Gruntwork, so I'm unlikely to have time to return to this anytime soon, but I'll bet @brikis98 would be keen to know about this as well. Seriously - very cool work 🎉 |
So is this less of a push model and more of a pull? A process that reverse engineers what it is missing to match the source repository in question, yeah?
Congratulations on the new adventure! Happy to talk shop with others as I appreciate the work here ❤️ |
@andyfeller 😂 Precisely - your gif game is on point! |
Description
Fixes #115.
These changes add support for git-xargs registered environment variables based on arguments and flags intended for use by the commands and scripts called by
git-xargs
. These environment variables start withXARGS_
to avoid collision with other use cases and include:XARGS_DRY_RUN
: whether--dry-run
flag was providedXARGS_REPO_NAME
: the name of the target repository being processedXARGS_REPO_OWNER
: the owner of the target repository being processedTODOs
Read the Gruntwork contribution guidelines.
Release Notes (draft)
Added support for environment variables registered by
git-xargs
based on flags and argumentsMigration Guide