repo-sync / github-sync

โคต๏ธ A GitHub Action for syncing current repository with remote
https://github.com/marketplace/actions/github-repo-sync
MIT License
393 stars 103 forks source link

fix: git URI matching for GitHub fallback #30

Closed notorious-gay closed 4 years ago

notorious-gay commented 4 years ago

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 :+1: (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:

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
wei commented 4 years ago

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?

notorious-gay commented 4 years ago

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

notorious-gay commented 4 years ago

All passed and running correctly on my test repo, looks like we're good to go! ๐ŸŽ‰

wei commented 4 years ago

@all-contributors please add @GlitchShtick for bugs

allcontributors[bot] commented 4 years ago

@wei

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

wei commented 4 years ago

@GlitchShtick It's been released and accessible via v2.1.3 and v2. Thanks for the help!!! ๐Ÿš€

notorious-gay commented 4 years ago

No worries at all! ๐Ÿ˜