Message ID | 1503660715-24287-1-git-send-email-a.hajda@samsung.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
On 25.08.2017 13:31, Andrzej Hajda wrote: > dim finds remote name by matching repository urls, but different users > requires different protocols/paths for remotes (ssh/git/https). Current > code incorrectly translates provided url to alternatives, the patch > fixes it. > > Signed-off-by: Andrzej Hajda <a.hajda@samsung.com> Gently ping. Andrzej > --- > dim | 26 ++++++++++++-------------- > 1 file changed, 12 insertions(+), 14 deletions(-) > > diff --git a/dim b/dim > index 11aa675..d6d9269 100755 > --- a/dim > +++ b/dim > @@ -223,15 +223,15 @@ fi > # git branch name - dim assumes that the remote and local name match > # url: > # url to a repo, using ssh:// protocol > -# git_url: > -# url to a repo, but using anonymous git:// protocol > +# urls: > +# alternative urls to a repo, derived from url > # > # The below functions map between these. > # > > function url_to_remote # url > { > - local url remote > + local url urls remote > > url="$1" > > @@ -240,19 +240,17 @@ function url_to_remote # url > return 1 > fi > > - remote=$(git remote -v | grep -m 1 "$url" | cut -f 1) > + urls=$(echo $url | sed -r \ > + -e 's!ssh://(git.freedesktop.org)/git/(.*)!\0|git://anon\1/\2|https://anon\1/git/\2.git!' \ > + -e 's!git://(git.kernel.org/.*)!\0|https://\1!') > + remote=$(git remote -v | grep -m 1 -P "$urls" | cut -f 1) > > if [[ -z "$remote" ]]; then > - git_url=$(echo $url | sed -e 's/git\./anongit./' -e 's/ssh:/git:/') > - remote=$(git remote -v | grep -m 1 "$git_url" | cut -f 1) > - > - if [[ -z "$remote" ]]; then > - echoerr "No git remote for url $url or $git_url found in $(pwd)" > - echoerr "Please set it up using:" > - echoerr " $ git remote add <name> $url" > - echoerr "with a name of your choice." > - return 1 > - fi > + echoerr "No git remote for url $url found in $(pwd)" > + echoerr "Please set it up using:" > + echoerr " $ git remote add <name> url" > + echoerr "with a name of your choice and url one of: ${urls//|/, }" > + return 1 > fi > > echo $remote
On Wed, 27 Sep 2017, Andrzej Hajda <a.hajda@samsung.com> wrote: > On 25.08.2017 13:31, Andrzej Hajda wrote: >> dim finds remote name by matching repository urls, but different users >> requires different protocols/paths for remotes (ssh/git/https). Current >> code incorrectly translates provided url to alternatives, the patch >> fixes it. >> >> Signed-off-by: Andrzej Hajda <a.hajda@samsung.com> > > Gently ping. Apologies for the delay. I had a hard time understanding all the sed trickery you have there. Then I decided the right solution is to be able to configure multiple URLs in nightly.conf for each repo in drm_tip_repos. Patch follows adding this support to dim, untested because I need to run now. Unfortunately we can't update nightly.conf before dim users have upgraded to the patched version, because otherwise their setups would break. BR, Jani.
diff --git a/dim b/dim index 11aa675..d6d9269 100755 --- a/dim +++ b/dim @@ -223,15 +223,15 @@ fi # git branch name - dim assumes that the remote and local name match # url: # url to a repo, using ssh:// protocol -# git_url: -# url to a repo, but using anonymous git:// protocol +# urls: +# alternative urls to a repo, derived from url # # The below functions map between these. # function url_to_remote # url { - local url remote + local url urls remote url="$1" @@ -240,19 +240,17 @@ function url_to_remote # url return 1 fi - remote=$(git remote -v | grep -m 1 "$url" | cut -f 1) + urls=$(echo $url | sed -r \ + -e 's!ssh://(git.freedesktop.org)/git/(.*)!\0|git://anon\1/\2|https://anon\1/git/\2.git!' \ + -e 's!git://(git.kernel.org/.*)!\0|https://\1!') + remote=$(git remote -v | grep -m 1 -P "$urls" | cut -f 1) if [[ -z "$remote" ]]; then - git_url=$(echo $url | sed -e 's/git\./anongit./' -e 's/ssh:/git:/') - remote=$(git remote -v | grep -m 1 "$git_url" | cut -f 1) - - if [[ -z "$remote" ]]; then - echoerr "No git remote for url $url or $git_url found in $(pwd)" - echoerr "Please set it up using:" - echoerr " $ git remote add <name> $url" - echoerr "with a name of your choice." - return 1 - fi + echoerr "No git remote for url $url found in $(pwd)" + echoerr "Please set it up using:" + echoerr " $ git remote add <name> url" + echoerr "with a name of your choice and url one of: ${urls//|/, }" + return 1 fi echo $remote
dim finds remote name by matching repository urls, but different users requires different protocols/paths for remotes (ssh/git/https). Current code incorrectly translates provided url to alternatives, the patch fixes it. Signed-off-by: Andrzej Hajda <a.hajda@samsung.com> --- dim | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-)