github / github/platform-samples

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

未關閉
#362 0 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視
主要語言
Shell
星號
2.2k
分支
1.9k
平均合併
7 天 19 小時
30 天內合併 PR
1

描述

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)"
```

貢獻指南

開啟貢獻指南

研究方向

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.

由索引模型根據 Issue 內容生成。

評估

技術堆疊
git, shell
領域
devops
Issue 類型
缺陷
難度
2/5
預估耗時
1-3 小時
活躍度
停滯
描述清晰度
描述清楚
新手友好度
50/100

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。