about summary refs log tree commit diff
diff options
context:
space:
mode:
authorclassabbyamp <void@placeviolette.net>2024-05-26 18:42:53 -0400
committerLeah Neukirchen <leah@vuxu.org>2024-05-27 15:14:23 +0200
commit4bbe95d257cb1f7e7edf6dcba30db1b7c14ea158 (patch)
treec7122597e4e2d9e32ad1c0f195909fb5e4d50ea5
parentba08489e60f65c3c38fef11ed2f0b22b39586e7b (diff)
downloadxtools-4bbe95d257cb1f7e7edf6dcba30db1b7c14ea158.tar.gz
xtools-4bbe95d257cb1f7e7edf6dcba30db1b7c14ea158.tar.xz
xtools-4bbe95d257cb1f7e7edf6dcba30db1b7c14ea158.zip
xbump: support multiple templates
-rwxr-xr-xxbump69
-rw-r--r--xtools.17
2 files changed, 47 insertions, 29 deletions
diff --git a/xbump b/xbump
index 3dab39b..2c775af 100755
--- a/xbump
+++ b/xbump
@@ -1,37 +1,50 @@
 #!/bin/sh -e
 # xbump PKGNAME [git commit options] - git commit a new package or package update
+# if PKGNAME is :, commit all staged templates, one per commit
 
 cd $(xdistdir)
 
-pkg=$1; shift
-[ -z "$pkg" ] && pkg=$(basename $PWD)
-version=$(./xbps-src show "$pkg" | sed -n '/^version/s/[^:]*:[\t]*//p')
+pkg="$1"; shift
+git_opts="$*"
 
-if [ -z "$version" ]; then
-	echo cannot parse version
-	exit 1
-fi
-
-spkpattern=$(xsubpkg "$pkg")
-shlibs=$(git diff common/shlibs | grep "^+[^+]" | \
-	sed "s/^+[^ ]\+ \(.*\)-[^-]\+_[0-9]\+$/\1/")
-if [ -n "$(echo "$shlibs" | grep -vFx "$spkpattern")" ]; then
-	echo "common/shlibs contains uncommitted changes for other packages." 2>&1
-	exit 1
-elif [ -n "$shlibs" ]; then
-	git add common/shlibs
-	dirs=common/shlibs
-fi
-
-dirs="$dirs $(./xbps-src show "$pkg" |
-	sed -n '/^\(pkgname\|subpackage\)/s/[^:]*:[\t]*/srcpkgs\//p')"
-
-git add $dirs
-
-if git diff --quiet --cached --diff-filter=A -- srcpkgs/"$pkg"/template; then
-	msg="$pkg: update to $version."
+if [ "$pkg" = ':' ]; then
+	# get a list of all templates staged in the git index
+	set -- $(git -C "$void_packages" diff --cached --name-only |
+		sed -ne 's|^srcpkgs/\([^/]*\)/template$|\1|p')
 else
-	msg="New package: $pkg-$version"
+    set -- "$pkg"
 fi
 
-git commit -m "$msg" "$@" $dirs
+for pkg; do
+    [ -z "$pkg" ] && pkg=$(basename $PWD)
+    version=$(./xbps-src show "$pkg" | sed -n '/^version/s/[^:]*:[\t]*//p')
+
+    if [ -z "$version" ]; then
+        echo "cannot parse version"
+        exit 1
+    fi
+
+    spkpattern=$(xsubpkg "$pkg")
+    shlibs=$(git diff common/shlibs | grep "^+[^+]" | \
+        sed "s/^+[^ ]\+ \(.*\)-[^-]\+_[0-9]\+$/\1/")
+    if [ -n "$(echo "$shlibs" | grep -vFx "$spkpattern")" ]; then
+        echo "common/shlibs contains uncommitted changes for other packages." 2>&1
+        exit 1
+    elif [ -n "$shlibs" ]; then
+        git add common/shlibs
+        dirs=common/shlibs
+    fi
+
+    dirs="$dirs $(./xbps-src show "$pkg" |
+        sed -n '/^\(pkgname\|subpackage\)/s/[^:]*:[\t]*/srcpkgs\//p')"
+
+    git add $dirs
+
+    if git diff --quiet --cached --diff-filter=A -- srcpkgs/"$pkg"/template; then
+        msg="$pkg: update to $version."
+    else
+        msg="New package: $pkg-$version"
+    fi
+
+    git commit -m "$msg" $git_opts $dirs
+done
diff --git a/xtools.1 b/xtools.1
index 98de74d..d175900 100644
--- a/xtools.1
+++ b/xtools.1
@@ -23,7 +23,12 @@ dry-run mode
 keep going on errors
 .El
 .It Nm xbump Ar pkgname Op Ar git\ commit\ options
-.Nd git commit a new package or package update
+.Nd git commit a new package or package update.
+If
+.Ar pkgname
+is
+.Sq Cm \&: ,
+a commit will be made for each template staged in the git index.
 .It Nm xchangelog Ar template | pkgname
 .Nd open package changelog
 .It Nm xcheckmypkgs Op Ar email