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

Add gitlab wrapper for use from within git repos to auto. set GITLAB … · python-gitlab/python-gitlab@3de3dc0 · GitHub

Repository navigation

Commit 3de3dc0

Browse files
committed
Add gitlab wrapper for use from within git repos to auto. set GITLAB and project-id args
Also add a script to show latest pipeline of current git repo
1 parent 44fd9dc commit 3de3dc0

2 files changed

Lines changed: 72 additions & 0 deletions

File tree

‎gitlab_wrapper.sh‎

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
#!/bin/sh
2+
3+
select_remote () {
4+
remotes=$(git remote)
5+
if [ $(echo $remotes | wc -w) -gt 1 ]; then
6+
for r in $remotes; do
7+
[ $r != origin ] || remote=$r
8+
u=$(git remote get-url $r)
9+
echo "$r, url: $u"
10+
done
11+
[ -n "$remote" ] || remote=$r
12+
read -p "Please select a remote [$remote]: " read_remote
13+
for r in $remotes; do
14+
[ $r != "$read_remote" ] || remote=$read_remote
15+
done
16+
else
17+
remote=$remotes
18+
fi
19+
}
20+
21+
instance_name() {
22+
host=$1
23+
grep -B 5 "^\s*url\s*=\s*http\(s\)*://$host" ~/.python-gitlab.cfg | grep "^\[" | tail -n 1 | sed -e 's#\[\(.\+\)\]#\1#'
24+
}
25+
26+
if [ "x$1" = "x--git-remote" ]; then
27+
remote=$2
28+
shift 2
29+
fi
30+
[ -n "$remote" ] || remote=$(git remote)
31+
if [ -z "$remote" ]; then
32+
echo "No remotes found in repository"
33+
exit 1
34+
fi
35+
if [ $(echo $remote | wc -w) -gt 1 ]; then
36+
echo "Multiple remotes found, specify a remote using --git-remote REMOTE"
37+
exit 1
38+
fi
39+
40+
url=$(git remote get-url $remote)
41+
host=$(echo $url | sed -e 's#^\(git\@\|[a-z]\+://\)\([^:/]\+\)[:/].*#\2#')
42+
instance=$(instance_name $host)
43+
if [ -z "$instance" ]; then
44+
echo "No instance found for $host in ~/python-gitlab.cfg"
45+
exit 1
46+
fi
47+
48+
proj=$(echo $url | sed -e 's#.*:\(.*\)$#\1#')
49+
proj=$(echo $proj | sed -e 's#\.git$##')
50+
projid=$proj
51+
52+
gitlab -g $instance $* --project-id $projid

‎glab-pipe.sh‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/bin/sh
2+
3+
# TODO:
4+
# check args for cfg file
5+
# set as git cmd
6+
if [ "x$1" = "x--git-remote" ]; then
7+
git_repo="$1 $2"
8+
shift 2
9+
fi
10+
# last pipeline:
11+
pipeid=$(gitlab_wrapper.sh $git_repo project-pipeline list | head -n 1 | cut -d: -f2)
12+
gitlab_wrapper.sh $git_repo -o yaml -f id,status,web_url project-pipeline get --id $pipeid
13+
14+
gitlab_wrapper.sh $git_repo -o yaml -f id,name,status,web_url project-pipeline-job list --pipeline-id $pipeid
15+
16+
#projurl=$(echo $url | sed "s#:\($proj\)#/\\1#")
17+
#projurl=$(echo $projurl | sed 's#git@#https://#')
18+
#projurl=$(echo $projurl | sed -e 's#\.git$##')
19+
#joburl="$projurl/-/jobs/"
20+
#echo $joburl

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL