I'm trying to create a script with list merged remote release
branches which haven't had any updates in last 6 months, and then remove them.
So far, I've been trying to do the list branches part with following script:
import subprocess
import subprocess
import sys
import git
from git import Repo, repo
from git import Git
def get_merged_release_branches():
result_release = subprocess.getoutput("git branch -r --merged | grep release | sed 's#origin/##'")
return (result_release)
command = 'git log -1 --pretty=format:"%Cgreen%as" --before \\\'6 month ago'
for branch in get_merged_release_branches():
output = subprocess.Popen(command, universal_newlines=True, shell=True,stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate()
print(output)
but that doesn´t seems to work. Getting black screen like iterating into something. Also not sure if with subprocess.popen
is the best choice. What should be the best recommendation if not for this?
Also tried with:
output = subprocess.call(["git","log -1","--pretty=format:\\\"%Cgreen%as\\\ --before \\\'6 month ago'"])
but didn´t work either.
I also know you have git for python here but don´t know the best way to implement this.
source https://stackoverflow.com/questions/70465239/git-log-with-python-for-showing-old-merged-branches
Comments
Post a Comment