git-hooks: overwrite the windows-links not with linux-links
Always when you call build or logerrit, then the windows-links overwrite with linux-links, but when you using GIT for Windows you need the windows-links. This patch made a check it is using GIT for Windows, and check what for link it is, when wrong link, it output the .git-hooks/README Improve the check for links, when a link is set not need to set the link anymore In .git-hooks/README improve the FOR with delete of the wrong link look here for GIT for Windows: https://wiki.documentfoundation.org/Development/BuildingOnWindows/de#Cygwin_and_git Change-Id: I9f6ef9aca316058ef74cb2b2d107236f03a2e2ee Reviewed-on: https://gerrit.libreoffice.org/c/core/+/147458 Tested-by: Jenkins Reviewed-by: Thorsten Behrens <thorsten.behrens@allotropia.de>
This commit is contained in:
parent
e32dfaf155
commit
9afc6b22e2
2 changed files with 49 additions and 17 deletions
|
@ -7,7 +7,7 @@ To install manually, run:
|
|||
When you using GIT for Windows, you need Windows links
|
||||
Open a Dos-Box with admin rights then
|
||||
cd .git/hooks
|
||||
FOR /F " usebackq " %i IN (`dir /b ..\..\.git-hooks`) DO mklink %i ..\..\.git-hooks\%i
|
||||
FOR /F " usebackq " %i IN (`dir /b ..\..\.git-hooks`) DO del /as /f %i & mklink %i ..\..\.git-hooks\%i
|
||||
|
||||
There are two groups of these hooks: client side and server side.
|
||||
|
||||
|
|
64
g
64
g
|
@ -42,7 +42,7 @@ refresh_submodule_hooks()
|
|||
continue
|
||||
fi
|
||||
hook="${repo?}/.git/hooks/${hook_name##*/}"
|
||||
if [ ! -e "${hook?}" ] || [ -L "${hook?}" ] ; then
|
||||
if [ ! -e "${hook?}" ] || [ ! -L "${hook?}" ] ; then
|
||||
rm -f "${hook?}"
|
||||
ln -sf "${hook_name}" "${hook?}"
|
||||
fi
|
||||
|
@ -53,7 +53,7 @@ refresh_submodule_hooks()
|
|||
continue
|
||||
fi
|
||||
hook="${repo?}/.git/hooks/${hook_name##*/}"
|
||||
if [ ! -e "${hook?}" ] || [ -L "${hook?}" ] ; then
|
||||
if [ ! -e "${hook?}" ] || [ ! -L "${hook?}" ] ; then
|
||||
rm -f "${hook?}"
|
||||
ln -sf "${hook_name}" "${hook?}"
|
||||
fi
|
||||
|
@ -64,7 +64,7 @@ refresh_submodule_hooks()
|
|||
continue
|
||||
fi
|
||||
hook=".git/modules/${repo?}/hooks/${hook_name##*/}"
|
||||
if [ ! -e "${hook?}" ] || [ -L "${hook?}" ] ; then
|
||||
if [ ! -e "${hook?}" ] || [ ! -L "${hook?}" ] ; then
|
||||
rm -f "${hook?}"
|
||||
ln -sf "${hook_name}" "${hook?}"
|
||||
fi
|
||||
|
@ -75,7 +75,7 @@ refresh_submodule_hooks()
|
|||
continue
|
||||
fi
|
||||
hook=".git/modules/${repo?}/hooks/${hook_name##*/}"
|
||||
if [ ! -e "${hook?}" ] || [ -L "${hook?}" ] ; then
|
||||
if [ ! -e "${hook?}" ] || [ ! -L "${hook?}" ] ; then
|
||||
rm -f "${hook?}"
|
||||
ln -sf "${hook_name}" "${hook?}"
|
||||
fi
|
||||
|
@ -89,22 +89,44 @@ refresh_all_hooks()
|
|||
local repo
|
||||
local hook_name
|
||||
local hook
|
||||
local winlnk
|
||||
local lnkfile=".git/hooks/pre-commit"
|
||||
|
||||
pushd "${COREDIR?}" > /dev/null
|
||||
# There's no ".git" e.g. in a secondary worktree
|
||||
if [ -d ".git" ]; then
|
||||
for hook_name in "${COREDIR?}/.git-hooks"/* ; do
|
||||
hook=".git/hooks/${hook_name##*/}"
|
||||
if [ ! -e "${hook?}" ] || [ -L "${hook?}" ] ; then
|
||||
rm -f "${hook?}"
|
||||
ln -sf "${hook_name}" "${hook?}"
|
||||
fi
|
||||
|
||||
if [ $WINGIT -eq 1 ]; then
|
||||
winlnk=0
|
||||
if [ -e "${lnkfile}" ] && [ -L "${lnkfile}" ] ; then
|
||||
# if linux-links or windows-links?
|
||||
# dos dir output windows link:
|
||||
# 04.09.2020 10:54 <SYMLINK> pre-commit [..\..\.git-hooks\pre-commit]
|
||||
# dos dir output linux link:
|
||||
# file not found
|
||||
winlnk=$(cmd /C "DIR ${lnkfile//'/'/'\'}" 2>&1)
|
||||
winlnk=$(echo "$winlnk" | grep -icE "<SYMLINK>.*${lnkfile##*/} \[")
|
||||
fi
|
||||
|
||||
if [ $winlnk -eq 0 ]; then
|
||||
echo "You using GIT for Windows, but the hook-links not right, change with mklink"
|
||||
cat .git-hooks/README
|
||||
fi
|
||||
else
|
||||
# There's no ".git" e.g. in a secondary worktree
|
||||
if [ -d ".git" ]; then
|
||||
for hook_name in "${COREDIR?}/.git-hooks"/* ; do
|
||||
hook=".git/hooks/${hook_name##*/}"
|
||||
if [ ! -e "${hook?}" ] || [ ! -L "${hook?}" ] ; then
|
||||
rm -f "${hook?}"
|
||||
ln -sf "${hook_name}" "${hook?}"
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
||||
for repo in ${SUBMODULES_ALL?} ; do
|
||||
refresh_submodule_hooks "$repo"
|
||||
done
|
||||
fi
|
||||
|
||||
for repo in ${SUBMODULES_ALL?} ; do
|
||||
refresh_submodule_hooks "$repo"
|
||||
done
|
||||
popd > /dev/null
|
||||
|
||||
}
|
||||
|
@ -294,7 +316,9 @@ if [ "$#" -eq "0" ] ; then
|
|||
usage
|
||||
fi
|
||||
|
||||
if [ ! "$(type -p git)" ]; then
|
||||
gitfile="$(type -p git)"
|
||||
|
||||
if [ ! "${gitfile}" ]; then
|
||||
echo "Cannot find the git binary! Is git installed and is in PATH?"
|
||||
exit 1
|
||||
fi
|
||||
|
@ -323,6 +347,14 @@ REPORT_REPOS=1
|
|||
REPORT_COMMANDS=0
|
||||
REPORT_COMPACT=0
|
||||
DO_HOOK_REFRESH=false
|
||||
WINGIT=
|
||||
|
||||
# it is 'GIT for Windows'
|
||||
WINGIT=$(echo $gitfile | grep -c cygdrive)
|
||||
if [ $WINGIT -eq 1 ]; then
|
||||
gitfile=$(git --version)
|
||||
WINGIT=$(echo $gitfile | grep -ic windows)
|
||||
fi
|
||||
|
||||
while [ "${COMMAND:0:1}" = "-" ] ; do
|
||||
case "$COMMAND" in
|
||||
|
|
Loading…
Reference in a new issue