src = user/my.git dest = /home/git_name ver = 1.1
def run
p = subprocess.run(cmd, stdout=PIPE, stderr=PIPE)
I am calling this run with the following cmds
1. self.run(['mkdir', '-p', dest])
2. self.run(['git', 'clone', '--no-checkout',src, dest])
3. self.run(['cd', dest, ';', 'git', 'checkout', '--detach', ver]])
output:
1st run is a success
2nd run to clone gets the error stderr=b"Cloning into ' /home/git_name'...\n
3rd run is a success.
This directory /home/git_name.OLD.1723430 gets created and I see a .git inside this directory. I also have a file /home/git_name which points to the src, basically has a link to the src directory.
Both of these should happen in the same directory and I don't know why there are two and partial results in both. I am not sure what's wrong
Also, src = user/my.git/repos/tags/1.1 is the actual location of the tags when I try to use the entire path git clone says path is not right
Why does this happen?
subprocess.runhasshell=Falseas a default, which means you cannot putcd <path>; <cmd>in and expect it to work. There are two obvious ways to handle this: use thecwd=optional argument tosubprocess.runso that you don't need acd <path>, solving this problem entirely in Python; or usegit -C <path>, solving this problem with an argument to the Git command you run.shell=True, but see xkcd.