Uploaded image for project: 'Maven SCM'
  1. Maven SCM
  2. SCM-387

CvsScmProviderRepository returns wrong CVSROOT for local repository

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Blocker
    • Resolution: Fixed
    • Affects Version/s: 1.1
    • Fix Version/s: 1.1
    • Component/s: maven-scm-provider-cvs
    • Labels:
      None

      Description

      For local repository getCvsRoot() returns just the root path without transport type - see getCvsRootForCvsPass:

      CvsScmProviderRepository.java
          /**
           * @return The cvs root
           */
          public String getCvsRoot()
          {
              String root = getCvsRootForCvsPass();
      
              return removeDefaultPortFromCvsRoot( root );
          }
      
          private String removeDefaultPortFromCvsRoot( String root )
          {
              if ( root != null && root.indexOf( ":2401" ) > 0 )
              {
                  root = root.substring( 0, root.indexOf( ":2401" ) ) + ":" + root.substring( root.indexOf( ":2401" ) + 5 );
              }
      
              return root;
          }
      
          /**
           * @return The cvs root stored in .cvspass
           */
          public String getCvsRootForCvsPass()
          {
              if ( getUser() != null )
              {
                  return getCvsRootWithCorrectUser( getUser() );
              }
              else
              {
                  if ( AbstractCvsScmProvider.TRANSPORT_LOCAL.equals( getTransport() ) )
                  {
                      return cvsroot;
                  }
                  else
                  {
                      throw new IllegalArgumentException( "Username isn't defined." );
                  }
              }
          }
      
          /**
           * @param user user name
           * @return
           */
          private String getCvsRootWithCorrectUser( String user )
          {
              //:transport:rest_of_cvsroot
              int indexOfUsername = getTransport().length() + 2;
      
              int indexOfAt = cvsroot.indexOf( "@" );
      
              String userString = user == null ? "" : ":" + user;
      
              if ( indexOfAt > 0 )
              {
                  cvsroot = ":" + getTransport() + userString + cvsroot.substring( indexOfAt );
              }
              else
              {
                  cvsroot = ":" + getTransport() + userString + "@" + cvsroot.substring( indexOfUsername );
              }
      
              return cvsroot;
          }
      

      And if user was set directly, then the getCvsRootWithCorrectUser logic will be wrong.

      So the method should be changed like:

      CvsScmProviderRepository.java
          /**
           * @return The cvs root stored in .cvspass
           */
          public String getCvsRootForCvsPass()
          {
              String result;
              String transport = getTransport();
              if ( AbstractCvsScmProvider.TRANSPORT_LOCAL.equals( transport ) )
              {
                  result = ":" + transport + ":" + cvsroot;
              }
              else if ( getUser() != null )
              {
                  result = getCvsRootWithCorrectUser( getUser() );
              }
              else
              {
                  throw new IllegalArgumentException( "Username isn't defined." );
              }
              return result;
          }
      

        Attachments

          Activity

            People

            • Assignee:
              siveton Siveton Vincent
              Reporter:
              szakusov Sergey Zakusov
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: