archrelease: actually fail in failure conditions
When svn ls fails due to network timeouts, this currently results in archrelease deleting all files, then committing this as the changeset. This causes data loss... With bash 4.4 and using wait $! we can get return the return code of the last backgrounded command -- which process substitution qualifies as. Key off of this to make sure that `svn ls` actually succeeded. Signed-off-by: Eli Schwartz <eschwartz@archlinux.org> Signed-off-by: Levente Polyak <anthraxx@archlinux.org>
This commit is contained in:
parent
10c6efc440
commit
93dbb14ab9
|
@ -48,7 +48,8 @@ if [[ $(svn status -q) ]]; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
pushd .. >/dev/null
|
pushd .. >/dev/null
|
||||||
IFS=$'\n' read -r -d '' -a known_files < <(svn ls -r HEAD "$trunk")
|
mapfile -t known_files < <(svn ls -r HEAD "$trunk")
|
||||||
|
wait $! || die "failed to discover committed files"
|
||||||
for file in "${known_files[@]}"; do
|
for file in "${known_files[@]}"; do
|
||||||
if [[ ${file:(-1)} = '/' ]]; then
|
if [[ ${file:(-1)} = '/' ]]; then
|
||||||
die "archrelease: subdirectories are not supported in package directories!"
|
die "archrelease: subdirectories are not supported in package directories!"
|
||||||
|
@ -65,12 +66,12 @@ for tag in "$@"; do
|
||||||
stat_busy "Copying %s to %s" "${trunk}" "${tag}"
|
stat_busy "Copying %s to %s" "${trunk}" "${tag}"
|
||||||
|
|
||||||
if [[ -d repos/$tag ]]; then
|
if [[ -d repos/$tag ]]; then
|
||||||
declare -a trash
|
mapfile -t trash < <(svn ls "repos/$tag")
|
||||||
trash=()
|
wait $! || die "failed to discover existing files"
|
||||||
while read -r file; do
|
if (( ${#trash[@]} )); then
|
||||||
trash+=("repos/$tag/$file")
|
trash=("${trash[@]/#/repos/$tag/}")
|
||||||
done < <(svn ls "repos/$tag")
|
svn rm -q "${trash[@]/%/@}"
|
||||||
[[ ${#trash[@]} == 0 ]] || svn rm -q "${trash[@]/%/@}"
|
fi
|
||||||
else
|
else
|
||||||
mkdir -p "repos/$tag"
|
mkdir -p "repos/$tag"
|
||||||
svn add --parents -q "repos/$tag"
|
svn add --parents -q "repos/$tag"
|
||||||
|
|
Loading…
Reference in New Issue