Add auto-default-branch
This commit is contained in:
parent
0dab6b6f05
commit
1e6f82e10d
@ -34,11 +34,13 @@ WORKDIR /var/lib/git
|
|||||||
COPY cgit.css /usr/share/webapps/cgit/cgit.css
|
COPY cgit.css /usr/share/webapps/cgit/cgit.css
|
||||||
COPY md2html /usr/lib/cgit/filters/html-converters/md2html
|
COPY md2html /usr/lib/cgit/filters/html-converters/md2html
|
||||||
COPY syntax-highlighting.py /usr/lib/cgit/filters/syntax-highlighting.py
|
COPY syntax-highlighting.py /usr/lib/cgit/filters/syntax-highlighting.py
|
||||||
|
COPY auto-default-branch.sh /usr/lib/gitolite/triggers/auto-default-branch
|
||||||
COPY gitolite.rc /var/lib/git/.gitolite.rc
|
COPY gitolite.rc /var/lib/git/.gitolite.rc
|
||||||
COPY entrypoint.sh /
|
COPY entrypoint.sh /
|
||||||
|
|
||||||
RUN chmod u+x /usr/lib/cgit/filters/html-converters/md2html
|
RUN chmod u+x /usr/lib/cgit/filters/html-converters/md2html
|
||||||
RUN chmod u+x /usr/lib/cgit/filters/syntax-highlighting.py
|
RUN chmod u+x /usr/lib/cgit/filters/syntax-highlighting.py
|
||||||
|
RUN chmod a+x /usr/lib/gitolite/triggers/auto-default-branch
|
||||||
RUN chmod u+x /entrypoint.sh
|
RUN chmod u+x /entrypoint.sh
|
||||||
|
|
||||||
ENTRYPOINT ["/entrypoint.sh"]
|
ENTRYPOINT ["/entrypoint.sh"]
|
||||||
|
29
gitolite-cgit/auto-default-branch.sh
Normal file
29
gitolite-cgit/auto-default-branch.sh
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
info() { printf >&2 %s\\n "$*" ; }
|
||||||
|
|
||||||
|
die() { info "$*" ; exit 1 ; }
|
||||||
|
|
||||||
|
ensure_HEAD() {
|
||||||
|
[ "$1" = 'POST_GIT' ] || die "unsupported trigger '$1'"
|
||||||
|
|
||||||
|
cd "$GL_REPO_BASE/$2.git"
|
||||||
|
|
||||||
|
# everything OK if the default in HEAD points to a real branch
|
||||||
|
git show-ref --quiet --verify "$(git symbolic-ref HEAD)" && return 0
|
||||||
|
|
||||||
|
# there *might* be a mismatch, so let's find out a real branch
|
||||||
|
local head
|
||||||
|
head="$(git show-ref --heads | head -1 | sed -e 's/^.* //')"
|
||||||
|
|
||||||
|
# the repo might still be empty
|
||||||
|
[ -n "$head" ] || return 0
|
||||||
|
|
||||||
|
# we have a default branch that we can set here
|
||||||
|
info "setting HEAD to <$head>"
|
||||||
|
git symbolic-ref HEAD "$head" -m "Default HEAD to branch <$head>"
|
||||||
|
}
|
||||||
|
|
||||||
|
set -eu
|
||||||
|
|
||||||
|
ensure_HEAD "$@"
|
@ -95,6 +95,7 @@
|
|||||||
'info',
|
'info',
|
||||||
'perms',
|
'perms',
|
||||||
'writable',
|
'writable',
|
||||||
|
'symbolic-ref',
|
||||||
|
|
||||||
# Uncomment or add new commands here.
|
# Uncomment or add new commands here.
|
||||||
'create',
|
'create',
|
||||||
@ -190,6 +191,10 @@
|
|||||||
# 'Kindergarten',
|
# 'Kindergarten',
|
||||||
],
|
],
|
||||||
|
|
||||||
|
POST_GIT => [
|
||||||
|
'auto-default-branch',
|
||||||
|
],
|
||||||
|
|
||||||
);
|
);
|
||||||
|
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
|
Loading…
x
Reference in New Issue
Block a user