diff options
author | Juergen Funk <juergen.funk_ml@cib.de> | 2023-02-22 12:15:06 +0100 |
---|---|---|
committer | Thorsten Behrens <thorsten.behrens@allotropia.de> | 2023-03-01 10:44:25 +0000 |
commit | 9afc6b22e225e8a6ec50c1cbb4d966585d15dbfd (patch) | |
tree | 71c5c5d6579d363a6f63f8def57a4fa2364c48e3 /g | |
parent | e32dfaf15563372ffae6e0da53998e20068ebf81 (diff) |
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>
Diffstat (limited to 'g')
-rwxr-xr-x | g | 64 |
1 files changed, 48 insertions, 16 deletions
@@ -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 |