[RFC PATCH 2/3] dohyphen2endash.sh: Add check of git status

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



>From 1fc4b3e11e22f12c0ca347cbbcae6dae329cdcf0 Mon Sep 17 00:00:00 2001
From: Akira Yokosawa <akiyks@xxxxxxxxx>
Date: Fri, 12 Aug 2016 23:58:46 +0900
Subject: [RFC PATCH 2/3] dohyphen2endash.sh: Add check of git status

This commit also adds option "-f" and "--force" to override the
check.

Signed-off-by: Akira Yokosawa <akiyks@xxxxxxxxx>
---
 utilities/dohyphen2endash.sh | 38 ++++++++++++++++++++++++++++++++++++++
 1 file changed, 38 insertions(+)

diff --git a/utilities/dohyphen2endash.sh b/utilities/dohyphen2endash.sh
index 3270983..05557f0 100644
--- a/utilities/dohyphen2endash.sh
+++ b/utilities/dohyphen2endash.sh
@@ -1,6 +1,9 @@
 #!/bin/sh
 #
 # Apply hypen2endash.sh for all .tex files
+# If invoked in non-clean git status, this script will abort.
+# If invoked with the "--force" option, this script will continue
+# regardless of git status.
 #
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -20,6 +23,41 @@
 #
 # Authors: Akira Yokosawa <akiyks@xxxxxxxxx>
 
+# parse option
+TEMP=`getopt -o f --long force -- "$@"`
+
+if [ $? != 0 ] ; then echo "Error in parse option..." >&2 ; exit 1 ; fi
+
+eval set -- "$TEMP"
+
+forced=0
+
+while true ; do
+	case "$1" in
+		-f|--force) forced=1 ; shift ;;
+		--) shift ; break ;;
+		*) echo "Unknown option!" ; exit 1 ;;
+	esac
+done
+# check if we are in git repository
+if ! test -e .git
+then
+	echo "not in a git repository"
+	exit 1
+fi
+# check if companion script exists
+if ! test -e utilities/hyphen2endash.sh
+then
+	echo "utilities/hyphen2endash.sh not found."
+	exit 1
+fi
+# check if git status is clean
+gitstatus=`git status --porcelain | wc -l`
+if [ $forced -eq 0 -a $gitstatus != "0" ]
+then
+	echo "git status not clean --- aborting."
+	exit 1
+fi
 texfiles=`find . -name '*.tex' -print`
 for i in $texfiles
 do
-- 
1.9.1


--
To unsubscribe from this list: send the line "unsubscribe perfbook" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux