diff --git a/commitbot.py b/commitbot.py index 0765550..eb3efe3 100644 --- a/commitbot.py +++ b/commitbot.py @@ -23,29 +23,28 @@ def update(): os.system('type nul > a.txt') -def pull(repo,url): - if os.path.exists(repo)==False: - os.system('git clone ' + url) +def pull(repo, url, branch="main"): + if not os.path.exists(repo): + os.system(f'git clone -b {branch} {url}') dirname = os.path.dirname(__file__) - filename = os.path.join(dirname, ''+repo) + filename = os.path.join(dirname, repo) os.chdir(filename) -def push(): +def push(branch="main"): global count - os.system('cd') os.system('git add . && git commit -m "commit ' + str(count) + '"') - os.system('git push origin master') - count+=1 + os.system(f'git push origin {branch}') + count += 1 def main(): - repo=input("Enter Git Repository name: ") + repo = input("Enter Git Repository name: ") url = input("Enter Git Repository URL: ") - comm=int(input("Enter Number Of Commits To Perform: ")) - pull(repo,url) - for i in range(0,comm): + branch = input("Enter Branch name (default: main): ") or "main" + comm = int(input("Enter Number Of Commits To Perform: ")) + pull(repo, url, branch) + for _ in range(comm): update() - push() + push(branch) - -if __name__=='__main__': - main() +if __name__ == '__main__': + main() \ No newline at end of file