You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by "Peter Hansson (JIRA)" <ji...@apache.org> on 2016/05/29 12:03:12 UTC

[jira] [Comment Edited] (SCM-826) Allow multiple identities on same VCS

    [ https://issues.apache.org/jira/browse/SCM-826?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15305866#comment-15305866 ] 

Peter Hansson edited comment on SCM-826 at 5/29/16 12:03 PM:
-------------------------------------------------------------

I've reviewed the code in the plugin.

The crucial part is [AbstractScmMojo.loadInfosFromSettings()|https://github.com/apache/maven-scm/blob/master/maven-scm-plugin/src/main/java/org/apache/maven/scm/plugin/AbstractScmMojo.java].

So what happens today is actually pure hostname matching except if port is given explicitly in the URL then the matching is done on host:port string. Incidentially I see no documentation about this outside of the source code (a little hidden gem).

I see now that my proposal will only work with SCMs that use an URL scheme such as Hg or Git. More specifically it will work with an SCM that supports URL schemes which supports a  {noformat}<protocol>://[user[:pass]@]host[:port]/[path]{noformat} like syntax. Normally this will be HTTP, HTTPS and SSH.

The way I would go about it is that I would create new non-abstract method in {{ScmProviderRepositoryWithHost}}. Something like 
{code:java}
public String getUrlStrForSettingsMatching() 
{
    return getHost();
}
{code}

SCM implementers could then implement this method or leave it as is.

The primary goal is to take URL username and URL path into account when matching. While the window is open there's no reason not to also include URL protocol name in the matching although the use case for that one is a bit far fetched.




was (Author: phansson):
I've reviewed the code in the plugin.

The crucial part is [AbstractScmMojo.loadInfosFromSettings()|https://github.com/apache/maven-scm/blob/master/maven-scm-plugin/src/main/java/org/apache/maven/scm/plugin/AbstractScmMojo.java].

So what happens today is actually pure hostname matching except if port is given explicitly in the URL then the matching is done on host:port string. Incidentially I see no documentation about this outside of the source code (a little hidden gem).

I see now that my proposal will only work with SCMs that use an URL scheme such as Hg or Git. More specifically it will work with an SCM that supports URL schemes which supports a  {noformat}<protocol>://[user[:pass]@]host[:port]/[path]{noformat} like syntax. Normally this will be HTTP, HTTPS and SSH.

The way I would go about it is that I would create new non-abstract method in {{ScmProviderRepositoryWithHost}}. Something like 
{code:java}
public String getUrlStrForSettingsMatching() 
{
    return getHost();
}
{code}

SCM implementers could then implement this method or leave it as is.

> Allow multiple identities on same VCS
> -------------------------------------
>
>                 Key: SCM-826
>                 URL: https://issues.apache.org/jira/browse/SCM-826
>             Project: Maven SCM
>          Issue Type: Improvement
>          Components: maven-plugin
>            Reporter: Peter Hansson
>
> It is no longer uncommon for a developer to have several identities on a single VCS (just think of sites such as GitHub and BitBucket).
> The current scheme for centralizing credentials is to put them in settings.xml and then Maven SCM Plugin will match the host name in {{<scm>}} section of the POM with the {{<id>}} section from {{<server>}} in settings.xml.
> As far as I know (pretty much undocumented) this scheme will currently only work for a single identity at the VCS host.
> My proposal is to expand on the current scheme so that it will allow some form of *longest match* which would include a potential prefixed username in the SCM URL  (e.g. john@github.com) or matching on the URL path (github.com/apache rather than just matching on the hostname itself).
> Here's an example of how I envisage it:
> {code:xml}
> <settings>
>   <servers>
>     <!-- Would match any GitHub URL with user1 prefixed in URL -->
>     <server>
>       <id>user1@github.com</id>
>       <username>user1</username>
>       <password>mysecret</password>
>     </server>
>     <!-- Would match any GitHub URL with user2 prefixed in URL -->
>     <server>
>       <id>user2@github.com</id>
>       <username>user2</username>
>       <password>mysecret</password>
>     </server>
>     <!-- Would match URLs from host github.com where path is 'apache' and also user2 is prefixed in URL -->
>     <server>
>       <id>user2@github.com/apache</id>
>       <username>user2</username>
>       <password>mysecret</password>
>     </server>
>     <!-- default -->
>     <server>
>       <id>github.com</id>
>       <username>user1</username>
>       <password>mysecret</password>
>     </server>
> {code}
> This enhancement would be completely backwards compatible, is simple to implement and will solve a lot of use cases in one go.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)