Last active
October 1, 2021 21:57
-
-
Save M-Porter/9c4717a7c645e256e97c4f1377d4554b to your computer and use it in GitHub Desktop.
Revisions
-
M-Porter revised this gist
Oct 1, 2021 . 1 changed file with 0 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -19,14 +19,12 @@ class PullThis: except IndexError: return "origin" def __get_branch(self) -> str: branch = subprocess.check_output( ["git", "rev-parse", "--abbrev-ref", "head"] ).decode("utf-8") return branch.strip() def run(self): """Pull down the latest commits from the active working branch. -
M-Porter revised this gist
Oct 1, 2021 . 1 changed file with 5 additions and 5 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -5,11 +5,11 @@ import subprocess class Colors: CYAN = "\033[96m" GREEN = "\033[92m" WARNING = "\033[93m" FAIL = "\033[91m" ENDC = "\033[0m" class PullThis: -
M-Porter created this gist
Oct 1, 2021 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,55 @@ #!/usr/bin/env python3 import sys import subprocess class Colors: CYAN = '\033[96m' GREEN = '\033[92m' WARNING = '\033[93m' FAIL = '\033[91m' ENDC = '\033[0m' class PullThis: def __get_origin(self) -> str: try: return sys.argv[1] except IndexError: return "origin" def __get_branch(self) -> str: branch = subprocess.check_output( ["git", "rev-parse", "--abbrev-ref", "head"] ).decode("utf-8") return branch.strip() def run(self): """Pull down the latest commits from the active working branch. >>> git pt Optionally, you can pull down commits from another remote on the current branch by providing an argument. By default, the command will always pull from origin. >>> git pt another-remote """ origin = self.__get_origin() try: branch = self.__get_branch() except subprocess.CalledProcessError: exit(1) print(f"{Colors.GREEN}Pulling down latest...{Colors.ENDC}") print(f"{Colors.CYAN}=>{Colors.ENDC} git pull {origin} {branch}\n") subprocess.run(["git", "pull", origin, branch]) if __name__ == "__main__": PullThis().run()