Skip to content

Instantly share code, notes, and snippets.

@vividtone
Created August 17, 2022 03:52
Show Gist options
  • Save vividtone/dc194a69ec18fba0575e4de234932380 to your computer and use it in GitHub Desktop.
Save vividtone/dc194a69ec18fba0575e4de234932380 to your computer and use it in GitHub Desktop.
Sync scripts for github.com/redmine/redmine
#!/bin/bash
set -euo pipefail
echo "--- BEGIN $(date)"
cd $(dirname $0)/redmine-svn
git for-each-ref refs/remotes | \
awk '{print $NF}' | \
grep -vE "tags|origin|trunk" | \
grep stable | while read remote; do
for gh in github0 github1 github2; do
if git config --get-all "remote.$gh.push" | grep -q "$remote:"; then
# branch already in config
continue
fi
echo "Missing on $gh: $remote"
cmd="git config --add remote.$gh.push $remote:${remote/remotes/heads}"
echo " running: $cmd"
$cmd
done
done
echo "--- END $(date)"
echo
*/5 * * * * ubuntu /home/ubuntu/redmine-mirror/sync.sh 2>&1 | tee -a /home/ubuntu/redmine-mirror/update.log
28 * * * * ubuntu /home/ubuntu/redmine-mirror/add-stable-branches.sh 2>&1 | tee -a /home/ubuntu/redmine-mirror/branches.log
#!/bin/bash
echo "--- BEGIN $(date)"
cd $(dirname $0)/redmine-svn
git svn fetch --all
git for-each-ref refs/remotes/tags | cut -d / -f 4- | while read ref; do
if test -z "$(git tag -l $ref)"; then
git tag -a "$ref" -m "tagged version $ref" "refs/remotes/tags/$ref"
fi
done
#git push github0
git push github1
#svn metadata
echo "--- END $(date)"
echo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment