diff options
Diffstat (limited to 'sbonewmaint')
| -rwxr-xr-x | sbonewmaint | 45 |
1 files changed, 39 insertions, 6 deletions
diff --git a/sbonewmaint b/sbonewmaint index ec40774..4e2c8f4 100755 --- a/sbonewmaint +++ b/sbonewmaint @@ -1,16 +1,30 @@ #!/bin/sh +SELF="$( basename $0 )" + +warn() { + echo "$SELF: warning: $@" 1>&2 +} + +die() { + echo "$SELF: fatal: $@" 1>&2 + exit 1 +} + # read config fresh, rather than use the env. if [ -e ~/.sbostuff.cfg ]; then source ~/.sbostuff.cfg else - echo "$( basename $0 ): warning: can't find ~/.sbostuff.cfg" + warn "can't find ~/.sbostuff.cfg" fi NAME="$1" EMAIL="$2" if [ "$NAME" = "me" -a "$EMAIL" = "" ]; then + if [ "$SBO_NAME" = "" -o "$SBO_EMAIL" = "" ]; then + die "can't use 'me' without SBO_NAME and SBO_EMAIL in the env" + fi NAME="$SBO_NAME" EMAIL="$SBO_EMAIL" elif [ "$NAME" = "nobody" -o "$NAME" = "orphaned" ]; then @@ -27,13 +41,32 @@ fi INFO="$( echo *.info )" if [ ! -e "$INFO" ]; then - echo "No (or multiple) .info file in current dir" 1>&2 + die "No (or multiple) .info file in current dir" exit 1 fi -sed -i "/^MAINTAINER=/s,\"[^\"]*\",\"$NAME\"," "$INFO" -sed -i "/^EMAIL=/s,\"[^\"]*\",\"$EMAIL\"," "$INFO" +cp "$INFO" "$INFO.bak" +sed -i \ + -e "/^MAINTAINER=/s,\"[^\"]*\",\"$NAME\"," "$INFO" \ + -e "/^EMAIL=/s,\"[^\"]*\",\"$EMAIL\"," "$INFO" + +if cmp -s "$INFO" "$INFO.bak"; then + warn "No change to .info file" + exit 0 +fi -PAGER=cat git diff . +if colordiff --version &>/dev/null; then + DIFF=colordiff +else + DIFF=diff +fi + +$DIFF -u "$INFO.bak" "$INFO" + +if git rev-parse &>/dev/null; then + echo + echo "Don't forget to do this:" + echo " git commit -a -m'New maintainer'" +fi -echo "git commit -a -m'New maintainer'" +rm -f "$INFO.bak" |
