FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

git-gitlab: robust processing of gitlab pre-command arguments · python-gitlab/python-gitlab@e23a0bd · GitHub

Repository navigation

Commit e23a0bd

Browse files
committed
git-gitlab: robust processing of gitlab pre-command arguments
1 parent 75fe957 commit e23a0bd

1 file changed

Lines changed: 26 additions & 5 deletions

File tree

‎git-gitlab.sh‎

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/sh
22

3-
PYGLAB_CONF=~/.python-gitlab.cfg
3+
DFLT_PYGLAB_CONF=~/.python-gitlab.cfg
44

55
select_remote () {
66
remotes=$(git remote)
@@ -22,7 +22,8 @@ select_remote () {
2222

2323
instance_name() {
2424
host=$1
25-
grep -B 5 "^\s*url\s*=\s*http\(s\)*://$host" $PYGLAB_CONF | grep "^\[" | tail -n 1 | sed -e 's#\[\(.\+\)\]#\1#'
25+
pyglab_conf=$2
26+
grep -B 5 "^\s*url\s*=\s*http\(s\)*://$host" $pyglab_conf | grep "^\[" | tail -n 1 | sed -e 's#\[\(.\+\)\]#\1#'
2627
}
2728

2829
remote=$(git config gitlab.remote)
@@ -31,6 +32,26 @@ if [ "x$1" = "x--remote" ]; then
3132
remote=$2
3233
shift 2
3334
fi
35+
36+
pyglab_conf=$DFLT_PYGLAB_CONF
37+
pre_cmd_args=""
38+
while echo $1 | grep -q "^-" ; do
39+
case $1 in
40+
-g|--gitlab|-o|--output|-f|--fields)
41+
pre_cmd_args="$pre_cmd_args $1 $2"
42+
shift 2
43+
;;
44+
-c|--config-file)
45+
pyglab_conf=$2
46+
pre_cmd_args="$pre_cmd_args $1 $2"
47+
shift 2
48+
;;
49+
*)
50+
pre_cmd_args="$pre_cmd_args $1"
51+
shift 1
52+
;;
53+
esac
54+
done
3455
if [ -z "$remote" ]; then
3556
echo "No remotes found in repository"
3657
exit 1
@@ -46,14 +67,14 @@ fi
4667

4768
url=$(git remote get-url $remote)
4869
host=$(echo $url | sed -e 's#^\(git\@\|[a-z]\+://\)\([^:/]\+\)[:/].*#\2#')
49-
instance=$(instance_name $host)
70+
instance=$(instance_name $host $pyglab_conf)
5071
if [ -z "$instance" ]; then
51-
echo "No instance found for $host in $PYGLAB_CONF"
72+
echo "No instance found for $host in $pyglab_conf"
5273
exit 1
5374
fi
5475

5576
proj=$(echo $url | sed -e 's#.*:\(.*\)$#\1#')
5677
proj=$(echo $proj | sed -e 's#\.git$##')
5778
projid=$proj
5879

59-
gitlab -g $instance $* --project-id $projid
80+
gitlab -g $instance $pre_cmd_args $* --project-id $projid

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL