Skip to content

Commit

Permalink
Better handling of git "safe.directory" (#316)
Browse files Browse the repository at this point in the history
  • Loading branch information
Nuru authored Apr 26, 2022
1 parent fa07ac3 commit 276132b
Show file tree
Hide file tree
Showing 4 changed files with 101 additions and 4 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
name: "docker"
on:
workflow_dispatch:

pull_request:
types: [opened, synchronize, reopened]
release:
Expand Down
50 changes: 49 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,57 @@ It's designed to work with CI/CD systems such as GitHub Actions, Codefresh, Trav

GitHub announced that the [`git.io` redirector service is shutting down on 2022-04-29](https://github.blog/changelog/2022-04-25-git-io-deprecation/). This means all references to `git.io/build-harness` will stop working.

We have acquired `cloudposse.tools` to mitigate this. Update all references of `git.io/build-harness` with `cloudposse.tools/build-harness`.
Critical references are in Makefiles, and there are also important references in README files that describe Makefiles.

We have acquired `cloudposse.tools` to mitigate this. Update all references of `git.io/build-harness` with `cloudposse.tools/build-harness`

Use the following command to replace all occurrences:
## Automating the update process

In all cases, these commands are intended to be run from a directory at the top of the directory tree
under which all your potentially affected code resides. Usually either the top-level directory of a single `git` repo
or a `src` (or similar) directory under which you have all your `git` repos (directly or in subdirectories).

### Finding affected files

Use the following command to find all occurrences in all directories recursively:
```
grep -l "git\.io/build-harness" -R .
```
Note that the above command can reach very deeply, such as into Terraform modules you have downloaded. You may want to impose some limits.
If you run from the top level of a `git` repo, where there is a `Makefile` and a `Dockerfile`, you can reduce that to
```
grep -l "git\.io/build-harness" *
```
If you have a lot of Cloud Posse projects under a single directory, then you might try
```
grep -l "git\.io/build-harness" * */*
```
or for full depth below the current directory
```
find . \( -name .terraform -prune -type f \) -o \( -name build-harness -prune -type f \) -o \( -name 'Makefile*' -o -name 'README*' \)
```

### Updating the affected files

Once you are happy with the command to generate the list of files to update, update the files by inserting that command into this command template:
```
sed -i '' 's/git.io\/build-harness/cloudposse.tools\/build-harness/' $(<command to list files>)
```

#### Examples

The quickest update will be if you only have a single project to update, in which case you can `cd` into the project root directory and
```
sed -i '' 's/git.io\/build-harness/cloudposse.tools\/build-harness/' $(grep -l "git\.io/build-harness" *)
```

If you have multiple projects to update and want to be thorough, then this is probably best:
```
sed -i '' 's/git.io\/build-harness/cloudposse.tools\/build-harness/' $(find . \( -name .terraform -prune -type f \) -o \( -name build-harness -prune -type f \) -o \( -name 'Makefile*' -o -name 'README*' \) )
```

This is the most thorough, but probably overkill for most people:
```
sed -i '' 's/git.io\/build-harness/cloudposse.tools\/build-harness/' $(grep -l "git\.io/build-harness" -R .)
```
Expand Down
51 changes: 49 additions & 2 deletions README.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,60 @@ description: |-
GitHub announced that the [`git.io` redirector service is shutting down on 2022-04-29](https://github.blog/changelog/2022-04-25-git-io-deprecation/). This means all references to `git.io/build-harness` will stop working.
We have acquired `cloudposse.tools` to mitigate this. Update all references of `git.io/build-harness` with `cloudposse.tools/build-harness`.
Critical references are in Makefiles, and there are also important references in README files that describe Makefiles.
We have acquired `cloudposse.tools` to mitigate this. Update all references of `git.io/build-harness` with `cloudposse.tools/build-harness`
Use the following command to replace all occurrences:
## Automating the update process
In all cases, these commands are intended to be run from a directory at the top of the directory tree
under which all your potentially affected code resides. Usually either the top-level directory of a single `git` repo
or a `src` (or similar) directory under which you have all your `git` repos (directly or in subdirectories).
### Finding affected files
Use the following command to find all occurrences in all directories recursively:
```
sed -i '' 's/git.io\/build-harness/cloudposse.tools\/build-harness/' $(grep -l "git\.io/build-harness" -R .)
grep -l "git\.io/build-harness" -R .
```
Note that the above command can reach very deeply, such as into Terraform modules you have downloaded. You may want to impose some limits.
If you run from the top level of a `git` repo, where there is a `Makefile` and a `Dockerfile`, you can reduce that to
```
grep -l "git\.io/build-harness" *
```
If you have a lot of Cloud Posse projects under a single directory, then you might try
```
grep -l "git\.io/build-harness" * */*
```
or for full depth below the current directory
```
find . \( -name .terraform -prune -type f \) -o \( -name build-harness -prune -type f \) -o \( -name 'Makefile*' -o -name 'README*' \)
```
### Updating the affected files
Once you are happy with the command to generate the list of files to update, update the files by inserting that command into this command template:
```
sed -i '' 's/git.io\/build-harness/cloudposse.tools\/build-harness/' $(<command to list files>)
```
#### Examples
The quickest update will be if you only have a single project to update, in which case you can `cd` into the project root directory and
```
sed -i '' 's/git.io\/build-harness/cloudposse.tools\/build-harness/' $(grep -l "git\.io/build-harness" *)
```
If you have multiple projects to update and want to be thorough, then this is probably best:
```
sed -i '' 's/git.io\/build-harness/cloudposse.tools\/build-harness/' $(find . \( -name .terraform -prune -type f \) -o \( -name build-harness -prune -type f \) -o \( -name 'Makefile*' -o -name 'README*' \) )
```
This is the most thorough, but probably overkill for most people:
```
sed -i '' 's/git.io\/build-harness/cloudposse.tools\/build-harness/' $(grep -l "git\.io/build-harness" -R .)
```
# Introduction to the project
#introduction: |-
Expand Down
2 changes: 1 addition & 1 deletion templates/Makefile.build-harness
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ clean::

# Workaround for https://github.com/actions/checkout/issues/766
safe-directory:
[[ -z "$$GITHUB_WORKSPACE" ]] || git config --global --add safe.directory "$$GITHUB_WORKSPACE"
[[ -n "$$GITHUB_WORKSPACE" ]] && git config --global --add safe.directory "$$GITHUB_WORKSPACE" || git config --global --add safe.directory '*'

.PHONY: build-harness/shell builder build-harness/shell/pull builder/pull builder/build builder-slim/build

Expand Down

0 comments on commit 276132b

Please sign in to comment.