Skip to content

Commit

Permalink
fix: allow update command to update or install dev version
Browse files Browse the repository at this point in the history
  • Loading branch information
stevearc committed Jan 18, 2024
1 parent a790548 commit 47d3d0e
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions gitstack.py
Original file line number Diff line number Diff line change
Expand Up @@ -1723,8 +1723,9 @@ def invoke(self, args: argparse.Namespace) -> None:

def run(self, version: str = "latest") -> None:
if __version__ == "dev":
print_err("Current version is 'dev'. Cannot update dev version.")
sys.exit(1)
msg = "gitstack is currently a development version. Are you sure you want to update? [y/n] "
if input(msg).lower() != "y":
return

if version == "latest":
contents = urllib.request.urlopen(
Expand All @@ -1736,10 +1737,15 @@ def run(self, version: str = "latest") -> None:
if version[1:] == __version__:
print("Already up to date")
return
if input(f"Update to {version}?").lower() != "y":
if input(f"Update to {version}? [y/n] ").lower() != "y":
return

url = f"https://github.com/stevearc/gitstack/releases/download/{version}/gitstack.py"
if version == "dev":
url = (
"https://raw.githubusercontent.com/stevearc/gitstack/master/gitstack.py"
)
else:
url = f"https://github.com/stevearc/gitstack/releases/download/{version}/gitstack.py"
(new_file, _) = urllib.request.urlretrieve(url)
os.unlink(__file__)
shutil.move(new_file, __file__)
Expand Down

0 comments on commit 47d3d0e

Please sign in to comment.