How can I run below git command with python?
git_cmd = f'git log --format="" --name-only --since=2021-08-26 | sort -u'
try:
stdout, stderr = subprocess.Popen(git_cmd, stdout=subprocess.PIPE, shell=True).communicate()
print(stdout)
except subprocess.CalledProcessError as e:
print("Exception on process, rc", e.returncode, "stdout=", e.output)
This is throwing error as :
-uThe system cannot find the file specified
And Then I tried:
git_cmd = f'git log --format="" --name-only --since=2021-08-26 | sort -u'
try:
stdout = subprocess.check_output(git_cmd, stderr=subprocess.STDOUT).decode('utf-8')
print(stdout)
except subprocess.CalledProcessError as e:
print("Exception on process, rc", e.returncode, "stdout=", e.output)
This throws below error:
Exception on process, rc=128 stdout=b"fatal: ambiguous argument '|': unknown revision or path not in the working tree.
\nUse '--' to seperate paths from revisions, like this:\n'git <command> [<revision>...] -- [<file>...]'\n"
I cloned repo in my local and created python file inside repo.