Created
September 30, 2022 08:07
-
-
Save notionparallax/ceb493cdc4171f008643f72d525e50ea to your computer and use it in GitHub Desktop.
A pyRevit script that pulls all the branches of a repo of pyRevit tools
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 characters
#! python3 | |
""" | |
Update (pull) all branches. | |
This is unsafe/may fail if you've been developing locally, so you need to clean | |
up your local env, and commit all your changes before you press this button. | |
""" | |
imports_worked = False | |
module_not_found_error_message = "" | |
try: | |
import git | |
imports_worked = True | |
except ModuleNotFoundError as e: | |
module_not_found_error_message = e | |
print("Can't run this, you need to pip install this module", e) | |
def pull_branchs(): | |
repo = git.cmd.Git(".") | |
response = repo.pull() | |
print(response) | |
# TODO: test to see what this does with different failure modes: | |
# * Local is dirty | |
# * Local is far behind remote | |
# * A new branch appears on the remote, will this pick it up? | |
# TODO: tell the user that the branches have updated | |
if __name__ == "__main__" and imports_worked: | |
pull_branchs() | |
elif not imports_worked: | |
print( | |
f"\n\n⚠ {module_not_found_error_message}\n" | |
"some imports didn't work, you need to install them using pip. " | |
"This is a bit of a dark art, and we need to work out good instructions " | |
"on how to do this. \n" | |
"There might be more missing modules, but this one was the first one " | |
"that made python fail." | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment