git: first iteration of git support

Signed-off-by: Morten Linderud <foxboron@archlinux.org>
Adjusted-by: Levente Polyak <anthraxx@archlinux.org>
This commit is contained in:
Morten Linderud 2020-05-27 17:48:53 +02:00 committed by Levente Polyak
parent 9297eb344e
commit 90aba4f84b
No known key found for this signature in database
GPG Key ID: FC1B547C8D8172C8
3 changed files with 21 additions and 79 deletions

View File

@ -34,54 +34,16 @@ if [[ ! -f PKGBUILD ]]; then
die 'archrelease: PKGBUILD not found'
fi
trunk=${PWD##*/}
. ./PKGBUILD
pkgbase=${pkgbase:-$pkgname}
pkgver=$(get_full_version "$pkgbase")
# Normally this should be trunk, but it may be something
# such as 'gnome-unstable'
IFS='/' read -r -d '' -a parts <<< "$PWD"
if [[ "${parts[*]:(-2):1}" == "repos" ]]; then
die 'archrelease: Should not be in repos dir (try from trunk/)'
if git rev-parse "$pkgver" >/dev/null 2>&1; then
die "archrelease: the tag $pkgver already exists in the repository!"
fi
unset parts
if [[ $(svn status -q) ]]; then
die 'archrelease: You have not committed your changes yet!'
fi
pushd .. >/dev/null
mapfile -t known_files < <(svn ls -r HEAD "$trunk")
wait $! || die "failed to discover committed files"
# gracefully handle files containing an "@" character
known_files=("${known_files[@]/%/@}")
# update repo directory first to avoid a commit failure
svn up repos
for tag in "$@"; do
stat_busy "Copying %s to %s" "${trunk}" "${tag}"
if [[ -d repos/$tag ]]; then
mapfile -t trash < <(svn ls --recursive "repos/$tag")
wait $! || die "failed to discover existing files"
if (( ${#trash[@]} )); then
trash=("${trash[@]/#/repos/$tag/}")
svn rm -q "${trash[@]/%/@}"
fi
else
mkdir -p "repos/$tag"
svn add --parents -q "repos/$tag"
fi
# copy all files at once from trunk to the subdirectory in repos/
svn copy -q -r HEAD "${known_files[@]/#/$trunk/}" "repos/$tag/"
stat_done
done
stat_busy "Releasing package"
printf -v tag_list ", %s" "$@"; tag_list="${tag_list#, }"
svn commit -q -m "archrelease: copy ${trunk} to $tag_list" || abort
git tag -s -m "archrelease: released $pkgbase-$pkgver to $tag_list" "$pkgver" || abort
git push --tags || abort
stat_done
popd >/dev/null

View File

@ -106,13 +106,13 @@ for key in "${validpgpkeys[@]}"; do
needsversioning+=("keys/pgp/$key.asc")
done
# assert that they really are controlled by SVN
# assert that they really are controlled by git
if (( ${#needsversioning[*]} )); then
# svn status's output is only two columns when the status is unknown
while read -r status filename; do
[[ $status = '?' ]] && unversioned+=("$filename")
done < <(svn status -v "${needsversioning[@]}")
(( ${#unversioned[*]} )) && die "%s is not under version control" "${unversioned[@]}"
for file in "${needsversioning[@]}"; do
if ! git ls-files --error-unmatch "$file"; then
die "%s is not under version control" "$file"
fi
done
fi
rsyncopts=(-e ssh -p '--chmod=ug=rw,o=r' -c -h -L --progress --partial -y)
@ -155,18 +155,18 @@ if [[ -z $server ]]; then
server='repos.archlinux.org'
fi
if [[ -n $(svn status -q) ]]; then
if [[ -n $(git status --short --untracked-files=no) ]]; then
msgtemplate="upgpkg: $pkgbase $(get_full_version)"
if [[ -n $1 ]]; then
stat_busy 'Committing changes to trunk'
svn commit -q -m "${msgtemplate}: ${1}" || die
stat_busy 'Committing changes'
git commit -q -m "${msgtemplate}: ${1}" || die
stat_done
else
[[ -z ${WORKDIR:-} ]] && setup_workdir
msgfile=$(mktemp --tmpdir="${WORKDIR}" commitpkg.XXXXXXXXXX)
echo "$msgtemplate" > "$msgfile"
if [[ -n $SVN_EDITOR ]]; then
$SVN_EDITOR "$msgfile" || die
if [[ -n $GIT_EDITOR ]]; then
$GIT_EDITOR "$msgfile" || die
elif [[ -n $VISUAL ]]; then
$VISUAL "$msgfile" || die
elif [[ -n $EDITOR ]]; then
@ -175,8 +175,8 @@ if [[ -n $(svn status -q) ]]; then
vi "$msgfile" || die
fi
[[ -s $msgfile ]] || die
stat_busy 'Committing changes to trunk'
svn commit -q -F "$msgfile" || die
stat_busy 'Committing changes'
git commit -v -q -F "$msgfile" || die
unlink "$msgfile"
stat_done
fi
@ -250,23 +250,3 @@ if [[ ${#uploads[*]} -gt 0 ]]; then
msg 'Uploading all package and signature files'
rsync "${rsyncopts[@]}" "${uploads[@]}" "$server:staging/$repo/" || die
fi
if [[ "${arch[*]}" == 'any' ]]; then
if [[ -d ../repos/$repo-x86_64 ]]; then
pushd ../repos/ >/dev/null
stat_busy "Removing %s" "$repo-x86_64"
svn rm -q "$repo-x86_64"
svn commit -q -m "Removed $repo-x86_64 for $pkgname"
stat_done
popd >/dev/null
fi
else
if [[ -d ../repos/$repo-any ]]; then
pushd ../repos/ >/dev/null
stat_busy "Removing %s" "$repo-any"
svn rm -q "$repo-any"
svn commit -q -m "Removed $repo-any for $pkgname"
stat_done
popd >/dev/null
fi
fi

View File

@ -38,7 +38,7 @@ elif [[ -r "$HOME/.makepkg.conf" ]]; then
fi
bump_pkgrel() {
# Get the current pkgrel from SVN and update the working copy with it
# Get the current pkgrel from git and update the working copy with it
# This prevents us from incrementing out of control :)
pbuild='.svn/text-base/PKGBUILD.svn-base'
oldrel=$(grep 'pkgrel=' $pbuild | cut -d= -f2)