Skip to content

Commit

Permalink
[FIXED JENKINS-49768] Detect scp style urls and translate to ssh style
Browse files Browse the repository at this point in the history
  • Loading branch information
stephenc committed Mar 14, 2018
1 parent 30dbeb9 commit bddf7b2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
3 changes: 1 addition & 2 deletions CHANGES.md
Expand Up @@ -12,8 +12,7 @@

## Version 1.0.5 (unreleased)

* ...

* Fix parsing of clone URLs when Gitea is publishes scp style clone URLs ([JENKINS-49768](https://issues.jenkins-ci.org/browse/JENKINS-49768))
## Version 1.0.4 (2017-12-18)

* Added support for Webhook notification of repository creation / deletion now that Gitea 1.3 supports those events
Expand Down
10 changes: 10 additions & 0 deletions src/main/java/org/jenkinsci/plugin/gitea/GiteaSCMBuilder.java
Expand Up @@ -152,6 +152,16 @@ public static UriTemplate checkoutUriTemplate(@CheckForNull Item context,
)
);
if (credentials instanceof SSHUserPrivateKey) {
int atIndex = sshRemote.indexOf('@');
int colonIndex = sshRemote.indexOf(':');
if (atIndex != -1 && colonIndex != -1 && atIndex < colonIndex) {
// this is an scp style url, we will translate to ssh style
return UriTemplate.buildFromTemplate("ssh://"+sshRemote.substring(0, colonIndex))
.path(UriTemplateBuilder.var("owner"))
.path(UriTemplateBuilder.var("repository"))
.literal(".git")
.build();
}
URI sshUri = URI.create(sshRemote);
return UriTemplate.buildFromTemplate(
"ssh://git@" + sshUri.getHost() + (sshUri.getPort() != 22 ? ":" + sshUri.getPort() : "")
Expand Down

0 comments on commit bddf7b2

Please sign in to comment.