Skip to content

Commit

Permalink
Fix: "git rm" fails when publish branch is empty (#24)
Browse files Browse the repository at this point in the history
When a publish branch exists and it has no files, `git rm -r '*'` fails with

```
fatal: pathspec '*' did not match any files
```

`--ignore-unmatch` option let git exit with a zero status in this case.

Reference: https://git-scm.com/docs/git-rm#Documentation/git-rm.txt---ignore-unmatch
  • Loading branch information
blue-jam authored and peaceiris committed Sep 15, 2019
1 parent 201f9af commit 47a6d63
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ remote_branch="${PUBLISH_BRANCH}"
local_dir="${HOME}/$(tr -cd 'a-f0-9' < /dev/urandom | head -c 32)"
if git clone --depth=1 --single-branch --branch "${remote_branch}" "${remote_repo}" "${local_dir}"; then
cd "${local_dir}"
git rm -r '*'
git rm -r --ignore-unmatch '*'
find "${GITHUB_WORKSPACE}/${PUBLISH_DIR}" -maxdepth 1 | \
tail -n +2 | \
xargs -I % cp -rf % "${local_dir}/"
Expand Down

0 comments on commit 47a6d63

Please sign in to comment.