8000 fix: git URI matching for GitHub fallback by notorious-gay · Pull Request #30 · repo-sync/github-sync · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

fix: git URI matching for GitHub fallback #30

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

Merged
merged 4 commits into from
Sep 3, 2020
Merged

fix: git URI matching for GitHub fallback #30

merged 4 commits into from
Sep 3, 2020

Conversation

notorious-gay
Copy link
Contributor

This allows the user to use this action to pull a glitch.com repo to GitHub as they too do not use the .git suffix 👍
(As well as many other origins thanks to @wei's suggestion!)

After wrangling with docker and GitHub not running the action correctly I've got this working, please note the following additional changes had to be made to get the regex to work:

  • Add bash to alpine's installed applications via the Dockerfile
  • Switch to bash for the sh scripts

Please let me know if you have any questions or suggestions 😄

This change has been tested to work with the following URI's:

https://user@api.glitch.com/git/project
git@github.com:repo-sync/github-sync.git
http://user@api.glitch.com/git/project
repo-sync/github-sync
ssh://user@host.xz:port/path/to/repo.git/
ssh://user@host.xz/path/to/repo.git/
ssh://host.xz:port/path/to/repo.git/
ssh://host.xz/path/to/repo.git/
ssh://user@host.xz/path/to/repo.git/
ssh://host.xz/path/to/repo.git/
ssh://user@host.xz/~user/path/to/repo.git/
ssh://host.xz/~user/path/to/repo.git/
ssh://user@host.xz/~/path/to/repo.git
ssh://host.xz/~/path/to/repo.git
user@host.xz:/path/to/repo.git/
host.xz:/path/to/repo.git/
user@host.xz:~user/path/to/repo.git/
host.xz:~user/path/to/repo.git/
user@host.xz:path/to/repo.git
host.xz:path/to/repo.git
rsync://host.xz/path/to/repo.git/
git://host.xz/path/to/repo.git/
git://host.xz/~user/path/to/repo.git/
http://host.xz/path/to/repo.git/
https://host.xz/path/to/repo.git/
https://user@host.xz/path/to/repo
https://user@host.xz/path/to/repo.git

notorious-gay and others added 3 commits September 3, 2020 06:43
This allows the user to use this action to pull a glitch.com repo to github as they too do not use the .git suffix 👍

This has been tested to work with the following styles:
https://user@api.glitch.com/git/project
git@github.com:repo-sync/github-sync.git
http://user@api.glitch.com/git/project
repo-sync/github-sync
ssh://user@host.xz:port/path/to/repo.git/
ssh://user@host.xz/path/to/repo.git/
ssh://host.xz:port/path/to/repo.git/
ssh://host.xz/path/to/repo.git/
ssh://user@host.xz/path/to/repo.git/
ssh://host.xz/path/to/repo.git/
ssh://user@host.xz/~user/path/to/repo.git/
ssh://host.xz/~user/path/to/repo.git/
ssh://user@host.xz/~/path/to/repo.git
ssh://host.xz/~/path/to/repo.git
user@host.xz:/path/to/repo.git/
host.xz:/path/to/repo.git/
user@host.xz:~user/path/to/repo.git/
host.xz:~user/path/to/repo.git/
user@host.xz:path/to/repo.git
host.xz:path/to/repo.git
rsync://host.xz/path/to/repo.git/
git://host.xz/path/to/repo.git/
git://host.xz/~user/path/to/repo.git/
http://host.xz/path/to/repo.git/
https://host.xz/path/to/repo.git/
https://user@host.xz/path/to/repo
https://user@host.xz/path/to/repo.git
@wei
Copy link
Member
wei commented Sep 3, 2020

Wow thanks so much for the PR! Instead of adding bash as a dependency, we could just use grep regex match.

if ! echo $UPSTREAM_REPO | grep -Eq ':|@|\.git\/?$'
then
  UPSTREAM_REPO="https://github.com/${UPSTREAM_REPO}.git"
fi

Also updated the regex a bit to cover something like host.xz:/path/to/repo too.

If you don't mind, could you pls review my change and perform some quick tests with the url examples you provided above?

@wei wei added the enhancement New feature or request label Sep 3, 2020
@wei wei changed the title Only remap upstream to github if it does not look like a valid git URI Improve git URI matching for GitHub fallback Sep 3, 2020
@notorious-gay
Copy link
Contributor Author

No worries, I'll give this a try and get back to you!

8000

@notorious-gay
Copy link
Contributor Author

All passed and running correctly on my test repo, looks like we're good to go! 🎉

@wei wei changed the title Improve git URI matching for GitHub fallback fix: git URI matching for GitHub fallback Sep 3, 2020
@wei wei merged commit 4c75501 into repo-sync:master Sep 3, 2020
@wei
Copy link
Member
wei commented Sep 3, 2020

@all-contributors please add @GlitchShtick for bugs

@allcontributors
Copy link
Contributor

@wei

I've put up a pull request to add @GlitchShtick! 🎉

@wei
Copy link
Member
wei commented Sep 3, 2020

@GlitchShtick It's been released and accessible via v2.1.3 and v2. Thanks for the help!!! 🚀

@notorious-gay
Copy link
Contributor Author

No worries at all! 😁

shakti-garg added a commit to shakti-garg/git-sync that referenced this pull request Oct 27, 2020
wei pushed a commit to wei/git-sync that referenced this pull request Nov 3, 2020
* Update grep regex for precise filtering of urls

* update source and destination repo regex

Regex derived from repo-sync/github-sync#30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
0