Created
December 5, 2023 15:52
-
-
Save jpmens/3ed741405934841f78810ea72d6d08d7 to your computer and use it in GitHub Desktop.
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
#!/bin/sh | |
# Copyright 2023 Codeberg e.V. | |
# This work is marked with CC0 1.0 Universal. To view a copy of this | |
# license, visit http://creativecommons.org/publicdomain/zero/1.0 | |
# This work is dedicated to the public domains under the terms of the | |
# Unlicense, visit https://unlicense.org/ | |
# You are free to choose either the CC0 1.0 Univesal or Unlicense for this | |
# work. | |
# via https://mastodon.social/@[email protected]/111524635192557943 | |
repo="" # url to repository | |
dir="" # directory to cd into (or fail) | |
refspec="main" | |
cd $dir || exit 2 | |
if [ -d repo.git ]; then | |
cd repo.git | |
OLD_HEAD=$(git rev-parse HEAD) | |
git pull -q origin $refspec | |
NEW_HEAD=$(git rev-parse HEAD) | |
else | |
git clone -q "$repo" repo.git | |
cd repo.git | |
OLD_HEAD=xxx | |
NEW_HEAD=$(git rev-parse HEAD) | |
fi | |
[ $OLD_HEAD = $NEW_HEAD ] && exit | |
# now perform whatever you want to do ... | |
echo "I am in $(pwd)" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment