mirror of
https://github.com/thomiceli/opengist.git
synced 2024-12-23 04:52:40 +00:00
Remove pre-receive hook script file
This commit is contained in:
parent
2e92b997fd
commit
2fe309663d
2 changed files with 28 additions and 34 deletions
|
@ -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
|
||||||
|
`
|
||||||
|
|
|
@ -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
|
|
Loading…
Reference in a new issue