Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

respect GitHubFileRef shorthand #37

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft

respect GitHubFileRef shorthand #37

wants to merge 3 commits into from

Conversation

zzstoatzz
Copy link
Contributor

@zzstoatzz zzstoatzz commented Feb 12, 2025

stacked on #35 (all changes specific to this PR are in 87d7f0d)

tries shorthand for GitHubFileRef or falls back to existing behavior

» alias prfx
prfx=prefect-cloud

» prfx deploy print_info -f gh/zzstoatzz/prefect-pack/flows/hello.py
Deployed print_info! 🎉
└─►
https://app.prefect.cloud/account/9b649228-0419-40e1-9e0d-44954b5c0ab6/workspace/e49488be-6d30-4980-94b2-a82a5edbb19c/deployments/deployment/74b5f9d4-aaa9-4792-b2ba-52688394970b
Run it with:
└─► prefect-cloud run print_info/print_info

and adds some tests

Comment on lines 76 to 101
@classmethod
def _try_shorthand(cls, url: str) -> "GitHubFileRef":
if not url.startswith("gh/"):
raise InvalidGitHubURL("Not a shorthand URL")

parts = url[3:].split("/") # Remove 'gh/' prefix
if len(parts) < 2: # Need at least owner/repo
raise InvalidGitHubURL("Invalid shorthand format")

owner = parts[0]
repo = parts[1]
branch = "main"

if "@" in owner:
owner, branch = owner.split("@")
elif "@" in repo:
repo, branch = repo.split("@")

filepath = "/".join(parts[2:]) if len(parts) > 2 else ""
return cls(
owner=owner,
repo=repo,
branch=branch,
filepath=filepath,
ref_type="blob",
)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

change

@zzstoatzz zzstoatzz force-pushed the gh branch 2 times, most recently from f05c96a to 87d7f0d Compare February 12, 2025 03:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant