[pkg-haskell-tools] 01/01: New script: mass-change (really useful!)

Joachim Breitner nomeata at moszumanska.debian.org
Thu Aug 13 18:29:11 UTC 2015


This is an automated email from the git hooks/post-receive script.

nomeata pushed a commit to branch master
in repository pkg-haskell-tools.

commit dcdb0b690cc6f58f45be332b4a79fbfd54221869
Author: Joachim Breitner <mail at joachim-breitner.de>
Date:   Thu Aug 13 20:26:38 2015 +0200

    New script: mass-change (really useful!)
---
 debian/changelog    |   6 +++
 scripts/mass-change | 107 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 113 insertions(+)

diff --git a/debian/changelog b/debian/changelog
index 207084f..2c66ac1 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,9 @@
+pkg-haskell-tools (0.6) unstable; urgency=medium
+
+  * New script: mass-change (really useful!)
+
+ -- Joachim Breitner <nomeata at debian.org>  Thu, 13 Aug 2015 20:26:36 +0200
+
 pkg-haskell-tools (0.5) unstable; urgency=medium
 
   * Install all scripts, relying on the order of debian/*.install
diff --git a/scripts/mass-change b/scripts/mass-change
new file mode 100755
index 0000000..de6390d
--- /dev/null
+++ b/scripts/mass-change
@@ -0,0 +1,107 @@
+#!/bin/bash
+
+if [ "$1" = "--help" -o -z "$1" ]
+then
+	cat <<__END__
+mass-change - Apply a change to many packages
+
+__END__
+	$0 --manpage
+	exit 0
+fi
+
+if [ "$1" = "--manpage" ]
+then
+cat <<__END__
+Usage: dht mass-change [-n] [MESSAGE] [ACTION] DIRECTORY ...
+
+This script runs ACTION in each of the given directories. If the ACTION
+effected a change, it will add MESSAGE to the changelog.
+
+It assumes that all directories are in the same git repository as this script.
+It ensures that the repository is clean tobegin with, and will commit all
+changes at once at the end, if there was a change.
+__END__
+	exit 0;
+fi
+
+
+if [ "$1" = "-n" ]
+then
+  dry_run=1
+  shift
+fi
+
+message=$1
+shift
+action=$1
+shift
+
+if ! git diff-files --quiet -- "$@"
+then
+	echo "The git repository is not clean. Please fix that first!"
+	exit 1
+fi
+
+if ! git diff-index --cached --quiet HEAD -- "$@"
+then
+	echo "WARNING: The git index is not clean, and will be amended!"
+fi
+
+if test -n "$(git ls-files --exclude-standard --others -- "$@")"
+then
+	echo "The git repository has untracked files. Please fix that first!"
+	exit 1
+fi
+
+changes=0
+while [ -n "$1" ]
+do
+	dir=$1
+	shift
+
+	if ! pushd "$dir" >/dev/null
+	then
+		echo "Failed to switch to \"$dir\""
+		continue
+	fi
+
+	if [ ! -e debian/changelog ]
+	then
+		echo "No changelog file found, skipping $dir"
+		popd >/dev/null
+		continue
+	fi
+
+	echo "Processing $dir"
+
+	eval "$action"
+
+	# some hack to make git update its cache of the working directory?
+	#git update-index --refresh -q
+	git diff . > /dev/null
+	if git diff-files --quiet .
+	then
+		echo "Action did not change $dir, skipping push"
+		popd >/dev/null
+		continue
+	fi
+	if [ -z "$dry_run" ]
+	then
+		echo "Staging these changes:"
+		git diff|colordiff
+		debchange --changelog=debian/changelog "$message"
+		git add .
+		changes=$((changes+1))
+	else
+		echo "Would stage these changes:"
+		git diff|colordiff
+		git checkout -- .
+	fi
+	popd >/dev/null
+done
+
+if [ $changes -gt 0 ]
+then
+	git commit -m "$message ($changes packages)"
+fi

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-haskell/pkg-haskell-tools.git



More information about the Pkg-haskell-commits mailing list