summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFlorian Pritz <bluewind@xinu.at>2014-01-31 19:53:48 +0100
committerFlorian Pritz <bluewind@xinu.at>2015-05-27 15:46:04 +0200
commit48177ff85854baaf184ebc1c9d46def6398b64d8 (patch)
tree64b037de0322569c88ee1f1f5027f71139c2dd52
parent5340bef937c5ce288d323873529545ffd5878e21 (diff)
downloaddbscripts-48177ff85854baaf184ebc1c9d46def6398b64d8.tar.gz
dbscripts-48177ff85854baaf184ebc1c9d46def6398b64d8.tar.xz
use global variable to track history changes and commit everything at once
Signed-off-by: Florian Pritz <bluewind@xinu.at>
-rwxr-xr-xdb-add2
-rw-r--r--db-functions19
-rwxr-xr-xdb-move2
-rwxr-xr-xdb-remove2
-rwxr-xr-xdb-update2
5 files changed, 19 insertions, 8 deletions
diff --git a/db-add b/db-add
index 531bbaf..6318a73 100755
--- a/db-add
+++ b/db-add
@@ -35,7 +35,7 @@ for pkgfile in ${pkgfiles[@]}; do
arch_db_add $repo "$pkgfile" ${tarches[@]}
done
-arch_git commit -q -m "db-add: ${tarches[@]}: ${pkgfiles[@]}"
+arch_history_commit "db-add: ${tarches[@]}: ${pkgfiles[@]}"
for tarch in ${tarches[@]}; do
repo_unlock $repo $tarch
diff --git a/db-functions b/db-functions
index 4b90d51..4c22bd8 100644
--- a/db-functions
+++ b/db-functions
@@ -28,6 +28,8 @@ mv_acl() {
WORKDIR=$(mktemp -d "${TMPDIR}/${0##*/}.XXXXXXXXXX")
LOCKS=()
REPO_MODIFIED=0
+declare -a HISTORY_add_files=()
+declare -a HISTORY_remove_files=()
# check if messages are to be printed using color
unset ALL_OFF BOLD BLUE GREEN RED YELLOW
@@ -565,7 +567,7 @@ arch_history_add() {
mkdir -p "${history_file%/*}"
echo "$pkgbase $pkgver" > "$history_file"
- arch_git add "$history_file"
+ HISTORY_add_files=("${HISTORY_add_files[@]}" "$history_file")
}
arch_history_remove() {
@@ -574,12 +576,21 @@ arch_history_remove() {
local tarches="$3"
local history_file="$GITREPO/$repo/$tarch/$pkgname"
- arch_git rm "$history_file"
+
+ [[ -f "$history_file" ]] || return 1
+
+ HISTORY_remove_files=("${HISTORY_remove_files[@]}" "$history_file")
}
-arch_git() {
+arch_history_commit() {
pushd "$GITREPO"
- git "$@"
+ if ((${#HISTORY_add_files[@]} > 0)); then
+ git add -- "${HISTORY_add_files[@]}"
+ fi
+ if ((${#HISTORY_remove_files[@]} > 0)); then
+ git rm -- "${HISTORY_remove_files[@]}"
+ fi
+ git commit -q -m "$1"
popd
}
diff --git a/db-move b/db-move
index 8352b94..27c08e1 100755
--- a/db-move
+++ b/db-move
@@ -35,7 +35,7 @@ for pkg in "${pkgs[@]}"; do
arch_db_remove "${repo_from}" "$arch" "$pkgname"
done
-arch_git commit -q -m "db-move: $add_pkgs[@]"
+arch_history_commit "db-move: $add_pkgs[@]"
for pkgarch in ${ARCHES[@]}; do
repo_unlock ${repo_from} ${pkgarch}
diff --git a/db-remove b/db-remove
index 8df44a2..f6d2e99 100755
--- a/db-remove
+++ b/db-remove
@@ -39,7 +39,7 @@ for tarch in ${tarches[@]}; do
arch_db_remove "${repo}" "${tarch}" ${remove_pkgs[@]}
done
-arch_git commit -q -m "db-remove: ${remove_pkgs[@]}"
+arch_history_commit "db-remove: ${remove_pkgs[@]}"
for tarch in ${tarches[@]}; do
repo_unlock $repo $tarch
diff --git a/db-update b/db-update
index 5e75498..272b575 100755
--- a/db-update
+++ b/db-update
@@ -70,7 +70,7 @@ for repo in ${repos[@]}; do
done
done
-arch_git commit -q -m "db-update: ${repos[@]}"
+arch_history_commit "db-update: ${repos[@]}"
for repo in ${repos[@]}; do
for pkgarch in ${ARCHES[@]}; do