Skip to content
Snippets Groups Projects
Commit 0a11c5e3 authored by Natanael Copa's avatar Natanael Copa
Browse files

apkgrel: optionally bump pkgrel when git is unclean

parent 761472d9
No related branches found
No related tags found
No related merge requests found
...@@ -14,6 +14,10 @@ do_set() { ...@@ -14,6 +14,10 @@ do_set() {
do_add () { do_add () {
local f= old= local f= old=
for f in "$@"; do for f in "$@"; do
[ -n "$only_clean_git" ] \
&& [ -n "$(git diff --name-only $f)" ] \
&& continue
[ -d "$f" ] && f="$f/APKBUILD"
old=$(do_show "$f") old=$(do_show "$f")
setto=$(($old + 1)) setto=$(($old + 1))
do_set "$f" || return 1 do_set "$f" || return 1
...@@ -22,12 +26,15 @@ do_add () { ...@@ -22,12 +26,15 @@ do_add () {
do_verify() { do_verify() {
[ -n "$force" ] && return 0 [ -n "$force" ] && return 0
if ! grep -q '^pkgrel=[0-9]' "$@"; then local f= rc=0
echo "The following files does not have proper pkgrel:" >&2 for f in "$@"; do
grep -L '^pkgrel=[0-9]' "$@" >&2 [ -d "$f" ] && f="$f/APKBUILD"
return 1 if ! grep -q '^pkgrel=[0-9]' "$f"; then
fi echo "$f: Has no proper pkgrel" >&2
return 0 rc=1
fi
done
return $rc
} }
do_nothing() { do_nothing() {
...@@ -39,6 +46,7 @@ do_usage() { ...@@ -39,6 +46,7 @@ do_usage() {
Usage: $program -a|-h|-s NUM|-t|-z [-f] FILE... Usage: $program -a|-h|-s NUM|-t|-z [-f] FILE...
Commands: Commands:
-a Add 1 to current pkgrel -a Add 1 to current pkgrel
-g Only do the change on files that have clean git status
-h Show this help -h Show this help
-s Set pkgrel to NUM -s Set pkgrel to NUM
-t Only verify that files are in proper format -t Only verify that files are in proper format
...@@ -52,9 +60,10 @@ __EOF__ ...@@ -52,9 +60,10 @@ __EOF__
cmd=do_show cmd=do_show
force= force=
while getopts "afhs:tz" opt; do while getopts "afghs:tz" opt; do
case $opt in case $opt in
a) cmd=do_add;; a) cmd=do_add;;
g) only_clean_git=1;;
f) force=1;; f) force=1;;
h) cmd=do_usage;; h) cmd=do_usage;;
s) setto=$OPTARG; cmd=do_set;; s) setto=$OPTARG; cmd=do_set;;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment