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

Remove the support for SCP syntax for ssh locations. #54

Merged
merged 3 commits into from
May 29, 2024
Merged

Conversation

plietar
Copy link
Member

@plietar plietar commented May 23, 2024

The SCP syntax, of the form username@hostname:path, makes inferring the type of location from a URL more difficult. Additionally it introduces two ways of doing the same thing for little benefit.

The only advantage this syntax had (other than conciseness) is that its path was relative by default, whereas the full "ssh://hostname/path" URL syntax always interpreted the path as absolute (following Git's semantics). We now follow the Mercurial semantics, where ssh://hostname/path is relative to the user's home directory and ssh://hostname//path is absolute.

The SCP syntax, of the form `username@hostname:path`, makes inferring
the type of location from a URL more difficult. Additionally it
introduces two ways of doing the same thing for little benefit.

The only advantage this syntax had (other than conciseness) is that its
path is relative by default, whereas the full "ssh://" URL syntax has an
absolute path. We can provide an alternative by interpreting paths that
start with `/~/` as relative. This works and makes sense because,
barring any unusual SSH server setups, the initial working directory of
an SFTP server is the user's home directory. This is similar as what Git
supports, though Git does a proper expansion of the tilde, and also
supports other users' home directory, eg. `/~alice/`. This only works
thanks to a server side git binary, which we don't have.

Interestingly, Mercurial actually solves that problem another way, by
not including the separating slash in the path: `ssh://hostname/path` is
relative, `ssh://hostname//path` is absolute.
@plietar plietar requested a review from richfitz May 23, 2024 11:33
@plietar
Copy link
Member Author

plietar commented May 23, 2024

Part of the motivation here is making the implementation of the outpack location add URL command simpler, by making the location type detection trivial through the URL scheme only.

raise Exception(msg)
# This condition is equivalent to path.is_relative_to("/~"), except that
# function isn't available on Python 3.8.
home = PurePosixPath("/~")
Copy link
Member

Choose a reason for hiding this comment

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

I think I prefer the mercurial approach here tbh. How strongly do you feel about this?

My reasoning is that relative paths will probably be more commonly used (most people will be used to scp ... popping files in their home directory unless they take additional action. I know that this is slightly inconsistent with http urls though.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah I think I actually prefer the mercurial approach too. My main reason for doing it this way is that more people will be familiar with Git than Mercurial.

That being said, probably very few people actually use Git in this way and instead use whatever magic GitHub does, so maybe it doesn’t matter. I’ll change it to the mercurial semantics.

Copy link

codecov bot commented May 28, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 97.76%. Comparing base (6ec900c) to head (7873bd6).
Report is 9 commits behind head on main.

Current head 7873bd6 differs from pull request most recent head 8101051

Please upload reports for the commit 8101051 to get more accurate results.

Additional details and impacted files
@@            Coverage Diff             @@
##             main      #54      +/-   ##
==========================================
- Coverage   99.28%   97.76%   -1.52%     
==========================================
  Files          45       50       +5     
  Lines        3351     4027     +676     
  Branches      527      660     +133     
==========================================
+ Hits         3327     3937     +610     
- Misses         21       65      +44     
- Partials        3       25      +22     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@plietar plietar force-pushed the no-scp-url branch 2 times, most recently from a3cf620 to 7873bd6 Compare May 28, 2024 15:08
@plietar plietar requested a review from richfitz May 28, 2024 17:02
@plietar plietar merged commit a2bd10a into main May 29, 2024
7 checks passed
@plietar plietar deleted the no-scp-url branch May 29, 2024 12:28
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.

2 participants