github / github/platform-samples

Problem with pre-receive hook if there is whitespace character in file/folder name

Aperta
#362 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub
Lingua principale
Shell
Stelle
2.2k
Fork
1.9k
Merge medio
7g 19h
PR unite (30g)
1

Descrizione

Hello,

This is a suggestion for a change in: "pre-receive-hooks/block_file_extensions.sh". When you try to push an blob object, which has whitespace in its name, the current loop will break. My suggestion is to transform:

```
for FILE in `git log -1 --name-only --pretty=format:'' $COMMIT`;
do
case $FILE in
*.zip|*.gz|*.tgz )
echo "Hello there! We have restricted committing that filetype. Please see Dave in IT to discuss alternatives."
exit 1
;;
esac
done
```

into:
```
while IFS= read -r FILE; do
case "$FILE" in
*.zip|*.gz|*.tgz )
echo "Hello there! We have restricted committing that filetype. Please see Dave in IT to discuss alternatives."
exit 1
esac
done <<< "$(git log -1 --name-only --pretty=format:'' $COMMIT)"
```

Guida per i contributori

Apri la guida per i contributori

Direzione di ricerca

Start with pre-receive-hooks/block_file_extensions.sh and inspect how the current git log output is iterated. Reproduce the hook with a file or folder name containing whitespace, then verify that the restricted extensions are still rejected and whitespace-containing names are processed correctly.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
git, shell
Ambito
devops
Tipo di issue
Bug
Difficoltà
2/5
Tempo stimato
1-3 ore
Stato di attività
Ferma
Chiarezza
Specificata chiaramente
Idoneità per principianti
50/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.