3

I am having a program continuously downloading projects from GitHub and then processing them. Then I found every now and then my program stuck in the GitHub prompt for typing user account and password.

My exploration about GitHub shows that these projects are no longer valid and that if I add my account and password in to "git clone" (e.g., https://user_name:pwd@github.com/dev/proj.git) I can avoid the password prompt and get a return code 32768.

Thus I use 32768 as a way to distinguish successfully downloads and failed downloads. But it turned out that the "git clone" of many valid GitHub projects also return "32768" as the status code.

So I am likely to have misunderstood "32768". My first problem is what "32768" means as a return code of "git clone".

I need to make the program run without supervision. My second question is how to make my program figure out the "git clone" finishes successfully without typing user account and password.

------add ---- Find some debugging, I found that the return code of git clone command in Linux terminal is 128. I ran the command using os.system(cmd_git_clone), the return code of os.system is 32768.

Peipei
  • 136
  • 1
  • 9
  • Is there a relationship between 128 and 32768? I suggest reading the documentation for `os.system` in whatever language that is, which will probably explain the rules it uses for return codes. – Edward Thomson Nov 14 '17 at 08:50

2 Answers2

2

I think this is feasible as number of steps. First, configure git not to prompt for a password (so that your program doesn't get stuck):

GIT_TERMINAL_PROMPT=0 git clone <repository>

Then check the return code of the command, and if it is valid, clone worked:

retVal=$?
if [ ! $? -eq 0 ]; then
    echo "Error"
else
    echo "Success"
fi
exit $retVal
Derek Brown
  • 4,232
  • 4
  • 27
  • 44
1

so I've just run into the same status code and had been puzzled for hours.

Turns out, for me, after debugging and reading the stderror messages, it turns out Git was complaining about not knowing who I am (See: Git: "please tell me who you are" error). I added a few lines in my program to configure my name and email in git, and everything was fine.

This seems to be quite a common error when you have scripts that do your job.

Winston Du
  • 340
  • 2
  • 9