You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+64-35Lines changed: 64 additions & 35 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -30,7 +30,7 @@ You can handle these use cases and many more with a single `git-xargs` command.
30
30
As an example, let's use `git-xargs` to create a new file in every repo:
31
31
32
32
```
33
-
./git-xargs \
33
+
git-xargs \
34
34
--branch-name test-branch \
35
35
--github-org <your-github-org> \
36
36
--commit-message "Create hello-world.txt" \
@@ -129,68 +129,71 @@ COMMAND SUPPLIED
129
129
130
130
## Getting started
131
131
132
-
### 1. Export a valid Github token
133
-
134
-
See the guide on [Github personal access tokens](https://docs.github.com/en/free-pro-team@latest/github/authenticating-to-github/creating-a-personal-access-token) for information on how to generate one.
Visit [the releases page](https://github.com/gruntwork-io/git-xargs/releases) and download the correct binary depending on your system. For example, you might opt to save it to `/usr/local/bin/git-xargs`.
140
+
1. **Download the correct binary for your platform**. Visit [the releases
141
+
page](https://github.com/gruntwork-io/git-xargs/releases) and download the correct binary depending on your system.
142
+
Save it to somewhere on your `PATH`, such as `/usr/local/bin/git-xargs`.
143
143
144
-
### 3. Set the correct permissions
144
+
1. **Set execute permissions**. For example, on Linux or Mac, you'd run:
145
145
146
-
`chmod u+x /usr/local/bin/git-xargs`
146
+
```bash
147
+
chmod u+x /usr/local/bin/git-xargs
148
+
```
147
149
148
-
### 4. Run the version command to ensure everything is working properly
150
+
1. **Check it's working**. Run the version command to ensure everything is working properly:
149
151
150
-
```
151
-
git-xargs --version
152
-
```
152
+
```bash
153
+
git-xargs --version
154
+
```
153
155
154
-
### 5. Provide a script or command and target some repos
156
+
1. **Provide a script or command and target some repos**. Here's a simple example of running the `touch` command in
157
+
every repo in your Github organization. Follow the same pattern to start running your own scripts and commands
158
+
against your own repos!
155
159
156
-
Here's a simple example of running a touch commnand in every repo in your Github organization. Follow the same pattern to start running your own scripts and commands against your own repos!
160
+
```bash
161
+
git-xargs \
162
+
--branch-name "test-branch" \
163
+
--commit-message "Testing git-xargs" \
164
+
--github-org <enter-your-github-org-name> \
165
+
touch git-xargs-is-awesome.txt
166
+
```
157
167
158
-
```
159
-
git-xargs \
160
-
--branch-name "test-branch" \
161
-
--commit-message "Testing git-xargs" \
162
-
--github-org <enter-your-github-org-name> \
163
-
touch git-xargs-is-awesome.txt
164
-
```
165
168
# Reference
166
169
167
170
## How to supply commands or scripts to run
168
171
169
172
The API for `git-xargs` is:
170
173
171
174
```
172
-
./git-xargs [-flags] <CMD>
175
+
git-xargs [-flags] <CMD>
173
176
```
174
177
175
178
Where `CMD` is either the full path to a (Bash, Python, Ruby) etc script on your local system or a binary. Note that, because the tool supports Bash scripts, Ruby scripts, Python scripts, etc, you must include the full filename for any given script, including its file extension.
176
179
177
180
In other words, all the following usages are valid:
@@ -208,7 +211,7 @@ Currently, `git-xargs` will find and add any and all new files, as well as any e
208
211
Scripts may be placed anywhere on your system, but you are responsible for providing absolute paths to your scripts when invoking `git-xargs`:
209
212
210
213
```
211
-
./git-xargs \
214
+
git-xargs \
212
215
--branch-name upgrade-tf-14 \
213
216
--commit-message "Update modules to Terraform 0.14" \
214
217
--repos data/batch3.txt \
@@ -217,7 +220,7 @@ Scripts may be placed anywhere on your system, but you are responsible for provi
217
220
or
218
221
219
222
```
220
-
./git-xargs \
223
+
git-xargs \
221
224
--branch-name upgrade-tf-14 \
222
225
--commit-message "Update modules to Terraform 0.14" \
223
226
--repos data/batch3.txt \
@@ -228,13 +231,14 @@ If you need to compose more complex behavior into a single pull request, write a
228
231
229
232
## How to target repos to run your scripts against
230
233
231
-
`git-xargs` supports **two** methods of targeting repos to run your selected scripts against. Note that you **must** select one or the other option when running `git-xargs`, meaning you must either pass `--repos` or `--github-org` as demonstrated below:
234
+
`git-xargs` supports **four** methods of targeting repos to run your selected scripts against. They are processed in
235
+
the order listed below, with whichever option is found first being used, and all others after it being ignored.
232
236
233
237
### Option #1: Github organization lookup
234
238
If you want the tool to find and select every repo in your Github organization, you can pass the name of your organization via the `--github-org` flag:
235
239
236
240
```
237
-
./git-xargs \
241
+
git-xargs \
238
242
--commit-message "Update copyright year" \
239
243
--github-org <your-github-org> \
240
244
"$(pwd)/scripts/update-copyright-year.sh"
@@ -247,7 +251,7 @@ This will signal the tool to look up, and page through, every repository in your
247
251
Oftentimes, you want finer-grained control over the exact repos you are going to run your script against. In this case, you can use the `--repos` flag and supply the path to a file defining the exact repos you want the tool to run your selected scripts against, like so:
Flat files contain one repo per line, each repository in the format of `<github-organization>/<repo-name>`. Commas, trailing or preceding spaces, and quotes are all filtered out at runtime. This is done in case you end up copying your repo list from a JSON list or CSV file.
266
270
271
+
### Option #3: Pass in repos via command line args
272
+
273
+
Another way to get fine-grained control is to pass in the individual repos you want to use via one or more `--repo`
274
+
arguments:
275
+
276
+
```
277
+
git-xargs \
278
+
--commit-mesage "Update copyright year" \
279
+
--repo gruntwork-io/terragrunt \
280
+
--repo gruntwork-io/terratest \
281
+
--repo gruntwork-io/cloud-nuke \
282
+
"$(pwd)/scripts/update-copyright-year.sh"
283
+
```
284
+
285
+
### Option #4: Pass in repos via stdin
286
+
287
+
And one more (Unix-philosophy friendly) way to get fine-grained control is to pass in the individual repos you want to
288
+
use by piping them in via `stdin`, separating repo names with whitespace or newlines:
`git-xargs` exposes several flags that allow you to customize its behavior to better suit your needs. For the latest info on flags, you should run `./git-xargs --help`. However, a couple of the flags are worth explaining more in depth here:
298
+
`git-xargs` exposes several flags that allow you to customize its behavior to better suit your needs. For the latest info on flags, you should run `git-xargs --help`. However, a couple of the flags are worth explaining more in depth here:
0 commit comments