Remove pre-receive hook script file

This commit is contained in:
Thomas Miceli 2023-04-10 22:44:58 +02:00
parent 2e92b997fd
commit 2fe309663d
No known key found for this signature in database
GPG key ID: D86C6F6390AF050F
2 changed files with 28 additions and 34 deletions

View file

@ -2,7 +2,6 @@ package git
import ( import (
"fmt" "fmt"
"io"
"opengist/internal/config" "opengist/internal/config"
"os" "os"
"os/exec" "os/exec"
@ -276,17 +275,37 @@ func copyFiles(repositoryPath string) error {
return err return err
} }
preReceiveSrc, err := os.OpenFile(filepath.Join("internal", "resources", "pre-receive"), os.O_RDONLY, os.ModeAppend) if _, err = preReceiveDst.WriteString(preReceive); err != nil {
if err != nil {
return err return err
} }
_, err = io.Copy(preReceiveDst, preReceiveSrc)
if err != nil {
return err
}
defer preReceiveDst.Close() defer preReceiveDst.Close()
defer preReceiveSrc.Close()
return nil return nil
} }
const preReceive = `#!/bin/sh
disallowed_files=""
while read -r old_rev new_rev ref
do
while IFS= read -r file
do
case $file in
*/*)
disallowed_files="${disallowed_files}${file} "
;;
esac
done <<EOF
$(git diff --name-only "$old_rev" "$new_rev")
EOF
done
if [ -n "$disallowed_files" ]; then
echo "Pushing files in folders is not allowed:"
for file in $disallowed_files; do
echo " $file"
done
exit 1
fi
`

View file

@ -1,25 +0,0 @@
#!/bin/sh
disallowed_files=""
while read -r old_rev new_rev ref
do
while IFS= read -r file
do
case $file in
*/*)
disallowed_files="${disallowed_files}${file} "
;;
esac
done <<EOF
$(git diff --name-only "$old_rev" "$new_rev")
EOF
done
if [ -n "$disallowed_files" ]; then
echo "Pushing files in folders is not allowed:"
for file in $disallowed_files; do
echo " $file"
done
exit 1
fi