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

Ignore git clone prefix when checking clipboard for source URL #9018

Conversation

nyankoframe
Copy link
Contributor

@nyankoframe nyankoframe commented Mar 20, 2021

Fixes #6260

Proposed changes

  • Detects whether clipboard contents contain a potential URL using regex; if so, clipboard contents are provided as-is allowing user to modify contents prior to clone operation.

Test methodology

  • Manual testing
  • Added new tests to PathUtilTest.IsUrl and PathUtilTest.CanBeGitURL

Test environment(s)

  • GIT 2.31.0.windows.1
  • Windows 10.0.19042.868

✒️ I contribute this code under The Developer Certificate of Origin.

@ghost ghost assigned nyankoframe Mar 20, 2021
GitUI/CommandsDialogs/FormClone.cs Outdated Show resolved Hide resolved
GitUI/CommandsDialogs/FormClone.cs Outdated Show resolved Hide resolved
@nyankoframe
Copy link
Contributor Author

I've been looking at using a regex and can see two approaches:

  1. Use a regex to remove any leading git commands (such as git clone, git checkout)
  2. Use a regex to capture anything that looks to be a URL

It would make more sense to modify PathUtil.IsUrl if doing the second approach, but I'm not sure what sort of effect it'll have on other features.

Copy link
Member

@RussKie RussKie left a comment

Choose a reason for hiding this comment

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

I'd like to see tests for this as well.

GitUI/CommandsDialogs/FormClone.cs Outdated Show resolved Hide resolved
GitUI/CommandsDialogs/FormClone.cs Outdated Show resolved Hide resolved
@RussKie RussKie added the 📭 needs: author feedback More info/confirmation awaited from OP; issues typically get closed after 30 days of inactivity label Mar 26, 2021
@ghost ghost removed the 📭 needs: author feedback More info/confirmation awaited from OP; issues typically get closed after 30 days of inactivity label Apr 19, 2021
@nyankoframe nyankoframe force-pushed the issue-6260-detect-ignore-git-clone-prefix branch from d817251 to 5905cba Compare April 19, 2021 03:09
@RussKie
Copy link
Member

RussKie commented Apr 21, 2021

Please do a clean rebase and squash, and it's good to go

@RussKie RussKie added the 📭 needs: author feedback More info/confirmation awaited from OP; issues typically get closed after 30 days of inactivity label Apr 21, 2021
@nyankoframe nyankoframe force-pushed the issue-6260-detect-ignore-git-clone-prefix branch from f3794cb to 2fafc7b Compare April 22, 2021 04:02
@ghost ghost removed the 📭 needs: author feedback More info/confirmation awaited from OP; issues typically get closed after 30 days of inactivity label Apr 22, 2021
Use a regex to determine if a URL might exist in a particular
string (from clipboard, user input or elsewhere). This change will not
remove any text that may surround the URL, allowing the user to remove it
themselves (such as in the clone dialog).
@nyankoframe nyankoframe force-pushed the issue-6260-detect-ignore-git-clone-prefix branch from 2fafc7b to a8128e2 Compare April 22, 2021 04:04
@RussKie RussKie merged commit 7d25651 into gitextensions:master Apr 24, 2021
@ghost ghost added this to the 3.6 milestone Apr 24, 2021
@RussKie
Copy link
Member

RussKie commented Apr 24, 2021

Thank you!

@RussKie RussKie modified the milestones: 3.6, 3.5 Apr 24, 2021
@RussKie
Copy link
Member

RussKie commented Apr 24, 2021

If you wish these changes to go out in 3.5 (which will be released very soon) then please make a PR against 3.5 branch.

@nyankoframe nyankoframe deleted the issue-6260-detect-ignore-git-clone-prefix branch April 26, 2021 04:24
@nyankoframe
Copy link
Contributor Author

If you wish these changes to go out in 3.5 (which will be released very soon) then please make a PR against 3.5 branch.

Done, see #9116

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.

Detect 'git clone' prefix and ignore
3 participants