-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Simplify git setup by exiting on .git presence
- Loading branch information
Showing
1 changed file
with
13 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,20 @@ | ||
#!/bin/sh | ||
|
||
apk update && apk add git | ||
|
||
git remote || INIT=true | ||
ls .git && return 0 | ||
|
||
echo "${GITHUB_REPO}" | grep -q "#" && TAG="${GITHUB_REPO#*#}" || TAG= | ||
|
||
if [ "${INIT}" ] | ||
apk update && apk add git | ||
git init | ||
chown -R "$(find . -maxdepth 1 -exec ls -ld {} + | awk '{print $3":"$4}' | tail -n1)" .git | ||
git config --global --add safe.directory "${PWD}" | ||
REPO="${GITHUB_REPO%%#*}" | ||
git remote add origin "${REPO}" | ||
git fetch | ||
DEFAULT_BRANCH=$(git remote show origin | sed -n '/HEAD branch/s/.*: //p') | ||
git reset --hard origin/"${DEFAULT_BRANCH}" | ||
git clean -fd | ||
if [ -n "${TAG}" ] | ||
then | ||
git init | ||
chown -R "$(find . -maxdepth 1 -exec ls -ld {} + | awk '{print $3":"$4}' | tail -n1)" .git | ||
git config --global --add safe.directory "${PWD}" | ||
REPO="${GITHUB_REPO%%#*}" | ||
git remote add origin "${REPO}" | ||
git fetch | ||
DEFAULT_BRANCH=$(git remote show origin | sed -n '/HEAD branch/s/.*: //p') | ||
git reset --hard origin/"${DEFAULT_BRANCH}" | ||
git clean -fd | ||
if [ -n "${TAG}" ] | ||
then | ||
git checkout "${TAG}" | ||
fi | ||
git checkout "${TAG}" | ||
fi |