mirror of
https://github.com/luzifer-aur/scripts.git
synced 2024-12-30 00:31:17 +00:00
No longer maintaining AUR / automation is unwanted
Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
parent
3a68b88f50
commit
4800e5b240
1 changed files with 0 additions and 71 deletions
71
sync.sh
71
sync.sh
|
@ -1,71 +0,0 @@
|
|||
#!/bin/bash
|
||||
set -euo pipefail
|
||||
|
||||
function cleanup() {
|
||||
step "Cleaning up"
|
||||
rm -rf \
|
||||
"${workdir}"
|
||||
}
|
||||
trap cleanup EXIT
|
||||
|
||||
function error() {
|
||||
echo -e "$(tput setaf 1)$@$(tput sgr0)" >&2
|
||||
}
|
||||
|
||||
function fail() {
|
||||
error "$@"
|
||||
exit 1
|
||||
}
|
||||
|
||||
function step() {
|
||||
echo -e "$(tput setaf 6)[$(date)] $@...$(tput sgr0)" >&2
|
||||
}
|
||||
|
||||
function success() {
|
||||
echo -e "$(tput setaf 2)$@$(tput sgr0)" >&2
|
||||
}
|
||||
|
||||
function warn() {
|
||||
echo -e "$(tput setaf 3)$@$(tput sgr0)" >&2
|
||||
}
|
||||
|
||||
# ---
|
||||
|
||||
step "Creating a tempdir as working dir"
|
||||
workdir=$(mktemp -d)
|
||||
|
||||
step "Checking input"
|
||||
PKG=${1:-}
|
||||
[[ -n ${PKG} ]] || fail "No package given as first argument"
|
||||
|
||||
step "Entering workdir"
|
||||
pushd "${workdir}"
|
||||
|
||||
step "Initialize empty repo"
|
||||
git init
|
||||
|
||||
step "Fetching remote state"
|
||||
git remote add github git@github.com:luzifer-aur/${PKG}.git
|
||||
git remote add aur ssh://aur@aur.archlinux.org/${PKG}.git
|
||||
|
||||
git fetch github
|
||||
git fetch aur
|
||||
|
||||
step "Checking for differences in remotes"
|
||||
[[ $(git rev-parse github/master) == $(git rev-parse aur/master) ]] && {
|
||||
success "Remote refs are at the same commit"
|
||||
exit 0
|
||||
} || warn "Differences found, action needed"
|
||||
|
||||
step "Resetting to Github working state"
|
||||
git reset --hard github/master
|
||||
|
||||
step "Rebasing onto AUR working state"
|
||||
git rebase aur/master
|
||||
|
||||
step "Push to both remotes"
|
||||
git push aur master
|
||||
git push github master
|
||||
|
||||
step "Leaving working dir"
|
||||
popd
|
Loading…
Reference in a new issue