Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

unable to use post-commit hook if it includes 'git push' command #8847

Open
pepeworld opened this issue Dec 31, 2019 · 4 comments
Open

unable to use post-commit hook if it includes 'git push' command #8847

pepeworld opened this issue Dec 31, 2019 · 4 comments
Labels
bug Confirmed bugs or reports that are very likely to be bugs priority-3 Bugs that affect small number of users and/or relatively cosmetic in nature

Comments

@pepeworld
Copy link

Describe the bug

What I am trying to do is having an automated git push after a commit is done.
The issue is when a post-commit hook includes git push command, the application's commit process gets stuck.

image

Version & OS

Github Desktop: version 2.2.4
OS: Windows 10 Version 1903

Steps to reproduce the behavior

  1. I have the following script in my hooks directory:
#!/bin/sh

git push 
  1. updated any file in the repo
  2. with the commit message written, pressed on the "commit to master" button

Expected behavior

Commits and pushes the commit automatically.
Doing a commit from git bash or vs code will run the hook without a problem.

Actual behavior

the commit process gets stuck.
image
The commit does happen, but the hook action doesn't, and the commit button doesn't revert back to the non-blocked "in progress" state.

Logs

2019-12-31T07:22:03.305Z - info: [ui] [AppStore] loading 6 repositories from store
2019-12-31T07:22:03.305Z - info: [ui] [AppStore] found account: pepeworld (bugs)
2019-12-31T07:22:04.093Z - info: [ui] launching: 2.2.4 (Windows 10.0.18362)
2019-12-31T07:22:04.093Z - info: [ui] execPath: 'C:\Users\potato\AppData\Local\GitHubDesktop\app-2.2.4\GitHubDesktop.exe'
2019-12-31T07:22:04.330Z - info: [ui] Current tutorial step is NotApplicable
2019-12-31T07:22:04.612Z - info: [ui] Current tutorial step is NotApplicable
2019-12-31T07:22:05.200Z - info: [ui] Executing installGlobalLFSFilter: git lfs install --skip-repo (took 1.122s)
2019-12-31T07:22:10.015Z - info: [ui] Current tutorial step is NotApplicable
2019-12-31T07:22:12.631Z - info: [ui] Current tutorial step is NotApplicable
2019-12-31T07:22:12.878Z - info: [ui] [Timing] Action 'create commit' for 'pepeworld/React-Tick-Tac' took 1.092s
2019-12-31T07:22:29.957Z - info: [ui] Current tutorial step is NotApplicable
2019-12-31T07:22:32.393Z - info: [ui] Current tutorial step is NotApplicable

Additional context

redirecting the script to run a python script would help getting certain git commands to run:

#!/bin/sh
echo 'Running post commit hook' > ~/Desktop/pythonoutput.txt

python .git/hooks/pushrepo.py >~/Desktop/pythonoutput.txt

pushrepo.py:

import os
import subprocess

print(os.getcwd())
subprocess.Popen("git --version")

output:

C:\Users\potato\Documents\GitHub\React-Tick-Tac
git version 2.19.2.windows.4

however running git push would once again produce the same behavior, with this output:

C:\Users\potato\Documents\GitHub\React-Tick-Tac
@steveward steveward added the priority-3 Bugs that affect small number of users and/or relatively cosmetic in nature label Jan 6, 2020
@steveward
Copy link
Member

@pepeworld thanks for the report. I was able to reproduce this issue as well on my machine. One interesting note -- I have a test repository that uses a SSH remote URL and the post-commit hook worked successfully in that repository.

@steveward steveward added the bug Confirmed bugs or reports that are very likely to be bugs label Jan 6, 2020
@riexn
Copy link

riexn commented Aug 8, 2020

for context, this is what I am using:

  • Windows 10
  • VS Code
  • Git Bash

I looked into this issue by building the development environment of github desktop.

In the hooks, whenever a git command that requires authentication to work is called, it would prompt the user to put in their username and password.
This is with commands such as git push

In order to get the prompt:

  • Login into github desktop
  • create a post-commit hook in a repository that already has remote set up with this code:
#!/bin/bash
git push
  • make changes in the repo and commit them in desktop

and this prompt will appear:

image

after putting in the username and the password, the hook will work fine without any issues in development environment only.

This prompt never appears in the production build, and this is why the committing to master button hangs forever.
and this is exactly why running the hook in a repository that has SSH remote set up works, but HTTPS doesn't.

Overall, it seems like the cached credentials are not carrying over to the hooks when running them through github desktop.

No clue on how to solve this issue, but those are my findings.

@steveward
Copy link
Member

@riexn thanks for sharing your findings! That's helpful.

@sergiou87 sergiou87 added this to Triage in Desktop Housekeeping via automation Apr 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Confirmed bugs or reports that are very likely to be bugs priority-3 Bugs that affect small number of users and/or relatively cosmetic in nature
Projects
Development

No branches or pull requests

4 participants
@steveward @riexn @pepeworld and others