-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
fix: get-app command should be able to clone from any git server #1233
Conversation
I would actually suggest using an external dependency (giturlparse) that has already solved the problem of managing git URLs. That handles everything we need, and even spits out URLs for whatever protocol we need. |
@Alchez - so had a chat with @ankush , we already use a git parsing library in frappe - https://github.com/coala/git-url-parse - so it'll be better to use the same :) |
@phot0n, yeah that works too. At this point though, I feel like we need to zoom out a bit and look at the design itself. Because we shouldn't even need to extract the host and just simply pass it to the The only place I can see where we could need a URL parser is if we wanted to validate if a provided URL is actually a valid git link before processing it. That's what the Frappe app does for the Github connector atleast. |
Agreed, had the same thought as to why we're deconstructing and then reconstructing the git url 😅 - though i think it makes sense on shorter slugs where we just pass the repo name and/or branch/tag instead of fully passing the git url |
the c872181 will probably fail on python v3.7 test (might fail on all of them 🙈 ) as i've used walrus operator over here (which was added in python v3.8 - will change it) I've used the git url parsing dependency we use in frappe and did not change the design on how the App Meta class was implemented. Also, please do let me know if any better name pops up for this function :P |
beb6496
to
37a5743
Compare
I've updated the pr description and added some screenshots as well :) |
IMHO get-app should use exact git clone address. Because get-app is a developer method. Bench should never use healthcare@develop shortcuts. The developer should be freely use his repo and branch like git clone method. It makes harder to get in frappeverse. |
@TurkerTunali that option is not new i think as i saw it in previous bench version as well and is only available for first party apps i.e apps present under frappe/erpnext github org(s) and if a git url is passed it will be treated like how |
@phot0n I think we have a litle bit trouble here, but I assume that development is already done. So we may leave it as it is. |
@TurkerTunali please do let me know, i don't mind writing it over again :) - this needs to be correct otherwise people won't be able to get their apps 😆 |
555b33d
to
e719c3e
Compare
I've added some changes last night, mostly the feature @Alchez talked about here (got a bit carried away 😅 ) - now we can use Please do let me know your thoughts and also if you want them removed as i guess i went a bit with flow 😅 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@phot0n, I've suggested some changes (plus documentation changes) that are really nitpicky, but otherwise this is looking good.
As a totally optional side, looking at the code now, I like giturlparse more for us, cause it'll offload the URL validation and generation to the library. But this PR can go as is too.
f07b587
to
5e0492c
Compare
elif parsed_git_obj and parsed_git_obj.owner: | ||
self.tag = self.branch | ||
self.org = parsed_git_obj.owner | ||
self.repo = parsed_git_obj.name |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could also set self.use_ssh
if the passed name was a git SSH url?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's not necessary i think - it's there to go with the partial url format (when user provides --use-ssh
- maybe we can change the naming a bit as it definitely is a bit confusing as to with what it might be used [maybe use_ssh_for_partial_url
?])
5. healthcare@develop, [email protected] | ||
4. frappe/healthcare | ||
5. healthcare | ||
6. healthcare@develop, [email protected] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can add support for github:frappe/healthcare@version-13
too? SInce we want the gitserver host to be available too 🤔 . We could allow passing TLDs too instead of hardcoding them unconditionally in the get_*_url
methods. Eg: git.gav.in:frappe/healthcare@version-13
would also be valid.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tbh i'm not sure ..i was thinking of removing the one i've added as it seemed a bit excessive to me (kinda went with the flow 😅 ) - though if you want it i can try to add that but the host one is kinda solved using --git-host
option which is also only for using with partial urls
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Passing --git-host
is one solution that seems to miss out on the whole idea of why this format was added.
We should get rid of the git_host kwarg altogether. Just fetch this by parsing the url. That's how partial URLs should be handled. Adding a new option doesn't work while integrating this system in the App Dependency System.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmm, so basically the we want to get the host from the partial format itself rather than providing it through an option - we can do that though i'm not sure how much different they are though cause they basically achieve the same thing 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can add support for
github:frappe/healthcare@version-13
too? SInce we want the gitserver host to be available too 🤔 . We could allow passing TLDs too instead of hardcoding them unconditionally in theget_*_url
methods. Eg:git.gav.in:frappe/healthcare@version-13
would also be valid.
If we end up supporting hosts in that partial fragment too, I think at that point we might as well expect people to use the full URL anyway, no?
The new get-app
is a good option to use when some of the things expected in the URL can be defaulted (host to github, ref to default branch/tag). IMHO, anything beyond that should be received either in the full URL, or as separate options.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1 for alchez's comment - i think most people don't really care about shortcuts like these - we/they just go to a repo and get the git url and start doing things
bench/utils/__init__.py
Outdated
parsed_obj = giturlparse.parse(url) | ||
except Exception: | ||
# the git url is not parsable | ||
return False |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not let it just raise instead? That's what I'd expect from a util named parse_git_url
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if we look at how it's being used - we'll see that we pass everything coming our way into parse_git_url
..so if the parser raises everytime we'll need to handle that. we can shift the exception handling to setup_details
method (?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The problem I was trying to address here was a naming one. Everything could stay wherever they are if this function is renamed to get_parsed_giturl
and returns None
instead of False
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah sorry i misinterpreted 😅 - will do 👍
5. healthcare@develop, [email protected] | ||
4. frappe/healthcare | ||
5. healthcare | ||
6. healthcare@develop, [email protected] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Passing --git-host
is one solution that seems to miss out on the whole idea of why this format was added.
We should get rid of the git_host kwarg altogether. Just fetch this by parsing the url. That's how partial URLs should be handled. Adding a new option doesn't work while integrating this system in the App Dependency System.
bench/utils/__init__.py
Outdated
parsed_obj = giturlparse.parse(url) | ||
except Exception: | ||
# the git url is not parsable | ||
return False |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The problem I was trying to address here was a naming one. Everything could stay wherever they are if this function is renamed to get_parsed_giturl
and returns None
instead of False
.
I believe the issue this PR was addressing is fixed via #1243. Do we need to salvage anything from here? |
@gavindsouza if we have a look at frappe/frappe#15229 - the git url being used there is |
and make get-app work with valid git urls
…url format currently only github and gitlab are supported as git hosts via the git-host option * minor: add logic for picking up branch when using partial url format
* feat(minor): added support for githost in partial url format
38399df
to
0f30528
Compare
0f30528
to
b9e3e50
Compare
Seems like giturlparse can't handle azure links either (ref: nephila/giturlparse#6, testing both libraries locally). Raised #1247 to fix the same. Edit: Updated after realizing Oopsie |
Just a note cause it seems like package names are to blame here, You've used code from the https://github.com/coala/git-url-parse (v1.2.2) library over at nephila/giturlparse#6 (v0.10.0). Both of these libraries seem to have their own issues though. |
closing this pr in lieu of #1247 - thanks for all the help Alchez, Gavin :) |
Currently the git remote server is hardcoded to
github.com
.Changes:
--git-host
(for providing from which git host to get the app from - currently only supported for gitlab and github[default]) and--use-ssh
- both of these options are to be used with partial url format (previously name tag format) i.eorg/repo@branch
ororg/repo
orrepo@branch
or justrepo
(the last 2 being for apps under frappe/erpnext org)org/repo
format in get-app (rest all partial url formats were already there)git-url-parse
- which we also use in frappecloses: #1228