No information is given on stdin for pre/post-receive #808

Closed
opened 2025-11-02 03:37:28 -06:00 by GiteaMirror · 4 comments
Owner

Originally created by @UziTech on GitHub (Jun 12, 2017).

  • Gitea version (or commit ref): 1.1.1
  • Git version: 2.13.0.windows.1
  • Operating system: Windows Server 2012 R2
  • Database (use [x]):
    • PostgreSQL
    • MySQL
    • MSSQL
    • SQLite
  • Can you reproduce the bug at https://try.gitea.io:
    • Yes (provide example URL)
    • No
    • Not relevant
  • Log gist:

Description

pre-receive and post-receive git hooks are supposed to receive information on stdin

related #1808

Originally created by @UziTech on GitHub (Jun 12, 2017). - Gitea version (or commit ref): 1.1.1 - Git version: 2.13.0.windows.1 - Operating system: Windows Server 2012 R2 - Database (use `[x]`): - [ ] PostgreSQL - [x] MySQL - [ ] MSSQL - [ ] SQLite - Can you reproduce the bug at https://try.gitea.io: - [ ] Yes (provide example URL) - [ ] No - [x] Not relevant - Log gist: ## Description [pre-receive](https://git-scm.com/docs/githooks#pre-receive) and [post-receive](https://git-scm.com/docs/githooks#post-receive) git hooks are supposed to receive information on `stdin` related #1808
GiteaMirror added the type/question label 2025-11-02 03:37:28 -06:00
Author
Owner

@olivier-mauras commented on GitHub (Jun 15, 2017):

I've noted the same issue when I migrated from my 0.9 Gogs install to Gitea.
This comes from the new post-receive wrapper script in hooks/post-receive

#!/usr/bin/env bash
ORI_DIR=`pwd`
SHELL_FOLDER=$(cd "$(dirname "$0")";pwd)
cd "$ORI_DIR"
for i in `ls "$SHELL_FOLDER/post-receive.d"`; do
    sh "$SHELL_FOLDER/post-receive.d/$i"
done

Your actual hook is in hooks/post-receive.d/post-receive
This indeed doesn't forward stdin to post-receive.d/ scripts.

Something like that would make your pre/post-receive work again:

#!/usr/bin/env bash
ORI_DIR=`pwd`
SHELL_FOLDER=$(cd "$(dirname "$0")";pwd)
read STDIN
cd "$ORI_DIR"
for i in `ls "$SHELL_FOLDER/post-receive.d"`; do
    echo "$STDIN" | sh "$SHELL_FOLDER/post-receive.d/$i"
done

I'll see if I can make a PR for that.

@olivier-mauras commented on GitHub (Jun 15, 2017): I've noted the same issue when I migrated from my 0.9 Gogs install to Gitea. This comes from the new post-receive wrapper script in `hooks/post-receive` ``` bash #!/usr/bin/env bash ORI_DIR=`pwd` SHELL_FOLDER=$(cd "$(dirname "$0")";pwd) cd "$ORI_DIR" for i in `ls "$SHELL_FOLDER/post-receive.d"`; do sh "$SHELL_FOLDER/post-receive.d/$i" done ``` Your actual hook is in `hooks/post-receive.d/post-receive` This indeed doesn't forward stdin to post-receive.d/ scripts. Something like that would make your pre/post-receive work again: ``` bash #!/usr/bin/env bash ORI_DIR=`pwd` SHELL_FOLDER=$(cd "$(dirname "$0")";pwd) read STDIN cd "$ORI_DIR" for i in `ls "$SHELL_FOLDER/post-receive.d"`; do echo "$STDIN" | sh "$SHELL_FOLDER/post-receive.d/$i" done ``` I'll see if I can make a PR for that.
Author
Owner

@lunny commented on GitHub (Jun 15, 2017):

We need also some integration tests about hooks.

@lunny commented on GitHub (Jun 15, 2017): We need also some integration tests about hooks.
Author
Owner

@lafriks commented on GitHub (Jul 1, 2017):

This issue is fixed in master with #1257 and duplicate of #1250

@lafriks commented on GitHub (Jul 1, 2017): This issue is fixed in master with #1257 and duplicate of #1250
Author
Owner

@lafriks commented on GitHub (Jul 1, 2017):

Also #1257 was backported to 1.1.x version but not migration. You should manually run Resync pre-receive, update and post-receive hooks of all repositories. from administrator dashboard to have correct hooks

@lafriks commented on GitHub (Jul 1, 2017): Also #1257 was backported to 1.1.x version but not migration. You should manually run `Resync pre-receive, update and post-receive hooks of all repositories.` from administrator dashboard to have correct hooks
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#808