From 219811b09b97d1e4ad9777fb017a6599e05aa3b6 Mon Sep 17 00:00:00 2001 From: Michael Osipov Date: Sun, 12 Mar 2023 13:24:21 +0100 Subject: [PATCH] [SCM-1005] Upgrade Parent to 39 This closes #165 --- maven-scm-api/pom.xml | 2 - .../apache/maven/scm/AbstractScmVersion.java | 26 +- .../java/org/apache/maven/scm/ChangeFile.java | 78 +- .../java/org/apache/maven/scm/ChangeSet.java | 462 ++++----- .../apache/maven/scm/CommandParameter.java | 72 +- .../apache/maven/scm/CommandParameters.java | 188 ++-- .../maven/scm/NoSuchCommandScmException.java | 17 +- .../java/org/apache/maven/scm/ScmBranch.java | 17 +- .../apache/maven/scm/ScmBranchParameters.java | 42 +- .../org/apache/maven/scm/ScmException.java | 19 +- .../java/org/apache/maven/scm/ScmFile.java | 39 +- .../java/org/apache/maven/scm/ScmFileSet.java | 80 +- .../org/apache/maven/scm/ScmFileStatus.java | 59 +- .../java/org/apache/maven/scm/ScmRequest.java | 34 +- .../java/org/apache/maven/scm/ScmResult.java | 53 +- .../org/apache/maven/scm/ScmRevision.java | 17 +- .../java/org/apache/maven/scm/ScmTag.java | 17 +- .../apache/maven/scm/ScmTagParameters.java | 48 +- .../apache/maven/scm/ScmUntagParameters.java | 27 +- .../java/org/apache/maven/scm/ScmVersion.java | 10 +- .../maven/scm/command/AbstractCommand.java | 42 +- .../org/apache/maven/scm/command/Command.java | 12 +- .../scm/command/add/AbstractAddCommand.java | 27 +- .../maven/scm/command/add/AddScmResult.java | 41 +- .../command/blame/AbstractBlameCommand.java | 27 +- .../maven/scm/command/blame/BlameLine.java | 61 +- .../scm/command/blame/BlameScmRequest.java | 43 +- .../scm/command/blame/BlameScmResult.java | 27 +- .../command/branch/AbstractBranchCommand.java | 54 +- .../scm/command/branch/BranchScmResult.java | 27 +- .../changelog/AbstractChangeLogCommand.java | 122 ++- .../command/changelog/ChangeLogCommand.java | 12 +- .../changelog/ChangeLogScmRequest.java | 143 +-- .../command/changelog/ChangeLogScmResult.java | 27 +- .../scm/command/changelog/ChangeLogSet.java | 102 +- .../checkin/AbstractCheckInCommand.java | 27 +- .../scm/command/checkin/CheckInScmResult.java | 46 +- .../checkout/AbstractCheckOutCommand.java | 42 +- .../command/checkout/CheckOutScmResult.java | 61 +- .../scm/command/diff/AbstractDiffCommand.java | 27 +- .../maven/scm/command/diff/DiffScmResult.java | 37 +- .../scm/command/edit/AbstractEditCommand.java | 21 +- .../maven/scm/command/edit/EditScmResult.java | 28 +- .../command/export/AbstractExportCommand.java | 27 +- .../scm/command/export/ExportScmResult.java | 22 +- .../export/ExportScmResultWithRevision.java | 24 +- .../fileinfo/AbstractFileInfoCommand.java | 28 +- .../maven/scm/command/info/InfoItem.java | 68 +- .../maven/scm/command/info/InfoScmResult.java | 38 +- .../scm/command/list/AbstractListCommand.java | 32 +- .../maven/scm/command/list/ListScmResult.java | 30 +- .../scm/command/lock/AbstractLockCommand.java | 28 +- .../command/login/AbstractLoginCommand.java | 22 +- .../scm/command/login/LoginScmResult.java | 15 +- .../command/mkdir/AbstractMkdirCommand.java | 36 +- .../scm/command/mkdir/MkdirScmResult.java | 45 +- .../remoteinfo/AbstractRemoteInfoCommand.java | 20 +- .../remoteinfo/RemoteInfoScmResult.java | 44 +- .../command/remove/AbstractRemoveCommand.java | 24 +- .../scm/command/remove/RemoveScmResult.java | 27 +- .../command/status/AbstractStatusCommand.java | 21 +- .../scm/command/status/StatusScmResult.java | 45 +- .../scm/command/tag/AbstractTagCommand.java | 48 +- .../maven/scm/command/tag/TagScmResult.java | 29 +- .../command/unedit/AbstractUnEditCommand.java | 21 +- .../scm/command/unedit/UnEditScmResult.java | 28 +- .../command/unlock/AbstractUnlockCommand.java | 25 +- .../command/untag/AbstractUntagCommand.java | 30 +- .../scm/command/untag/UntagScmResult.java | 24 +- .../command/update/AbstractUpdateCommand.java | 77 +- .../scm/command/update/UpdateScmResult.java | 43 +- .../update/UpdateScmResultWithRevision.java | 31 +- .../maven/scm/manager/AbstractScmManager.java | 476 ++++------ .../maven/scm/manager/BasicScmManager.java | 10 +- .../manager/NoSuchScmProviderException.java | 19 +- .../apache/maven/scm/manager/ScmManager.java | 199 ++-- .../scm/provider/AbstractScmProvider.java | 885 ++++++++---------- .../maven/scm/provider/ScmProvider.java | 292 +++--- .../scm/provider/ScmProviderRepository.java | 51 +- .../ScmProviderRepositoryWithHost.java | 33 +- .../maven/scm/provider/ScmUrlUtils.java | 87 +- .../maven/scm/repository/ScmRepository.java | 21 +- .../repository/ScmRepositoryException.java | 31 +- .../UnknownRepositoryStructure.java | 9 +- .../maven/scm/util/AbstractConsumer.java | 86 +- .../apache/maven/scm/util/ConsumerUtils.java | 29 +- .../apache/maven/scm/util/FilenameUtils.java | 26 +- .../maven/scm/util/ThreadSafeDateFormat.java | 48 +- .../org/apache/maven/scm/ChangeFileTest.java | 41 +- .../org/apache/maven/scm/ChangeSetTest.java | 159 ++-- .../org/apache/maven/scm/ScmFileSetTest.java | 81 +- .../org/apache/maven/scm/ScmResultTest.java | 33 +- .../maven/scm/manager/ScmManagerTest.java | 36 +- .../maven/scm/provider/ScmUrlUtilsTest.java | 50 +- .../maven/scm/util/FilenameUtilsTest.java | 25 +- maven-scm-client/pom.xml | 4 +- .../maven/scm/client/cli/MavenScmCli.java | 277 ++---- .../maven-scm-manager-plexus/pom.xml | 2 - .../scm/manager/plexus/DefaultScmManager.java | 25 +- maven-scm-managers/pom.xml | 6 +- maven-scm-plugin/pom.xml | 82 +- .../maven/scm/plugin/AbstractScmMojo.java | 353 +++---- .../org/apache/maven/scm/plugin/AddMojo.java | 34 +- .../maven/scm/plugin/BootstrapMojo.java | 142 +-- .../apache/maven/scm/plugin/BranchMojo.java | 62 +- .../maven/scm/plugin/ChangeLogMojo.java | 153 ++- .../plugin/CheckLocalModificationsMojo.java | 54 +- .../apache/maven/scm/plugin/CheckinMojo.java | 44 +- .../apache/maven/scm/plugin/CheckoutMojo.java | 102 +- .../org/apache/maven/scm/plugin/DiffMojo.java | 67 +- .../org/apache/maven/scm/plugin/EditMojo.java | 32 +- .../apache/maven/scm/plugin/ExportMojo.java | 86 +- .../org/apache/maven/scm/plugin/ListMojo.java | 46 +- .../apache/maven/scm/plugin/RemoveMojo.java | 34 +- .../apache/maven/scm/plugin/StatusMojo.java | 57 +- .../org/apache/maven/scm/plugin/TagMojo.java | 107 +-- .../apache/maven/scm/plugin/UnEditMojo.java | 32 +- .../apache/maven/scm/plugin/UntagMojo.java | 43 +- .../apache/maven/scm/plugin/UpdateMojo.java | 58 +- .../scm/plugin/UpdateSubprojectsMojo.java | 49 +- .../apache/maven/scm/plugin/ValidateMojo.java | 89 +- .../maven/scm/plugin/ValidateRecursively.java | 13 +- .../maven/scm/plugin/BootstrapMojoTest.java | 68 +- .../maven/scm/plugin/BranchMojoTest.java | 96 +- .../maven/scm/plugin/ChangeLogMojoTest.java | 136 ++- .../maven/scm/plugin/CheckoutMojoTest.java | 168 ++-- .../maven/scm/plugin/ExportMojoTest.java | 108 +-- .../maven/scm/plugin/StatusMojoTest.java | 27 +- .../apache/maven/scm/plugin/TagMojoTest.java | 108 +-- .../maven/scm/plugin/UntagMojoTest.java | 96 +- .../maven/scm/plugin/UpdateMojoTest.java | 61 +- .../maven/scm/plugin/ValidateMojoTest.java | 44 +- .../maven-scm-provider-hg/pom.xml | 10 +- .../maven/scm/provider/hg/HgConfig.java | 114 +-- .../maven/scm/provider/hg/HgScmProvider.java | 211 ++--- .../apache/maven/scm/provider/hg/HgUtils.java | 274 +++--- .../hg/command/HgCommandConstants.java | 16 +- .../scm/provider/hg/command/HgConsumer.java | 143 ++- .../provider/hg/command/add/HgAddCommand.java | 38 +- .../hg/command/add/HgAddConsumer.java | 54 +- .../hg/command/blame/HgBlameCommand.java | 28 +- .../hg/command/blame/HgBlameConsumer.java | 45 +- .../hg/command/branch/HgBranchCommand.java | 117 +-- .../command/changelog/HgChangeLogCommand.java | 144 ++- .../changelog/HgChangeLogConsumer.java | 103 +- .../hg/command/checkin/HgCheckInCommand.java | 77 +- .../command/checkout/HgCheckOutCommand.java | 82 +- .../command/checkout/HgCheckOutConsumer.java | 33 +- .../hg/command/diff/HgDiffCommand.java | 39 +- .../hg/command/diff/HgDiffConsumer.java | 98 +- .../hg/command/info/HgInfoCommand.java | 23 +- .../hg/command/info/HgInfoConsumer.java | 23 +- .../hg/command/inventory/HgChangeSet.java | 19 +- .../hg/command/inventory/HgListCommand.java | 42 +- .../hg/command/inventory/HgListConsumer.java | 27 +- .../command/inventory/HgOutgoingConsumer.java | 28 +- .../hg/command/remove/HgRemoveCommand.java | 29 +- .../hg/command/remove/HgRemoveConsumer.java | 56 +- .../hg/command/status/HgStatusCommand.java | 25 +- .../hg/command/status/HgStatusConsumer.java | 60 +- .../provider/hg/command/tag/HgTagCommand.java | 120 +-- .../hg/command/tag/HgTagConsumer.java | 13 +- .../hg/command/update/HgUpdateCommand.java | 90 +- .../repository/HgScmProviderRepository.java | 218 ++--- .../maven/scm/provider/hg/HgRepoUtils.java | 96 +- .../maven/scm/provider/hg/HgUtilsTest.java | 49 +- .../command/blame/HgBlameCommandTckTest.java | 33 +- .../changelog/HgChangeLogCommandTckTest.java | 24 +- .../checkin/HgCheckInCommandTckTest.java | 43 +- .../checkout/HgCheckOutCommandTckTest.java | 20 +- .../hg/command/diff/HgDiffCommandTckTest.java | 112 +-- .../status/HgStatusCommandTckTest.java | 20 +- .../hg/command/tag/HgTagCommandTckTest.java | 20 +- .../update/HgUpdateCommandTckTest.java | 20 +- .../HgScmProviderRepositoryTest.java | 164 ++-- .../maven-scm-provider-local/pom.xml | 14 +- .../scm/provider/local/LocalScmProvider.java | 152 ++- .../provider/local/command/LocalCommand.java | 10 +- .../local/command/add/LocalAddCommand.java | 35 +- .../changelog/LocalChangeLogCommand.java | 113 +-- .../command/checkin/LocalCheckInCommand.java | 106 +-- .../checkout/LocalCheckOutCommand.java | 101 +- .../checkout/LocalCheckOutScmResult.java | 14 +- .../local/command/list/LocalListCommand.java | 101 +- .../command/list/LocalListScmResult.java | 14 +- .../command/mkdir/LocalMkdirCommand.java | 64 +- .../command/status/LocalStatusCommand.java | 17 +- .../local/command/tag/LocalTagCommand.java | 29 +- .../command/update/LocalUpdateCommand.java | 148 ++- .../command/update/LocalUpdateScmResult.java | 14 +- .../local/metadata/LocalScmMetadataUtils.java | 91 +- .../LocalScmProviderRepository.java | 32 +- .../provider/local/LocalScmProviderTest.java | 20 +- .../checkin/LocalCheckInCommandTckTest.java | 37 +- .../checkout/LocalCheckOutCommandTckTest.java | 66 +- .../command/list/LocalListCommandTckTest.java | 33 +- .../mkdir/LocalMkdirCommandTckTest.java | 67 +- .../update/LocalUpdateCommandTckTest.java | 112 +-- .../local/repository/LocalRepositoryTest.java | 112 +-- .../maven-scm-provider-git-commons/pom.xml | 62 +- .../provider/git/AbstractGitScmProvider.java | 216 ++--- .../scm/provider/git/GitCommandUtils.java | 42 +- .../scm/provider/git/GitConfigFileReader.java | 102 +- .../scm/provider/git/command/GitCommand.java | 10 +- .../git/command/diff/GitDiffConsumer.java | 120 +-- .../git/command/info/GitInfoItem.java | 9 +- .../git/command/info/GitInfoScmResult.java | 36 +- .../command/update/GitUpdateScmResult.java | 14 +- .../repository/GitScmProviderRepository.java | 346 +++---- .../git/repository/RepositoryUrl.java | 63 +- .../maven/scm/provider/git/util/GitUtil.java | 58 +- .../scm/provider/git/TestGitScmProvider.java | 64 +- .../git/command/diff/GitDiffConsumerTest.java | 141 ++- .../GitScmProviderRepositoryTest.java | 608 +++++++----- .../maven-scm-provider-gitexe/pom.xml | 2 - .../git/gitexe/GitExeScmProvider.java | 89 +- .../command/AbstractFileCheckingConsumer.java | 66 +- .../gitexe/command/AnonymousCommandLine.java | 29 +- .../gitexe/command/GitCommandLineUtils.java | 202 ++-- .../git/gitexe/command/add/GitAddCommand.java | 119 +-- .../gitexe/command/blame/GitBlameCommand.java | 64 +- .../command/blame/GitBlameConsumer.java | 89 +- .../command/branch/GitBranchCommand.java | 110 +-- .../branch/GitCurrentBranchConsumer.java | 27 +- .../changelog/GitChangeLogCommand.java | 329 ++++--- .../changelog/GitChangeLogConsumer.java | 283 +++--- .../command/checkin/GitCheckInCommand.java | 224 ++--- .../command/checkout/GitCheckOutCommand.java | 208 ++-- .../gitexe/command/diff/GitDiffCommand.java | 82 +- .../command/diff/GitDiffRawConsumer.java | 51 +- .../gitexe/command/info/GitInfoCommand.java | 64 +- .../gitexe/command/info/GitInfoConsumer.java | 43 +- .../gitexe/command/list/GitListCommand.java | 14 +- .../gitexe/command/list/GitListConsumer.java | 28 +- .../remoteinfo/GitRemoteInfoCommand.java | 41 +- .../remoteinfo/GitRemoteInfoConsumer.java | 58 +- .../command/remove/GitRemoveCommand.java | 76 +- .../command/remove/GitRemoveConsumer.java | 57 +- .../command/status/GitStatusCommand.java | 69 +- .../command/status/GitStatusConsumer.java | 276 ++---- .../git/gitexe/command/tag/GitTagCommand.java | 147 ++- .../gitexe/command/untag/GitUntagCommand.java | 70 +- .../GitLatestRevisionCommandConsumer.java | 43 +- .../command/update/GitUpdateCommand.java | 105 +-- .../command/GitCommandLineUtilsTest.java | 109 +-- .../command/add/GitExeAddCommandTest.java | 64 +- .../command/blame/GitBlameConsumerTest.java | 174 ++-- .../blame/GitExeBlameCommandTckTest.java | 37 +- .../branch/GitExeBranchCommandTckTest.java | 19 +- .../changelog/GitChangeLogCommandTest.java | 252 ++--- .../changelog/GitChangeLogConsumerTest.java | 232 +++-- .../GitExeChangeLogCommandTckTest.java | 18 +- .../GitCheckInCommandNoBranchTest.java | 81 +- .../checkin/GitCheckInCommandTest.java | 156 ++- .../checkin/GitExeCheckInCommandTckTest.java | 18 +- .../checkout/GitCheckOutCommandTest.java | 36 +- .../GitExeCheckOutCommandNoBranchTest.java | 55 +- .../GitExeCheckOutCommandTckTest.java | 12 +- .../GitExeSshCheckOutCommandTckTest.java | 40 +- .../command/diff/GitDiffRawConsumerTest.java | 59 +- .../diff/GitExeDiffCommandTckTest.java | 18 +- .../command/info/GitInfoCommandTest.java | 134 ++- .../GitExeRemoteInfoCommandTckTest.java | 31 +- .../remoteinfo/GitRemoteInfoConsumerTest.java | 35 +- .../remove/GitExeRemoveCommandTckTest.java | 28 +- .../command/remove/GitRemoveCommandTest.java | 63 +- .../command/remove/GitRemoveConsumerTest.java | 73 +- .../status/GitExeStatusCommandTckTest.java | 18 +- .../command/status/GitStatusConsumerTest.java | 681 +++++++------- .../command/tag/GitExeTagCommandTckTest.java | 18 +- .../gitexe/command/tag/GitTagCommandTest.java | 63 +- .../untag/GitExeUntagCommandTckTest.java | 18 +- .../update/GitExeUpdateCommandTckTest.java | 18 +- .../GitLatestRevisionCommandConsumerTest.java | 64 +- .../command/update/GitUpdateCommandTest.java | 67 +- .../maven-scm-provider-gittest/pom.xml | 4 +- .../scm/provider/git/GitScmTestUtils.java | 116 +-- .../command/blame/GitBlameCommandTckTest.java | 33 +- .../branch/GitBranchCommandTckTest.java | 33 +- .../changelog/GitChangeLogCommandTckTest.java | 252 +++-- .../checkin/GitCheckInCommandTckTest.java | 33 +- .../checkout/GitCheckOutCommandTckTest.java | 23 +- .../GitSshCheckOutCommandTckTest.java | 111 +-- .../command/diff/GitDiffCommandTckTest.java | 15 +- .../command/list/GitListCommandTckTest.java | 15 +- .../AbstractGitRemoteInfoCommandTckTest.java | 24 +- .../remove/GitRemoveCommandTckTest.java | 21 +- .../status/GitStatusCommandTckTest.java | 33 +- .../git/command/tag/GitTagCommandTckTest.java | 33 +- .../command/untag/GitUntagCommandTckTest.java | 30 +- .../update/GitUpdateCommandTckTest.java | 33 +- .../maven-scm-provider-jgit/pom.xml | 14 +- .../provider/git/jgit/JGitScmProvider.java | 91 +- .../command/JGitTransportConfigCallback.java | 20 +- .../provider/git/jgit/command/JGitUtils.java | 411 ++++---- ...lexusInteractivityCredentialsProvider.java | 115 +-- .../ScmProviderAwareSshdSessionFactory.java | 56 +- .../git/jgit/command/add/JGitAddCommand.java | 56 +- .../jgit/command/blame/JGitBlameCommand.java | 58 +- .../command/branch/JGitBranchCommand.java | 103 +- .../changelog/JGitChangeLogCommand.java | 272 +++--- .../command/checkin/JGitCheckInCommand.java | 211 ++--- .../command/checkout/JGitCheckOutCommand.java | 169 ++-- .../jgit/command/diff/JGitDiffCommand.java | 107 +-- .../jgit/command/info/JGitInfoCommand.java | 45 +- .../jgit/command/list/JGitListCommand.java | 72 +- .../remoteinfo/JGitRemoteInfoCommand.java | 82 +- .../command/remove/JGitRemoveCommand.java | 50 +- .../command/status/JGitStatusCommand.java | 64 +- .../git/jgit/command/tag/JGitTagCommand.java | 93 +- .../jgit/command/untag/JGitUntagCommand.java | 70 +- .../git/jgit/JGitTestScmProvider.java | 52 +- .../branch/JGitBranchCommandTckTest.java | 24 +- .../JGitChangeLogCommandTckTest.java | 38 +- ...tCheckInCommandCommitterAuthorTckTest.java | 316 +++---- .../checkin/JGitCheckInCommandTckTest.java | 24 +- .../checkout/JGitCheckOutCommandTckTest.java | 25 +- .../JGitSshCheckOutCommandTckTest.java | 96 +- .../command/diff/JGitDiffCommandTckTest.java | 24 +- .../JGitRemoteInfoCommandTckTest.java | 39 +- .../remove/JGitRemoveCommandTckTest.java | 24 +- .../status/JGitStatusCommandTckTest.java | 24 +- .../command/tag/JGitTagCommandTckTest.java | 24 +- .../untag/JGitUntagCommandTckTest.java | 25 +- .../maven-scm-providers-git/pom.xml | 8 +- .../maven-scm-providers-standard/pom.xml | 2 - .../maven-scm-provider-svn-commons/pom.xml | 18 +- .../provider/svn/AbstractSvnScmProvider.java | 331 +++---- .../maven/scm/provider/svn/SvnChangeSet.java | 48 +- .../scm/provider/svn/SvnCommandUtils.java | 32 +- .../scm/provider/svn/SvnConfigFileReader.java | 99 +- .../scm/provider/svn/SvnTagBranchUtils.java | 166 ++-- .../scm/provider/svn/command/SvnCommand.java | 9 +- .../svn/command/diff/SvnDiffConsumer.java | 96 +- .../svn/command/info/SvnInfoItem.java | 9 +- .../svn/command/info/SvnInfoScmResult.java | 36 +- .../command/update/SvnUpdateScmResult.java | 14 +- .../repository/SvnScmProviderRepository.java | 175 ++-- .../maven/scm/provider/svn/util/SvnUtil.java | 57 +- .../scm/provider/svn/SvnCommandUtilsTest.java | 71 +- .../provider/svn/SvnTagBranchUtilsTest.java | 372 ++++---- .../scm/provider/svn/TestSvnScmProvider.java | 70 +- .../SvnScmProviderRepositoryTest.java | 315 ++++--- .../maven-scm-provider-svnexe/pom.xml | 4 +- .../svn/svnexe/SvnExeScmProvider.java | 90 +- .../command/AbstractFileCheckingConsumer.java | 76 +- .../svnexe/command/SvnCommandLineUtils.java | 244 ++--- .../svn/svnexe/command/add/SvnAddCommand.java | 92 +- .../svnexe/command/add/SvnAddConsumer.java | 49 +- .../svnexe/command/blame/SvnBlameCommand.java | 63 +- .../command/blame/SvnBlameConsumer.java | 87 +- .../command/branch/SvnBranchCommand.java | 183 ++-- .../changelog/IllegalOutputException.java | 18 +- .../changelog/SvnChangeLogCommand.java | 277 +++--- .../changelog/SvnChangeLogConsumer.java | 215 ++--- .../command/checkin/SvnCheckInCommand.java | 121 +-- .../command/checkin/SvnCheckInConsumer.java | 72 +- .../command/checkout/SvnCheckOutCommand.java | 110 +-- .../command/checkout/SvnCheckOutConsumer.java | 88 +- .../svnexe/command/diff/SvnDiffCommand.java | 85 +- .../command/export/SvnExeExportCommand.java | 107 +-- .../svnexe/command/info/SvnInfoCommand.java | 98 +- .../svnexe/command/info/SvnInfoConsumer.java | 97 +- .../svnexe/command/list/SvnListCommand.java | 85 +- .../svnexe/command/list/SvnListConsumer.java | 24 +- .../svnexe/command/mkdir/SvnMkdirCommand.java | 137 ++- .../command/mkdir/SvnMkdirConsumer.java | 61 +- .../remoteinfo/SvnRemoteInfoCommand.java | 132 ++- .../command/remove/SvnRemoveCommand.java | 80 +- .../command/remove/SvnRemoveConsumer.java | 49 +- .../command/status/SvnStatusCommand.java | 53 +- .../command/status/SvnStatusConsumer.java | 103 +- .../svn/svnexe/command/tag/SvnTagCommand.java | 237 ++--- .../svnexe/command/untag/SvnUntagCommand.java | 105 +-- .../command/update/SvnUpdateCommand.java | 118 +-- .../command/update/SvnUpdateConsumer.java | 104 +- .../svn/svnexe/SvnExeScmProviderTest.java | 85 +- .../command/SvnCommandLineUtilsTest.java | 157 ++-- .../blame/SvnExeBlameCommandTckTest.java | 16 +- .../branch/SvnExeBranchCommandTckTest.java | 194 ++-- .../changelog/SvnChangeLogCommandTest.java | 242 ++--- .../changelog/SvnChangeLogConsumerTest.java | 227 ++--- .../checkin/SvnCheckInCommandTest.java | 86 +- .../checkin/SvnExeCheckInCommandTckTest.java | 12 +- .../checkout/SvnCheckOutCommandTest.java | 88 +- .../checkout/SvnCheckOutConsumerTest.java | 27 +- .../SvnExeCheckOutCommandTckTest.java | 12 +- .../diff/SvnExeDiffCommandTckTest.java | 12 +- .../command/export/SvnExportCommandTest.java | 52 +- .../command/info/SvnInfoCommandTest.java | 33 +- .../list/SvnExeListCommandTckTest.java | 12 +- .../command/list/SvnListCommandTest.java | 80 +- .../mkdir/SvnExeMkdirCommandTckTest.java | 12 +- .../command/mkdir/SvnMkdirCommandTest.java | 68 +- ...bstractSvnExeRemoteInfoCommandTckTest.java | 29 +- .../SvnExeRemoteInfoCommandTckTest.java | 16 +- ...RemoteInfoCommandTrailingSlashTckTest.java | 16 +- .../remoteinfo/SvnRemoteInfoCommandTest.java | 27 +- .../remove/SvnExeRemoveCommandTckTest.java | 12 +- .../status/SvnExeStatusCommandTckTest.java | 12 +- .../command/tag/SvnExeTagCommandTckTest.java | 141 +-- .../untag/SvnExeUntagCommandTckTest.java | 69 +- .../command/untag/SvnUntagCommandTest.java | 72 +- .../update/SvnExeUpdateCommandTckTest.java | 12 +- .../command/update/SvnUpdateCommandTest.java | 222 ++--- .../maven-scm-provider-svntest/pom.xml | 2 - .../scm/provider/svn/SvnScmTestUtils.java | 123 ++- .../command/blame/SvnBlameCommandTckTest.java | 38 +- .../branch/SvnBranchCommandTckTest.java | 25 +- .../checkin/SvnCheckInCommandTckTest.java | 25 +- .../checkout/SvnCheckOutCommandTckTest.java | 25 +- .../command/diff/SvnDiffCommandTckTest.java | 25 +- .../command/list/SvnListCommandTckTest.java | 25 +- .../command/mkdir/SvnMkdirCommandTckTest.java | 85 +- .../AbstractSvnRemoteInfoCommandTckTest.java | 26 +- .../remove/SvnRemoveCommandTckTest.java | 25 +- .../status/SvnStatusCommandTckTest.java | 25 +- .../svn/command/tag/SvnTagCommandTckTest.java | 25 +- .../command/untag/SvnUntagCommandTckTest.java | 25 +- .../update/SvnUpdateCommandTckTest.java | 25 +- .../maven-scm-providers-svn/pom.xml | 4 +- maven-scm-providers/pom.xml | 4 +- maven-scm-test/pom.xml | 2 - .../maven/scm/PlexusJUnit4TestSupport.java | 220 ++--- .../org/apache/maven/scm/ScmTckTestCase.java | 153 ++- .../org/apache/maven/scm/ScmTestCase.java | 317 +++---- .../maven/scm/manager/ScmManagerStub.java | 389 ++++---- .../provider/ScmProviderRepositoryStub.java | 20 +- .../maven/scm/provider/ScmProviderStub.java | 535 +++++------ .../scm/repository/ScmRepositoryStub.java | 15 +- .../command/blame/BlameCommandTckTest.java | 97 +- .../command/branch/BranchCommandTckTest.java | 86 +- .../changelog/ChangeLogCommandTckTest.java | 97 +- .../checkin/CheckInCommandTckTest.java | 298 +++--- .../checkout/CheckOutCommandTckTest.java | 31 +- .../tck/command/diff/DiffCommandTckTest.java | 89 +- .../tck/command/list/ListCommandTckTest.java | 55 +- .../command/mkdir/MkdirCommandTckTest.java | 29 +- .../AbstractRemoteInfoCommandTckTest.java | 24 +- .../command/remove/RemoveCommandTckTest.java | 61 +- .../command/status/StatusCommandTckTest.java | 96 +- .../tck/command/tag/TagCommandTckTest.java | 84 +- .../command/untag/UntagCommandTckTest.java | 53 +- .../command/update/UpdateCommandTckTest.java | 105 +-- .../maven/scm/manager/ScmManagerStubTest.java | 76 +- pom.xml | 161 ++-- 446 files changed, 15020 insertions(+), 20899 deletions(-) diff --git a/maven-scm-api/pom.xml b/maven-scm-api/pom.xml index b8f81a489..829c67eb7 100644 --- a/maven-scm-api/pom.xml +++ b/maven-scm-api/pom.xml @@ -1,5 +1,4 @@ - - 4.0.0 diff --git a/maven-scm-api/src/main/java/org/apache/maven/scm/AbstractScmVersion.java b/maven-scm-api/src/main/java/org/apache/maven/scm/AbstractScmVersion.java index 34925641b..a6d3f786f 100644 --- a/maven-scm-api/src/main/java/org/apache/maven/scm/AbstractScmVersion.java +++ b/maven-scm-api/src/main/java/org/apache/maven/scm/AbstractScmVersion.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm; import java.io.Serializable; @@ -25,9 +24,7 @@ * @author Emmanuel Venisse * */ -public abstract class AbstractScmVersion - implements ScmVersion, Serializable -{ +public abstract class AbstractScmVersion implements ScmVersion, Serializable { private static final long serialVersionUID = -3388495744009098066L; private String name; @@ -35,30 +32,25 @@ public abstract class AbstractScmVersion /** * @param name could be null */ - public AbstractScmVersion( String name ) - { - setName( name ); + public AbstractScmVersion(String name) { + setName(name); } /** {@inheritDoc} */ - public String getName() - { + public String getName() { return name; } /** {@inheritDoc} */ - public void setName( String name ) - { - if ( name != null ) - { + public void setName(String name) { + if (name != null) { name = name.trim(); } this.name = name; } /** {@inheritDoc} */ - public String toString() - { + public String toString() { return getName(); } } diff --git a/maven-scm-api/src/main/java/org/apache/maven/scm/ChangeFile.java b/maven-scm-api/src/main/java/org/apache/maven/scm/ChangeFile.java index 301e1501c..9776c0ae3 100644 --- a/maven-scm-api/src/main/java/org/apache/maven/scm/ChangeFile.java +++ b/maven-scm-api/src/main/java/org/apache/maven/scm/ChangeFile.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm; import java.io.Serializable; @@ -29,9 +28,7 @@ * @author Emmanuel Venisse * */ -public class ChangeFile - implements Serializable -{ +public class ChangeFile implements Serializable { private static final long serialVersionUID = 6294855290542668753L; /** @@ -68,9 +65,8 @@ public class ChangeFile * * @param name file name */ - public ChangeFile( String name ) - { - setName( name ); + public ChangeFile(String name) { + setName(name); } /** @@ -79,11 +75,10 @@ public ChangeFile( String name ) * @param name file name * @param rev latest revision of the file */ - public ChangeFile( String name, String rev ) - { - setName( name ); + public ChangeFile(String name, String rev) { + setName(name); - setRevision( rev ); + setRevision(rev); } /** @@ -91,8 +86,7 @@ public ChangeFile( String name, String rev ) * * @return the file name */ - public String getName() - { + public String getName() { return name; } @@ -101,29 +95,24 @@ public String getName() * * @param name New value of property name. */ - public void setName( String name ) - { + public void setName(String name) { this.name = name; } - public String getOriginalName() - { + public String getOriginalName() { return originalName; } - public void setOriginalName( String originalName ) - { + public void setOriginalName(String originalName) { this.originalName = originalName; } - public String getOriginalRevision() - { + public String getOriginalRevision() { return originalRevision; } - public void setOriginalRevision( String originalRevision ) - { + public void setOriginalRevision(String originalRevision) { this.originalRevision = originalRevision; } @@ -132,8 +121,7 @@ public void setOriginalRevision( String originalRevision ) * * @return the latest revision of the file */ - public String getRevision() - { + public String getRevision() { return revision; } @@ -142,18 +130,15 @@ public String getRevision() * * @param revision New value of property revision. */ - public void setRevision( String revision ) - { + public void setRevision(String revision) { this.revision = revision; } - public ScmFileStatus getAction() - { + public ScmFileStatus getAction() { return action; } - public void setAction( ScmFileStatus action ) - { + public void setAction(ScmFileStatus action) { this.action = action; } @@ -162,29 +147,24 @@ public void setAction( ScmFileStatus action ) * * @return a {@link String}made up of the properties of the object */ - public String toString() - { - StringBuilder buffer = new StringBuilder( ); + public String toString() { + StringBuilder buffer = new StringBuilder(); - if ( getAction() != null ) - { - buffer.append( "[" ).append( getAction() ).append( "]:" ); + if (getAction() != null) { + buffer.append("[").append(getAction()).append("]:"); } - buffer.append( getName() ); - if ( getRevision() != null ) - { - buffer.append( ", " ).append( getRevision() ); + buffer.append(getName()); + if (getRevision() != null) { + buffer.append(", ").append(getRevision()); } - if ( getOriginalName() != null ) - { - buffer.append( ", originalName=" ).append( getOriginalName() ); + if (getOriginalName() != null) { + buffer.append(", originalName=").append(getOriginalName()); } - if ( getOriginalRevision() != null ) - { - buffer.append( ", originalRevision=" ).append( getOriginalRevision() ); + if (getOriginalRevision() != null) { + buffer.append(", originalRevision=").append(getOriginalRevision()); } return buffer.toString(); diff --git a/maven-scm-api/src/main/java/org/apache/maven/scm/ChangeSet.java b/maven-scm-api/src/main/java/org/apache/maven/scm/ChangeSet.java index 6e49543f5..a9663f0ee 100644 --- a/maven-scm-api/src/main/java/org/apache/maven/scm/ChangeSet.java +++ b/maven-scm-api/src/main/java/org/apache/maven/scm/ChangeSet.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm; import java.io.Serializable; import java.text.ParseException; @@ -38,9 +37,7 @@ * @author Emmanuel Venisse * */ -public class ChangeSet - implements Serializable -{ +public class ChangeSet implements Serializable { /** * */ @@ -76,25 +73,25 @@ public class ChangeSet /** * Formatter used by the getDateFormatted method. */ - private static final ThreadSafeDateFormat DATE_FORMAT = new ThreadSafeDateFormat( DATE_PATTERN ); + private static final ThreadSafeDateFormat DATE_FORMAT = new ThreadSafeDateFormat(DATE_PATTERN); private static final String TIME_PATTERN = "HH:mm:ss"; /** * Formatter used by the getTimeFormatted method. */ - private static final ThreadSafeDateFormat TIME_FORMAT = new ThreadSafeDateFormat( TIME_PATTERN ); + private static final ThreadSafeDateFormat TIME_FORMAT = new ThreadSafeDateFormat(TIME_PATTERN); /** * Formatter used to parse date/timestamp. */ - private static final ThreadSafeDateFormat TIMESTAMP_FORMAT_1 = new ThreadSafeDateFormat( "yyyy/MM/dd HH:mm:ss" ); + private static final ThreadSafeDateFormat TIMESTAMP_FORMAT_1 = new ThreadSafeDateFormat("yyyy/MM/dd HH:mm:ss"); - private static final ThreadSafeDateFormat TIMESTAMP_FORMAT_2 = new ThreadSafeDateFormat( "yyyy-MM-dd HH:mm:ss" ); + private static final ThreadSafeDateFormat TIMESTAMP_FORMAT_2 = new ThreadSafeDateFormat("yyyy-MM-dd HH:mm:ss"); - private static final ThreadSafeDateFormat TIMESTAMP_FORMAT_3 = new ThreadSafeDateFormat( "yyyy/MM/dd HH:mm:ss z" ); + private static final ThreadSafeDateFormat TIMESTAMP_FORMAT_3 = new ThreadSafeDateFormat("yyyy/MM/dd HH:mm:ss z"); - private static final ThreadSafeDateFormat TIMESTAMP_FORMAT_4 = new ThreadSafeDateFormat( "yyyy-MM-dd HH:mm:ss z" ); + private static final ThreadSafeDateFormat TIMESTAMP_FORMAT_4 = new ThreadSafeDateFormat("yyyy-MM-dd HH:mm:ss z"); /** * Date the changes were committed @@ -146,12 +143,10 @@ public class ChangeSet * @param author User who made changes * @param files The ChangeFile list */ - public ChangeSet( String strDate, String userDatePattern, String comment, String author, - List files ) - { - this( null, comment, author, files ); + public ChangeSet(String strDate, String userDatePattern, String comment, String author, List files) { + this(null, comment, author, files); - setDate( strDate, userDatePattern ); + setDate(strDate, userDatePattern); } /** @@ -160,13 +155,12 @@ public ChangeSet( String strDate, String userDatePattern, String comment, String * @param author User who made changes * @param files The ChangeFile list */ - public ChangeSet( Date date, String comment, String author, List files ) - { - setDate( date ); + public ChangeSet(Date date, String comment, String author, List files) { + setDate(date); - setAuthor( author ); + setAuthor(author); - setComment( comment ); + setComment(comment); this.files = files; } @@ -174,8 +168,7 @@ public ChangeSet( Date date, String comment, String author, List fil /** * Constructor used when attributes aren't available until later */ - public ChangeSet() - { + public ChangeSet() { // no op } @@ -184,10 +177,8 @@ public ChangeSet() * * @return List of ChangeFile. */ - public List getFiles() - { - if ( files == null ) - { + public List getFiles() { + if (files == null) { return new ArrayList(); } return files; @@ -198,19 +189,16 @@ public List getFiles() * * @param files List of ChangeFiles. */ - public void setFiles( List files ) - { + public void setFiles(List files) { this.files = files; } - public void addFile( ChangeFile file ) - { - if ( files == null ) - { + public void addFile(ChangeFile file) { + if (files == null) { files = new ArrayList(); } - files.add( file ); + files.add(file); } /** @@ -219,21 +207,16 @@ public void addFile( ChangeFile file ) * @param repository NOT USED * @return TODO */ - public boolean containsFilename( String filename, ScmProviderRepository repository ) - { - return containsFilename( filename ); - } - - public boolean containsFilename( String filename ) - { - if ( files != null ) - { - for ( ChangeFile file : files ) - { - String f1 = FilenameUtils.normalizeFilename( file.getName() ); - String f2 = FilenameUtils.normalizeFilename( filename ); - if ( f1.indexOf( f2 ) >= 0 ) - { + public boolean containsFilename(String filename, ScmProviderRepository repository) { + return containsFilename(filename); + } + + public boolean containsFilename(String filename) { + if (files != null) { + for (ChangeFile file : files) { + String f1 = FilenameUtils.normalizeFilename(file.getName()); + String f2 = FilenameUtils.normalizeFilename(filename); + if (f1.indexOf(f2) >= 0) { return true; } } @@ -247,8 +230,7 @@ public boolean containsFilename( String filename ) * * @return Value of property author. */ - public String getAuthor() - { + public String getAuthor() { return author; } @@ -257,8 +239,7 @@ public String getAuthor() * * @param author New value of property author. */ - public void setAuthor( String author ) - { + public void setAuthor(String author) { this.author = author; } @@ -267,8 +248,7 @@ public void setAuthor( String author ) * * @return Value of property comment. */ - public String getComment() - { + public String getComment() { return comment; } @@ -277,8 +257,7 @@ public String getComment() * * @param comment New value of property comment. */ - public void setComment( String comment ) - { + public void setComment(String comment) { this.comment = comment; } @@ -287,10 +266,8 @@ public void setComment( String comment ) * * @return Value of property date. */ - public Date getDate() - { - if ( date != null ) - { + public Date getDate() { + if (date != null) { return (Date) date.clone(); } @@ -302,11 +279,9 @@ public Date getDate() * * @param date New value of property date. */ - public void setDate( Date date ) - { - if ( date != null ) - { - this.date = new Date( date.getTime() ); + public void setDate(Date date) { + if (date != null) { + this.date = new Date(date.getTime()); } } @@ -315,9 +290,8 @@ public void setDate( Date date ) * * @param date - a string in yyyy/MM/dd HH:mm:ss format */ - public void setDate( String date ) - { - setDate( date, null ); + public void setDate(String date) { + setDate(date, null); } /** @@ -326,76 +300,45 @@ public void setDate( String date ) * @param date - a string in yyyy/MM/dd HH:mm:ss format * @param userDatePattern - pattern of date */ - public void setDate( String date, String userDatePattern ) - { - try - { - if ( !StringUtils.isEmpty( userDatePattern ) ) - { - SimpleDateFormat format = new SimpleDateFormat( userDatePattern ); + public void setDate(String date, String userDatePattern) { + try { + if (!StringUtils.isEmpty(userDatePattern)) { + SimpleDateFormat format = new SimpleDateFormat(userDatePattern); - this.date = format.parse( date ); - } - else - { - this.date = TIMESTAMP_FORMAT_3.parse( date ); + this.date = format.parse(date); + } else { + this.date = TIMESTAMP_FORMAT_3.parse(date); } - } - catch ( ParseException e ) - { - if ( !StringUtils.isEmpty( userDatePattern ) ) - { - try - { - this.date = TIMESTAMP_FORMAT_3.parse( date ); - } - catch ( ParseException pe ) - { - try - { - this.date = TIMESTAMP_FORMAT_4.parse( date ); - } - catch ( ParseException pe1 ) - { - try - { - this.date = TIMESTAMP_FORMAT_1.parse( date ); - } - catch ( ParseException pe2 ) - { - try - { - this.date = TIMESTAMP_FORMAT_2.parse( date ); - } - catch ( ParseException pe3 ) - { - throw new IllegalArgumentException( "Unable to parse date: " + date ); + } catch (ParseException e) { + if (!StringUtils.isEmpty(userDatePattern)) { + try { + this.date = TIMESTAMP_FORMAT_3.parse(date); + } catch (ParseException pe) { + try { + this.date = TIMESTAMP_FORMAT_4.parse(date); + } catch (ParseException pe1) { + try { + this.date = TIMESTAMP_FORMAT_1.parse(date); + } catch (ParseException pe2) { + try { + this.date = TIMESTAMP_FORMAT_2.parse(date); + } catch (ParseException pe3) { + throw new IllegalArgumentException("Unable to parse date: " + date); } } } } - } - else - { - try - { - this.date = TIMESTAMP_FORMAT_4.parse( date ); - } - catch ( ParseException pe1 ) - { - try - { - this.date = TIMESTAMP_FORMAT_1.parse( date ); - } - catch ( ParseException pe2 ) - { - try - { - this.date = TIMESTAMP_FORMAT_2.parse( date ); - } - catch ( ParseException pe3 ) - { - throw new IllegalArgumentException( "Unable to parse date: " + date ); + } else { + try { + this.date = TIMESTAMP_FORMAT_4.parse(date); + } catch (ParseException pe1) { + try { + this.date = TIMESTAMP_FORMAT_1.parse(date); + } catch (ParseException pe2) { + try { + this.date = TIMESTAMP_FORMAT_2.parse(date); + } catch (ParseException pe3) { + throw new IllegalArgumentException("Unable to parse date: " + date); } } } @@ -406,17 +349,15 @@ public void setDate( String date, String userDatePattern ) /** * @return date in yyyy-mm-dd format */ - public String getDateFormatted() - { - return DATE_FORMAT.format( getDate() ); + public String getDateFormatted() { + return DATE_FORMAT.format(getDate()); } /** * @return time in HH:mm:ss format */ - public String getTimeFormatted() - { - return TIME_FORMAT.format( getDate() ); + public String getTimeFormatted() { + return TIME_FORMAT.format(getDate()); } /** @@ -424,10 +365,8 @@ public String getTimeFormatted() * * @return Value of property author. */ - public List getTags() - { - if ( tags == null ) - { + public List getTags() { + if (tags == null) { return new ArrayList<>(); } return tags; @@ -438,8 +377,7 @@ public List getTags() * * @param tags New value of property tags. This replaces the existing list (if any). */ - public void setTags( List tags ) - { + public void setTags(List tags) { this.tags = tags; } @@ -448,30 +386,25 @@ public void setTags( List tags ) * * @param tag New tag to add to the list of tags. */ - public void addTag( String tag ) - { - if ( tag == null ) - { + public void addTag(String tag) { + if (tag == null) { return; } tag = tag.trim(); - if ( tag.isEmpty() ) - { + if (tag.isEmpty()) { return; } - if ( tags == null ) - { + if (tags == null) { tags = new ArrayList<>(); } - tags.add( tag ); + tags.add(tag); } /** * @return TODO * @since 1.3 */ - public String getRevision() - { + public String getRevision() { return revision; } @@ -479,70 +412,57 @@ public String getRevision() * @param revision TODO * @since 1.3 */ - public void setRevision( String revision ) - { + public void setRevision(String revision) { this.revision = revision; } - public String getParentRevision() - { + public String getParentRevision() { return parentRevision; } - public void setParentRevision( String parentRevision ) - { + public void setParentRevision(String parentRevision) { this.parentRevision = parentRevision; } - public void addMergedRevision( String mergedRevision ) - { - if ( mergedRevisions == null ) - { + public void addMergedRevision(String mergedRevision) { + if (mergedRevisions == null) { mergedRevisions = new LinkedHashSet(); } - mergedRevisions.add( mergedRevision ); + mergedRevisions.add(mergedRevision); } - public Set getMergedRevisions() - { + public Set getMergedRevisions() { return mergedRevisions == null ? Collections.emptySet() : mergedRevisions; } - public void setMergedRevisions( Set mergedRevisions ) - { + public void setMergedRevisions(Set mergedRevisions) { this.mergedRevisions = mergedRevisions; } /** {@inheritDoc} */ - public String toString() - { - StringBuilder result = new StringBuilder( author == null ? " null " : author ); - result.append( "\n" ).append( date == null ? "null " : date.toString() ).append( "\n" ); + public String toString() { + StringBuilder result = new StringBuilder(author == null ? " null " : author); + result.append("\n").append(date == null ? "null " : date.toString()).append("\n"); List tags = getTags(); - if ( !tags.isEmpty() ) - { - result.append( "tags:" ).append( tags ).append( "\n" ); + if (!tags.isEmpty()) { + result.append("tags:").append(tags).append("\n"); } // parent(s) - if ( parentRevision != null ) - { - result.append( "parent: " ).append( parentRevision ); - if ( !getMergedRevisions().isEmpty() ) - { - result.append( " + " ); - result.append( getMergedRevisions() ); + if (parentRevision != null) { + result.append("parent: ").append(parentRevision); + if (!getMergedRevisions().isEmpty()) { + result.append(" + "); + result.append(getMergedRevisions()); } - result.append( "\n" ); + result.append("\n"); } - if ( files != null ) - { - for ( ChangeFile file : files ) - { - result.append( file == null ? " null " : file.toString() ).append( "\n" ); + if (files != null) { + for (ChangeFile file : files) { + result.append(file == null ? " null " : file.toString()).append("\n"); } } - result.append( comment == null ? " null " : comment ); + result.append(comment == null ? " null " : comment); return result.toString(); } @@ -553,86 +473,70 @@ public String toString() * @return a changelog-entry in xml format * TODO make sure comment doesn't contain CDATA tags - MAVEN114 */ - public String toXML() - { - StringBuilder buffer = new StringBuilder( "\t\n" ); - - if ( getDate() != null ) - { - buffer.append( "\t\t" ) - .append( getDateFormatted() ) - .append( "\n" ) - .append( "\t\t\n" ); + public String toXML() { + StringBuilder buffer = new StringBuilder("\t\n"); + + if (getDate() != null) { + buffer.append("\t\t") + .append(getDateFormatted()) + .append("\n") + .append("\t\t\n"); } - buffer.append( "\t\t\n" ); + buffer.append("\t\t\n"); - if ( parentRevision != null ) - { - buffer.append( "\t\t" ).append( getParentRevision() ).append( "\n" ); + if (parentRevision != null) { + buffer.append("\t\t").append(getParentRevision()).append("\n"); } - for ( String mergedRevision : getMergedRevisions() ) - { - buffer.append( "\t\t" ).append( mergedRevision ).append( "\n" ); + for (String mergedRevision : getMergedRevisions()) { + buffer.append("\t\t").append(mergedRevision).append("\n"); } - if ( files != null ) - { - for ( ChangeFile file : files ) - { - buffer.append( "\t\t\n" ); - if ( file.getAction() != null ) - { - buffer.append( "\t\t\t" ).append( file.getAction() ).append( "\n" ); + if (files != null) { + for (ChangeFile file : files) { + buffer.append("\t\t\n"); + if (file.getAction() != null) { + buffer.append("\t\t\t").append(file.getAction()).append("\n"); } - buffer.append( "\t\t\t" ).append( escapeValue( file.getName() ) ).append( "\n" ); - buffer.append( "\t\t\t" ).append( file.getRevision() ).append( "\n" ); - if ( file.getOriginalName() != null ) - { - buffer.append( "\t\t\t" ); - buffer.append( escapeValue( file.getOriginalName() ) ); - buffer.append( "\n" ); + buffer.append("\t\t\t") + .append(escapeValue(file.getName())) + .append("\n"); + buffer.append("\t\t\t").append(file.getRevision()).append("\n"); + if (file.getOriginalName() != null) { + buffer.append("\t\t\t"); + buffer.append(escapeValue(file.getOriginalName())); + buffer.append("\n"); } - if ( file.getOriginalRevision() != null ) - { - buffer.append( "\t\t\t" ); - buffer.append( file.getOriginalRevision() ); - buffer.append( "\n" ); + if (file.getOriginalRevision() != null) { + buffer.append("\t\t\t"); + buffer.append(file.getOriginalRevision()); + buffer.append("\n"); } - buffer.append( "\t\t\n" ); + buffer.append("\t\t\n"); } } - buffer.append( "\t\t\n" ); + buffer.append("\t\t\n"); List tags = getTags(); - if ( !tags.isEmpty() ) - { - buffer.append( "\t\t\n" ); - for ( String tag: tags ) - { - buffer.append( "\t\t\t" ).append( escapeValue( tag ) ).append( "\n" ); + if (!tags.isEmpty()) { + buffer.append("\t\t\n"); + for (String tag : tags) { + buffer.append("\t\t\t").append(escapeValue(tag)).append("\n"); } - buffer.append( "\t\t\n" ); + buffer.append("\t\t\n"); } - buffer.append( "\t\n" ); + buffer.append("\t\n"); return buffer.toString(); } /** {@inheritDoc} */ - public boolean equals( Object obj ) - { - if ( obj instanceof ChangeSet ) - { + public boolean equals(Object obj) { + if (obj instanceof ChangeSet) { ChangeSet changeSet = (ChangeSet) obj; - if ( toString().equals( changeSet.toString() ) ) - { + if (toString().equals(changeSet.toString())) { return true; } } @@ -641,16 +545,15 @@ public boolean equals( Object obj ) } /** {@inheritDoc} */ - public int hashCode() - { + public int hashCode() { final int prime = 31; int result = 1; - result = prime * result + ( ( author == null ) ? 0 : author.hashCode() ); - result = prime * result + ( ( comment == null ) ? 0 : comment.hashCode() ); - result = prime * result + ( ( date == null ) ? 0 : date.hashCode() ); - result = prime * result + ( ( parentRevision == null ) ? 0 : parentRevision.hashCode() ); - result = prime * result + ( ( mergedRevisions == null ) ? 0 : mergedRevisions.hashCode() ); - result = prime * result + ( ( files == null ) ? 0 : files.hashCode() ); + result = prime * result + ((author == null) ? 0 : author.hashCode()); + result = prime * result + ((comment == null) ? 0 : comment.hashCode()); + result = prime * result + ((date == null) ? 0 : date.hashCode()); + result = prime * result + ((parentRevision == null) ? 0 : parentRevision.hashCode()); + result = prime * result + ((mergedRevisions == null) ? 0 : mergedRevisions.hashCode()); + result = prime * result + ((files == null) ? 0 : files.hashCode()); return result; } @@ -660,13 +563,11 @@ public int hashCode() * @param message The message to modify * @return a clean string */ - private String removeCDataEnd( String message ) - { + private String removeCDataEnd(String message) { // check for invalid sequence ]]> int endCdata; - while ( message != null && ( endCdata = message.indexOf( "]]>" ) ) > -1 ) - { - message = message.substring( 0, endCdata ) + "] ] >" + message.substring( endCdata + 3, message.length() ); + while (message != null && (endCdata = message.indexOf("]]>")) > -1) { + message = message.substring(0, endCdata) + "] ] >" + message.substring(endCdata + 3, message.length()); } return message; } @@ -680,35 +581,32 @@ private String removeCDataEnd( String message ) * @param value escape value.toString() * @return text with characters restricted (for use in attributes) escaped */ - public static String escapeValue( Object value ) - { - StringBuilder buffer = new StringBuilder( value.toString() ); - for ( int i = 0, size = buffer.length(); i < size; i++ ) - { - switch ( buffer.charAt( i ) ) - { - case'<': - buffer.replace( i, i + 1, LESS_THAN_ENTITY ); + public static String escapeValue(Object value) { + StringBuilder buffer = new StringBuilder(value.toString()); + for (int i = 0, size = buffer.length(); i < size; i++) { + switch (buffer.charAt(i)) { + case '<': + buffer.replace(i, i + 1, LESS_THAN_ENTITY); size += 3; i += 3; break; - case'>': - buffer.replace( i, i + 1, GREATER_THAN_ENTITY ); + case '>': + buffer.replace(i, i + 1, GREATER_THAN_ENTITY); size += 3; i += 3; break; - case'&': - buffer.replace( i, i + 1, AMPERSAND_ENTITY ); + case '&': + buffer.replace(i, i + 1, AMPERSAND_ENTITY); size += 4; i += 4; break; - case'\'': - buffer.replace( i, i + 1, APOSTROPHE_ENTITY ); + case '\'': + buffer.replace(i, i + 1, APOSTROPHE_ENTITY); size += 5; i += 5; break; - case'\"': - buffer.replace( i, i + 1, QUOTE_ENTITY ); + case '\"': + buffer.replace(i, i + 1, QUOTE_ENTITY); size += 5; i += 5; break; diff --git a/maven-scm-api/src/main/java/org/apache/maven/scm/CommandParameter.java b/maven-scm-api/src/main/java/org/apache/maven/scm/CommandParameter.java index c8edd3541..ceff4c6fd 100644 --- a/maven-scm-api/src/main/java/org/apache/maven/scm/CommandParameter.java +++ b/maven-scm-api/src/main/java/org/apache/maven/scm/CommandParameter.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm; import java.io.Serializable; @@ -25,78 +24,74 @@ * @author Trygve Laugstøl * */ -public class CommandParameter - implements Serializable -{ +public class CommandParameter implements Serializable { private static final long serialVersionUID = -3391190831054016735L; - public static final CommandParameter BINARY = new CommandParameter( "binary" ); + public static final CommandParameter BINARY = new CommandParameter("binary"); - public static final CommandParameter RECURSIVE = new CommandParameter( "recursive" ); + public static final CommandParameter RECURSIVE = new CommandParameter("recursive"); - public static final CommandParameter SHALLOW = new CommandParameter( "shallow" ); + public static final CommandParameter SHALLOW = new CommandParameter("shallow"); - public static final CommandParameter MESSAGE = new CommandParameter( "message" ); + public static final CommandParameter MESSAGE = new CommandParameter("message"); - public static final CommandParameter BRANCH_NAME = new CommandParameter( "branchName" ); + public static final CommandParameter BRANCH_NAME = new CommandParameter("branchName"); - public static final CommandParameter START_DATE = new CommandParameter( "startDate" ); + public static final CommandParameter START_DATE = new CommandParameter("startDate"); - public static final CommandParameter END_DATE = new CommandParameter( "endDate" ); + public static final CommandParameter END_DATE = new CommandParameter("endDate"); - public static final CommandParameter NUM_DAYS = new CommandParameter( "numDays" ); + public static final CommandParameter NUM_DAYS = new CommandParameter("numDays"); - public static final CommandParameter LIMIT = new CommandParameter( "limit" ); + public static final CommandParameter LIMIT = new CommandParameter("limit"); - public static final CommandParameter BRANCH = new CommandParameter( "branch" ); + public static final CommandParameter BRANCH = new CommandParameter("branch"); - public static final CommandParameter START_SCM_VERSION = new CommandParameter( "startScmVersion" ); + public static final CommandParameter START_SCM_VERSION = new CommandParameter("startScmVersion"); - public static final CommandParameter END_SCM_VERSION = new CommandParameter( "endScmVersion" ); + public static final CommandParameter END_SCM_VERSION = new CommandParameter("endScmVersion"); - public static final CommandParameter CHANGELOG_DATE_PATTERN = new CommandParameter( "changelogDatePattern" ); + public static final CommandParameter CHANGELOG_DATE_PATTERN = new CommandParameter("changelogDatePattern"); - public static final CommandParameter SCM_VERSION = new CommandParameter( "scmVersion" ); + public static final CommandParameter SCM_VERSION = new CommandParameter("scmVersion"); - public static final CommandParameter TAG_NAME = new CommandParameter( "tagName" ); + public static final CommandParameter TAG_NAME = new CommandParameter("tagName"); - public static final CommandParameter FILE = new CommandParameter( "file" ); + public static final CommandParameter FILE = new CommandParameter("file"); - public static final CommandParameter FILES = new CommandParameter( "files" ); + public static final CommandParameter FILES = new CommandParameter("files"); - public static final CommandParameter OUTPUT_FILE = new CommandParameter( "outputFile" ); + public static final CommandParameter OUTPUT_FILE = new CommandParameter("outputFile"); - public static final CommandParameter OUTPUT_DIRECTORY = new CommandParameter( "outputDirectory" ); + public static final CommandParameter OUTPUT_DIRECTORY = new CommandParameter("outputDirectory"); - public static final CommandParameter RUN_CHANGELOG_WITH_UPDATE = - new CommandParameter( "run_changelog_with_update" ); + public static final CommandParameter RUN_CHANGELOG_WITH_UPDATE = new CommandParameter("run_changelog_with_update"); - public static final CommandParameter SCM_TAG_PARAMETERS = new CommandParameter( "ScmTagParameters" ); + public static final CommandParameter SCM_TAG_PARAMETERS = new CommandParameter("ScmTagParameters"); - public static final CommandParameter SCM_BRANCH_PARAMETERS = new CommandParameter( "ScmBranchParameters" ); + public static final CommandParameter SCM_BRANCH_PARAMETERS = new CommandParameter("ScmBranchParameters"); - public static final CommandParameter SCM_MKDIR_CREATE_IN_LOCAL = new CommandParameter( "createInLocal" ); + public static final CommandParameter SCM_MKDIR_CREATE_IN_LOCAL = new CommandParameter("createInLocal"); /** * Parameter used only for Git SCM and simulate the git rev-parse --short=lenght command. * * @since 1.7 */ - public static final CommandParameter SCM_SHORT_REVISION_LENGTH = new CommandParameter( "shortRevisionLength" ); + public static final CommandParameter SCM_SHORT_REVISION_LENGTH = new CommandParameter("shortRevisionLength"); /** * Parameter to force add * * @since 1.7 */ - public static final CommandParameter FORCE_ADD = new CommandParameter( "forceAdd" ); + public static final CommandParameter FORCE_ADD = new CommandParameter("forceAdd"); /** * contains true or false * @since 1.8 */ - public static final CommandParameter IGNORE_WHITESPACE = new CommandParameter( "ignoreWhitespace" ); - + public static final CommandParameter IGNORE_WHITESPACE = new CommandParameter("ignoreWhitespace"); /** * Parameter name @@ -106,21 +101,18 @@ public class CommandParameter /** * @param name The parameter name */ - private CommandParameter( String name ) - { + private CommandParameter(String name) { this.name = name; } /** * @return The parameter name */ - public String getName() - { + public String getName() { return name; } - public String toString() - { + public String toString() { return name; } } diff --git a/maven-scm-api/src/main/java/org/apache/maven/scm/CommandParameters.java b/maven-scm-api/src/main/java/org/apache/maven/scm/CommandParameters.java index 3c71b65f4..4cca6878a 100644 --- a/maven-scm-api/src/main/java/org/apache/maven/scm/CommandParameters.java +++ b/maven-scm-api/src/main/java/org/apache/maven/scm/CommandParameters.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm; import java.io.File; import java.io.Serializable; @@ -30,9 +29,7 @@ * @author Olivier Lamy * */ -public class CommandParameters - implements Serializable -{ +public class CommandParameters implements Serializable { private static final long serialVersionUID = -7346070735958137283L; private Map parameters = new HashMap(); @@ -48,10 +45,8 @@ public class CommandParameters * @return The parameter value as a String * @throws ScmException if the parameter doesn't exist */ - public String getString( CommandParameter parameter ) - throws ScmException - { - Object object = getObject( String.class, parameter ); + public String getString(CommandParameter parameter) throws ScmException { + Object object = getObject(String.class, parameter); return object.toString(); } @@ -64,13 +59,10 @@ public String getString( CommandParameter parameter ) * @return The parameter value as a String * @throws ScmException if the value is in the wrong type */ - public String getString( CommandParameter parameter, String defaultValue ) - throws ScmException - { - Object object = getObject( String.class, parameter, null ); + public String getString(CommandParameter parameter, String defaultValue) throws ScmException { + Object object = getObject(String.class, parameter, null); - if ( object == null ) - { + if (object == null) { return defaultValue; } @@ -84,10 +76,8 @@ public String getString( CommandParameter parameter, String defaultValue ) * @param value The value of the parameter * @throws ScmException if the parameter already exist */ - public void setString( CommandParameter parameter, String value ) - throws ScmException - { - setObject( parameter, value ); + public void setString(CommandParameter parameter, String value) throws ScmException { + setObject(parameter, value); } // ---------------------------------------------------------------------- @@ -101,10 +91,8 @@ public void setString( CommandParameter parameter, String value ) * @return The parameter value as a String * @throws ScmException if the parameter doesn't exist */ - public int getInt( CommandParameter parameter ) - throws ScmException - { - return ( (Integer) getObject( Integer.class, parameter ) ).intValue(); + public int getInt(CommandParameter parameter) throws ScmException { + return ((Integer) getObject(Integer.class, parameter)).intValue(); } /** @@ -115,13 +103,10 @@ public int getInt( CommandParameter parameter ) * @return The parameter value as a int * @throws ScmException if the value is in the wrong type */ - public int getInt( CommandParameter parameter, int defaultValue ) - throws ScmException - { - Integer value = ( (Integer) getObject( Integer.class, parameter, null ) ); + public int getInt(CommandParameter parameter, int defaultValue) throws ScmException { + Integer value = ((Integer) getObject(Integer.class, parameter, null)); - if ( value == null ) - { + if (value == null) { return defaultValue; } @@ -135,10 +120,8 @@ public int getInt( CommandParameter parameter, int defaultValue ) * @param value The value of the parameter * @throws ScmException if the parameter already exist */ - public void setInt( CommandParameter parameter, int value ) - throws ScmException - { - setObject( parameter, Integer.valueOf( value ) ); + public void setInt(CommandParameter parameter, int value) throws ScmException { + setObject(parameter, Integer.valueOf(value)); } // ---------------------------------------------------------------------- @@ -152,10 +135,8 @@ public void setInt( CommandParameter parameter, int value ) * @return The parameter value as a Date * @throws ScmException if the parameter doesn't exist */ - public Date getDate( CommandParameter parameter ) - throws ScmException - { - return (Date) getObject( Date.class, parameter ); + public Date getDate(CommandParameter parameter) throws ScmException { + return (Date) getObject(Date.class, parameter); } /** @@ -166,10 +147,8 @@ public Date getDate( CommandParameter parameter ) * @return The parameter value as a Date * @throws ScmException if the value is in the wrong type */ - public Date getDate( CommandParameter parameter, Date defaultValue ) - throws ScmException - { - return (Date) getObject( Date.class, parameter, defaultValue ); + public Date getDate(CommandParameter parameter, Date defaultValue) throws ScmException { + return (Date) getObject(Date.class, parameter, defaultValue); } /** @@ -179,10 +158,8 @@ public Date getDate( CommandParameter parameter, Date defaultValue ) * @param date The value of the parameter * @throws ScmException if the parameter already exist */ - public void setDate( CommandParameter parameter, Date date ) - throws ScmException - { - setObject( parameter, date ); + public void setDate(CommandParameter parameter, Date date) throws ScmException { + setObject(parameter, date); } // ---------------------------------------------------------------------- @@ -196,10 +173,8 @@ public void setDate( CommandParameter parameter, Date date ) * @return The parameter value as a boolean * @throws ScmException if the parameter doesn't exist */ - public boolean getBoolean( CommandParameter parameter ) - throws ScmException - { - return Boolean.valueOf( getString( parameter ) ).booleanValue(); + public boolean getBoolean(CommandParameter parameter) throws ScmException { + return Boolean.valueOf(getString(parameter)).booleanValue(); } /** @@ -211,10 +186,9 @@ public boolean getBoolean( CommandParameter parameter ) * @return The parameter value as a boolean * @throws ScmException if the parameter doesn't exist */ - public boolean getBoolean( CommandParameter parameter, boolean defaultValue ) - throws ScmException - { - return Boolean.valueOf( getString( parameter, Boolean.toString( defaultValue ) ) ).booleanValue(); + public boolean getBoolean(CommandParameter parameter, boolean defaultValue) throws ScmException { + return Boolean.valueOf(getString(parameter, Boolean.toString(defaultValue))) + .booleanValue(); } // ---------------------------------------------------------------------- @@ -228,10 +202,8 @@ public boolean getBoolean( CommandParameter parameter, boolean defaultValue ) * @return The parameter value as a ScmVersion * @throws ScmException if the parameter doesn't exist */ - public ScmVersion getScmVersion( CommandParameter parameter ) - throws ScmException - { - return (ScmVersion) getObject( ScmVersion.class, parameter ); + public ScmVersion getScmVersion(CommandParameter parameter) throws ScmException { + return (ScmVersion) getObject(ScmVersion.class, parameter); } /** @@ -242,10 +214,8 @@ public ScmVersion getScmVersion( CommandParameter parameter ) * @return The parameter value as a ScmVersion * @throws ScmException if the parameter doesn't exist */ - public ScmVersion getScmVersion( CommandParameter parameter, ScmVersion defaultValue ) - throws ScmException - { - return (ScmVersion) getObject( ScmVersion.class, parameter, defaultValue ); + public ScmVersion getScmVersion(CommandParameter parameter, ScmVersion defaultValue) throws ScmException { + return (ScmVersion) getObject(ScmVersion.class, parameter, defaultValue); } /** @@ -255,10 +225,8 @@ public ScmVersion getScmVersion( CommandParameter parameter, ScmVersion defaultV * @param scmVersion The tbranch/tag/revision * @throws ScmException if the parameter already exist */ - public void setScmVersion( CommandParameter parameter, ScmVersion scmVersion ) - throws ScmException - { - setObject( parameter, scmVersion ); + public void setScmVersion(CommandParameter parameter, ScmVersion scmVersion) throws ScmException { + setObject(parameter, scmVersion); } // ---------------------------------------------------------------------- @@ -270,10 +238,8 @@ public void setScmVersion( CommandParameter parameter, ScmVersion scmVersion ) * @return an array of files * @throws ScmException if any */ - public File[] getFileArray( CommandParameter parameter ) - throws ScmException - { - return (File[]) getObject( File[].class, parameter ); + public File[] getFileArray(CommandParameter parameter) throws ScmException { + return (File[]) getObject(File[].class, parameter); } /** @@ -282,35 +248,25 @@ public File[] getFileArray( CommandParameter parameter ) * @return an array of files * @throws ScmException if any */ - public File[] getFileArray( CommandParameter parameter, File[] defaultValue ) - throws ScmException - { - return (File[]) getObject( File[].class, parameter, defaultValue ); + public File[] getFileArray(CommandParameter parameter, File[] defaultValue) throws ScmException { + return (File[]) getObject(File[].class, parameter, defaultValue); } - - public ScmTagParameters getScmTagParameters( CommandParameter parameter ) - throws ScmException - { - return (ScmTagParameters) getObject( ScmTagParameters.class, parameter, new ScmTagParameters() ); + public ScmTagParameters getScmTagParameters(CommandParameter parameter) throws ScmException { + return (ScmTagParameters) getObject(ScmTagParameters.class, parameter, new ScmTagParameters()); } - public void setScmTagParameters( CommandParameter parameter, ScmTagParameters scmTagParameters ) - throws ScmException - { - setObject( parameter, scmTagParameters ); + public void setScmTagParameters(CommandParameter parameter, ScmTagParameters scmTagParameters) throws ScmException { + setObject(parameter, scmTagParameters); } - public void setScmBranchParameters( CommandParameter parameter, ScmBranchParameters scmBranchParameters ) - throws ScmException - { - setObject( parameter, scmBranchParameters ); + public void setScmBranchParameters(CommandParameter parameter, ScmBranchParameters scmBranchParameters) + throws ScmException { + setObject(parameter, scmBranchParameters); } - public ScmBranchParameters getScmBranchParameters( CommandParameter parameter ) - throws ScmException - { - return (ScmBranchParameters) getObject( ScmBranchParameters.class, parameter, new ScmBranchParameters() ); + public ScmBranchParameters getScmBranchParameters(CommandParameter parameter) throws ScmException { + return (ScmBranchParameters) getObject(ScmBranchParameters.class, parameter, new ScmBranchParameters()); } // ---------------------------------------------------------------------- @@ -325,14 +281,11 @@ public ScmBranchParameters getScmBranchParameters( CommandParameter parameter ) * @return The parameter value * @throws ScmException if the parameter doesn't exist */ - private Object getObject( Class clazz, CommandParameter parameter ) - throws ScmException - { - Object object = getObject( clazz, parameter, null ); - - if ( object == null ) - { - throw new ScmException( "Missing parameter: '" + parameter.getName() + "'." ); + private Object getObject(Class clazz, CommandParameter parameter) throws ScmException { + Object object = getObject(clazz, parameter, null); + + if (object == null) { + throw new ScmException("Missing parameter: '" + parameter.getName() + "'."); } return object; @@ -347,21 +300,16 @@ private Object getObject( Class clazz, CommandParameter parameter ) * @return The parameter value * @throws ScmException if the defaultValue is in the wrong type */ - private Object getObject( Class clazz, CommandParameter parameter, Object defaultValue ) - throws ScmException - { - Object object = parameters.get( parameter.getName() ); + private Object getObject(Class clazz, CommandParameter parameter, Object defaultValue) throws ScmException { + Object object = parameters.get(parameter.getName()); - if ( object == null ) - { + if (object == null) { return defaultValue; } - if ( clazz != null && !clazz.isAssignableFrom( object.getClass() ) ) - { - throw new ScmException( - "Wrong parameter type for '" + parameter.getName() + ". " + "Expected: " + clazz.getName() + ", got: " - + object.getClass().getName() ); + if (clazz != null && !clazz.isAssignableFrom(object.getClass())) { + throw new ScmException("Wrong parameter type for '" + parameter.getName() + ". " + "Expected: " + + clazz.getName() + ", got: " + object.getClass().getName()); } return object; @@ -374,17 +322,14 @@ private Object getObject( Class clazz, CommandParameter parameter, Object def * @param value The parameter value * @throws ScmException if the parameter already exist */ - private void setObject( CommandParameter parameter, Object value ) - throws ScmException - { - Object object = getObject( null, parameter, null ); - - if ( object != null ) - { - throw new ScmException( "The parameter is already set: " + parameter.getName() ); + private void setObject(CommandParameter parameter, Object value) throws ScmException { + Object object = getObject(null, parameter, null); + + if (object != null) { + throw new ScmException("The parameter is already set: " + parameter.getName()); } - parameters.put( parameter.getName(), value ); + parameters.put(parameter.getName(), value); } /** @@ -392,8 +337,7 @@ private void setObject( CommandParameter parameter, Object value ) * * @param parameter to remove */ - public void remove( CommandParameter parameter ) - { - parameters.remove( parameter.getName() ); + public void remove(CommandParameter parameter) { + parameters.remove(parameter.getName()); } } diff --git a/maven-scm-api/src/main/java/org/apache/maven/scm/NoSuchCommandScmException.java b/maven-scm-api/src/main/java/org/apache/maven/scm/NoSuchCommandScmException.java index d96f22140..b9e743a0b 100644 --- a/maven-scm-api/src/main/java/org/apache/maven/scm/NoSuchCommandScmException.java +++ b/maven-scm-api/src/main/java/org/apache/maven/scm/NoSuchCommandScmException.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,22 +16,20 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm; /** * @author Trygve Laugstøl * */ -public class NoSuchCommandScmException - extends ScmException -{ +public class NoSuchCommandScmException extends ScmException { static final long serialVersionUID = 5789657554664703221L; private String commandName; - public NoSuchCommandScmException( String commandName ) - { - super( "No such command '" + commandName + "'." ); + public NoSuchCommandScmException(String commandName) { + super("No such command '" + commandName + "'."); } /** @@ -41,8 +37,7 @@ public NoSuchCommandScmException( String commandName ) * * @return The command name */ - public String getCommandName() - { + public String getCommandName() { return commandName; } } diff --git a/maven-scm-api/src/main/java/org/apache/maven/scm/ScmBranch.java b/maven-scm-api/src/main/java/org/apache/maven/scm/ScmBranch.java index 9c8704a70..690b3ba3b 100644 --- a/maven-scm-api/src/main/java/org/apache/maven/scm/ScmBranch.java +++ b/maven-scm-api/src/main/java/org/apache/maven/scm/ScmBranch.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,27 +16,24 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm; /** * @author Emmanuel Venisse * */ -public class ScmBranch - extends AbstractScmVersion -{ +public class ScmBranch extends AbstractScmVersion { private static final long serialVersionUID = 6305050785257168739L; /** {@inheritDoc} */ - public String getType() - { + public String getType() { return "Branch"; } /** * @param name the branch name */ - public ScmBranch( String name ) - { - super( name ); + public ScmBranch(String name) { + super(name); } } diff --git a/maven-scm-api/src/main/java/org/apache/maven/scm/ScmBranchParameters.java b/maven-scm-api/src/main/java/org/apache/maven/scm/ScmBranchParameters.java index 06d374583..f035dec43 100644 --- a/maven-scm-api/src/main/java/org/apache/maven/scm/ScmBranchParameters.java +++ b/maven-scm-api/src/main/java/org/apache/maven/scm/ScmBranchParameters.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm; import java.io.Serializable; @@ -25,9 +24,7 @@ * @author Olivier Lamy * @since 1.2 */ -public class ScmBranchParameters - implements Serializable -{ +public class ScmBranchParameters implements Serializable { private static final long serialVersionUID = 7241536408630608707L; private String message; @@ -38,59 +35,48 @@ public class ScmBranchParameters private String scmRevision; - public ScmBranchParameters() - { + public ScmBranchParameters() { this.remoteBranching = false; this.pinExternals = false; } - public ScmBranchParameters( String message ) - { + public ScmBranchParameters(String message) { this.message = message; } - public String getMessage() - { + public String getMessage() { return message; } - public void setMessage( String message ) - { + public void setMessage(String message) { this.message = message; } - public String getScmRevision() - { + public String getScmRevision() { return scmRevision; } - public void setScmRevision( String scmRevision ) - { + public void setScmRevision(String scmRevision) { this.scmRevision = scmRevision; } - public boolean isRemoteBranching() - { + public boolean isRemoteBranching() { return remoteBranching; } - public void setRemoteBranching( boolean remoteBranching ) - { + public void setRemoteBranching(boolean remoteBranching) { this.remoteBranching = remoteBranching; } - public boolean isPinExternals() - { + public boolean isPinExternals() { return pinExternals; } - public void setPinExternals( boolean pinExternals ) - { + public void setPinExternals(boolean pinExternals) { this.pinExternals = pinExternals; } - public String toString() - { + public String toString() { return "[" + scmRevision + "] " + message; } } diff --git a/maven-scm-api/src/main/java/org/apache/maven/scm/ScmException.java b/maven-scm-api/src/main/java/org/apache/maven/scm/ScmException.java index 812641f3e..fe188eb92 100644 --- a/maven-scm-api/src/main/java/org/apache/maven/scm/ScmException.java +++ b/maven-scm-api/src/main/java/org/apache/maven/scm/ScmException.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,30 +16,27 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm; /** * @author Emmanuel Venisse * */ -public class ScmException - extends Exception -{ +public class ScmException extends Exception { static final long serialVersionUID = 5041965569154385323L; /** * @param message the message could be null */ - public ScmException( String message ) - { - super( message ); + public ScmException(String message) { + super(message); } /** * @param message the message could be null * @param cause the cause could be null */ - public ScmException( String message, Throwable cause ) - { - super( message, cause ); + public ScmException(String message, Throwable cause) { + super(message, cause); } } diff --git a/maven-scm-api/src/main/java/org/apache/maven/scm/ScmFile.java b/maven-scm-api/src/main/java/org/apache/maven/scm/ScmFile.java index d677a0c16..04ee15f41 100644 --- a/maven-scm-api/src/main/java/org/apache/maven/scm/ScmFile.java +++ b/maven-scm-api/src/main/java/org/apache/maven/scm/ScmFile.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm; import java.io.Serializable; @@ -25,9 +24,7 @@ * @author Trygve Laugstøl * */ -public class ScmFile - implements Comparable, Serializable -{ +public class ScmFile implements Comparable, Serializable { private static final long serialVersionUID = -9133015730693522690L; private String path; @@ -38,8 +35,7 @@ public class ScmFile * @param path The relative path of the file, should never start with any {@link java.io.File#separator}. * @param status The file status */ - public ScmFile( String path, ScmFileStatus status ) - { + public ScmFile(String path, ScmFileStatus status) { this.path = path; this.status = status; @@ -47,19 +43,17 @@ public ScmFile( String path, ScmFileStatus status ) /** * Returns the relative path of the file. - * + * * @return the file path */ - public String getPath() - { + public String getPath() { return path; } /** * @return The file status */ - public ScmFileStatus getStatus() - { + public ScmFileStatus getStatus() { return status; } @@ -68,9 +62,8 @@ public ScmFileStatus getStatus() // ---------------------------------------------------------------------- /** {@inheritDoc} */ - public int compareTo( ScmFile other ) - { - return other.getPath().compareTo( path ); + public int compareTo(ScmFile other) { + return other.getPath().compareTo(path); } // ---------------------------------------------------------------------- @@ -78,25 +71,21 @@ public int compareTo( ScmFile other ) // ---------------------------------------------------------------------- /** {@inheritDoc} */ - public boolean equals( Object other ) - { - if ( !( other instanceof ScmFile ) ) - { + public boolean equals(Object other) { + if (!(other instanceof ScmFile)) { return false; } - return ( (ScmFile) other ).getPath().equals( path ); + return ((ScmFile) other).getPath().equals(path); } /** {@inheritDoc} */ - public int hashCode() - { + public int hashCode() { return path.hashCode(); } /** {@inheritDoc} */ - public String toString() - { + public String toString() { return "[" + path + ":" + status + "]"; } } diff --git a/maven-scm-api/src/main/java/org/apache/maven/scm/ScmFileSet.java b/maven-scm-api/src/main/java/org/apache/maven/scm/ScmFileSet.java index 8401c844b..6c02d7dbe 100644 --- a/maven-scm-api/src/main/java/org/apache/maven/scm/ScmFileSet.java +++ b/maven-scm-api/src/main/java/org/apache/maven/scm/ScmFileSet.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm; import java.io.File; import java.io.IOException; @@ -37,15 +36,13 @@ * @author Brett Porter * */ -public class ScmFileSet - implements Serializable -{ +public class ScmFileSet implements Serializable { private static final long serialVersionUID = -5978597349974797556L; private static final String DELIMITER = ","; /** @see DirectoryScanner#DEFAULTEXCLUDES */ - private static final String DEFAULT_EXCLUDES = StringUtils.join( DirectoryScanner.DEFAULTEXCLUDES, DELIMITER ); + private static final String DEFAULT_EXCLUDES = StringUtils.join(DirectoryScanner.DEFAULTEXCLUDES, DELIMITER); private final File basedir; @@ -63,9 +60,8 @@ public class ScmFileSet * * @param basedir directory files in the set are relative to */ - public ScmFileSet( File basedir ) - { - this( basedir, new ArrayList( 0 ) ); + public ScmFileSet(File basedir) { + this(basedir, new ArrayList(0)); } /** @@ -74,9 +70,8 @@ public ScmFileSet( File basedir ) * @param basedir directory file is relative to * @param file file that the set will contain, has to be relative to basedir */ - public ScmFileSet( File basedir, File file ) - { - this( basedir, new File[]{file} ); + public ScmFileSet(File basedir, File file) { + this(basedir, new File[] {file}); } /** @@ -89,20 +84,15 @@ public ScmFileSet( File basedir, File file ) * if null DEFAULT_EXCLUDES is used, else DEFAULT_EXCLUDES is added. * @throws IOException if any */ - public ScmFileSet( File basedir, String includes, String excludes ) - throws IOException - { + public ScmFileSet(File basedir, String includes, String excludes) throws IOException { this.basedir = basedir; - if ( excludes != null && excludes.length() > 0 ) - { + if (excludes != null && excludes.length() > 0) { excludes += DELIMITER + DEFAULT_EXCLUDES; - } - else - { + } else { excludes = DEFAULT_EXCLUDES; } - this.files = FileUtils.getFiles( basedir, includes, excludes, false ); + this.files = FileUtils.getFiles(basedir, includes, excludes, false); this.includes = includes; this.excludes = excludes; } @@ -115,10 +105,8 @@ public ScmFileSet( File basedir, String includes, String excludes ) * @throws IOException if any * @since 1.0 */ - public ScmFileSet( File basedir, String includes ) - throws IOException - { - this( basedir, includes, null ); + public ScmFileSet(File basedir, String includes) throws IOException { + this(basedir, includes, null); } /** @@ -128,9 +116,8 @@ public ScmFileSet( File basedir, String includes ) * @param files files that the set will contain, have to be relative to basedir * @deprecated use ScmFileSet( File, List ) */ - public ScmFileSet( File basedir, File[] files ) - { - this( basedir, Arrays.asList( files ) ); + public ScmFileSet(File basedir, File[] files) { + this(basedir, Arrays.asList(files)); } /** @@ -139,16 +126,13 @@ public ScmFileSet( File basedir, File[] files ) * @param basedir directory files are relative to * @param files list of File objects, files that the set will contain, have to be relative to basedir */ - public ScmFileSet( File basedir, List files ) - { - if ( basedir == null ) - { - throw new NullPointerException( "basedir must not be null" ); + public ScmFileSet(File basedir, List files) { + if (basedir == null) { + throw new NullPointerException("basedir must not be null"); } - if ( files == null ) - { - throw new NullPointerException( "files must not be null" ); + if (files == null) { + throw new NullPointerException("files must not be null"); } this.basedir = basedir; @@ -160,8 +144,7 @@ public ScmFileSet( File basedir, List files ) * * @return base directory */ - public File getBasedir() - { + public File getBasedir() { return basedir; } @@ -171,9 +154,8 @@ public File getBasedir() * @return files in this set * @deprecated use getFileList() instead */ - public File[] getFiles() - { - return this.files.toArray( new File[this.files.size()] ); + public File[] getFiles() { + return this.files.toArray(new File[this.files.size()]); } /** @@ -181,32 +163,26 @@ public File[] getFiles() * * @return List of File objects */ - public List getFileList() - { + public List getFileList() { return this.files; } - /** * @return the includes files as a comma separated string */ - public String getIncludes() - { + public String getIncludes() { return this.includes; } - /** * @return the excludes files as a comma separated string */ - public String getExcludes() - { + public String getExcludes() { return this.excludes; } /** {@inheritDoc} */ - public String toString() - { + public String toString() { return "basedir = " + basedir + "; files = " + files; } } diff --git a/maven-scm-api/src/main/java/org/apache/maven/scm/ScmFileStatus.java b/maven-scm-api/src/main/java/org/apache/maven/scm/ScmFileStatus.java index 6a3a8720f..3ca51b704 100644 --- a/maven-scm-api/src/main/java/org/apache/maven/scm/ScmFileStatus.java +++ b/maven-scm-api/src/main/java/org/apache/maven/scm/ScmFileStatus.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm; import java.io.Serializable; @@ -35,106 +34,102 @@ * @author Trygve Laugstøl * */ -public final class ScmFileStatus - implements Serializable -{ +public final class ScmFileStatus implements Serializable { private static final long serialVersionUID = -7840223279162817915L; /** * File is added to the working tree and does not yet exist in the repository */ - public static final ScmFileStatus ADDED = new ScmFileStatus( "added" ); + public static final ScmFileStatus ADDED = new ScmFileStatus("added"); /** * File is removed from the working tree thus not revisioned anymore.
* The file is still present in the repository.
* The file could be deleted from the filesystem depending on the provider. */ - public static final ScmFileStatus DELETED = new ScmFileStatus( "deleted" ); + public static final ScmFileStatus DELETED = new ScmFileStatus("deleted"); /** * The file has been modified in the working tree. */ - public static final ScmFileStatus MODIFIED = new ScmFileStatus( "modified" ); + public static final ScmFileStatus MODIFIED = new ScmFileStatus("modified"); /** * The file has been renamed or moved in the working tree. * @since 1.7 */ - public static final ScmFileStatus RENAMED = new ScmFileStatus( "renamed" ); + public static final ScmFileStatus RENAMED = new ScmFileStatus("renamed"); /** * The file has been copied in the working tree. * @since 1.7 */ - public static final ScmFileStatus COPIED = new ScmFileStatus( "copied" ); + public static final ScmFileStatus COPIED = new ScmFileStatus("copied"); /** * The file is missing in the working tree. */ - public static final ScmFileStatus MISSING = new ScmFileStatus( "missing" ); + public static final ScmFileStatus MISSING = new ScmFileStatus("missing"); /** * File from working tree is checked into the repository */ - public static final ScmFileStatus CHECKED_IN = new ScmFileStatus( "checked-in" ); + public static final ScmFileStatus CHECKED_IN = new ScmFileStatus("checked-in"); /** * File is checked out from the repository and into the working tree */ - public static final ScmFileStatus CHECKED_OUT = new ScmFileStatus( "checked-out" ); + public static final ScmFileStatus CHECKED_OUT = new ScmFileStatus("checked-out"); /** * The file in the working tree has differences to the one in repository that * conflicts ie. it cannot automatically be merged. */ - public static final ScmFileStatus CONFLICT = new ScmFileStatus( "conflict" ); + public static final ScmFileStatus CONFLICT = new ScmFileStatus("conflict"); /** * The file in the working tree has been updated with changes from the repository. */ - public static final ScmFileStatus PATCHED = new ScmFileStatus( "patched" ); + public static final ScmFileStatus PATCHED = new ScmFileStatus("patched"); /** * The file is added, removed or updated from the repository, thus its * up-to-date with the version in the repository. See also isUpdate() */ - public static final ScmFileStatus UPDATED = new ScmFileStatus( "updated" ); + public static final ScmFileStatus UPDATED = new ScmFileStatus("updated"); /** * The file is part of a tag. */ - public static final ScmFileStatus TAGGED = new ScmFileStatus( "tagged" ); + public static final ScmFileStatus TAGGED = new ScmFileStatus("tagged"); /** * The file is locked. */ - public static final ScmFileStatus LOCKED = new ScmFileStatus( "locked" ); + public static final ScmFileStatus LOCKED = new ScmFileStatus("locked"); /** * The file is in the working tree but is not versioned and not ignored either. */ - public static final ScmFileStatus UNKNOWN = new ScmFileStatus( "unknown" ); + public static final ScmFileStatus UNKNOWN = new ScmFileStatus("unknown"); /** * @since 1.5 * The file is being edited */ - public static final ScmFileStatus EDITED = new ScmFileStatus( "edit" ); - + public static final ScmFileStatus EDITED = new ScmFileStatus("edit"); + /** * The status name */ private final String name; - private ScmFileStatus( String name ) - { + private ScmFileStatus(String name) { this.name = name; } /** {@inheritDoc} */ - public String toString() - { + public String toString() { return name; } @@ -144,8 +139,7 @@ public String toString() * * @return true on changes in the working tree or if the file is unknown. */ - public boolean isStatus() - { + public boolean isStatus() { return this == UNKNOWN || isDiff(); } @@ -154,16 +148,14 @@ public boolean isStatus() * * @return true on changes in the working tree */ - public boolean isDiff() - { + public boolean isDiff() { return this == ADDED || this == DELETED || this == MODIFIED; } /** * @return true if the file was part of a transaction with the repository. */ - public boolean isTransaction() - { + public boolean isTransaction() { return this == CHECKED_IN || this == CHECKED_OUT || this == LOCKED || this == TAGGED || isUpdate(); } @@ -176,8 +168,7 @@ public boolean isTransaction() * * @return true if the status is conflict, updated or patched. */ - public boolean isUpdate() - { + public boolean isUpdate() { return this == CONFLICT || this == UPDATED || this == PATCHED; } } diff --git a/maven-scm-api/src/main/java/org/apache/maven/scm/ScmRequest.java b/maven-scm-api/src/main/java/org/apache/maven/scm/ScmRequest.java index 9541a03b4..2ac10a1d8 100644 --- a/maven-scm-api/src/main/java/org/apache/maven/scm/ScmRequest.java +++ b/maven-scm-api/src/main/java/org/apache/maven/scm/ScmRequest.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,11 +16,12 @@ * specific language governing permissions and limitations * under the License. */ - -import org.apache.maven.scm.repository.ScmRepository; +package org.apache.maven.scm; import java.io.Serializable; +import org.apache.maven.scm.repository.ScmRepository; + /** * Base class for SCM wrapped parameters. * Unlike {@link ScmResult}, this is mutable, as its use requires more flexibility when configuring the call. @@ -35,9 +34,7 @@ * @author Petr Kozelka * @since 1.8 */ -public class ScmRequest - implements Serializable -{ +public class ScmRequest implements Serializable { private static final long serialVersionUID = 20120620L; private ScmRepository scmRepository; @@ -46,32 +43,27 @@ public class ScmRequest protected final CommandParameters parameters = new CommandParameters(); - public ScmRequest() - { + public ScmRequest() { // no op } - public ScmRequest( ScmRepository scmRepository, ScmFileSet scmFileSet ) - { + public ScmRequest(ScmRepository scmRepository, ScmFileSet scmFileSet) { this.scmRepository = scmRepository; this.scmFileSet = scmFileSet; } - public ScmRepository getScmRepository() - { + public ScmRepository getScmRepository() { return scmRepository; } /** * @param scmRepository the source control system */ - public void setScmRepository( ScmRepository scmRepository ) - { + public void setScmRepository(ScmRepository scmRepository) { this.scmRepository = scmRepository; } - public ScmFileSet getScmFileSet() - { + public ScmFileSet getScmFileSet() { return scmFileSet; } @@ -80,8 +72,7 @@ public ScmFileSet getScmFileSet() * {@link org.apache.maven.scm.ScmFileSet#getBasedir()} downwards. * @param scmFileSet working copy and its selected files */ - public void setScmFileSet( ScmFileSet scmFileSet ) - { + public void setScmFileSet(ScmFileSet scmFileSet) { this.scmFileSet = scmFileSet; } @@ -90,8 +81,7 @@ public void setScmFileSet( ScmFileSet scmFileSet ) * These parameters are usually translated to commandline options or arguments. * @return command parameters */ - public CommandParameters getCommandParameters() - { + public CommandParameters getCommandParameters() { return parameters; } } diff --git a/maven-scm-api/src/main/java/org/apache/maven/scm/ScmResult.java b/maven-scm-api/src/main/java/org/apache/maven/scm/ScmResult.java index aefd9a555..229675091 100644 --- a/maven-scm-api/src/main/java/org/apache/maven/scm/ScmResult.java +++ b/maven-scm-api/src/main/java/org/apache/maven/scm/ScmResult.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm; import java.io.Serializable; import java.util.regex.Matcher; @@ -27,9 +26,7 @@ * @author Trygve Laugstøl * */ -public class ScmResult - implements Serializable -{ +public class ScmResult implements Serializable { private static final long serialVersionUID = 7037918334820621525L; private final boolean success; @@ -40,11 +37,10 @@ public class ScmResult private final String commandLine; - public static final String PASSWORD_PLACE_HOLDER = "********"; - //works for SVN and git - private Pattern patternForUserColonPasswordAtHost = Pattern.compile( "^.*:(.*)@.*$", Pattern.DOTALL ); + // works for SVN and git + private Pattern patternForUserColonPasswordAtHost = Pattern.compile("^.*:(.*)@.*$", Pattern.DOTALL); /** * Copy constructor. @@ -54,18 +50,16 @@ public class ScmResult * * @param scmResult not null */ - public ScmResult( ScmResult scmResult ) - { + public ScmResult(ScmResult scmResult) { this.commandLine = scmResult.commandLine; this.providerMessage = scmResult.providerMessage; - this.commandOutput = masked( scmResult.commandOutput ); + this.commandOutput = masked(scmResult.commandOutput); this.success = scmResult.success; } - /** * ScmResult contructor. * @@ -74,13 +68,12 @@ public ScmResult( ScmResult scmResult ) * @param commandOutput The command output of the scm tool * @param success True if the command is in success */ - public ScmResult( String commandLine, String providerMessage, String commandOutput, boolean success ) - { + public ScmResult(String commandLine, String providerMessage, String commandOutput, boolean success) { this.commandLine = commandLine; this.providerMessage = providerMessage; - this.commandOutput = masked( commandOutput ); + this.commandOutput = masked(commandOutput); this.success = success; } @@ -88,8 +81,7 @@ public ScmResult( String commandLine, String providerMessage, String commandOutp /** * @return True if the command was in success */ - public boolean isSuccess() - { + public boolean isSuccess() { return success; } @@ -97,8 +89,7 @@ public boolean isSuccess() * @return A message from the provider. On success this would typically be null or * an empty string. On failure it would be the error message from the provider */ - public String getProviderMessage() - { + public String getProviderMessage() { return providerMessage; } @@ -106,31 +97,25 @@ public String getProviderMessage() * @return Output from Std.Out from the provider during execution * of the command that resulted in this */ - public String getCommandOutput() - { + public String getCommandOutput() { return commandOutput; } /** * @return The actual provider specific command that resulted in this */ - public String getCommandLine() - { + public String getCommandLine() { return commandLine; } - - private String masked( String commandOutput ) - { - if ( null != commandOutput ) - { - final Matcher passwordMatcher = patternForUserColonPasswordAtHost.matcher( commandOutput ); - if ( passwordMatcher.find() ) - { + private String masked(String commandOutput) { + if (null != commandOutput) { + final Matcher passwordMatcher = patternForUserColonPasswordAtHost.matcher(commandOutput); + if (passwordMatcher.find()) { // clear password - final String clearPassword = passwordMatcher.group( 1 ); + final String clearPassword = passwordMatcher.group(1); // to be replaced in output by stars - commandOutput = commandOutput.replace( clearPassword, PASSWORD_PLACE_HOLDER ); + commandOutput = commandOutput.replace(clearPassword, PASSWORD_PLACE_HOLDER); } } return commandOutput; diff --git a/maven-scm-api/src/main/java/org/apache/maven/scm/ScmRevision.java b/maven-scm-api/src/main/java/org/apache/maven/scm/ScmRevision.java index 76b70eceb..9d8983aa0 100644 --- a/maven-scm-api/src/main/java/org/apache/maven/scm/ScmRevision.java +++ b/maven-scm-api/src/main/java/org/apache/maven/scm/ScmRevision.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,24 +16,21 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm; /** * @author Emmanuel Venisse * */ -public class ScmRevision - extends AbstractScmVersion -{ +public class ScmRevision extends AbstractScmVersion { private static final long serialVersionUID = 3831426256650754391L; /** {@inheritDoc} */ - public String getType() - { + public String getType() { return "Revision"; } - public ScmRevision( String name ) - { - super( name ); + public ScmRevision(String name) { + super(name); } } diff --git a/maven-scm-api/src/main/java/org/apache/maven/scm/ScmTag.java b/maven-scm-api/src/main/java/org/apache/maven/scm/ScmTag.java index 162b592dd..3b5be6546 100644 --- a/maven-scm-api/src/main/java/org/apache/maven/scm/ScmTag.java +++ b/maven-scm-api/src/main/java/org/apache/maven/scm/ScmTag.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,27 +16,24 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm; /** * @author Emmanuel Venisse * */ -public class ScmTag - extends ScmBranch -{ +public class ScmTag extends ScmBranch { private static final long serialVersionUID = 2286671802987769257L; /** {@inheritDoc} */ - public String getType() - { + public String getType() { return "Tag"; } /** * @param name not null */ - public ScmTag( String name ) - { - super( name ); + public ScmTag(String name) { + super(name); } } diff --git a/maven-scm-api/src/main/java/org/apache/maven/scm/ScmTagParameters.java b/maven-scm-api/src/main/java/org/apache/maven/scm/ScmTagParameters.java index 12cea80b2..c3f7dcf51 100644 --- a/maven-scm-api/src/main/java/org/apache/maven/scm/ScmTagParameters.java +++ b/maven-scm-api/src/main/java/org/apache/maven/scm/ScmTagParameters.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm; import java.io.Serializable; @@ -25,9 +24,7 @@ * @author Olivier Lamy * @since 1.2 */ -public class ScmTagParameters - implements Serializable -{ +public class ScmTagParameters implements Serializable { private static final long serialVersionUID = 7241536408630606807L; private String message; @@ -40,70 +37,57 @@ public class ScmTagParameters private String scmRevision; - public ScmTagParameters() - { + public ScmTagParameters() { this.remoteTagging = false; this.pinExternals = false; this.sign = false; } - public ScmTagParameters( String message ) - { + public ScmTagParameters(String message) { this.message = message; } - public String getMessage() - { + public String getMessage() { return message; } - public void setMessage( String message ) - { + public void setMessage(String message) { this.message = message; } - public boolean isRemoteTagging() - { + public boolean isRemoteTagging() { return remoteTagging; } - public void setRemoteTagging( boolean remoteTagging ) - { + public void setRemoteTagging(boolean remoteTagging) { this.remoteTagging = remoteTagging; } - public boolean isPinExternals() - { + public boolean isPinExternals() { return pinExternals; } - public void setPinExternals( boolean pinExternals ) - { + public void setPinExternals(boolean pinExternals) { this.pinExternals = pinExternals; } - public boolean isSign() - { + public boolean isSign() { return sign; } - public void setSign( boolean sign ) - { + public void setSign(boolean sign) { this.sign = sign; } - public String getScmRevision() - { + public String getScmRevision() { return scmRevision; } - public void setScmRevision( String scmRevision ) - { + public void setScmRevision(String scmRevision) { this.scmRevision = scmRevision; } - public String toString() - { + public String toString() { return "[" + scmRevision + "] " + message; } } diff --git a/maven-scm-api/src/main/java/org/apache/maven/scm/ScmUntagParameters.java b/maven-scm-api/src/main/java/org/apache/maven/scm/ScmUntagParameters.java index cda8ab3f4..099ce7460 100644 --- a/maven-scm-api/src/main/java/org/apache/maven/scm/ScmUntagParameters.java +++ b/maven-scm-api/src/main/java/org/apache/maven/scm/ScmUntagParameters.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm; import java.io.Serializable; @@ -26,9 +25,7 @@ * * @since 1.11.2 */ -public class ScmUntagParameters - implements Serializable -{ +public class ScmUntagParameters implements Serializable { /** * serial version id */ @@ -50,8 +47,7 @@ public class ScmUntagParameters * @param tag tag id * @param message commit message */ - public ScmUntagParameters( String tag, String message ) - { + public ScmUntagParameters(String tag, String message) { this.tag = tag; this.message = message; } @@ -61,8 +57,7 @@ public ScmUntagParameters( String tag, String message ) * * @return tag id */ - public String getTag() - { + public String getTag() { return tag; } @@ -71,8 +66,7 @@ public String getTag() * * @param tag tag id */ - public void setTag( String tag ) - { + public void setTag(String tag) { this.tag = tag; } @@ -81,8 +75,7 @@ public void setTag( String tag ) * * @return commit message */ - public String getMessage() - { + public String getMessage() { return message; } @@ -91,14 +84,12 @@ public String getMessage() * * @param message commit message */ - public void setMessage( String message ) - { + public void setMessage(String message) { this.message = message; } @Override - public String toString() - { + public String toString() { return ScmUntagParameters.class.getSimpleName() + " [tag=" + tag + ", message=" + message + "]"; } } diff --git a/maven-scm-api/src/main/java/org/apache/maven/scm/ScmVersion.java b/maven-scm-api/src/main/java/org/apache/maven/scm/ScmVersion.java index f8bc9747f..9503c044a 100644 --- a/maven-scm-api/src/main/java/org/apache/maven/scm/ScmVersion.java +++ b/maven-scm-api/src/main/java/org/apache/maven/scm/ScmVersion.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,13 +16,13 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm; /** * @author Emmanuel Venisse * */ -public interface ScmVersion -{ +public interface ScmVersion { /** * @return the Version type like branch */ @@ -38,5 +36,5 @@ public interface ScmVersion /** * @param name new Version name could be null */ - void setName( String name ); + void setName(String name); } diff --git a/maven-scm-api/src/main/java/org/apache/maven/scm/command/AbstractCommand.java b/maven-scm-api/src/main/java/org/apache/maven/scm/command/AbstractCommand.java index 5dbceea3c..cb12be3ca 100644 --- a/maven-scm-api/src/main/java/org/apache/maven/scm/command/AbstractCommand.java +++ b/maven-scm-api/src/main/java/org/apache/maven/scm/command/AbstractCommand.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.command; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.command; import org.apache.maven.scm.CommandParameters; import org.apache.maven.scm.ScmException; @@ -32,36 +31,27 @@ * @author Trygve Laugstøl * */ -public abstract class AbstractCommand - implements Command -{ - protected Logger logger = LoggerFactory.getLogger( getClass() ); +public abstract class AbstractCommand implements Command { + protected Logger logger = LoggerFactory.getLogger(getClass()); - protected abstract ScmResult executeCommand( ScmProviderRepository repository, ScmFileSet fileSet, - CommandParameters parameters ) - throws ScmException; + protected abstract ScmResult executeCommand( + ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters) throws ScmException; /** {@inheritDoc} */ - public final ScmResult execute( ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters ) - throws ScmException - { - if ( repository == null ) - { - throw new NullPointerException( "repository cannot be null" ); + public final ScmResult execute(ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters) + throws ScmException { + if (repository == null) { + throw new NullPointerException("repository cannot be null"); } - if ( fileSet == null ) - { - throw new NullPointerException( "fileSet cannot be null" ); + if (fileSet == null) { + throw new NullPointerException("fileSet cannot be null"); } - try - { - return executeCommand( repository, fileSet, parameters ); - } - catch ( Exception ex ) - { - throw new ScmException( "Exception while executing SCM command.", ex ); + try { + return executeCommand(repository, fileSet, parameters); + } catch (Exception ex) { + throw new ScmException("Exception while executing SCM command.", ex); } } } diff --git a/maven-scm-api/src/main/java/org/apache/maven/scm/command/Command.java b/maven-scm-api/src/main/java/org/apache/maven/scm/command/Command.java index 47cd10477..7debbf0bd 100644 --- a/maven-scm-api/src/main/java/org/apache/maven/scm/command/Command.java +++ b/maven-scm-api/src/main/java/org/apache/maven/scm/command/Command.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.command; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.command; import org.apache.maven.scm.CommandParameters; import org.apache.maven.scm.ScmException; @@ -30,8 +29,7 @@ * @author Trygve Laugstøl * */ -public interface Command -{ +public interface Command { /** Plexus component key */ String ROLE = Command.class.getName(); @@ -42,6 +40,6 @@ public interface Command * @return the result object * @throws ScmException if any */ - ScmResult execute( ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters ) - throws ScmException; + ScmResult execute(ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters) + throws ScmException; } diff --git a/maven-scm-api/src/main/java/org/apache/maven/scm/command/add/AbstractAddCommand.java b/maven-scm-api/src/main/java/org/apache/maven/scm/command/add/AbstractAddCommand.java index 4a65bb2a5..8553d6da6 100644 --- a/maven-scm-api/src/main/java/org/apache/maven/scm/command/add/AbstractAddCommand.java +++ b/maven-scm-api/src/main/java/org/apache/maven/scm/command/add/AbstractAddCommand.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.command.add; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.command.add; import org.apache.maven.scm.CommandParameter; import org.apache.maven.scm.CommandParameters; @@ -31,19 +30,17 @@ * @author Trygve Laugstøl * */ -public abstract class AbstractAddCommand - extends AbstractCommand -{ - protected abstract ScmResult executeAddCommand( ScmProviderRepository repository, ScmFileSet fileSet, - String message, boolean binary ) - throws ScmException; +public abstract class AbstractAddCommand extends AbstractCommand { + protected abstract ScmResult executeAddCommand( + ScmProviderRepository repository, ScmFileSet fileSet, String message, boolean binary) throws ScmException; /** {@inheritDoc} */ - protected ScmResult executeCommand( ScmProviderRepository repository, ScmFileSet fileSet, - CommandParameters parameters ) - throws ScmException - { - return executeAddCommand( repository, fileSet, parameters.getString( CommandParameter.MESSAGE, "no message" ), - parameters.getBoolean( CommandParameter.BINARY ) ); + protected ScmResult executeCommand( + ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters) throws ScmException { + return executeAddCommand( + repository, + fileSet, + parameters.getString(CommandParameter.MESSAGE, "no message"), + parameters.getBoolean(CommandParameter.BINARY)); } } diff --git a/maven-scm-api/src/main/java/org/apache/maven/scm/command/add/AddScmResult.java b/maven-scm-api/src/main/java/org/apache/maven/scm/command/add/AddScmResult.java index 507dc1eea..ade880aa5 100644 --- a/maven-scm-api/src/main/java/org/apache/maven/scm/command/add/AddScmResult.java +++ b/maven-scm-api/src/main/java/org/apache/maven/scm/command/add/AddScmResult.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.command.add; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.command.add; import java.util.ArrayList; import java.util.List; @@ -31,39 +30,32 @@ * @author Brett Porter * */ -public class AddScmResult - extends ScmResult -{ +public class AddScmResult extends ScmResult { private static final long serialVersionUID = 1L; - + private List addedFiles; - public AddScmResult( String commandLine, String providerMessage, String commandOutput, boolean success ) - { - super( commandLine, providerMessage, commandOutput, success ); + public AddScmResult(String commandLine, String providerMessage, String commandOutput, boolean success) { + super(commandLine, providerMessage, commandOutput, success); - addedFiles = new ArrayList( 0 ); + addedFiles = new ArrayList(0); } - public AddScmResult( String commandLine, List addedFiles ) - { - this( commandLine, null, null, true ); + public AddScmResult(String commandLine, List addedFiles) { + this(commandLine, null, null, true); - if ( addedFiles == null ) - { - throw new NullPointerException( "addedFiles can't be null" ); + if (addedFiles == null) { + throw new NullPointerException("addedFiles can't be null"); } this.addedFiles = addedFiles; } - public AddScmResult( List addedFiles, ScmResult result ) - { - super( result ); + public AddScmResult(List addedFiles, ScmResult result) { + super(result); - if ( addedFiles == null ) - { - throw new NullPointerException( "addedFiles can't be null" ); + if (addedFiles == null) { + throw new NullPointerException("addedFiles can't be null"); } this.addedFiles = addedFiles; @@ -74,8 +66,7 @@ public AddScmResult( List addedFiles, ScmResult result ) * * @return non null list of added files */ - public List getAddedFiles() - { + public List getAddedFiles() { return addedFiles; } } diff --git a/maven-scm-api/src/main/java/org/apache/maven/scm/command/blame/AbstractBlameCommand.java b/maven-scm-api/src/main/java/org/apache/maven/scm/command/blame/AbstractBlameCommand.java index d66298fa2..763d82f96 100644 --- a/maven-scm-api/src/main/java/org/apache/maven/scm/command/blame/AbstractBlameCommand.java +++ b/maven-scm-api/src/main/java/org/apache/maven/scm/command/blame/AbstractBlameCommand.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.command.blame; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.command.blame; import org.apache.maven.scm.CommandParameter; import org.apache.maven.scm.CommandParameters; @@ -31,21 +30,15 @@ * @author Evgeny Mandrikov * @since 1.4 */ -public abstract class AbstractBlameCommand - extends AbstractCommand -{ - public abstract BlameScmResult executeBlameCommand( ScmProviderRepository repo, ScmFileSet workingDirectory, - String filename ) - throws ScmException; +public abstract class AbstractBlameCommand extends AbstractCommand { + public abstract BlameScmResult executeBlameCommand( + ScmProviderRepository repo, ScmFileSet workingDirectory, String filename) throws ScmException; - protected ScmResult executeCommand( ScmProviderRepository repository, ScmFileSet workingDirectory, - CommandParameters parameters ) - throws ScmException - { - String file = parameters.getString( CommandParameter.FILE ); + protected ScmResult executeCommand( + ScmProviderRepository repository, ScmFileSet workingDirectory, CommandParameters parameters) + throws ScmException { + String file = parameters.getString(CommandParameter.FILE); - return executeBlameCommand( repository, workingDirectory, file ); + return executeBlameCommand(repository, workingDirectory, file); } - - } diff --git a/maven-scm-api/src/main/java/org/apache/maven/scm/command/blame/BlameLine.java b/maven-scm-api/src/main/java/org/apache/maven/scm/command/blame/BlameLine.java index 0cba26cdf..9e9a6ebc1 100644 --- a/maven-scm-api/src/main/java/org/apache/maven/scm/command/blame/BlameLine.java +++ b/maven-scm-api/src/main/java/org/apache/maven/scm/command/blame/BlameLine.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.command.blame; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.command.blame; import java.io.Serializable; import java.util.Date; @@ -26,9 +25,7 @@ * @author Evgeny Mandrikov * @since 1.4 */ -public class BlameLine - implements Serializable -{ +public class BlameLine implements Serializable { private static final long serialVersionUID = 2675122069344705612L; @@ -45,9 +42,8 @@ public class BlameLine * @param revision of the commit * @param author will also be used as committer identification */ - public BlameLine( Date date, String revision, String author ) - { - this( date, revision, author, author ); + public BlameLine(Date date, String revision, String author) { + this(date, revision, author, author); } /** @@ -57,64 +53,51 @@ public BlameLine( Date date, String revision, String author ) * @param author the person who wrote the line * @param committer the person who committed the change */ - public BlameLine( Date date, String revision, String author, String committer ) - { - setDate( date ); - setRevision( revision ); - setAuthor( author ); - setCommitter( committer ); + public BlameLine(Date date, String revision, String author, String committer) { + setDate(date); + setRevision(revision); + setAuthor(author); + setCommitter(committer); } - public String getRevision() - { + public String getRevision() { return revision; } - public void setRevision( String revision ) - { + public void setRevision(String revision) { this.revision = revision; } - public String getAuthor() - { + public String getAuthor() { return author; } - public void setAuthor( String author ) - { + public void setAuthor(String author) { this.author = author; } - public String getCommitter() - { + public String getCommitter() { return committer; } - public void setCommitter( String committer ) - { + public void setCommitter(String committer) { this.committer = committer; } /** * @return the commit date */ - public Date getDate() - { - if ( date != null ) - { + public Date getDate() { + if (date != null) { return (Date) date.clone(); } return null; } - public void setDate( Date date ) - { - if ( date != null ) - { - this.date = new Date( date.getTime() ); - } - else - { + public void setDate(Date date) { + if (date != null) { + this.date = new Date(date.getTime()); + } else { this.date = null; } } diff --git a/maven-scm-api/src/main/java/org/apache/maven/scm/command/blame/BlameScmRequest.java b/maven-scm-api/src/main/java/org/apache/maven/scm/command/blame/BlameScmRequest.java index b8eec3fc3..318c6b37e 100644 --- a/maven-scm-api/src/main/java/org/apache/maven/scm/command/blame/BlameScmRequest.java +++ b/maven-scm-api/src/main/java/org/apache/maven/scm/command/blame/BlameScmRequest.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.command.blame; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -18,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.command.blame; import org.apache.maven.scm.CommandParameter; import org.apache.maven.scm.ScmException; @@ -29,9 +28,7 @@ * @author Olivier Lamy * @since 1.8 */ -public class BlameScmRequest - extends ScmRequest -{ +public class BlameScmRequest extends ScmRequest { private static final long serialVersionUID = 8257038591897128936L; /** @@ -39,41 +36,29 @@ public class BlameScmRequest */ private boolean ignoreWhitespace; - - public BlameScmRequest( ScmRepository scmRepository, ScmFileSet scmFileSet ) - { - super( scmRepository, scmFileSet ); + public BlameScmRequest(ScmRepository scmRepository, ScmFileSet scmFileSet) { + super(scmRepository, scmFileSet); } - public void setFilename( String filename ) - throws ScmException - { - this.getCommandParameters().setString( CommandParameter.FILE, filename ); + public void setFilename(String filename) throws ScmException { + this.getCommandParameters().setString(CommandParameter.FILE, filename); } - public String getFilename() - throws ScmException - { - return this.getCommandParameters().getString( CommandParameter.FILE ); + public String getFilename() throws ScmException { + return this.getCommandParameters().getString(CommandParameter.FILE); } - public boolean isIgnoreWhitespace() - { + public boolean isIgnoreWhitespace() { return ignoreWhitespace; } - public void setIgnoreWhitespace( boolean ignoreWhitespace ) - throws ScmException - { + public void setIgnoreWhitespace(boolean ignoreWhitespace) throws ScmException { this.ignoreWhitespace = ignoreWhitespace; - if ( ignoreWhitespace ) - { - this.getCommandParameters().setString( CommandParameter.IGNORE_WHITESPACE, "TRUE" ); - } - else - { - this.getCommandParameters().setString( CommandParameter.IGNORE_WHITESPACE, "FALSE" ); + if (ignoreWhitespace) { + this.getCommandParameters().setString(CommandParameter.IGNORE_WHITESPACE, "TRUE"); + } else { + this.getCommandParameters().setString(CommandParameter.IGNORE_WHITESPACE, "FALSE"); } } } diff --git a/maven-scm-api/src/main/java/org/apache/maven/scm/command/blame/BlameScmResult.java b/maven-scm-api/src/main/java/org/apache/maven/scm/command/blame/BlameScmResult.java index ddbaf2ede..8db68a0b8 100644 --- a/maven-scm-api/src/main/java/org/apache/maven/scm/command/blame/BlameScmResult.java +++ b/maven-scm-api/src/main/java/org/apache/maven/scm/command/blame/BlameScmResult.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.command.blame; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.command.blame; import java.util.List; @@ -28,34 +27,28 @@ * @author Olivier Lamy * @since 1.4 */ -public class BlameScmResult - extends ScmResult -{ +public class BlameScmResult extends ScmResult { private static final long serialVersionUID = -3877526036464636595L; private List lines; - public BlameScmResult( String commandLine, List lines ) - { - this( commandLine, null, null, true ); + public BlameScmResult(String commandLine, List lines) { + this(commandLine, null, null, true); this.lines = lines; } - public BlameScmResult( String commandLine, String providerMessage, String commandOutput, boolean success ) - { - super( commandLine, providerMessage, commandOutput, success ); + public BlameScmResult(String commandLine, String providerMessage, String commandOutput, boolean success) { + super(commandLine, providerMessage, commandOutput, success); } - public BlameScmResult( List lines, ScmResult scmResult ) - { - super( scmResult ); + public BlameScmResult(List lines, ScmResult scmResult) { + super(scmResult); this.lines = lines; } - public List getLines() - { + public List getLines() { return lines; } } diff --git a/maven-scm-api/src/main/java/org/apache/maven/scm/command/branch/AbstractBranchCommand.java b/maven-scm-api/src/main/java/org/apache/maven/scm/command/branch/AbstractBranchCommand.java index 09fbf4d2e..b5a8cb0e1 100644 --- a/maven-scm-api/src/main/java/org/apache/maven/scm/command/branch/AbstractBranchCommand.java +++ b/maven-scm-api/src/main/java/org/apache/maven/scm/command/branch/AbstractBranchCommand.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.command.branch; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.command.branch; import org.apache.maven.scm.CommandParameter; import org.apache.maven.scm.CommandParameters; @@ -34,13 +33,11 @@ * @author Trygve Laugstøl * */ -public abstract class AbstractBranchCommand - extends AbstractCommand -{ - protected abstract ScmResult executeBranchCommand( ScmProviderRepository repository, ScmFileSet fileSet, - String branchName, String message ) - throws ScmException; - +public abstract class AbstractBranchCommand extends AbstractCommand { + protected abstract ScmResult executeBranchCommand( + ScmProviderRepository repository, ScmFileSet fileSet, String branchName, String message) + throws ScmException; + /** * default impl to provide backward comp * @since 1.3 @@ -51,30 +48,29 @@ protected abstract ScmResult executeBranchCommand( ScmProviderRepository reposit * @return TODO * @throws ScmException if any */ - protected ScmResult executeBranchCommand( ScmProviderRepository repository, ScmFileSet fileSet, String branchName, - ScmBranchParameters scmBranchParameters ) - throws ScmException - { - return executeBranchCommand( repository, fileSet, branchName, scmBranchParameters.getMessage() ); + protected ScmResult executeBranchCommand( + ScmProviderRepository repository, + ScmFileSet fileSet, + String branchName, + ScmBranchParameters scmBranchParameters) + throws ScmException { + return executeBranchCommand(repository, fileSet, branchName, scmBranchParameters.getMessage()); } /** {@inheritDoc} */ - public ScmResult executeCommand( ScmProviderRepository repository, ScmFileSet fileSet, - CommandParameters parameters ) - throws ScmException - { - String branchName = parameters.getString( CommandParameter.BRANCH_NAME ); + public ScmResult executeCommand(ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters) + throws ScmException { + String branchName = parameters.getString(CommandParameter.BRANCH_NAME); ScmBranchParameters scmBranchParameters = - parameters.getScmBranchParameters( CommandParameter.SCM_BRANCH_PARAMETERS ); - - String message = parameters.getString( CommandParameter.MESSAGE, "[maven-scm] copy for branch " + branchName ); - - if ( StringUtils.isBlank( scmBranchParameters.getMessage() ) && StringUtils.isNotBlank( message ) ) - { - scmBranchParameters.setMessage( message ); + parameters.getScmBranchParameters(CommandParameter.SCM_BRANCH_PARAMETERS); + + String message = parameters.getString(CommandParameter.MESSAGE, "[maven-scm] copy for branch " + branchName); + + if (StringUtils.isBlank(scmBranchParameters.getMessage()) && StringUtils.isNotBlank(message)) { + scmBranchParameters.setMessage(message); } - - return executeBranchCommand( repository, fileSet, branchName, scmBranchParameters ); + + return executeBranchCommand(repository, fileSet, branchName, scmBranchParameters); } } diff --git a/maven-scm-api/src/main/java/org/apache/maven/scm/command/branch/BranchScmResult.java b/maven-scm-api/src/main/java/org/apache/maven/scm/command/branch/BranchScmResult.java index 7c0bcc912..493d24e76 100644 --- a/maven-scm-api/src/main/java/org/apache/maven/scm/command/branch/BranchScmResult.java +++ b/maven-scm-api/src/main/java/org/apache/maven/scm/command/branch/BranchScmResult.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.command.branch; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.command.branch; import java.util.List; @@ -29,34 +28,28 @@ * @author Olivier Lamy * */ -public class BranchScmResult - extends ScmResult -{ +public class BranchScmResult extends ScmResult { private static final long serialVersionUID = -4241972929129557932L; private List branchedFiles; - public BranchScmResult( String commandLine, String providerMessage, String commandOutput, boolean success ) - { - super( commandLine, providerMessage, commandOutput, success ); + public BranchScmResult(String commandLine, String providerMessage, String commandOutput, boolean success) { + super(commandLine, providerMessage, commandOutput, success); } - public BranchScmResult( String commandLine, List branchedFiles ) - { - super( commandLine, null, null, true ); + public BranchScmResult(String commandLine, List branchedFiles) { + super(commandLine, null, null, true); this.branchedFiles = branchedFiles; } - public BranchScmResult( List branchedFiles, ScmResult result ) - { - super( result ); + public BranchScmResult(List branchedFiles, ScmResult result) { + super(result); this.branchedFiles = branchedFiles; } - public List getBranchedFiles() - { + public List getBranchedFiles() { return branchedFiles; } } diff --git a/maven-scm-api/src/main/java/org/apache/maven/scm/command/changelog/AbstractChangeLogCommand.java b/maven-scm-api/src/main/java/org/apache/maven/scm/command/changelog/AbstractChangeLogCommand.java index aeaae563e..1dd6f01cc 100644 --- a/maven-scm-api/src/main/java/org/apache/maven/scm/command/changelog/AbstractChangeLogCommand.java +++ b/maven-scm-api/src/main/java/org/apache/maven/scm/command/changelog/AbstractChangeLogCommand.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.command.changelog; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,9 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.command.changelog; + +import java.util.Date; import org.apache.maven.scm.CommandParameter; import org.apache.maven.scm.CommandParameters; @@ -29,111 +30,96 @@ import org.apache.maven.scm.command.AbstractCommand; import org.apache.maven.scm.provider.ScmProviderRepository; -import java.util.Date; - /** * @author Trygve Laugstøl * @author Olivier Lamy * */ -public abstract class AbstractChangeLogCommand - extends AbstractCommand - implements ChangeLogCommand -{ +public abstract class AbstractChangeLogCommand extends AbstractCommand implements ChangeLogCommand { @Deprecated - protected abstract ChangeLogScmResult executeChangeLogCommand( ScmProviderRepository repository, ScmFileSet fileSet, - Date startDate, Date endDate, ScmBranch branch, - String datePattern ) - throws ScmException; + protected abstract ChangeLogScmResult executeChangeLogCommand( + ScmProviderRepository repository, + ScmFileSet fileSet, + Date startDate, + Date endDate, + ScmBranch branch, + String datePattern) + throws ScmException; @Deprecated - protected ChangeLogScmResult executeChangeLogCommand( ScmProviderRepository repository, ScmFileSet fileSet, - ScmVersion startVersion, ScmVersion endVersion, - String datePattern ) - throws ScmException - { - throw new ScmException( "Unsupported method for this provider." ); + protected ChangeLogScmResult executeChangeLogCommand( + ScmProviderRepository repository, + ScmFileSet fileSet, + ScmVersion startVersion, + ScmVersion endVersion, + String datePattern) + throws ScmException { + throw new ScmException("Unsupported method for this provider."); } @Deprecated - protected ChangeLogScmResult executeChangeLogCommand( ScmProviderRepository repository, ScmFileSet fileSet, - ScmVersion version, String datePattern ) - throws ScmException - { - throw new ScmException( "Unsupported method for this provider." ); + protected ChangeLogScmResult executeChangeLogCommand( + ScmProviderRepository repository, ScmFileSet fileSet, ScmVersion version, String datePattern) + throws ScmException { + throw new ScmException("Unsupported method for this provider."); } /** * {@inheritDoc} */ - public ScmResult executeCommand( ScmProviderRepository repository, ScmFileSet fileSet, - CommandParameters parameters ) - throws ScmException - { - Date startDate = parameters.getDate( CommandParameter.START_DATE, null ); + public ScmResult executeCommand(ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters) + throws ScmException { + Date startDate = parameters.getDate(CommandParameter.START_DATE, null); - Date endDate = parameters.getDate( CommandParameter.END_DATE, null ); + Date endDate = parameters.getDate(CommandParameter.END_DATE, null); - int numDays = parameters.getInt( CommandParameter.NUM_DAYS, 0 ); + int numDays = parameters.getInt(CommandParameter.NUM_DAYS, 0); - Integer limit = parameters.getInt( CommandParameter.LIMIT, -1 ); - if ( limit < 1 ) - { + Integer limit = parameters.getInt(CommandParameter.LIMIT, -1); + if (limit < 1) { limit = null; } - ScmBranch branch = (ScmBranch) parameters.getScmVersion( CommandParameter.BRANCH, null ); + ScmBranch branch = (ScmBranch) parameters.getScmVersion(CommandParameter.BRANCH, null); - ScmVersion version = parameters.getScmVersion( CommandParameter.SCM_VERSION, null ); + ScmVersion version = parameters.getScmVersion(CommandParameter.SCM_VERSION, null); - ScmVersion startVersion = parameters.getScmVersion( CommandParameter.START_SCM_VERSION, null ); + ScmVersion startVersion = parameters.getScmVersion(CommandParameter.START_SCM_VERSION, null); - ScmVersion endVersion = parameters.getScmVersion( CommandParameter.END_SCM_VERSION, null ); + ScmVersion endVersion = parameters.getScmVersion(CommandParameter.END_SCM_VERSION, null); - String datePattern = parameters.getString( CommandParameter.CHANGELOG_DATE_PATTERN, null ); + String datePattern = parameters.getString(CommandParameter.CHANGELOG_DATE_PATTERN, null); boolean versionOnly = startVersion == null && endVersion == null && version != null; - if ( versionOnly ) - { - return executeChangeLogCommand( repository, fileSet, version, datePattern ); - } - else if ( startVersion != null || endVersion != null ) - { - return executeChangeLogCommand( repository, fileSet, startVersion, endVersion, datePattern ); - } - else - { - if ( numDays != 0 && ( startDate != null || endDate != null ) ) - { - throw new ScmException( "Start or end date cannot be set if num days is set." ); + if (versionOnly) { + return executeChangeLogCommand(repository, fileSet, version, datePattern); + } else if (startVersion != null || endVersion != null) { + return executeChangeLogCommand(repository, fileSet, startVersion, endVersion, datePattern); + } else { + if (numDays != 0 && (startDate != null || endDate != null)) { + throw new ScmException("Start or end date cannot be set if num days is set."); } - if ( endDate != null && startDate == null ) - { - throw new ScmException( "The end date is set but the start date isn't." ); + if (endDate != null && startDate == null) { + throw new ScmException("The end date is set but the start date isn't."); } - if ( numDays > 0 ) - { - @SuppressWarnings( "checkstyle:magicnumber" ) + if (numDays > 0) { + @SuppressWarnings("checkstyle:magicnumber") int day = 24 * 60 * 60 * 1000; - startDate = new Date( System.currentTimeMillis() - (long) numDays * day ); + startDate = new Date(System.currentTimeMillis() - (long) numDays * day); - endDate = new Date( System.currentTimeMillis() + (long) day ); - } - else if ( endDate == null ) - { + endDate = new Date(System.currentTimeMillis() + (long) day); + } else if (endDate == null) { endDate = new Date(); } - return executeChangeLogCommand( repository, fileSet, startDate, endDate, branch, datePattern ); + return executeChangeLogCommand(repository, fileSet, startDate, endDate, branch, datePattern); } } - protected ChangeLogScmResult executeChangeLogCommand( ChangeLogScmRequest request ) - throws ScmException - { - throw new ScmException( "Unsupported method for this provider." ); + protected ChangeLogScmResult executeChangeLogCommand(ChangeLogScmRequest request) throws ScmException { + throw new ScmException("Unsupported method for this provider."); } } diff --git a/maven-scm-api/src/main/java/org/apache/maven/scm/command/changelog/ChangeLogCommand.java b/maven-scm-api/src/main/java/org/apache/maven/scm/command/changelog/ChangeLogCommand.java index c9c0099a5..bb12fc53d 100644 --- a/maven-scm-api/src/main/java/org/apache/maven/scm/command/changelog/ChangeLogCommand.java +++ b/maven-scm-api/src/main/java/org/apache/maven/scm/command/changelog/ChangeLogCommand.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.command.changelog; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.command.changelog; import org.apache.maven.scm.CommandParameters; import org.apache.maven.scm.ScmException; @@ -29,8 +28,7 @@ * @author Emmanuel Venisse * */ -public interface ChangeLogCommand -{ - ScmResult executeCommand( ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters ) - throws ScmException; +public interface ChangeLogCommand { + ScmResult executeCommand(ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters) + throws ScmException; } diff --git a/maven-scm-api/src/main/java/org/apache/maven/scm/command/changelog/ChangeLogScmRequest.java b/maven-scm-api/src/main/java/org/apache/maven/scm/command/changelog/ChangeLogScmRequest.java index 3591ed009..517022cc8 100644 --- a/maven-scm-api/src/main/java/org/apache/maven/scm/command/changelog/ChangeLogScmRequest.java +++ b/maven-scm-api/src/main/java/org/apache/maven/scm/command/changelog/ChangeLogScmRequest.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.command.changelog; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,9 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.command.changelog; + +import java.util.Date; import org.apache.maven.scm.CommandParameter; import org.apache.maven.scm.ScmBranch; @@ -27,134 +28,99 @@ import org.apache.maven.scm.ScmVersion; import org.apache.maven.scm.repository.ScmRepository; -import java.util.Date; - /** * @author Petr Kozelka * @since 1.8 */ -public class ChangeLogScmRequest - extends ScmRequest -{ +public class ChangeLogScmRequest extends ScmRequest { private static final long serialVersionUID = 20120620L; - public ChangeLogScmRequest( ScmRepository scmRepository, ScmFileSet scmFileSet ) - { - super( scmRepository, scmFileSet ); + public ChangeLogScmRequest(ScmRepository scmRepository, ScmFileSet scmFileSet) { + super(scmRepository, scmFileSet); } - public ScmBranch getScmBranch() - throws ScmException - { - return (ScmBranch) parameters.getScmVersion( CommandParameter.BRANCH, null ); + public ScmBranch getScmBranch() throws ScmException { + return (ScmBranch) parameters.getScmVersion(CommandParameter.BRANCH, null); } - public void setScmBranch( ScmBranch scmBranch ) - throws ScmException - { - parameters.setScmVersion( CommandParameter.BRANCH, scmBranch ); + public void setScmBranch(ScmBranch scmBranch) throws ScmException { + parameters.setScmVersion(CommandParameter.BRANCH, scmBranch); } - public Date getStartDate() - throws ScmException - { - return parameters.getDate( CommandParameter.START_DATE ); + public Date getStartDate() throws ScmException { + return parameters.getDate(CommandParameter.START_DATE); } /** * @param startDate the start date of the period * @throws ScmException if any */ - public void setStartDate( Date startDate ) - throws ScmException - { - parameters.setDate( CommandParameter.START_DATE, startDate ); + public void setStartDate(Date startDate) throws ScmException { + parameters.setDate(CommandParameter.START_DATE, startDate); } - public Date getEndDate() - throws ScmException - { - return parameters.getDate( CommandParameter.END_DATE ); + public Date getEndDate() throws ScmException { + return parameters.getDate(CommandParameter.END_DATE); } /** * @param endDate the end date of the period * @throws ScmException if any */ - public void setEndDate( Date endDate ) - throws ScmException - { - parameters.setDate( CommandParameter.END_DATE, endDate ); + public void setEndDate(Date endDate) throws ScmException { + parameters.setDate(CommandParameter.END_DATE, endDate); } - public int getNumDays() - throws ScmException - { - return parameters.getInt( CommandParameter.START_DATE ); + public int getNumDays() throws ScmException { + return parameters.getInt(CommandParameter.START_DATE); } /** * @param numDays the number days before the current time if startdate and enddate are null * @throws ScmException if any */ - public void setNumDays( int numDays ) - throws ScmException - { - parameters.setInt( CommandParameter.NUM_DAYS, numDays ); + public void setNumDays(int numDays) throws ScmException { + parameters.setInt(CommandParameter.NUM_DAYS, numDays); } - public ScmVersion getStartRevision() - throws ScmException - { - return parameters.getScmVersion( CommandParameter.START_SCM_VERSION, null ); + public ScmVersion getStartRevision() throws ScmException { + return parameters.getScmVersion(CommandParameter.START_SCM_VERSION, null); } /** * @param startRevision the start branch/tag/revision * @throws ScmException if any */ - public void setStartRevision( ScmVersion startRevision ) - throws ScmException - { - parameters.setScmVersion( CommandParameter.START_SCM_VERSION, startRevision ); + public void setStartRevision(ScmVersion startRevision) throws ScmException { + parameters.setScmVersion(CommandParameter.START_SCM_VERSION, startRevision); } - public ScmVersion getEndRevision() - throws ScmException - { - return parameters.getScmVersion( CommandParameter.END_SCM_VERSION, null ); + public ScmVersion getEndRevision() throws ScmException { + return parameters.getScmVersion(CommandParameter.END_SCM_VERSION, null); } /** * @param endRevision the end branch/tag/revision * @throws ScmException if any */ - public void setEndRevision( ScmVersion endRevision ) - throws ScmException - { - parameters.setScmVersion( CommandParameter.END_SCM_VERSION, endRevision ); + public void setEndRevision(ScmVersion endRevision) throws ScmException { + parameters.setScmVersion(CommandParameter.END_SCM_VERSION, endRevision); } - public String getDatePattern() - throws ScmException - { - return parameters.getString( CommandParameter.CHANGELOG_DATE_PATTERN, null ); + public String getDatePattern() throws ScmException { + return parameters.getString(CommandParameter.CHANGELOG_DATE_PATTERN, null); } /** * @param datePattern the date pattern used in changelog output returned by scm tool * @throws ScmException if any */ - public void setDatePattern( String datePattern ) - throws ScmException - { - parameters.setString( CommandParameter.CHANGELOG_DATE_PATTERN, datePattern ); + public void setDatePattern(String datePattern) throws ScmException { + parameters.setString(CommandParameter.CHANGELOG_DATE_PATTERN, datePattern); } - public Integer getLimit() - throws ScmException - { - final int limit = parameters.getInt( CommandParameter.LIMIT, -1 ); + public Integer getLimit() throws ScmException { + final int limit = parameters.getInt(CommandParameter.LIMIT, -1); return limit > 0 ? limit : null; } @@ -162,35 +128,24 @@ public Integer getLimit() * @param limit the maximal count of returned changesets * @throws ScmException if any */ - public void setLimit( Integer limit ) - throws ScmException - { - if ( limit != null ) - { - parameters.setInt( CommandParameter.LIMIT, limit ); - } - else - { - parameters.remove( CommandParameter.LIMIT ); + public void setLimit(Integer limit) throws ScmException { + if (limit != null) { + parameters.setInt(CommandParameter.LIMIT, limit); + } else { + parameters.remove(CommandParameter.LIMIT); } } - public void setDateRange( Date startDate, Date endDate ) - throws ScmException - { - setStartDate( startDate ); - setEndDate( endDate ); + public void setDateRange(Date startDate, Date endDate) throws ScmException { + setStartDate(startDate); + setEndDate(endDate); } - public void setRevision( ScmVersion revision ) - throws ScmException - { - parameters.setScmVersion( CommandParameter.SCM_VERSION, revision ); + public void setRevision(ScmVersion revision) throws ScmException { + parameters.setScmVersion(CommandParameter.SCM_VERSION, revision); } - public ScmVersion getRevision() - throws ScmException - { - return parameters.getScmVersion( CommandParameter.SCM_VERSION, null ); + public ScmVersion getRevision() throws ScmException { + return parameters.getScmVersion(CommandParameter.SCM_VERSION, null); } } diff --git a/maven-scm-api/src/main/java/org/apache/maven/scm/command/changelog/ChangeLogScmResult.java b/maven-scm-api/src/main/java/org/apache/maven/scm/command/changelog/ChangeLogScmResult.java index 9826b639d..09044459d 100644 --- a/maven-scm-api/src/main/java/org/apache/maven/scm/command/changelog/ChangeLogScmResult.java +++ b/maven-scm-api/src/main/java/org/apache/maven/scm/command/changelog/ChangeLogScmResult.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.command.changelog; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.command.changelog; import org.apache.maven.scm.ScmResult; @@ -26,34 +25,28 @@ * @author Olivier Lamy * */ -public class ChangeLogScmResult - extends ScmResult -{ +public class ChangeLogScmResult extends ScmResult { private static final long serialVersionUID = 559431861541372265L; private ChangeLogSet changeLog; - public ChangeLogScmResult( String commandLine, String providerMessage, String commandOutput, boolean success ) - { - super( commandLine, providerMessage, commandOutput, success ); + public ChangeLogScmResult(String commandLine, String providerMessage, String commandOutput, boolean success) { + super(commandLine, providerMessage, commandOutput, success); } - public ChangeLogScmResult( String commandLine, ChangeLogSet changeLog ) - { - super( commandLine, null, null, true ); + public ChangeLogScmResult(String commandLine, ChangeLogSet changeLog) { + super(commandLine, null, null, true); this.changeLog = changeLog; } - public ChangeLogScmResult( ChangeLogSet changeLog, ScmResult result ) - { - super( result ); + public ChangeLogScmResult(ChangeLogSet changeLog, ScmResult result) { + super(result); this.changeLog = changeLog; } - public ChangeLogSet getChangeLog() - { + public ChangeLogSet getChangeLog() { return changeLog; } } diff --git a/maven-scm-api/src/main/java/org/apache/maven/scm/command/changelog/ChangeLogSet.java b/maven-scm-api/src/main/java/org/apache/maven/scm/command/changelog/ChangeLogSet.java index 7a545df9a..6f46c8ce3 100644 --- a/maven-scm-api/src/main/java/org/apache/maven/scm/command/changelog/ChangeLogSet.java +++ b/maven-scm-api/src/main/java/org/apache/maven/scm/command/changelog/ChangeLogSet.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.command.changelog; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.command.changelog; import java.text.SimpleDateFormat; import java.util.Date; @@ -30,8 +29,7 @@ * @author Emmanuel Venisse * */ -public class ChangeLogSet -{ +public class ChangeLogSet { public static final String DEFAULT_ENCODING = "ISO-8859-1"; private List entries; @@ -50,8 +48,7 @@ public class ChangeLogSet * @param startDate the start date/tag for this set. * @param endDate the end date/tag for this set, or null if this set goes to the present time. */ - public ChangeLogSet( Date startDate, Date endDate ) - { + public ChangeLogSet(Date startDate, Date endDate) { this.startDate = startDate; this.endDate = endDate; } @@ -63,10 +60,9 @@ public ChangeLogSet( Date startDate, Date endDate ) * @param startDate the start date/tag for this set. * @param endDate the end date/tag for this set, or null if this set goes to the present time. */ - public ChangeLogSet( List entries, Date startDate, Date endDate ) - { - this( startDate, endDate ); - setChangeSets( entries ); + public ChangeLogSet(List entries, Date startDate, Date endDate) { + this(startDate, endDate); + setChangeSets(entries); } /** @@ -74,8 +70,7 @@ public ChangeLogSet( List entries, Date startDate, Date endDate ) * * @return the start date. */ - public Date getStartDate() - { + public Date getStartDate() { return startDate; } @@ -84,8 +79,7 @@ public Date getStartDate() * * @return the end date for this set, or null if this set goes to the present time. */ - public Date getEndDate() - { + public Date getEndDate() { return endDate; } @@ -94,13 +88,11 @@ public Date getEndDate() * * @return the start version (revision/branch/label) for this set, or null. */ - public ScmVersion getStartVersion() - { + public ScmVersion getStartVersion() { return startVersion; } - public void setStartVersion( ScmVersion startVersion ) - { + public void setStartVersion(ScmVersion startVersion) { this.startVersion = startVersion; } @@ -109,13 +101,11 @@ public void setStartVersion( ScmVersion startVersion ) * * @return the end version (revision/branch/label) for this set, or null. */ - public ScmVersion getEndVersion() - { + public ScmVersion getEndVersion() { return endVersion; } - public void setEndVersion( ScmVersion endVersion ) - { + public void setEndVersion(ScmVersion endVersion) { this.endVersion = endVersion; } @@ -124,13 +114,11 @@ public void setEndVersion( ScmVersion endVersion ) * * @return the collection of {@link org.apache.maven.scm.ChangeSet} objects for this set. */ - public List getChangeSets() - { + public List getChangeSets() { return entries; } - public void setChangeSets( List changeSets ) - { + public void setChangeSets(List changeSets) { this.entries = changeSets; } @@ -139,9 +127,8 @@ public void setChangeSets( List changeSets ) * * @return TODO */ - public String toXML() - { - return toXML( DEFAULT_ENCODING ); + public String toXML() { + return toXML(DEFAULT_ENCODING); } /** @@ -150,59 +137,42 @@ public String toXML() * @param encoding encoding of output * @return TODO */ - public String toXML( String encoding ) - { + public String toXML(String encoding) { String encodingString = encoding; - if ( encodingString == null ) - { + if (encodingString == null) { encodingString = DEFAULT_ENCODING; } StringBuilder buffer = new StringBuilder(); String pattern = "yyyyMMdd HH:mm:ss z"; - SimpleDateFormat formatter = new SimpleDateFormat( pattern ); - - buffer.append( "\n" ); - buffer.append( "\n"); + buffer.append("\n" ); + buffer.append(">\n"); // Write out the entries - for ( ChangeSet changeSet : getChangeSets() ) - { - buffer.append( changeSet.toXML() ); + for (ChangeSet changeSet : getChangeSets()) { + buffer.append(changeSet.toXML()); } - buffer.append( "\n" ); + buffer.append("\n"); return buffer.toString(); } diff --git a/maven-scm-api/src/main/java/org/apache/maven/scm/command/checkin/AbstractCheckInCommand.java b/maven-scm-api/src/main/java/org/apache/maven/scm/command/checkin/AbstractCheckInCommand.java index 0204bc1d8..c09abd374 100644 --- a/maven-scm-api/src/main/java/org/apache/maven/scm/command/checkin/AbstractCheckInCommand.java +++ b/maven-scm-api/src/main/java/org/apache/maven/scm/command/checkin/AbstractCheckInCommand.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.command.checkin; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.command.checkin; import org.apache.maven.scm.CommandParameter; import org.apache.maven.scm.CommandParameters; @@ -34,23 +33,19 @@ * @author Olivier Lamy * */ -public abstract class AbstractCheckInCommand - extends AbstractCommand -{ +public abstract class AbstractCheckInCommand extends AbstractCommand { public static final String NAME = "check-in"; - protected abstract CheckInScmResult executeCheckInCommand( ScmProviderRepository repository, ScmFileSet fileSet, - String message, ScmVersion scmVersion ) - throws ScmException; + protected abstract CheckInScmResult executeCheckInCommand( + ScmProviderRepository repository, ScmFileSet fileSet, String message, ScmVersion scmVersion) + throws ScmException; - public ScmResult executeCommand( ScmProviderRepository repository, ScmFileSet fileSet, - CommandParameters parameters ) - throws ScmException - { - String message = parameters.getString( CommandParameter.MESSAGE ); + public ScmResult executeCommand(ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters) + throws ScmException { + String message = parameters.getString(CommandParameter.MESSAGE); - ScmVersion scmVersion = parameters.getScmVersion( CommandParameter.SCM_VERSION, null ); + ScmVersion scmVersion = parameters.getScmVersion(CommandParameter.SCM_VERSION, null); - return executeCheckInCommand( repository, fileSet, message, scmVersion ); + return executeCheckInCommand(repository, fileSet, message, scmVersion); } } diff --git a/maven-scm-api/src/main/java/org/apache/maven/scm/command/checkin/CheckInScmResult.java b/maven-scm-api/src/main/java/org/apache/maven/scm/command/checkin/CheckInScmResult.java index 3a5d8000e..a2c6aa609 100644 --- a/maven-scm-api/src/main/java/org/apache/maven/scm/command/checkin/CheckInScmResult.java +++ b/maven-scm-api/src/main/java/org/apache/maven/scm/command/checkin/CheckInScmResult.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.command.checkin; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.command.checkin; import java.util.ArrayList; import java.util.List; @@ -30,23 +29,19 @@ * @author Olivier Lamy * */ -public class CheckInScmResult - extends ScmResult -{ +public class CheckInScmResult extends ScmResult { private static final long serialVersionUID = 954225589449445354L; private List checkedInFiles; - + private String scmRevision; - public CheckInScmResult( String commandLine, String providerMessage, String commandOutput, boolean success ) - { - super( commandLine, providerMessage, commandOutput, success ); + public CheckInScmResult(String commandLine, String providerMessage, String commandOutput, boolean success) { + super(commandLine, providerMessage, commandOutput, success); } - public CheckInScmResult( String commandLine, List checkedInFiles ) - { - super( commandLine, null, null, true ); + public CheckInScmResult(String commandLine, List checkedInFiles) { + super(commandLine, null, null, true); this.checkedInFiles = checkedInFiles; } @@ -57,24 +52,20 @@ public CheckInScmResult( String commandLine, List checkedInFiles ) * @param scmRevision TODO * @since 1.2 */ - public CheckInScmResult( String commandLine, List checkedInFiles, String scmRevision ) - { - this( commandLine, checkedInFiles ); + public CheckInScmResult(String commandLine, List checkedInFiles, String scmRevision) { + this(commandLine, checkedInFiles); this.scmRevision = scmRevision; - } - - public CheckInScmResult( List checkedInFiles, ScmResult result ) - { - super( result ); + } + + public CheckInScmResult(List checkedInFiles, ScmResult result) { + super(result); this.checkedInFiles = checkedInFiles; } - - public List getCheckedInFiles() - { - if ( this.checkedInFiles == null ) - { + + public List getCheckedInFiles() { + if (this.checkedInFiles == null) { this.checkedInFiles = new ArrayList(); } return checkedInFiles; @@ -84,8 +75,7 @@ public List getCheckedInFiles() * @since 1.2 * @return can be null for some providers (implemented at least for svn) */ - public String getScmRevision() - { + public String getScmRevision() { return scmRevision; } } diff --git a/maven-scm-api/src/main/java/org/apache/maven/scm/command/checkout/AbstractCheckOutCommand.java b/maven-scm-api/src/main/java/org/apache/maven/scm/command/checkout/AbstractCheckOutCommand.java index 56d35c88b..90ce3f40d 100644 --- a/maven-scm-api/src/main/java/org/apache/maven/scm/command/checkout/AbstractCheckOutCommand.java +++ b/maven-scm-api/src/main/java/org/apache/maven/scm/command/checkout/AbstractCheckOutCommand.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.command.checkout; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.command.checkout; import org.apache.maven.scm.CommandParameter; import org.apache.maven.scm.CommandParameters; @@ -34,9 +33,7 @@ * @author Olivier Lamy * */ -public abstract class AbstractCheckOutCommand - extends AbstractCommand -{ +public abstract class AbstractCheckOutCommand extends AbstractCommand { /** * Execute Check out command line in a recursive check out way. * @@ -47,11 +44,9 @@ public abstract class AbstractCheckOutCommand * @throws ScmException if any * @see #executeCheckOutCommand(ScmProviderRepository, ScmFileSet, ScmVersion, boolean, boolean) */ - protected CheckOutScmResult executeCheckOutCommand( ScmProviderRepository repository, ScmFileSet fileSet, - ScmVersion scmVersion ) - throws ScmException - { - return executeCheckOutCommand( repository, fileSet, scmVersion, true, false ); + protected CheckOutScmResult executeCheckOutCommand( + ScmProviderRepository repository, ScmFileSet fileSet, ScmVersion scmVersion) throws ScmException { + return executeCheckOutCommand(repository, fileSet, scmVersion, true, false); } /** @@ -66,19 +61,20 @@ protected CheckOutScmResult executeCheckOutCommand( ScmProviderRepository reposi * @throws ScmException if any * @since 1.1.1 */ - protected abstract CheckOutScmResult executeCheckOutCommand( ScmProviderRepository repository, ScmFileSet fileSet, - ScmVersion scmVersion, boolean recursive, - boolean shallow ) - throws ScmException; + protected abstract CheckOutScmResult executeCheckOutCommand( + ScmProviderRepository repository, + ScmFileSet fileSet, + ScmVersion scmVersion, + boolean recursive, + boolean shallow) + throws ScmException; /** {@inheritDoc} */ - public ScmResult executeCommand( ScmProviderRepository repository, ScmFileSet fileSet, - CommandParameters parameters ) - throws ScmException - { - ScmVersion scmVersion = parameters.getScmVersion( CommandParameter.SCM_VERSION, null ); - boolean recursive = parameters.getBoolean( CommandParameter.RECURSIVE, true ); - boolean shallow = parameters.getBoolean( CommandParameter.SHALLOW, false ); - return executeCheckOutCommand( repository, fileSet, scmVersion, recursive, shallow ); + public ScmResult executeCommand(ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters) + throws ScmException { + ScmVersion scmVersion = parameters.getScmVersion(CommandParameter.SCM_VERSION, null); + boolean recursive = parameters.getBoolean(CommandParameter.RECURSIVE, true); + boolean shallow = parameters.getBoolean(CommandParameter.SHALLOW, false); + return executeCheckOutCommand(repository, fileSet, scmVersion, recursive, shallow); } } diff --git a/maven-scm-api/src/main/java/org/apache/maven/scm/command/checkout/CheckOutScmResult.java b/maven-scm-api/src/main/java/org/apache/maven/scm/command/checkout/CheckOutScmResult.java index 6e3ae21b1..a5198c134 100644 --- a/maven-scm-api/src/main/java/org/apache/maven/scm/command/checkout/CheckOutScmResult.java +++ b/maven-scm-api/src/main/java/org/apache/maven/scm/command/checkout/CheckOutScmResult.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.command.checkout; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,20 +16,19 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.command.checkout; + +import java.util.List; import org.apache.maven.scm.ScmFile; import org.apache.maven.scm.ScmResult; -import java.util.List; - /** * @author Trygve Laugstøl * @author Olivier Lamy * */ -public class CheckOutScmResult - extends ScmResult -{ +public class CheckOutScmResult extends ScmResult { private static final long serialVersionUID = 3345964619749320210L; @@ -54,54 +51,44 @@ public class CheckOutScmResult */ protected String relativePathProjectDirectory = ""; - public CheckOutScmResult( String commandLine, String providerMessage, String commandOutput, boolean success ) - { - super( commandLine, providerMessage, commandOutput, success ); + public CheckOutScmResult(String commandLine, String providerMessage, String commandOutput, boolean success) { + super(commandLine, providerMessage, commandOutput, success); } - public CheckOutScmResult( String commandLine, List checkedOutFiles ) - { - this( commandLine, null, checkedOutFiles ); + public CheckOutScmResult(String commandLine, List checkedOutFiles) { + this(commandLine, null, checkedOutFiles); } - public CheckOutScmResult( String commandLine, String revision, List checkedOutFiles ) - { - super( commandLine, null, null, true ); + public CheckOutScmResult(String commandLine, String revision, List checkedOutFiles) { + super(commandLine, null, null, true); this.revision = revision; this.checkedOutFiles = checkedOutFiles; } - public CheckOutScmResult( String commandLine, List checkedOutFiles, String relativePathProjectDirectory ) - { - this( commandLine, null, checkedOutFiles ); - if ( relativePathProjectDirectory != null ) - { + public CheckOutScmResult(String commandLine, List checkedOutFiles, String relativePathProjectDirectory) { + this(commandLine, null, checkedOutFiles); + if (relativePathProjectDirectory != null) { this.relativePathProjectDirectory = relativePathProjectDirectory; } } - public CheckOutScmResult( String commandLine, String revision, List checkedOutFiles, - String relativePathProjectDirectory ) - { - this( commandLine, revision, checkedOutFiles ); - if ( relativePathProjectDirectory != null ) - { + public CheckOutScmResult( + String commandLine, String revision, List checkedOutFiles, String relativePathProjectDirectory) { + this(commandLine, revision, checkedOutFiles); + if (relativePathProjectDirectory != null) { this.relativePathProjectDirectory = relativePathProjectDirectory; } - } - public CheckOutScmResult( List checkedOutFiles, ScmResult result ) - { - super( result ); + public CheckOutScmResult(List checkedOutFiles, ScmResult result) { + super(result); this.checkedOutFiles = checkedOutFiles; } - public List getCheckedOutFiles() - { + public List getCheckedOutFiles() { return checkedOutFiles; } @@ -109,8 +96,7 @@ public List getCheckedOutFiles() * @return the contents of {@link #relativePathProjectDirectory} * @see #relativePathProjectDirectory */ - public String getRelativePathProjectDirectory() - { + public String getRelativePathProjectDirectory() { return relativePathProjectDirectory; } @@ -121,8 +107,7 @@ public String getRelativePathProjectDirectory() * @return the revision that was checked out. * @since 1.8 */ - public String getRevision() - { + public String getRevision() { return revision; } } diff --git a/maven-scm-api/src/main/java/org/apache/maven/scm/command/diff/AbstractDiffCommand.java b/maven-scm-api/src/main/java/org/apache/maven/scm/command/diff/AbstractDiffCommand.java index 53049e77c..37d549546 100644 --- a/maven-scm-api/src/main/java/org/apache/maven/scm/command/diff/AbstractDiffCommand.java +++ b/maven-scm-api/src/main/java/org/apache/maven/scm/command/diff/AbstractDiffCommand.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.command.diff; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.command.diff; import org.apache.maven.scm.CommandParameter; import org.apache.maven.scm.CommandParameters; @@ -38,22 +37,18 @@ * @author Brett Porter * */ -public abstract class AbstractDiffCommand - extends AbstractCommand -{ - protected abstract DiffScmResult executeDiffCommand( ScmProviderRepository repository, ScmFileSet fileSet, - ScmVersion startRevision, ScmVersion endRevision ) - throws ScmException; +public abstract class AbstractDiffCommand extends AbstractCommand { + protected abstract DiffScmResult executeDiffCommand( + ScmProviderRepository repository, ScmFileSet fileSet, ScmVersion startRevision, ScmVersion endRevision) + throws ScmException; /** {@inheritDoc} */ - public ScmResult executeCommand( ScmProviderRepository repository, ScmFileSet fileSet, - CommandParameters parameters ) - throws ScmException - { - ScmVersion startRevision = parameters.getScmVersion( CommandParameter.START_SCM_VERSION, null ); + public ScmResult executeCommand(ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters) + throws ScmException { + ScmVersion startRevision = parameters.getScmVersion(CommandParameter.START_SCM_VERSION, null); - ScmVersion endRevision = parameters.getScmVersion( CommandParameter.END_SCM_VERSION, null ); + ScmVersion endRevision = parameters.getScmVersion(CommandParameter.END_SCM_VERSION, null); - return executeDiffCommand( repository, fileSet, startRevision, endRevision ); + return executeDiffCommand(repository, fileSet, startRevision, endRevision); } } diff --git a/maven-scm-api/src/main/java/org/apache/maven/scm/command/diff/DiffScmResult.java b/maven-scm-api/src/main/java/org/apache/maven/scm/command/diff/DiffScmResult.java index 64107e9a9..0ca17aed6 100644 --- a/maven-scm-api/src/main/java/org/apache/maven/scm/command/diff/DiffScmResult.java +++ b/maven-scm-api/src/main/java/org/apache/maven/scm/command/diff/DiffScmResult.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.command.diff; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.command.diff; import java.util.List; import java.util.Map; @@ -29,9 +28,7 @@ * @author Brett Porter * */ -public class DiffScmResult - extends ScmResult -{ +public class DiffScmResult extends ScmResult { private static final long serialVersionUID = 4036970486972633082L; private List changedFiles; @@ -40,24 +37,21 @@ public class DiffScmResult private String patch; - public DiffScmResult( String commandLine, List changedFiles, Map differences, - String patch ) - { - this( commandLine, null, null, true ); + public DiffScmResult( + String commandLine, List changedFiles, Map differences, String patch) { + this(commandLine, null, null, true); this.changedFiles = changedFiles; this.differences = differences; this.patch = patch; } - public DiffScmResult( String commandLine, String providerMessage, String commandOutput, boolean success ) - { - super( commandLine, providerMessage, commandOutput, success ); + public DiffScmResult(String commandLine, String providerMessage, String commandOutput, boolean success) { + super(commandLine, providerMessage, commandOutput, success); } - public DiffScmResult( List changedFiles, Map differences, String patch, - ScmResult result ) - { - super( result ); + public DiffScmResult( + List changedFiles, Map differences, String patch, ScmResult result) { + super(result); this.changedFiles = changedFiles; @@ -66,18 +60,15 @@ public DiffScmResult( List changedFiles, Map diff this.patch = patch; } - public List getChangedFiles() - { + public List getChangedFiles() { return changedFiles; } - public Map getDifferences() - { + public Map getDifferences() { return differences; } - public String getPatch() - { + public String getPatch() { return patch; } } diff --git a/maven-scm-api/src/main/java/org/apache/maven/scm/command/edit/AbstractEditCommand.java b/maven-scm-api/src/main/java/org/apache/maven/scm/command/edit/AbstractEditCommand.java index b8a98bce2..333de68cf 100644 --- a/maven-scm-api/src/main/java/org/apache/maven/scm/command/edit/AbstractEditCommand.java +++ b/maven-scm-api/src/main/java/org/apache/maven/scm/command/edit/AbstractEditCommand.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.command.edit; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.command.edit; import org.apache.maven.scm.CommandParameters; import org.apache.maven.scm.ScmException; @@ -29,17 +28,13 @@ /** * */ -public abstract class AbstractEditCommand - extends AbstractCommand -{ +public abstract class AbstractEditCommand extends AbstractCommand { /** {@inheritDoc} */ - public ScmResult executeCommand( ScmProviderRepository repository, ScmFileSet fileSet, - CommandParameters parameters ) - throws ScmException - { - return executeEditCommand( repository, fileSet ); + public ScmResult executeCommand(ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters) + throws ScmException { + return executeEditCommand(repository, fileSet); } - protected abstract ScmResult executeEditCommand( ScmProviderRepository repository, ScmFileSet fileSet ) - throws ScmException; + protected abstract ScmResult executeEditCommand(ScmProviderRepository repository, ScmFileSet fileSet) + throws ScmException; } diff --git a/maven-scm-api/src/main/java/org/apache/maven/scm/command/edit/EditScmResult.java b/maven-scm-api/src/main/java/org/apache/maven/scm/command/edit/EditScmResult.java index 5d7be1736..017dabf04 100644 --- a/maven-scm-api/src/main/java/org/apache/maven/scm/command/edit/EditScmResult.java +++ b/maven-scm-api/src/main/java/org/apache/maven/scm/command/edit/EditScmResult.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.command.edit; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.command.edit; import java.util.List; @@ -28,35 +27,28 @@ * @since 1.5 {@link ScmFile} will have the {@link org.apache.maven.scm.ScmFileStatus} * {@link org.apache.maven.scm.ScmFileStatus#EDITED} */ -public class EditScmResult - extends ScmResult -{ +public class EditScmResult extends ScmResult { private static final long serialVersionUID = -6274938710679161288L; private List editFiles; - public EditScmResult( String commandLine, String providerMessage, String commandOutput, boolean success ) - { - super( commandLine, providerMessage, commandOutput, success ); + public EditScmResult(String commandLine, String providerMessage, String commandOutput, boolean success) { + super(commandLine, providerMessage, commandOutput, success); } - public EditScmResult( String commandLine, List editFiles ) - { - super( commandLine, null, null, true ); + public EditScmResult(String commandLine, List editFiles) { + super(commandLine, null, null, true); this.editFiles = editFiles; } - public EditScmResult( List editFiles, ScmResult result ) - { - super( result ); + public EditScmResult(List editFiles, ScmResult result) { + super(result); this.editFiles = editFiles; } - public List getEditFiles() - { + public List getEditFiles() { return editFiles; } - } diff --git a/maven-scm-api/src/main/java/org/apache/maven/scm/command/export/AbstractExportCommand.java b/maven-scm-api/src/main/java/org/apache/maven/scm/command/export/AbstractExportCommand.java index 2097ce127..1de37edec 100644 --- a/maven-scm-api/src/main/java/org/apache/maven/scm/command/export/AbstractExportCommand.java +++ b/maven-scm-api/src/main/java/org/apache/maven/scm/command/export/AbstractExportCommand.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.command.export; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.command.export; import org.apache.maven.scm.CommandParameter; import org.apache.maven.scm.CommandParameters; @@ -32,22 +31,18 @@ * @author Emmanuel Venisse * */ -public abstract class AbstractExportCommand - extends AbstractCommand -{ - protected abstract ExportScmResult executeExportCommand( ScmProviderRepository repository, ScmFileSet fileSet, - ScmVersion scmVersion, String outputDirectory ) - throws ScmException; +public abstract class AbstractExportCommand extends AbstractCommand { + protected abstract ExportScmResult executeExportCommand( + ScmProviderRepository repository, ScmFileSet fileSet, ScmVersion scmVersion, String outputDirectory) + throws ScmException; /** {@inheritDoc} */ - protected ScmResult executeCommand( ScmProviderRepository repository, ScmFileSet fileSet, - CommandParameters parameters ) - throws ScmException - { - ScmVersion scmVersion = parameters.getScmVersion( CommandParameter.SCM_VERSION, null ); + protected ScmResult executeCommand( + ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters) throws ScmException { + ScmVersion scmVersion = parameters.getScmVersion(CommandParameter.SCM_VERSION, null); - String outputDirectory = parameters.getString( CommandParameter.OUTPUT_DIRECTORY, null ); + String outputDirectory = parameters.getString(CommandParameter.OUTPUT_DIRECTORY, null); - return executeExportCommand( repository, fileSet, scmVersion, outputDirectory ); + return executeExportCommand(repository, fileSet, scmVersion, outputDirectory); } } diff --git a/maven-scm-api/src/main/java/org/apache/maven/scm/command/export/ExportScmResult.java b/maven-scm-api/src/main/java/org/apache/maven/scm/command/export/ExportScmResult.java index d86c46a98..e4da89987 100644 --- a/maven-scm-api/src/main/java/org/apache/maven/scm/command/export/ExportScmResult.java +++ b/maven-scm-api/src/main/java/org/apache/maven/scm/command/export/ExportScmResult.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.command.export; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.command.export; import java.util.List; @@ -28,27 +27,22 @@ * @author Emmanuel Venisse * */ -public class ExportScmResult - extends ScmResult -{ +public class ExportScmResult extends ScmResult { private static final long serialVersionUID = 8564643361304165292L; private List exportedFiles; - public ExportScmResult( String commandLine, String providerMessage, String commandOutput, boolean success ) - { - super( commandLine, providerMessage, commandOutput, success ); + public ExportScmResult(String commandLine, String providerMessage, String commandOutput, boolean success) { + super(commandLine, providerMessage, commandOutput, success); } - public ExportScmResult( String commandLine, List updatedFiles ) - { - super( commandLine, null, null, true ); + public ExportScmResult(String commandLine, List updatedFiles) { + super(commandLine, null, null, true); this.exportedFiles = updatedFiles; } - public List getExportedFiles() - { + public List getExportedFiles() { return exportedFiles; } } diff --git a/maven-scm-api/src/main/java/org/apache/maven/scm/command/export/ExportScmResultWithRevision.java b/maven-scm-api/src/main/java/org/apache/maven/scm/command/export/ExportScmResultWithRevision.java index 23476ff6a..06d4d1e95 100644 --- a/maven-scm-api/src/main/java/org/apache/maven/scm/command/export/ExportScmResultWithRevision.java +++ b/maven-scm-api/src/main/java/org/apache/maven/scm/command/export/ExportScmResultWithRevision.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.command.export; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.command.export; import java.util.List; @@ -27,30 +26,25 @@ * @author Emmanuel Venisse * */ -public class ExportScmResultWithRevision - extends ExportScmResult -{ +public class ExportScmResultWithRevision extends ExportScmResult { private static final long serialVersionUID = -7962912849216079039L; private String revision; - public ExportScmResultWithRevision( String commandLine, String providerMessage, String commandOutput, - String revision, boolean success ) - { - super( commandLine, providerMessage, commandOutput, success ); + public ExportScmResultWithRevision( + String commandLine, String providerMessage, String commandOutput, String revision, boolean success) { + super(commandLine, providerMessage, commandOutput, success); this.revision = revision; } - public ExportScmResultWithRevision( String commandLine, List exportedFiles, String revision ) - { - super( commandLine, exportedFiles ); + public ExportScmResultWithRevision(String commandLine, List exportedFiles, String revision) { + super(commandLine, exportedFiles); this.revision = revision; } - public String getRevision() - { + public String getRevision() { return revision; } } diff --git a/maven-scm-api/src/main/java/org/apache/maven/scm/command/fileinfo/AbstractFileInfoCommand.java b/maven-scm-api/src/main/java/org/apache/maven/scm/command/fileinfo/AbstractFileInfoCommand.java index 10774e86d..a3a40bed7 100644 --- a/maven-scm-api/src/main/java/org/apache/maven/scm/command/fileinfo/AbstractFileInfoCommand.java +++ b/maven-scm-api/src/main/java/org/apache/maven/scm/command/fileinfo/AbstractFileInfoCommand.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.command.fileinfo; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,9 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.command.fileinfo; + +import java.io.File; import org.apache.maven.scm.CommandParameter; import org.apache.maven.scm.CommandParameters; @@ -26,26 +27,19 @@ import org.apache.maven.scm.command.AbstractCommand; import org.apache.maven.scm.provider.ScmProviderRepository; -import java.io.File; - /** * @author Emmanuel Venisse * @author Trygve Laugstøl * */ -public abstract class AbstractFileInfoCommand - extends AbstractCommand -{ - protected abstract ScmResult executeFileInfoCommand( ScmProviderRepository repository, File workingDirectory, - String filename ) - throws ScmException; +public abstract class AbstractFileInfoCommand extends AbstractCommand { + protected abstract ScmResult executeFileInfoCommand( + ScmProviderRepository repository, File workingDirectory, String filename) throws ScmException; - public ScmResult executeCommand( ScmProviderRepository repository, File workingDirectory, - CommandParameters parameters ) - throws ScmException - { - String file = parameters.getString( CommandParameter.FILE ); + public ScmResult executeCommand( + ScmProviderRepository repository, File workingDirectory, CommandParameters parameters) throws ScmException { + String file = parameters.getString(CommandParameter.FILE); - return executeFileInfoCommand( repository, workingDirectory, file ); + return executeFileInfoCommand(repository, workingDirectory, file); } } diff --git a/maven-scm-api/src/main/java/org/apache/maven/scm/command/info/InfoItem.java b/maven-scm-api/src/main/java/org/apache/maven/scm/command/info/InfoItem.java index 952e93573..83837dc91 100644 --- a/maven-scm-api/src/main/java/org/apache/maven/scm/command/info/InfoItem.java +++ b/maven-scm-api/src/main/java/org/apache/maven/scm/command/info/InfoItem.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.command.info; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.command.info; /** * @author Kenney Westerhof @@ -25,8 +24,7 @@ * * @since 1.5 */ -public class InfoItem -{ +public class InfoItem { private String path; private String url; @@ -47,103 +45,83 @@ public class InfoItem private String lastChangedDate; - public String getPath() - { + public String getPath() { return path; } - public void setPath( String path ) - { + public void setPath(String path) { this.path = path; } - public String getURL() - { + public String getURL() { return url; } - public void setURL( String url ) - { + public void setURL(String url) { this.url = url; } - public String getRepositoryRoot() - { + public String getRepositoryRoot() { return repositoryRoot; } - public void setRepositoryRoot( String repositoryRoot ) - { + public void setRepositoryRoot(String repositoryRoot) { this.repositoryRoot = repositoryRoot; } - public String getRepositoryUUID() - { + public String getRepositoryUUID() { return repositoryUUID; } - public void setRepositoryUUID( String repositoryUUID ) - { + public void setRepositoryUUID(String repositoryUUID) { this.repositoryUUID = repositoryUUID; } - public String getRevision() - { + public String getRevision() { return revision; } - public void setRevision( String revision ) - { + public void setRevision(String revision) { this.revision = revision; } - public String getNodeKind() - { + public String getNodeKind() { return nodeKind; } - public void setNodeKind( String nodeKind ) - { + public void setNodeKind(String nodeKind) { this.nodeKind = nodeKind; } - public String getSchedule() - { + public String getSchedule() { return schedule; } - public void setSchedule( String schedule ) - { + public void setSchedule(String schedule) { this.schedule = schedule; } - public String getLastChangedAuthor() - { + public String getLastChangedAuthor() { return lastChangedAuthor; } - public void setLastChangedAuthor( String lastChangedAuthor ) - { + public void setLastChangedAuthor(String lastChangedAuthor) { this.lastChangedAuthor = lastChangedAuthor; } - public String getLastChangedRevision() - { + public String getLastChangedRevision() { return lastChangedRevision; } - public void setLastChangedRevision( String lastChangedRevision ) - { + public void setLastChangedRevision(String lastChangedRevision) { this.lastChangedRevision = lastChangedRevision; } - public String getLastChangedDate() - { + public String getLastChangedDate() { return lastChangedDate; } - public void setLastChangedDate( String lastChangedDate ) - { + public void setLastChangedDate(String lastChangedDate) { this.lastChangedDate = lastChangedDate; } } diff --git a/maven-scm-api/src/main/java/org/apache/maven/scm/command/info/InfoScmResult.java b/maven-scm-api/src/main/java/org/apache/maven/scm/command/info/InfoScmResult.java index cd81c121e..9addc3fd9 100644 --- a/maven-scm-api/src/main/java/org/apache/maven/scm/command/info/InfoScmResult.java +++ b/maven-scm-api/src/main/java/org/apache/maven/scm/command/info/InfoScmResult.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.command.info; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,52 +16,46 @@ * specific language governing permissions and limitations * under the License. */ - -import org.apache.maven.scm.ScmResult; +package org.apache.maven.scm.command.info; import java.util.ArrayList; import java.util.List; +import org.apache.maven.scm.ScmResult; + /** * @author Kenney Westerhof * @author Olivier Lamy * */ -public class InfoScmResult - extends ScmResult -{ +public class InfoScmResult extends ScmResult { private static final long serialVersionUID = 955993340040530451L; private List infoItems; - public InfoScmResult( String commandLine, String providerMessage, String commandOutput, boolean success ) - { - super( commandLine, providerMessage, commandOutput, success ); + public InfoScmResult(String commandLine, String providerMessage, String commandOutput, boolean success) { + super(commandLine, providerMessage, commandOutput, success); - infoItems = new ArrayList( 0 ); + infoItems = new ArrayList(0); } - public InfoScmResult( String commandLine, List files ) - { - super( commandLine, null, null, true ); + public InfoScmResult(String commandLine, List files) { + super(commandLine, null, null, true); this.infoItems = files; } - public InfoScmResult( List infoItems, ScmResult result ) - { - super( result ); + public InfoScmResult(List infoItems, ScmResult result) { + super(result); this.infoItems = infoItems; } - public InfoScmResult( ScmResult result ) - { - super( result ); + public InfoScmResult(ScmResult result) { + super(result); } - public List getInfoItems() - { + public List getInfoItems() { return infoItems; } } diff --git a/maven-scm-api/src/main/java/org/apache/maven/scm/command/list/AbstractListCommand.java b/maven-scm-api/src/main/java/org/apache/maven/scm/command/list/AbstractListCommand.java index e5089a33d..ed7cb581e 100644 --- a/maven-scm-api/src/main/java/org/apache/maven/scm/command/list/AbstractListCommand.java +++ b/maven-scm-api/src/main/java/org/apache/maven/scm/command/list/AbstractListCommand.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.command.list; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.command.list; import org.apache.maven.scm.CommandParameter; import org.apache.maven.scm.CommandParameters; @@ -32,9 +31,7 @@ * @author Carlos Sanchez * */ -public abstract class AbstractListCommand - extends AbstractCommand -{ +public abstract class AbstractListCommand extends AbstractCommand { /** * List contents of the remote repository * @@ -45,24 +42,21 @@ public abstract class AbstractListCommand * @return the list of files * @throws ScmException if any */ - protected abstract ListScmResult executeListCommand( ScmProviderRepository repository, ScmFileSet fileSet, - boolean recursive, ScmVersion scmVersion ) - throws ScmException; + protected abstract ListScmResult executeListCommand( + ScmProviderRepository repository, ScmFileSet fileSet, boolean recursive, ScmVersion scmVersion) + throws ScmException; /** {@inheritDoc} */ - public ScmResult executeCommand( ScmProviderRepository repository, ScmFileSet fileSet, - CommandParameters parameters ) - throws ScmException - { - if ( fileSet.getFileList().isEmpty() ) - { - throw new IllegalArgumentException( "fileSet can not be empty" ); + public ScmResult executeCommand(ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters) + throws ScmException { + if (fileSet.getFileList().isEmpty()) { + throw new IllegalArgumentException("fileSet can not be empty"); } - boolean recursive = parameters.getBoolean( CommandParameter.RECURSIVE ); + boolean recursive = parameters.getBoolean(CommandParameter.RECURSIVE); - ScmVersion scmVersion = parameters.getScmVersion( CommandParameter.SCM_VERSION, null ); + ScmVersion scmVersion = parameters.getScmVersion(CommandParameter.SCM_VERSION, null); - return executeListCommand( repository, fileSet, recursive, scmVersion ); + return executeListCommand(repository, fileSet, recursive, scmVersion); } } diff --git a/maven-scm-api/src/main/java/org/apache/maven/scm/command/list/ListScmResult.java b/maven-scm-api/src/main/java/org/apache/maven/scm/command/list/ListScmResult.java index ac7760e93..acf846e3e 100644 --- a/maven-scm-api/src/main/java/org/apache/maven/scm/command/list/ListScmResult.java +++ b/maven-scm-api/src/main/java/org/apache/maven/scm/command/list/ListScmResult.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.command.list; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.command.list; import java.util.ArrayList; import java.util.List; @@ -32,37 +31,30 @@ * @author Carlos Sanchez * */ -public class ListScmResult - extends ScmResult -{ +public class ListScmResult extends ScmResult { private static final long serialVersionUID = 5402161066844465281L; private List files; - public ListScmResult( String commandLine, String providerMessage, String commandOutput, boolean success ) - { - super( commandLine, providerMessage, commandOutput, success ); + public ListScmResult(String commandLine, String providerMessage, String commandOutput, boolean success) { + super(commandLine, providerMessage, commandOutput, success); - files = new ArrayList( 0 ); + files = new ArrayList(0); } - public ListScmResult( String commandLine, List files ) - { - super( commandLine, null, null, true ); + public ListScmResult(String commandLine, List files) { + super(commandLine, null, null, true); this.files = files; } - public ListScmResult( List files, ScmResult result ) - { - super( result ); + public ListScmResult(List files, ScmResult result) { + super(result); this.files = files; } - public List getFiles() - { + public List getFiles() { return files; } - } diff --git a/maven-scm-api/src/main/java/org/apache/maven/scm/command/lock/AbstractLockCommand.java b/maven-scm-api/src/main/java/org/apache/maven/scm/command/lock/AbstractLockCommand.java index 46e689ea1..55da4e6a6 100644 --- a/maven-scm-api/src/main/java/org/apache/maven/scm/command/lock/AbstractLockCommand.java +++ b/maven-scm-api/src/main/java/org/apache/maven/scm/command/lock/AbstractLockCommand.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.command.lock; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,9 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.command.lock; + +import java.io.File; import org.apache.maven.scm.CommandParameter; import org.apache.maven.scm.CommandParameters; @@ -26,26 +27,19 @@ import org.apache.maven.scm.command.AbstractCommand; import org.apache.maven.scm.provider.ScmProviderRepository; -import java.io.File; - /** * @author Emmanuel Venisse * @author Trygve Laugstøl * */ -public abstract class AbstractLockCommand - extends AbstractCommand -{ - protected abstract ScmResult executeLockCommand( ScmProviderRepository repository, File workingDirectory, - String filename ) - throws ScmException; +public abstract class AbstractLockCommand extends AbstractCommand { + protected abstract ScmResult executeLockCommand( + ScmProviderRepository repository, File workingDirectory, String filename) throws ScmException; - public ScmResult executeCommand( ScmProviderRepository repository, File workingDirectory, - CommandParameters parameters ) - throws ScmException - { - String file = parameters.getString( CommandParameter.FILE ); + public ScmResult executeCommand( + ScmProviderRepository repository, File workingDirectory, CommandParameters parameters) throws ScmException { + String file = parameters.getString(CommandParameter.FILE); - return executeLockCommand( repository, workingDirectory, file ); + return executeLockCommand(repository, workingDirectory, file); } } diff --git a/maven-scm-api/src/main/java/org/apache/maven/scm/command/login/AbstractLoginCommand.java b/maven-scm-api/src/main/java/org/apache/maven/scm/command/login/AbstractLoginCommand.java index d2146983f..7dac7ee17 100644 --- a/maven-scm-api/src/main/java/org/apache/maven/scm/command/login/AbstractLoginCommand.java +++ b/maven-scm-api/src/main/java/org/apache/maven/scm/command/login/AbstractLoginCommand.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.command.login; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.command.login; import org.apache.maven.scm.CommandParameters; import org.apache.maven.scm.ScmException; @@ -30,18 +29,13 @@ * @author Emmanuel Venisse * */ -public abstract class AbstractLoginCommand - extends AbstractCommand -{ - public abstract LoginScmResult executeLoginCommand( ScmProviderRepository repository, ScmFileSet fileSet, - CommandParameters parameters ) - throws ScmException; +public abstract class AbstractLoginCommand extends AbstractCommand { + public abstract LoginScmResult executeLoginCommand( + ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters) throws ScmException; /** {@inheritDoc} */ - protected ScmResult executeCommand( ScmProviderRepository repository, ScmFileSet fileSet, - CommandParameters parameters ) - throws ScmException - { - return executeLoginCommand( repository, fileSet, parameters ); + protected ScmResult executeCommand( + ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters) throws ScmException { + return executeLoginCommand(repository, fileSet, parameters); } } diff --git a/maven-scm-api/src/main/java/org/apache/maven/scm/command/login/LoginScmResult.java b/maven-scm-api/src/main/java/org/apache/maven/scm/command/login/LoginScmResult.java index dd478f2cf..f5d9fc7b1 100644 --- a/maven-scm-api/src/main/java/org/apache/maven/scm/command/login/LoginScmResult.java +++ b/maven-scm-api/src/main/java/org/apache/maven/scm/command/login/LoginScmResult.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.command.login; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.command.login; import org.apache.maven.scm.ScmResult; @@ -25,14 +24,10 @@ * @author Emmanuel Venisse * */ -public class LoginScmResult - extends ScmResult -{ +public class LoginScmResult extends ScmResult { private static final long serialVersionUID = -179242524702253809L; - public LoginScmResult( String commandLine, String providerMessage, String commandOutput, boolean success ) - { - super( commandLine, providerMessage, commandOutput, success ); + public LoginScmResult(String commandLine, String providerMessage, String commandOutput, boolean success) { + super(commandLine, providerMessage, commandOutput, success); } - } diff --git a/maven-scm-api/src/main/java/org/apache/maven/scm/command/mkdir/AbstractMkdirCommand.java b/maven-scm-api/src/main/java/org/apache/maven/scm/command/mkdir/AbstractMkdirCommand.java index daa4ac58e..e2534b113 100644 --- a/maven-scm-api/src/main/java/org/apache/maven/scm/command/mkdir/AbstractMkdirCommand.java +++ b/maven-scm-api/src/main/java/org/apache/maven/scm/command/mkdir/AbstractMkdirCommand.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.command.mkdir; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.command.mkdir; import org.apache.maven.scm.CommandParameter; import org.apache.maven.scm.CommandParameters; @@ -31,12 +30,10 @@ * @author Maria Odea Ching * */ -public abstract class AbstractMkdirCommand - extends AbstractCommand -{ +public abstract class AbstractMkdirCommand extends AbstractCommand { /** * Creates directories in the remote repository. - * + * * @param repository TODO * @param fileSet TODO * @param message TODO @@ -44,22 +41,21 @@ public abstract class AbstractMkdirCommand * @return TODO * @throws ScmException if any */ - protected abstract MkdirScmResult executeMkdirCommand( ScmProviderRepository repository, ScmFileSet fileSet, - String message, boolean createInLocal ) - throws ScmException; + protected abstract MkdirScmResult executeMkdirCommand( + ScmProviderRepository repository, ScmFileSet fileSet, String message, boolean createInLocal) + throws ScmException; /** {@inheritDoc} */ - protected ScmResult executeCommand( ScmProviderRepository repository, ScmFileSet fileSet, - CommandParameters parameters ) - throws ScmException - { - if ( fileSet.getFileList().isEmpty() ) - { - throw new IllegalArgumentException( "fileSet can not be empty" ); + protected ScmResult executeCommand( + ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters) throws ScmException { + if (fileSet.getFileList().isEmpty()) { + throw new IllegalArgumentException("fileSet can not be empty"); } - return executeMkdirCommand( repository, fileSet, parameters.getString( CommandParameter.MESSAGE ), - parameters.getBoolean( CommandParameter.SCM_MKDIR_CREATE_IN_LOCAL ) ); + return executeMkdirCommand( + repository, + fileSet, + parameters.getString(CommandParameter.MESSAGE), + parameters.getBoolean(CommandParameter.SCM_MKDIR_CREATE_IN_LOCAL)); } - } diff --git a/maven-scm-api/src/main/java/org/apache/maven/scm/command/mkdir/MkdirScmResult.java b/maven-scm-api/src/main/java/org/apache/maven/scm/command/mkdir/MkdirScmResult.java index abee6d6ca..2ea1f26fd 100644 --- a/maven-scm-api/src/main/java/org/apache/maven/scm/command/mkdir/MkdirScmResult.java +++ b/maven-scm-api/src/main/java/org/apache/maven/scm/command/mkdir/MkdirScmResult.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.command.mkdir; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.command.mkdir; import java.util.List; @@ -30,60 +29,50 @@ * @author Maria Odea Ching * */ -public class MkdirScmResult - extends ScmResult -{ +public class MkdirScmResult extends ScmResult { private static final long serialVersionUID = -8717329738246682608L; private String revision; private List createdDirs; - public MkdirScmResult( ScmResult scmResult ) - { - super( scmResult ); + public MkdirScmResult(ScmResult scmResult) { + super(scmResult); } - public MkdirScmResult( String commandLine, String providerMessage, String commandOutput, boolean success ) - { - super( commandLine, providerMessage, commandOutput, success ); + public MkdirScmResult(String commandLine, String providerMessage, String commandOutput, boolean success) { + super(commandLine, providerMessage, commandOutput, success); } - public MkdirScmResult( String commandLine, String revision ) - { - this( commandLine, null, null, true ); + public MkdirScmResult(String commandLine, String revision) { + this(commandLine, null, null, true); this.revision = revision; } - public MkdirScmResult( String commandLine, List createdDirs ) - { - this( commandLine, null, null, true ); + public MkdirScmResult(String commandLine, List createdDirs) { + this(commandLine, null, null, true); this.createdDirs = createdDirs; } - public MkdirScmResult( String revision, ScmResult result ) - { - super( result ); + public MkdirScmResult(String revision, ScmResult result) { + super(result); this.revision = revision; } - public MkdirScmResult( List createdDirs, ScmResult result ) - { - super( result ); + public MkdirScmResult(List createdDirs, ScmResult result) { + super(result); this.createdDirs = createdDirs; } - public String getRevision() - { + public String getRevision() { return revision; } - public List getCreatedDirs() - { + public List getCreatedDirs() { return createdDirs; } } diff --git a/maven-scm-api/src/main/java/org/apache/maven/scm/command/remoteinfo/AbstractRemoteInfoCommand.java b/maven-scm-api/src/main/java/org/apache/maven/scm/command/remoteinfo/AbstractRemoteInfoCommand.java index aa5631964..00aa1b5eb 100644 --- a/maven-scm-api/src/main/java/org/apache/maven/scm/command/remoteinfo/AbstractRemoteInfoCommand.java +++ b/maven-scm-api/src/main/java/org/apache/maven/scm/command/remoteinfo/AbstractRemoteInfoCommand.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.command.remoteinfo; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -18,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.command.remoteinfo; import org.apache.maven.scm.CommandParameters; import org.apache.maven.scm.ScmException; @@ -30,19 +29,14 @@ * @author Olivier Lamy * @since 1.6 */ -public abstract class AbstractRemoteInfoCommand - extends AbstractCommand -{ +public abstract class AbstractRemoteInfoCommand extends AbstractCommand { - public abstract RemoteInfoScmResult executeRemoteInfoCommand( ScmProviderRepository repository, ScmFileSet fileSet, - CommandParameters parameters ) - throws ScmException; + public abstract RemoteInfoScmResult executeRemoteInfoCommand( + ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters) throws ScmException; @Override - protected ScmResult executeCommand( ScmProviderRepository repository, ScmFileSet fileSet, - CommandParameters parameters ) - throws ScmException - { - return executeRemoteInfoCommand( repository, fileSet, parameters ); + protected ScmResult executeCommand( + ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters) throws ScmException { + return executeRemoteInfoCommand(repository, fileSet, parameters); } } diff --git a/maven-scm-api/src/main/java/org/apache/maven/scm/command/remoteinfo/RemoteInfoScmResult.java b/maven-scm-api/src/main/java/org/apache/maven/scm/command/remoteinfo/RemoteInfoScmResult.java index a1cf883e8..a20a673a5 100644 --- a/maven-scm-api/src/main/java/org/apache/maven/scm/command/remoteinfo/RemoteInfoScmResult.java +++ b/maven-scm-api/src/main/java/org/apache/maven/scm/command/remoteinfo/RemoteInfoScmResult.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.command.remoteinfo; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -18,19 +16,18 @@ * specific language governing permissions and limitations * under the License. */ - -import org.apache.maven.scm.ScmResult; +package org.apache.maven.scm.command.remoteinfo; import java.util.HashMap; import java.util.Map; +import org.apache.maven.scm.ScmResult; + /** * @author Olivier Lamy * @since 1.6 */ -public class RemoteInfoScmResult - extends ScmResult -{ +public class RemoteInfoScmResult extends ScmResult { private static final long serialVersionUID = -5571403202068311222L; /** @@ -45,46 +42,39 @@ public class RemoteInfoScmResult */ private Map tags = new HashMap(); - public RemoteInfoScmResult( String commandLine, String providerMessage, String commandOutput, boolean success ) - { - super( commandLine, providerMessage, commandOutput, success ); + public RemoteInfoScmResult(String commandLine, String providerMessage, String commandOutput, boolean success) { + super(commandLine, providerMessage, commandOutput, success); } - public RemoteInfoScmResult( String commandLine, Map branches, Map tags ) - { - super( commandLine, null, null, true ); + public RemoteInfoScmResult(String commandLine, Map branches, Map tags) { + super(commandLine, null, null, true); this.branches = branches; this.tags = tags; } - public Map getBranches() - { + public Map getBranches() { return branches; } - public void setBranches( Map branches ) - { + public void setBranches(Map branches) { this.branches = branches; } - public Map getTags() - { + public Map getTags() { return tags; } - public void setTags( Map tags ) - { + public void setTags(Map tags) { this.tags = tags; } @Override - public String toString() - { + public String toString() { final StringBuilder sb = new StringBuilder(); - sb.append( "RemoteInfoScmResult" ); - sb.append( "{branches=" ).append( branches ); - sb.append( ", tags=" ).append( tags ); - sb.append( '}' ); + sb.append("RemoteInfoScmResult"); + sb.append("{branches=").append(branches); + sb.append(", tags=").append(tags); + sb.append('}'); return sb.toString(); } } diff --git a/maven-scm-api/src/main/java/org/apache/maven/scm/command/remove/AbstractRemoveCommand.java b/maven-scm-api/src/main/java/org/apache/maven/scm/command/remove/AbstractRemoveCommand.java index 406eb9a52..a89c230b3 100644 --- a/maven-scm-api/src/main/java/org/apache/maven/scm/command/remove/AbstractRemoveCommand.java +++ b/maven-scm-api/src/main/java/org/apache/maven/scm/command/remove/AbstractRemoveCommand.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.command.remove; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.command.remove; import org.apache.maven.scm.CommandParameter; import org.apache.maven.scm.CommandParameters; @@ -32,20 +31,15 @@ * @author Trygve Laugstøl * */ -public abstract class AbstractRemoveCommand - extends AbstractCommand -{ - protected abstract ScmResult executeRemoveCommand( ScmProviderRepository repository, ScmFileSet fileSet, - String message ) - throws ScmException; +public abstract class AbstractRemoveCommand extends AbstractCommand { + protected abstract ScmResult executeRemoveCommand( + ScmProviderRepository repository, ScmFileSet fileSet, String message) throws ScmException; /** {@inheritDoc} */ - protected ScmResult executeCommand( ScmProviderRepository repository, ScmFileSet fileSet, - CommandParameters parameters ) - throws ScmException - { - String message = parameters.getString( CommandParameter.MESSAGE ); + protected ScmResult executeCommand( + ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters) throws ScmException { + String message = parameters.getString(CommandParameter.MESSAGE); - return executeRemoveCommand( repository, fileSet, message ); + return executeRemoveCommand(repository, fileSet, message); } } diff --git a/maven-scm-api/src/main/java/org/apache/maven/scm/command/remove/RemoveScmResult.java b/maven-scm-api/src/main/java/org/apache/maven/scm/command/remove/RemoveScmResult.java index 5eb03a857..4685f81e3 100644 --- a/maven-scm-api/src/main/java/org/apache/maven/scm/command/remove/RemoveScmResult.java +++ b/maven-scm-api/src/main/java/org/apache/maven/scm/command/remove/RemoveScmResult.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.command.remove; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.command.remove; import java.util.List; @@ -29,34 +28,28 @@ * @author Olivier Lamy * */ -public class RemoveScmResult - extends ScmResult -{ +public class RemoveScmResult extends ScmResult { private static final long serialVersionUID = 8852310735079996771L; private List removedFiles; - public RemoveScmResult( String commandLine, String providerMessage, String commandOutput, boolean success ) - { - super( commandLine, providerMessage, commandOutput, success ); + public RemoveScmResult(String commandLine, String providerMessage, String commandOutput, boolean success) { + super(commandLine, providerMessage, commandOutput, success); } - public RemoveScmResult( String commandLine, List removedFiles ) - { - super( commandLine, null, null, true ); + public RemoveScmResult(String commandLine, List removedFiles) { + super(commandLine, null, null, true); this.removedFiles = removedFiles; } - public RemoveScmResult( List removedFiles, ScmResult result ) - { - super( result ); + public RemoveScmResult(List removedFiles, ScmResult result) { + super(result); this.removedFiles = removedFiles; } - public List getRemovedFiles() - { + public List getRemovedFiles() { return removedFiles; } } diff --git a/maven-scm-api/src/main/java/org/apache/maven/scm/command/status/AbstractStatusCommand.java b/maven-scm-api/src/main/java/org/apache/maven/scm/command/status/AbstractStatusCommand.java index 0fe059fed..5b48be64f 100644 --- a/maven-scm-api/src/main/java/org/apache/maven/scm/command/status/AbstractStatusCommand.java +++ b/maven-scm-api/src/main/java/org/apache/maven/scm/command/status/AbstractStatusCommand.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.command.status; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.command.status; import org.apache.maven.scm.CommandParameters; import org.apache.maven.scm.ScmException; @@ -30,17 +29,13 @@ * @author Brett Porter * */ -public abstract class AbstractStatusCommand - extends AbstractCommand -{ - protected abstract StatusScmResult executeStatusCommand( ScmProviderRepository repository, ScmFileSet fileSet ) - throws ScmException; +public abstract class AbstractStatusCommand extends AbstractCommand { + protected abstract StatusScmResult executeStatusCommand(ScmProviderRepository repository, ScmFileSet fileSet) + throws ScmException; /** {@inheritDoc} */ - public ScmResult executeCommand( ScmProviderRepository repository, ScmFileSet fileSet, - CommandParameters parameters ) - throws ScmException - { - return executeStatusCommand( repository, fileSet ); + public ScmResult executeCommand(ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters) + throws ScmException { + return executeStatusCommand(repository, fileSet); } } diff --git a/maven-scm-api/src/main/java/org/apache/maven/scm/command/status/StatusScmResult.java b/maven-scm-api/src/main/java/org/apache/maven/scm/command/status/StatusScmResult.java index 8a4e8acf2..7985d2294 100644 --- a/maven-scm-api/src/main/java/org/apache/maven/scm/command/status/StatusScmResult.java +++ b/maven-scm-api/src/main/java/org/apache/maven/scm/command/status/StatusScmResult.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.command.status; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,57 +16,50 @@ * specific language governing permissions and limitations * under the License. */ - -import org.apache.maven.scm.ScmFile; -import org.apache.maven.scm.ScmResult; +package org.apache.maven.scm.command.status; import java.util.Collections; import java.util.List; +import org.apache.maven.scm.ScmFile; +import org.apache.maven.scm.ScmResult; + /** * @author Brett Porter * */ -public class StatusScmResult - extends ScmResult -{ +public class StatusScmResult extends ScmResult { private static final long serialVersionUID = 7152442589455369403L; - + private List changedFiles; - public StatusScmResult( String commandLine, String providerMessage, String commandOutput, boolean success ) - { - super( commandLine, providerMessage, commandOutput, success ); + public StatusScmResult(String commandLine, String providerMessage, String commandOutput, boolean success) { + super(commandLine, providerMessage, commandOutput, success); this.changedFiles = Collections.emptyList(); } - public StatusScmResult( String commandLine, List changedFiles ) - { - super( commandLine, null, null, true ); + public StatusScmResult(String commandLine, List changedFiles) { + super(commandLine, null, null, true); - if ( changedFiles == null ) - { - throw new NullPointerException( "changedFiles can't be null." ); + if (changedFiles == null) { + throw new NullPointerException("changedFiles can't be null."); } this.changedFiles = changedFiles; } - public StatusScmResult( List changedFiles, ScmResult result ) - { - super( result ); + public StatusScmResult(List changedFiles, ScmResult result) { + super(result); - if ( changedFiles == null ) - { - throw new NullPointerException( "changedFiles can't be null." ); + if (changedFiles == null) { + throw new NullPointerException("changedFiles can't be null."); } this.changedFiles = changedFiles; } - public List getChangedFiles() - { + public List getChangedFiles() { return changedFiles; } } diff --git a/maven-scm-api/src/main/java/org/apache/maven/scm/command/tag/AbstractTagCommand.java b/maven-scm-api/src/main/java/org/apache/maven/scm/command/tag/AbstractTagCommand.java index 17188c91c..0dec628c8 100644 --- a/maven-scm-api/src/main/java/org/apache/maven/scm/command/tag/AbstractTagCommand.java +++ b/maven-scm-api/src/main/java/org/apache/maven/scm/command/tag/AbstractTagCommand.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.command.tag; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.command.tag; import org.apache.maven.scm.CommandParameter; import org.apache.maven.scm.CommandParameters; @@ -33,9 +32,7 @@ * @author Trygve Laugstøl * */ -public abstract class AbstractTagCommand - extends AbstractCommand -{ +public abstract class AbstractTagCommand extends AbstractCommand { /** * @deprecated use method {@link #executeTagCommand(ScmProviderRepository, ScmFileSet, String, ScmTagParameters)} * @param repository TODO @@ -45,41 +42,34 @@ public abstract class AbstractTagCommand * @return TODO * @throws ScmException if any */ - protected ScmResult executeTagCommand( ScmProviderRepository repository, ScmFileSet fileSet, String tagName, - String message ) - throws ScmException - { - return executeTagCommand( repository, fileSet, tagName, new ScmTagParameters( message ) ); + protected ScmResult executeTagCommand( + ScmProviderRepository repository, ScmFileSet fileSet, String tagName, String message) throws ScmException { + return executeTagCommand(repository, fileSet, tagName, new ScmTagParameters(message)); } - protected abstract ScmResult executeTagCommand( ScmProviderRepository repository, ScmFileSet fileSet, - String tagName, ScmTagParameters scmTagParameters ) - throws ScmException; + protected abstract ScmResult executeTagCommand( + ScmProviderRepository repository, ScmFileSet fileSet, String tagName, ScmTagParameters scmTagParameters) + throws ScmException; /** {@inheritDoc} */ - public ScmResult executeCommand( ScmProviderRepository repository, ScmFileSet fileSet, - CommandParameters parameters ) - throws ScmException - { - String tagName = parameters.getString( CommandParameter.TAG_NAME ); + public ScmResult executeCommand(ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters) + throws ScmException { + String tagName = parameters.getString(CommandParameter.TAG_NAME); - ScmTagParameters scmTagParameters = parameters.getScmTagParameters( CommandParameter.SCM_TAG_PARAMETERS ); + ScmTagParameters scmTagParameters = parameters.getScmTagParameters(CommandParameter.SCM_TAG_PARAMETERS); - String message = parameters.getString( CommandParameter.MESSAGE, null ); + String message = parameters.getString(CommandParameter.MESSAGE, null); - if ( message != null ) - { + if (message != null) { // if message was passed by CommandParameter.MESSAGE then use it. - scmTagParameters.setMessage( message ); + scmTagParameters.setMessage(message); } - if ( scmTagParameters.getMessage() == null ) - { + if (scmTagParameters.getMessage() == null) { // if message hasn't been passed nor by ScmTagParameters nor by CommandParameter.MESSAGE then use default. - scmTagParameters.setMessage( "[maven-scm] copy for tag " + tagName ); + scmTagParameters.setMessage("[maven-scm] copy for tag " + tagName); } - return executeTagCommand( repository, fileSet, tagName, scmTagParameters ); + return executeTagCommand(repository, fileSet, tagName, scmTagParameters); } - } diff --git a/maven-scm-api/src/main/java/org/apache/maven/scm/command/tag/TagScmResult.java b/maven-scm-api/src/main/java/org/apache/maven/scm/command/tag/TagScmResult.java index 497b2e086..9939109c7 100644 --- a/maven-scm-api/src/main/java/org/apache/maven/scm/command/tag/TagScmResult.java +++ b/maven-scm-api/src/main/java/org/apache/maven/scm/command/tag/TagScmResult.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.command.tag; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.command.tag; import java.util.List; @@ -29,34 +28,28 @@ * @author Olivier Lamy * */ -public class TagScmResult - extends ScmResult -{ +public class TagScmResult extends ScmResult { private static final long serialVersionUID = -5068975000282095635L; - + private List taggedFiles; - public TagScmResult( String commandLine, String providerMessage, String commandOutput, boolean success ) - { - super( commandLine, providerMessage, commandOutput, success ); + public TagScmResult(String commandLine, String providerMessage, String commandOutput, boolean success) { + super(commandLine, providerMessage, commandOutput, success); } - public TagScmResult( String commandLine, List taggedFiles ) - { - super( commandLine, null, null, true ); + public TagScmResult(String commandLine, List taggedFiles) { + super(commandLine, null, null, true); this.taggedFiles = taggedFiles; } - public TagScmResult( List taggedFiles, ScmResult result ) - { - super( result ); + public TagScmResult(List taggedFiles, ScmResult result) { + super(result); this.taggedFiles = taggedFiles; } - public List getTaggedFiles() - { + public List getTaggedFiles() { return taggedFiles; } } diff --git a/maven-scm-api/src/main/java/org/apache/maven/scm/command/unedit/AbstractUnEditCommand.java b/maven-scm-api/src/main/java/org/apache/maven/scm/command/unedit/AbstractUnEditCommand.java index bc2b4cba7..929d2ca7d 100644 --- a/maven-scm-api/src/main/java/org/apache/maven/scm/command/unedit/AbstractUnEditCommand.java +++ b/maven-scm-api/src/main/java/org/apache/maven/scm/command/unedit/AbstractUnEditCommand.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.command.unedit; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.command.unedit; import org.apache.maven.scm.CommandParameters; import org.apache.maven.scm.ScmException; @@ -29,17 +28,13 @@ /** * */ -public abstract class AbstractUnEditCommand - extends AbstractCommand -{ +public abstract class AbstractUnEditCommand extends AbstractCommand { /** {@inheritDoc} */ - public ScmResult executeCommand( ScmProviderRepository repository, ScmFileSet fileSet, - CommandParameters parameters ) - throws ScmException - { - return executeUnEditCommand( repository, fileSet ); + public ScmResult executeCommand(ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters) + throws ScmException { + return executeUnEditCommand(repository, fileSet); } - protected abstract ScmResult executeUnEditCommand( ScmProviderRepository repository, ScmFileSet fileSet ) - throws ScmException; + protected abstract ScmResult executeUnEditCommand(ScmProviderRepository repository, ScmFileSet fileSet) + throws ScmException; } diff --git a/maven-scm-api/src/main/java/org/apache/maven/scm/command/unedit/UnEditScmResult.java b/maven-scm-api/src/main/java/org/apache/maven/scm/command/unedit/UnEditScmResult.java index 687079c2e..d029ff777 100644 --- a/maven-scm-api/src/main/java/org/apache/maven/scm/command/unedit/UnEditScmResult.java +++ b/maven-scm-api/src/main/java/org/apache/maven/scm/command/unedit/UnEditScmResult.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.command.unedit; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.command.unedit; import java.util.List; @@ -28,35 +27,28 @@ * @author Olivier Lamy * */ -public class UnEditScmResult - extends ScmResult -{ +public class UnEditScmResult extends ScmResult { private static final long serialVersionUID = 257465331122587798L; private List unEditFiles; - public UnEditScmResult( String commandLine, String providerMessage, String commandOutput, boolean success ) - { - super( commandLine, providerMessage, commandOutput, success ); + public UnEditScmResult(String commandLine, String providerMessage, String commandOutput, boolean success) { + super(commandLine, providerMessage, commandOutput, success); } - public UnEditScmResult( String commandLine, List unEditFiles ) - { - super( commandLine, null, null, true ); + public UnEditScmResult(String commandLine, List unEditFiles) { + super(commandLine, null, null, true); this.unEditFiles = unEditFiles; } - public UnEditScmResult( List unEditFiles, ScmResult result ) - { - super( result ); + public UnEditScmResult(List unEditFiles, ScmResult result) { + super(result); this.unEditFiles = unEditFiles; } - public List getUnEditFiles() - { + public List getUnEditFiles() { return unEditFiles; } - } diff --git a/maven-scm-api/src/main/java/org/apache/maven/scm/command/unlock/AbstractUnlockCommand.java b/maven-scm-api/src/main/java/org/apache/maven/scm/command/unlock/AbstractUnlockCommand.java index b38e5b8ed..2801f2a64 100644 --- a/maven-scm-api/src/main/java/org/apache/maven/scm/command/unlock/AbstractUnlockCommand.java +++ b/maven-scm-api/src/main/java/org/apache/maven/scm/command/unlock/AbstractUnlockCommand.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.command.unlock; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,9 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.command.unlock; + +import java.io.File; import org.apache.maven.scm.CommandParameters; import org.apache.maven.scm.ScmException; @@ -25,23 +26,17 @@ import org.apache.maven.scm.command.AbstractCommand; import org.apache.maven.scm.provider.ScmProviderRepository; -import java.io.File; - /** * @author Emmanuel Venisse * @author Trygve Laugstøl * */ -public abstract class AbstractUnlockCommand - extends AbstractCommand -{ - protected abstract ScmResult executeUnlockCommand( ScmProviderRepository repository, File workingDirectory ) - throws ScmException; +public abstract class AbstractUnlockCommand extends AbstractCommand { + protected abstract ScmResult executeUnlockCommand(ScmProviderRepository repository, File workingDirectory) + throws ScmException; - public ScmResult executeCommand( ScmProviderRepository repository, File workingDirectory, - CommandParameters parameters ) - throws ScmException - { - return executeUnlockCommand( repository, workingDirectory ); + public ScmResult executeCommand( + ScmProviderRepository repository, File workingDirectory, CommandParameters parameters) throws ScmException { + return executeUnlockCommand(repository, workingDirectory); } } diff --git a/maven-scm-api/src/main/java/org/apache/maven/scm/command/untag/AbstractUntagCommand.java b/maven-scm-api/src/main/java/org/apache/maven/scm/command/untag/AbstractUntagCommand.java index d3a9c16bb..a44eab243 100644 --- a/maven-scm-api/src/main/java/org/apache/maven/scm/command/untag/AbstractUntagCommand.java +++ b/maven-scm-api/src/main/java/org/apache/maven/scm/command/untag/AbstractUntagCommand.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.command.untag; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.command.untag; import org.apache.maven.scm.CommandParameter; import org.apache.maven.scm.CommandParameters; @@ -29,9 +28,7 @@ import org.apache.maven.scm.provider.ScmProviderRepository; /** {@inheritDoc} */ -public abstract class AbstractUntagCommand - extends AbstractCommand -{ +public abstract class AbstractUntagCommand extends AbstractCommand { /** * execute untag command * @@ -41,21 +38,18 @@ public abstract class AbstractUntagCommand * @return result of untag command * @throws ScmException in case of error */ - protected abstract ScmResult executeUntagCommand( ScmProviderRepository repository, - ScmFileSet fileSet, ScmUntagParameters scmUntagParameters ) - throws ScmException; + protected abstract ScmResult executeUntagCommand( + ScmProviderRepository repository, ScmFileSet fileSet, ScmUntagParameters scmUntagParameters) + throws ScmException; /** {@inheritDoc} */ @Override - public ScmResult executeCommand( ScmProviderRepository repository, ScmFileSet fileSet, - CommandParameters parameters ) - throws ScmException - { - String tagName = parameters.getString( CommandParameter.TAG_NAME ); - String message = parameters.getString( CommandParameter.MESSAGE, "[maven-scm] remove tag " + tagName ); - ScmUntagParameters scmUntagParameters = new ScmUntagParameters( tagName, message ); + public ScmResult executeCommand(ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters) + throws ScmException { + String tagName = parameters.getString(CommandParameter.TAG_NAME); + String message = parameters.getString(CommandParameter.MESSAGE, "[maven-scm] remove tag " + tagName); + ScmUntagParameters scmUntagParameters = new ScmUntagParameters(tagName, message); - return executeUntagCommand( repository, fileSet, scmUntagParameters ); + return executeUntagCommand(repository, fileSet, scmUntagParameters); } - } diff --git a/maven-scm-api/src/main/java/org/apache/maven/scm/command/untag/UntagScmResult.java b/maven-scm-api/src/main/java/org/apache/maven/scm/command/untag/UntagScmResult.java index 47babaf2f..dbbe769c3 100644 --- a/maven-scm-api/src/main/java/org/apache/maven/scm/command/untag/UntagScmResult.java +++ b/maven-scm-api/src/main/java/org/apache/maven/scm/command/untag/UntagScmResult.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.command.untag; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,27 +16,23 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.command.untag; import org.apache.maven.scm.ScmResult; /** {@inheritDoc} */ -public class UntagScmResult - extends ScmResult -{ +public class UntagScmResult extends ScmResult { private static final long serialVersionUID = -5068975000282095635L; - public UntagScmResult( String commandLine, String providerMessage, String commandOutput, boolean success ) - { - super( commandLine, providerMessage, commandOutput, success ); + public UntagScmResult(String commandLine, String providerMessage, String commandOutput, boolean success) { + super(commandLine, providerMessage, commandOutput, success); } - public UntagScmResult( String commandLine ) - { - super( commandLine, null, null, true ); + public UntagScmResult(String commandLine) { + super(commandLine, null, null, true); } - public UntagScmResult( ScmResult result ) - { - super( result ); + public UntagScmResult(ScmResult result) { + super(result); } } diff --git a/maven-scm-api/src/main/java/org/apache/maven/scm/command/update/AbstractUpdateCommand.java b/maven-scm-api/src/main/java/org/apache/maven/scm/command/update/AbstractUpdateCommand.java index 09f32376b..0d33b87d9 100644 --- a/maven-scm-api/src/main/java/org/apache/maven/scm/command/update/AbstractUpdateCommand.java +++ b/maven-scm-api/src/main/java/org/apache/maven/scm/command/update/AbstractUpdateCommand.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.command.update; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,11 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.command.update; + +import java.util.ArrayList; +import java.util.Date; +import java.util.List; import org.apache.maven.scm.ChangeSet; import org.apache.maven.scm.CommandParameter; @@ -33,80 +36,60 @@ import org.apache.maven.scm.command.changelog.ChangeLogSet; import org.apache.maven.scm.provider.ScmProviderRepository; -import java.util.ArrayList; -import java.util.Date; -import java.util.List; - /** * @author Emmanuel Venisse * @author Trygve Laugstøl * */ -public abstract class AbstractUpdateCommand - extends AbstractCommand -{ - protected abstract UpdateScmResult executeUpdateCommand( ScmProviderRepository repository, ScmFileSet fileSet, - ScmVersion scmVersion ) - throws ScmException; +public abstract class AbstractUpdateCommand extends AbstractCommand { + protected abstract UpdateScmResult executeUpdateCommand( + ScmProviderRepository repository, ScmFileSet fileSet, ScmVersion scmVersion) throws ScmException; /** {@inheritDoc} */ - public ScmResult executeCommand( ScmProviderRepository repository, ScmFileSet fileSet, - CommandParameters parameters ) - throws ScmException - { - ScmVersion scmVersion = parameters.getScmVersion( CommandParameter.SCM_VERSION, null ); + public ScmResult executeCommand(ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters) + throws ScmException { + ScmVersion scmVersion = parameters.getScmVersion(CommandParameter.SCM_VERSION, null); - boolean runChangelog = Boolean.valueOf( - parameters.getString( CommandParameter.RUN_CHANGELOG_WITH_UPDATE, "true" ) ).booleanValue(); + boolean runChangelog = Boolean.valueOf(parameters.getString(CommandParameter.RUN_CHANGELOG_WITH_UPDATE, "true")) + .booleanValue(); - UpdateScmResult updateScmResult = executeUpdateCommand( repository, fileSet, scmVersion ); + UpdateScmResult updateScmResult = executeUpdateCommand(repository, fileSet, scmVersion); List filesList = updateScmResult.getUpdatedFiles(); - if ( !runChangelog ) - { + if (!runChangelog) { return updateScmResult; } ChangeLogCommand changeLogCmd = getChangeLogCommand(); - if ( filesList != null && filesList.size() > 0 && changeLogCmd != null ) - { + if (filesList != null && filesList.size() > 0 && changeLogCmd != null) { ChangeLogScmResult changeLogScmResult = - (ChangeLogScmResult) changeLogCmd.executeCommand( repository, fileSet, parameters ); + (ChangeLogScmResult) changeLogCmd.executeCommand(repository, fileSet, parameters); List changes = new ArrayList(); ChangeLogSet changeLogSet = changeLogScmResult.getChangeLog(); - if ( changeLogSet != null ) - { + if (changeLogSet != null) { Date startDate = null; - try - { - startDate = parameters.getDate( CommandParameter.START_DATE ); - } - catch ( ScmException e ) - { - //Do nothing, startDate isn't define. + try { + startDate = parameters.getDate(CommandParameter.START_DATE); + } catch (ScmException e) { + // Do nothing, startDate isn't define. } - for ( ChangeSet change : changeLogSet.getChangeSets() ) - { - if ( startDate != null && change.getDate() != null ) - { - if ( startDate.after( change.getDate() ) ) - { + for (ChangeSet change : changeLogSet.getChangeSets()) { + if (startDate != null && change.getDate() != null) { + if (startDate.after(change.getDate())) { continue; } } - for ( ScmFile currentFile : filesList ) - { - if ( change.containsFilename( currentFile.getPath() ) ) - { - changes.add( change ); + for (ScmFile currentFile : filesList) { + if (change.containsFilename(currentFile.getPath())) { + changes.add(change); break; } @@ -114,7 +97,7 @@ public ScmResult executeCommand( ScmProviderRepository repository, ScmFileSet fi } } - updateScmResult.setChanges( changes ); + updateScmResult.setChanges(changes); } return updateScmResult; diff --git a/maven-scm-api/src/main/java/org/apache/maven/scm/command/update/UpdateScmResult.java b/maven-scm-api/src/main/java/org/apache/maven/scm/command/update/UpdateScmResult.java index 7bfabf24f..57296e06f 100644 --- a/maven-scm-api/src/main/java/org/apache/maven/scm/command/update/UpdateScmResult.java +++ b/maven-scm-api/src/main/java/org/apache/maven/scm/command/update/UpdateScmResult.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.command.update; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,43 +16,38 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.command.update; + +import java.util.ArrayList; +import java.util.List; import org.apache.maven.scm.ChangeSet; import org.apache.maven.scm.ScmFile; import org.apache.maven.scm.ScmResult; -import java.util.ArrayList; -import java.util.List; - /** * @author Trygve Laugstøl * */ -public class UpdateScmResult - extends ScmResult -{ +public class UpdateScmResult extends ScmResult { private static final long serialVersionUID = -1578149496089492585L; private List updatedFiles; private List changes; - public UpdateScmResult( String commandLine, String providerMessage, String commandOutput, boolean success ) - { - super( commandLine, providerMessage, commandOutput, success ); + public UpdateScmResult(String commandLine, String providerMessage, String commandOutput, boolean success) { + super(commandLine, providerMessage, commandOutput, success); } - public UpdateScmResult( String commandLine, List updatedFiles ) - { - super( commandLine, null, null, true ); + public UpdateScmResult(String commandLine, List updatedFiles) { + super(commandLine, null, null, true); this.updatedFiles = updatedFiles; - } - public UpdateScmResult( List updatedFiles, List changes, ScmResult result ) - { - super( result ); + public UpdateScmResult(List updatedFiles, List changes, ScmResult result) { + super(result); this.updatedFiles = updatedFiles; @@ -65,25 +58,21 @@ public UpdateScmResult( List updatedFiles, List changes, Scm * * @return List of {@link ScmFile} */ - public List getUpdatedFiles() - { + public List getUpdatedFiles() { return updatedFiles; } /** * @return {@link List} of {@link ChangeSet} */ - public List getChanges() - { - if ( changes == null ) - { + public List getChanges() { + if (changes == null) { return new ArrayList(); } return changes; } - public void setChanges( List changes ) - { + public void setChanges(List changes) { this.changes = changes; } } diff --git a/maven-scm-api/src/main/java/org/apache/maven/scm/command/update/UpdateScmResultWithRevision.java b/maven-scm-api/src/main/java/org/apache/maven/scm/command/update/UpdateScmResultWithRevision.java index d735faccd..91190e85e 100644 --- a/maven-scm-api/src/main/java/org/apache/maven/scm/command/update/UpdateScmResultWithRevision.java +++ b/maven-scm-api/src/main/java/org/apache/maven/scm/command/update/UpdateScmResultWithRevision.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.command.update; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.command.update; import java.util.List; @@ -31,38 +30,32 @@ * @author Olivier Lamy * */ -public class UpdateScmResultWithRevision - extends UpdateScmResult -{ +public class UpdateScmResultWithRevision extends UpdateScmResult { private static final long serialVersionUID = 7644079089026359667L; private String revision; - public UpdateScmResultWithRevision( String commandLine, String providerMessage, String commandOutput, - String revision, boolean success ) - { - super( commandLine, providerMessage, commandOutput, success ); + public UpdateScmResultWithRevision( + String commandLine, String providerMessage, String commandOutput, String revision, boolean success) { + super(commandLine, providerMessage, commandOutput, success); this.revision = revision; } - public UpdateScmResultWithRevision( String commandLine, List updatedFiles, String revision ) - { - super( commandLine, updatedFiles ); + public UpdateScmResultWithRevision(String commandLine, List updatedFiles, String revision) { + super(commandLine, updatedFiles); this.revision = revision; } - public UpdateScmResultWithRevision( List updatedFiles, List changes, String revision, - ScmResult result ) - { - super( updatedFiles, changes, result ); + public UpdateScmResultWithRevision( + List updatedFiles, List changes, String revision, ScmResult result) { + super(updatedFiles, changes, result); this.revision = revision; } - public String getRevision() - { + public String getRevision() { return revision; } } diff --git a/maven-scm-api/src/main/java/org/apache/maven/scm/manager/AbstractScmManager.java b/maven-scm-api/src/main/java/org/apache/maven/scm/manager/AbstractScmManager.java index 8514a1bb9..5abd458a0 100644 --- a/maven-scm-api/src/main/java/org/apache/maven/scm/manager/AbstractScmManager.java +++ b/maven-scm-api/src/main/java/org/apache/maven/scm/manager/AbstractScmManager.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.manager; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.manager; import java.io.File; import java.util.ArrayList; @@ -66,21 +65,18 @@ * @author Brett Porter * @author Emmanuel Venisse */ -public abstract class AbstractScmManager - implements ScmManager -{ - protected final Logger logger = LoggerFactory.getLogger( getClass() ); +public abstract class AbstractScmManager implements ScmManager { + protected final Logger logger = LoggerFactory.getLogger(getClass()); private final Map scmProviders = new ConcurrentHashMap<>(); private final Map userProviderTypes = new ConcurrentHashMap<>(); - protected void setScmProviders( Map providers ) - { - requireNonNull( providers ); + protected void setScmProviders(Map providers) { + requireNonNull(providers); this.scmProviders.clear(); // first provider must not be overwritten by subsequent ones if they are registered for the same key - providers.forEach( this.scmProviders::putIfAbsent ); + providers.forEach(this.scmProviders::putIfAbsent); } /** @@ -89,9 +85,8 @@ protected void setScmProviders( Map providers ) * @deprecated use {@link #setScmProvider(String, ScmProvider)} instead */ @Deprecated - protected void addScmProvider( String providerType, ScmProvider provider ) - { - setScmProvider( providerType, provider ); + protected void addScmProvider(String providerType, ScmProvider provider) { + setScmProvider(providerType, provider); } /** @@ -102,11 +97,10 @@ protected void addScmProvider( String providerType, ScmProvider provider ) * @param provider the provider that will be used for that SCM type */ @Override - public void setScmProvider( String providerType, ScmProvider provider ) - { - requireNonNull( providerType ); - requireNonNull( provider ); - scmProviders.put( providerType, provider ); + public void setScmProvider(String providerType, ScmProvider provider) { + requireNonNull(providerType); + requireNonNull(provider); + scmProviders.put(providerType, provider); } // ---------------------------------------------------------------------- @@ -117,46 +111,39 @@ public void setScmProvider( String providerType, ScmProvider provider ) * {@inheritDoc} */ @Override - public ScmProvider getProviderByUrl( String scmUrl ) - throws ScmRepositoryException, NoSuchScmProviderException - { - requireNonNull( scmUrl, "The scm url cannot be null." ); + public ScmProvider getProviderByUrl(String scmUrl) throws ScmRepositoryException, NoSuchScmProviderException { + requireNonNull(scmUrl, "The scm url cannot be null."); - String providerType = ScmUrlUtils.getProvider( scmUrl ); + String providerType = ScmUrlUtils.getProvider(scmUrl); - return getProviderByType( providerType ); + return getProviderByType(providerType); } /** * {@inheritDoc} */ @Override - public void setScmProviderImplementation( String providerType, String providerImplementation ) - { - requireNonNull( providerType ); - requireNonNull( providerImplementation ); - userProviderTypes.put( providerType, providerImplementation ); + public void setScmProviderImplementation(String providerType, String providerImplementation) { + requireNonNull(providerType); + requireNonNull(providerImplementation); + userProviderTypes.put(providerType, providerImplementation); } /** * {@inheritDoc} */ @Override - public ScmProvider getProviderByType( String providerType ) - throws NoSuchScmProviderException - { - String usedProviderType = System.getProperty( "maven.scm.provider." + providerType + ".implementation" ); + public ScmProvider getProviderByType(String providerType) throws NoSuchScmProviderException { + String usedProviderType = System.getProperty("maven.scm.provider." + providerType + ".implementation"); - if ( usedProviderType == null ) - { - usedProviderType = userProviderTypes.getOrDefault( providerType, providerType ); + if (usedProviderType == null) { + usedProviderType = userProviderTypes.getOrDefault(providerType, providerType); } - ScmProvider scmProvider = scmProviders.get( usedProviderType ); + ScmProvider scmProvider = scmProviders.get(usedProviderType); - if ( scmProvider == null ) - { - throw new NoSuchScmProviderException( usedProviderType ); + if (scmProvider == null) { + throw new NoSuchScmProviderException(usedProviderType); } return scmProvider; @@ -166,10 +153,8 @@ public ScmProvider getProviderByType( String providerType ) * {@inheritDoc} */ @Override - public ScmProvider getProviderByRepository( ScmRepository repository ) - throws NoSuchScmProviderException - { - return getProviderByType( repository.getProvider() ); + public ScmProvider getProviderByRepository(ScmRepository repository) throws NoSuchScmProviderException { + return getProviderByType(repository.getProvider()); } // ---------------------------------------------------------------------- @@ -180,22 +165,20 @@ public ScmProvider getProviderByRepository( ScmRepository repository ) * {@inheritDoc} */ @Override - public ScmRepository makeScmRepository( String scmUrl ) - throws ScmRepositoryException, NoSuchScmProviderException - { - requireNonNull( scmUrl, "The scm url cannot be null." ); + public ScmRepository makeScmRepository(String scmUrl) throws ScmRepositoryException, NoSuchScmProviderException { + requireNonNull(scmUrl, "The scm url cannot be null."); - char delimiter = ScmUrlUtils.getDelimiter( scmUrl ).charAt( 0 ); + char delimiter = ScmUrlUtils.getDelimiter(scmUrl).charAt(0); - String providerType = ScmUrlUtils.getProvider( scmUrl ); + String providerType = ScmUrlUtils.getProvider(scmUrl); - ScmProvider provider = getProviderByType( providerType ); + ScmProvider provider = getProviderByType(providerType); - String scmSpecificUrl = cleanScmUrl( scmUrl.substring( providerType.length() + 5 ) ); + String scmSpecificUrl = cleanScmUrl(scmUrl.substring(providerType.length() + 5)); - ScmProviderRepository providerRepository = provider.makeProviderScmRepository( scmSpecificUrl, delimiter ); + ScmProviderRepository providerRepository = provider.makeProviderScmRepository(scmSpecificUrl, delimiter); - return new ScmRepository( providerType, providerRepository ); + return new ScmRepository(providerType, providerRepository); } /** @@ -204,48 +187,42 @@ public ScmRepository makeScmRepository( String scmUrl ) * @param scmUrl the SCM url * @return the cleaned SCM url */ - protected String cleanScmUrl( String scmUrl ) - { - requireNonNull( scmUrl, "The scm url cannot be null." ); + protected String cleanScmUrl(String scmUrl) { + requireNonNull(scmUrl, "The scm url cannot be null."); String pathSeparator = ""; int indexOfDoubleDot = -1; // Clean Unix path - if ( scmUrl.indexOf( "../" ) > 1 ) - { + if (scmUrl.indexOf("../") > 1) { pathSeparator = "/"; - indexOfDoubleDot = scmUrl.indexOf( "../" ); + indexOfDoubleDot = scmUrl.indexOf("../"); } // Clean windows path - if ( scmUrl.indexOf( "..\\" ) > 1 ) - { + if (scmUrl.indexOf("..\\") > 1) { pathSeparator = "\\"; - indexOfDoubleDot = scmUrl.indexOf( "..\\" ); + indexOfDoubleDot = scmUrl.indexOf("..\\"); } - if ( indexOfDoubleDot > 1 ) - { - int startOfTextToRemove = scmUrl.substring( 0, indexOfDoubleDot - 1 ).lastIndexOf( pathSeparator ); + if (indexOfDoubleDot > 1) { + int startOfTextToRemove = scmUrl.substring(0, indexOfDoubleDot - 1).lastIndexOf(pathSeparator); String beginUrl = ""; - if ( startOfTextToRemove >= 0 ) - { - beginUrl = scmUrl.substring( 0, startOfTextToRemove ); + if (startOfTextToRemove >= 0) { + beginUrl = scmUrl.substring(0, startOfTextToRemove); } - String endUrl = scmUrl.substring( indexOfDoubleDot + 3 ); + String endUrl = scmUrl.substring(indexOfDoubleDot + 3); scmUrl = beginUrl + pathSeparator + endUrl; // Check if we have other double dot - if ( scmUrl.indexOf( "../" ) > 1 || scmUrl.indexOf( "..\\" ) > 1 ) - { - scmUrl = cleanScmUrl( scmUrl ); + if (scmUrl.indexOf("../") > 1 || scmUrl.indexOf("..\\") > 1) { + scmUrl = cleanScmUrl(scmUrl); } } @@ -256,49 +233,44 @@ protected String cleanScmUrl( String scmUrl ) * {@inheritDoc} */ @Override - public ScmRepository makeProviderScmRepository( String providerType, File path ) - throws ScmRepositoryException, UnknownRepositoryStructure, NoSuchScmProviderException - { - requireNonNull( providerType, "The provider type cannot be null." ); + public ScmRepository makeProviderScmRepository(String providerType, File path) + throws ScmRepositoryException, UnknownRepositoryStructure, NoSuchScmProviderException { + requireNonNull(providerType, "The provider type cannot be null."); - ScmProvider provider = getProviderByType( providerType ); + ScmProvider provider = getProviderByType(providerType); - ScmProviderRepository providerRepository = provider.makeProviderScmRepository( path ); + ScmProviderRepository providerRepository = provider.makeProviderScmRepository(path); - return new ScmRepository( providerType, providerRepository ); + return new ScmRepository(providerType, providerRepository); } /** * {@inheritDoc} */ @Override - public List validateScmRepository( String scmUrl ) - { - List messages = new ArrayList<>( ScmUrlUtils.validate( scmUrl ) ); + public List validateScmRepository(String scmUrl) { + List messages = new ArrayList<>(ScmUrlUtils.validate(scmUrl)); - String providerType = ScmUrlUtils.getProvider( scmUrl ); + String providerType = ScmUrlUtils.getProvider(scmUrl); ScmProvider provider; - try - { - provider = getProviderByType( providerType ); - } - catch ( NoSuchScmProviderException e ) - { - messages.add( "No such provider installed '" + providerType + "'." ); + try { + provider = getProviderByType(providerType); + } catch (NoSuchScmProviderException e) { + messages.add("No such provider installed '" + providerType + "'."); return messages; } - String scmSpecificUrl = cleanScmUrl( scmUrl.substring( providerType.length() + 5 ) ); + String scmSpecificUrl = cleanScmUrl(scmUrl.substring(providerType.length() + 5)); - List providerMessages = - provider.validateScmUrl( scmSpecificUrl, ScmUrlUtils.getDelimiter( scmUrl ).charAt( 0 ) ); + List providerMessages = provider.validateScmUrl( + scmSpecificUrl, ScmUrlUtils.getDelimiter(scmUrl).charAt(0)); - requireNonNull( providerMessages, "The SCM provider cannot return null from validateScmUrl()." ); + requireNonNull(providerMessages, "The SCM provider cannot return null from validateScmUrl()."); - messages.addAll( providerMessages ); + messages.addAll(providerMessages); return messages; } @@ -307,417 +279,365 @@ public List validateScmRepository( String scmUrl ) * {@inheritDoc} */ @Override - public AddScmResult add( ScmRepository repository, ScmFileSet fileSet ) - throws ScmException - { - return this.getProviderByRepository( repository ).add( repository, fileSet ); + public AddScmResult add(ScmRepository repository, ScmFileSet fileSet) throws ScmException { + return this.getProviderByRepository(repository).add(repository, fileSet); } /** * {@inheritDoc} */ @Override - public AddScmResult add( ScmRepository repository, ScmFileSet fileSet, String message ) - throws ScmException - { - return this.getProviderByRepository( repository ).add( repository, fileSet, message ); + public AddScmResult add(ScmRepository repository, ScmFileSet fileSet, String message) throws ScmException { + return this.getProviderByRepository(repository).add(repository, fileSet, message); } /** * {@inheritDoc} */ @Override - public BranchScmResult branch( ScmRepository repository, ScmFileSet fileSet, String branchName ) - throws ScmException - { - ScmBranchParameters scmBranchParameters = new ScmBranchParameters( "" ); - return this.getProviderByRepository( repository ).branch( repository, fileSet, branchName, - scmBranchParameters ); + public BranchScmResult branch(ScmRepository repository, ScmFileSet fileSet, String branchName) throws ScmException { + ScmBranchParameters scmBranchParameters = new ScmBranchParameters(""); + return this.getProviderByRepository(repository).branch(repository, fileSet, branchName, scmBranchParameters); } /** * {@inheritDoc} */ @Override - public BranchScmResult branch( ScmRepository repository, ScmFileSet fileSet, String branchName, String message ) - throws ScmException - { - ScmBranchParameters scmBranchParameters = new ScmBranchParameters( message ); - return this.getProviderByRepository( repository ).branch( repository, fileSet, branchName, - scmBranchParameters ); + public BranchScmResult branch(ScmRepository repository, ScmFileSet fileSet, String branchName, String message) + throws ScmException { + ScmBranchParameters scmBranchParameters = new ScmBranchParameters(message); + return this.getProviderByRepository(repository).branch(repository, fileSet, branchName, scmBranchParameters); } /** * {@inheritDoc} */ @Override - public ChangeLogScmResult changeLog( ScmRepository repository, ScmFileSet fileSet, Date startDate, Date endDate, - int numDays, ScmBranch branch ) - throws ScmException - { - return this.getProviderByRepository( repository ).changeLog( repository, fileSet, startDate, endDate, numDays, - branch ); + public ChangeLogScmResult changeLog( + ScmRepository repository, ScmFileSet fileSet, Date startDate, Date endDate, int numDays, ScmBranch branch) + throws ScmException { + return this.getProviderByRepository(repository) + .changeLog(repository, fileSet, startDate, endDate, numDays, branch); } /** * {@inheritDoc} */ @Override - public ChangeLogScmResult changeLog( ScmRepository repository, ScmFileSet fileSet, Date startDate, Date endDate, - int numDays, ScmBranch branch, String datePattern ) - throws ScmException - { - return this.getProviderByRepository( repository ).changeLog( repository, fileSet, startDate, endDate, numDays, - branch, datePattern ); + public ChangeLogScmResult changeLog( + ScmRepository repository, + ScmFileSet fileSet, + Date startDate, + Date endDate, + int numDays, + ScmBranch branch, + String datePattern) + throws ScmException { + return this.getProviderByRepository(repository) + .changeLog(repository, fileSet, startDate, endDate, numDays, branch, datePattern); } /** * {@inheritDoc} */ @Override - public ChangeLogScmResult changeLog( ChangeLogScmRequest scmRequest ) - throws ScmException - { - return this.getProviderByRepository( scmRequest.getScmRepository() ).changeLog( scmRequest ); + public ChangeLogScmResult changeLog(ChangeLogScmRequest scmRequest) throws ScmException { + return this.getProviderByRepository(scmRequest.getScmRepository()).changeLog(scmRequest); } /** * {@inheritDoc} */ @Override - public ChangeLogScmResult changeLog( ScmRepository repository, ScmFileSet fileSet, ScmVersion startVersion, - ScmVersion endVersion ) - throws ScmException - { - return this.getProviderByRepository( repository ).changeLog( repository, fileSet, startVersion, endVersion ); + public ChangeLogScmResult changeLog( + ScmRepository repository, ScmFileSet fileSet, ScmVersion startVersion, ScmVersion endVersion) + throws ScmException { + return this.getProviderByRepository(repository).changeLog(repository, fileSet, startVersion, endVersion); } /** * {@inheritDoc} */ @Override - public ChangeLogScmResult changeLog( ScmRepository repository, ScmFileSet fileSet, ScmVersion startRevision, - ScmVersion endRevision, String datePattern ) - throws ScmException - { - return this.getProviderByRepository( repository ).changeLog( repository, fileSet, startRevision, endRevision, - datePattern ); + public ChangeLogScmResult changeLog( + ScmRepository repository, + ScmFileSet fileSet, + ScmVersion startRevision, + ScmVersion endRevision, + String datePattern) + throws ScmException { + return this.getProviderByRepository(repository) + .changeLog(repository, fileSet, startRevision, endRevision, datePattern); } /** * {@inheritDoc} */ @Override - public CheckInScmResult checkIn( ScmRepository repository, ScmFileSet fileSet, String message ) - throws ScmException - { - return this.getProviderByRepository( repository ).checkIn( repository, fileSet, message ); + public CheckInScmResult checkIn(ScmRepository repository, ScmFileSet fileSet, String message) throws ScmException { + return this.getProviderByRepository(repository).checkIn(repository, fileSet, message); } /** * {@inheritDoc} */ @Override - public CheckInScmResult checkIn( ScmRepository repository, ScmFileSet fileSet, ScmVersion revision, String message ) - throws ScmException - { - return this.getProviderByRepository( repository ).checkIn( repository, fileSet, revision, message ); + public CheckInScmResult checkIn(ScmRepository repository, ScmFileSet fileSet, ScmVersion revision, String message) + throws ScmException { + return this.getProviderByRepository(repository).checkIn(repository, fileSet, revision, message); } /** * {@inheritDoc} */ @Override - public CheckOutScmResult checkOut( ScmRepository repository, ScmFileSet fileSet ) - throws ScmException - { - return this.getProviderByRepository( repository ).checkOut( repository, fileSet ); + public CheckOutScmResult checkOut(ScmRepository repository, ScmFileSet fileSet) throws ScmException { + return this.getProviderByRepository(repository).checkOut(repository, fileSet); } /** * {@inheritDoc} */ @Override - public CheckOutScmResult checkOut( ScmRepository repository, ScmFileSet fileSet, ScmVersion version ) - throws ScmException - { - return this.getProviderByRepository( repository ).checkOut( repository, fileSet, version ); + public CheckOutScmResult checkOut(ScmRepository repository, ScmFileSet fileSet, ScmVersion version) + throws ScmException { + return this.getProviderByRepository(repository).checkOut(repository, fileSet, version); } /** * {@inheritDoc} */ @Override - public CheckOutScmResult checkOut( ScmRepository repository, ScmFileSet fileSet, boolean recursive ) - throws ScmException - { - return this.getProviderByRepository( repository ).checkOut( repository, fileSet, recursive ); + public CheckOutScmResult checkOut(ScmRepository repository, ScmFileSet fileSet, boolean recursive) + throws ScmException { + return this.getProviderByRepository(repository).checkOut(repository, fileSet, recursive); } /** * {@inheritDoc} */ @Override - public CheckOutScmResult checkOut( ScmRepository repository, ScmFileSet fileSet, ScmVersion version, - boolean recursive ) - throws ScmException - { - return this.getProviderByRepository( repository ).checkOut( repository, fileSet, version, recursive ); + public CheckOutScmResult checkOut( + ScmRepository repository, ScmFileSet fileSet, ScmVersion version, boolean recursive) throws ScmException { + return this.getProviderByRepository(repository).checkOut(repository, fileSet, version, recursive); } /** * {@inheritDoc} */ @Override - public DiffScmResult diff( ScmRepository repository, ScmFileSet fileSet, ScmVersion startVersion, - ScmVersion endVersion ) - throws ScmException - { - return this.getProviderByRepository( repository ).diff( repository, fileSet, startVersion, endVersion ); + public DiffScmResult diff( + ScmRepository repository, ScmFileSet fileSet, ScmVersion startVersion, ScmVersion endVersion) + throws ScmException { + return this.getProviderByRepository(repository).diff(repository, fileSet, startVersion, endVersion); } /** * {@inheritDoc} */ @Override - public EditScmResult edit( ScmRepository repository, ScmFileSet fileSet ) - throws ScmException - { - return this.getProviderByRepository( repository ).edit( repository, fileSet ); + public EditScmResult edit(ScmRepository repository, ScmFileSet fileSet) throws ScmException { + return this.getProviderByRepository(repository).edit(repository, fileSet); } /** * {@inheritDoc} */ @Override - public ExportScmResult export( ScmRepository repository, ScmFileSet fileSet ) - throws ScmException - { - return this.getProviderByRepository( repository ).export( repository, fileSet ); + public ExportScmResult export(ScmRepository repository, ScmFileSet fileSet) throws ScmException { + return this.getProviderByRepository(repository).export(repository, fileSet); } /** * {@inheritDoc} */ @Override - public ExportScmResult export( ScmRepository repository, ScmFileSet fileSet, ScmVersion version ) - throws ScmException - { - return this.getProviderByRepository( repository ).export( repository, fileSet, version ); + public ExportScmResult export(ScmRepository repository, ScmFileSet fileSet, ScmVersion version) + throws ScmException { + return this.getProviderByRepository(repository).export(repository, fileSet, version); } /** * {@inheritDoc} */ @Override - public ExportScmResult export( ScmRepository repository, ScmFileSet fileSet, String outputDirectory ) - throws ScmException - { - return this.getProviderByRepository( repository ).export( repository, fileSet, (ScmVersion) null, - outputDirectory ); + public ExportScmResult export(ScmRepository repository, ScmFileSet fileSet, String outputDirectory) + throws ScmException { + return this.getProviderByRepository(repository).export(repository, fileSet, (ScmVersion) null, outputDirectory); } /** * {@inheritDoc} */ @Override - public ExportScmResult export( ScmRepository repository, ScmFileSet fileSet, ScmVersion version, - String outputDirectory ) - throws ScmException - { - return this.getProviderByRepository( repository ).export( repository, fileSet, version, outputDirectory ); + public ExportScmResult export( + ScmRepository repository, ScmFileSet fileSet, ScmVersion version, String outputDirectory) + throws ScmException { + return this.getProviderByRepository(repository).export(repository, fileSet, version, outputDirectory); } /** * {@inheritDoc} */ @Override - public ListScmResult list( ScmRepository repository, ScmFileSet fileSet, boolean recursive, ScmVersion version ) - throws ScmException - { - return this.getProviderByRepository( repository ).list( repository, fileSet, recursive, version ); + public ListScmResult list(ScmRepository repository, ScmFileSet fileSet, boolean recursive, ScmVersion version) + throws ScmException { + return this.getProviderByRepository(repository).list(repository, fileSet, recursive, version); } /** * {@inheritDoc} */ @Override - public MkdirScmResult mkdir( ScmRepository repository, ScmFileSet fileSet, String message, boolean createInLocal ) - throws ScmException - { - return this.getProviderByRepository( repository ).mkdir( repository, fileSet, message, createInLocal ); + public MkdirScmResult mkdir(ScmRepository repository, ScmFileSet fileSet, String message, boolean createInLocal) + throws ScmException { + return this.getProviderByRepository(repository).mkdir(repository, fileSet, message, createInLocal); } /** * {@inheritDoc} */ @Override - public RemoveScmResult remove( ScmRepository repository, ScmFileSet fileSet, String message ) - throws ScmException - { - return this.getProviderByRepository( repository ).remove( repository, fileSet, message ); + public RemoveScmResult remove(ScmRepository repository, ScmFileSet fileSet, String message) throws ScmException { + return this.getProviderByRepository(repository).remove(repository, fileSet, message); } /** * {@inheritDoc} */ @Override - public StatusScmResult status( ScmRepository repository, ScmFileSet fileSet ) - throws ScmException - { - return this.getProviderByRepository( repository ).status( repository, fileSet ); + public StatusScmResult status(ScmRepository repository, ScmFileSet fileSet) throws ScmException { + return this.getProviderByRepository(repository).status(repository, fileSet); } /** * {@inheritDoc} */ @Override - public TagScmResult tag( ScmRepository repository, ScmFileSet fileSet, String tagName ) - throws ScmException - { - return this.tag( repository, fileSet, tagName, "" ); + public TagScmResult tag(ScmRepository repository, ScmFileSet fileSet, String tagName) throws ScmException { + return this.tag(repository, fileSet, tagName, ""); } /** * {@inheritDoc} */ @Override - public TagScmResult tag( ScmRepository repository, ScmFileSet fileSet, String tagName, String message ) - throws ScmException - { - ScmTagParameters scmTagParameters = new ScmTagParameters( message ); - return this.getProviderByRepository( repository ).tag( repository, fileSet, tagName, scmTagParameters ); + public TagScmResult tag(ScmRepository repository, ScmFileSet fileSet, String tagName, String message) + throws ScmException { + ScmTagParameters scmTagParameters = new ScmTagParameters(message); + return this.getProviderByRepository(repository).tag(repository, fileSet, tagName, scmTagParameters); } /** * {@inheritDoc} */ @Override - public UnEditScmResult unedit( ScmRepository repository, ScmFileSet fileSet ) - throws ScmException - { - return this.getProviderByRepository( repository ).unedit( repository, fileSet ); + public UnEditScmResult unedit(ScmRepository repository, ScmFileSet fileSet) throws ScmException { + return this.getProviderByRepository(repository).unedit(repository, fileSet); } /** * {@inheritDoc} */ @Override - public UpdateScmResult update( ScmRepository repository, ScmFileSet fileSet ) - throws ScmException - { - return this.getProviderByRepository( repository ).update( repository, fileSet ); + public UpdateScmResult update(ScmRepository repository, ScmFileSet fileSet) throws ScmException { + return this.getProviderByRepository(repository).update(repository, fileSet); } /** * {@inheritDoc} */ @Override - public UpdateScmResult update( ScmRepository repository, ScmFileSet fileSet, ScmVersion version ) - throws ScmException - { - return this.getProviderByRepository( repository ).update( repository, fileSet, version ); + public UpdateScmResult update(ScmRepository repository, ScmFileSet fileSet, ScmVersion version) + throws ScmException { + return this.getProviderByRepository(repository).update(repository, fileSet, version); } /** * {@inheritDoc} */ @Override - public UpdateScmResult update( ScmRepository repository, ScmFileSet fileSet, boolean runChangelog ) - throws ScmException - { - return this.getProviderByRepository( repository ).update( repository, fileSet, runChangelog ); + public UpdateScmResult update(ScmRepository repository, ScmFileSet fileSet, boolean runChangelog) + throws ScmException { + return this.getProviderByRepository(repository).update(repository, fileSet, runChangelog); } /** * {@inheritDoc} */ @Override - public UpdateScmResult update( ScmRepository repository, ScmFileSet fileSet, ScmVersion version, - boolean runChangelog ) - throws ScmException - { - return this.getProviderByRepository( repository ).update( repository, fileSet, version, runChangelog ); + public UpdateScmResult update( + ScmRepository repository, ScmFileSet fileSet, ScmVersion version, boolean runChangelog) + throws ScmException { + return this.getProviderByRepository(repository).update(repository, fileSet, version, runChangelog); } /** * {@inheritDoc} */ @Override - public UpdateScmResult update( ScmRepository repository, ScmFileSet fileSet, String datePattern ) - throws ScmException - { - return this.getProviderByRepository( repository ).update( repository, fileSet, (ScmVersion) null, datePattern ); + public UpdateScmResult update(ScmRepository repository, ScmFileSet fileSet, String datePattern) + throws ScmException { + return this.getProviderByRepository(repository).update(repository, fileSet, (ScmVersion) null, datePattern); } /** * {@inheritDoc} */ @Override - public UpdateScmResult update( ScmRepository repository, ScmFileSet fileSet, ScmVersion version, - String datePattern ) - throws ScmException - { - return this.getProviderByRepository( repository ).update( repository, fileSet, version, datePattern ); + public UpdateScmResult update(ScmRepository repository, ScmFileSet fileSet, ScmVersion version, String datePattern) + throws ScmException { + return this.getProviderByRepository(repository).update(repository, fileSet, version, datePattern); } /** * {@inheritDoc} */ @Override - public UpdateScmResult update( ScmRepository repository, ScmFileSet fileSet, Date lastUpdate ) - throws ScmException - { - return this.getProviderByRepository( repository ).update( repository, fileSet, (ScmVersion) null, lastUpdate ); + public UpdateScmResult update(ScmRepository repository, ScmFileSet fileSet, Date lastUpdate) throws ScmException { + return this.getProviderByRepository(repository).update(repository, fileSet, (ScmVersion) null, lastUpdate); } /** * {@inheritDoc} */ @Override - public UpdateScmResult update( ScmRepository repository, ScmFileSet fileSet, ScmVersion version, Date lastUpdate ) - throws ScmException - { - return this.getProviderByRepository( repository ).update( repository, fileSet, version, lastUpdate ); + public UpdateScmResult update(ScmRepository repository, ScmFileSet fileSet, ScmVersion version, Date lastUpdate) + throws ScmException { + return this.getProviderByRepository(repository).update(repository, fileSet, version, lastUpdate); } /** * {@inheritDoc} */ @Override - public UpdateScmResult update( ScmRepository repository, ScmFileSet fileSet, Date lastUpdate, String datePattern ) - throws ScmException - { - return this.getProviderByRepository( repository ).update( repository, fileSet, (ScmVersion) null, lastUpdate, - datePattern ); + public UpdateScmResult update(ScmRepository repository, ScmFileSet fileSet, Date lastUpdate, String datePattern) + throws ScmException { + return this.getProviderByRepository(repository) + .update(repository, fileSet, (ScmVersion) null, lastUpdate, datePattern); } /** * {@inheritDoc} */ @Override - public UpdateScmResult update( ScmRepository repository, ScmFileSet fileSet, ScmVersion version, Date lastUpdate, - String datePattern ) - throws ScmException - { - return this.getProviderByRepository( repository ).update( repository, fileSet, version, lastUpdate, - datePattern ); + public UpdateScmResult update( + ScmRepository repository, ScmFileSet fileSet, ScmVersion version, Date lastUpdate, String datePattern) + throws ScmException { + return this.getProviderByRepository(repository).update(repository, fileSet, version, lastUpdate, datePattern); } /** * {@inheritDoc} */ @Override - public BlameScmResult blame( ScmRepository repository, ScmFileSet fileSet, String filename ) - throws ScmException - { - return this.getProviderByRepository( repository ).blame( repository, fileSet, filename ); + public BlameScmResult blame(ScmRepository repository, ScmFileSet fileSet, String filename) throws ScmException { + return this.getProviderByRepository(repository).blame(repository, fileSet, filename); } @Override - public BlameScmResult blame( BlameScmRequest blameScmRequest ) - throws ScmException - { - return this.getProviderByRepository( blameScmRequest.getScmRepository() ).blame( blameScmRequest ); + public BlameScmResult blame(BlameScmRequest blameScmRequest) throws ScmException { + return this.getProviderByRepository(blameScmRequest.getScmRepository()).blame(blameScmRequest); } } diff --git a/maven-scm-api/src/main/java/org/apache/maven/scm/manager/BasicScmManager.java b/maven-scm-api/src/main/java/org/apache/maven/scm/manager/BasicScmManager.java index 31eef8ecf..0ab0630e2 100644 --- a/maven-scm-api/src/main/java/org/apache/maven/scm/manager/BasicScmManager.java +++ b/maven-scm-api/src/main/java/org/apache/maven/scm/manager/BasicScmManager.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.manager; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,12 +16,10 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.manager; /** * @author Emmanuel Venisse * */ -public class BasicScmManager - extends AbstractScmManager -{ -} +public class BasicScmManager extends AbstractScmManager {} diff --git a/maven-scm-api/src/main/java/org/apache/maven/scm/manager/NoSuchScmProviderException.java b/maven-scm-api/src/main/java/org/apache/maven/scm/manager/NoSuchScmProviderException.java index 9b1ad888f..bef6757d9 100644 --- a/maven-scm-api/src/main/java/org/apache/maven/scm/manager/NoSuchScmProviderException.java +++ b/maven-scm-api/src/main/java/org/apache/maven/scm/manager/NoSuchScmProviderException.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.manager; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.manager; import org.apache.maven.scm.ScmException; @@ -28,21 +27,17 @@ * @author Emmanuel Venisse * */ -public class NoSuchScmProviderException - extends ScmException -{ +public class NoSuchScmProviderException extends ScmException { static final long serialVersionUID = 4770645185214496323L; private final String providerName; - public NoSuchScmProviderException( String providerName ) - { - super( "No such provider: '" + providerName + "'." ); - this.providerName = requireNonNull( providerName ); + public NoSuchScmProviderException(String providerName) { + super("No such provider: '" + providerName + "'."); + this.providerName = requireNonNull(providerName); } - public String getProviderName() - { + public String getProviderName() { return providerName; } } diff --git a/maven-scm-api/src/main/java/org/apache/maven/scm/manager/ScmManager.java b/maven-scm-api/src/main/java/org/apache/maven/scm/manager/ScmManager.java index 7ff10b862..3e893a23a 100644 --- a/maven-scm-api/src/main/java/org/apache/maven/scm/manager/ScmManager.java +++ b/maven-scm-api/src/main/java/org/apache/maven/scm/manager/ScmManager.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.manager; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,11 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.manager; + +import java.io.File; +import java.util.Date; +import java.util.List; import org.apache.maven.scm.ScmBranch; import org.apache.maven.scm.ScmException; @@ -46,10 +49,6 @@ import org.apache.maven.scm.repository.ScmRepositoryException; import org.apache.maven.scm.repository.UnknownRepositoryStructure; -import java.io.File; -import java.util.Date; -import java.util.List; - /** * @author Trygve Laugstøl * @author Brett Porter @@ -57,8 +56,7 @@ * @author Olivier Lamy * */ -public interface ScmManager -{ +public interface ScmManager { // ---------------------------------------------------------------------- // Repository // ---------------------------------------------------------------------- @@ -71,11 +69,10 @@ public interface ScmManager * @throws ScmRepositoryException if an error occurs in the scm repository construction * @throws NoSuchScmProviderException if the provider doesn't exist */ - ScmRepository makeScmRepository( String scmUrl ) - throws ScmRepositoryException, NoSuchScmProviderException; + ScmRepository makeScmRepository(String scmUrl) throws ScmRepositoryException, NoSuchScmProviderException; - ScmRepository makeProviderScmRepository( String providerType, File path ) - throws ScmRepositoryException, UnknownRepositoryStructure, NoSuchScmProviderException; + ScmRepository makeProviderScmRepository(String providerType, File path) + throws ScmRepositoryException, UnknownRepositoryStructure, NoSuchScmProviderException; /** * Validate a SCM URL. @@ -83,10 +80,9 @@ ScmRepository makeProviderScmRepository( String providerType, File path ) * @param scmUrl the SCM URL to validate * @return List of String objects with the messages returned by the SCM provider */ - List validateScmRepository( String scmUrl ); + List validateScmRepository(String scmUrl); - ScmProvider getProviderByUrl( String scmUrl ) - throws ScmRepositoryException, NoSuchScmProviderException; + ScmProvider getProviderByUrl(String scmUrl) throws ScmRepositoryException, NoSuchScmProviderException; /** * Returns the default provider registered for this providerType or a specific implementation if the @@ -97,11 +93,9 @@ ScmProvider getProviderByUrl( String scmUrl ) * @return The scm provider * @throws NoSuchScmProviderException if the provider doesn't exist */ - ScmProvider getProviderByType( String providerType ) - throws NoSuchScmProviderException; + ScmProvider getProviderByType(String providerType) throws NoSuchScmProviderException; - ScmProvider getProviderByRepository( ScmRepository repository ) - throws NoSuchScmProviderException; + ScmProvider getProviderByRepository(ScmRepository repository) throws NoSuchScmProviderException; /** * Set a provider to be used for a type of SCM. If there was already a designed provider for that type it will be @@ -110,7 +104,7 @@ ScmProvider getProviderByRepository( ScmRepository repository ) * @param providerType the type of SCM, eg. svn, git * @param provider the provider that will be used for that SCM type */ - void setScmProvider( String providerType, ScmProvider provider ); + void setScmProvider(String providerType, ScmProvider provider); /** * Set the provider implementation @@ -119,7 +113,7 @@ ScmProvider getProviderByRepository( ScmRepository repository ) * @param providerImplementation The provider implementation (the role-hint of the provider), eg. git, * svn */ - void setScmProviderImplementation( String providerType, String providerImplementation ); + void setScmProviderImplementation(String providerType, String providerImplementation); /** * Adds the given files to the source control system @@ -131,8 +125,7 @@ ScmProvider getProviderByRepository( ScmRepository repository ) * @throws ScmException if any * */ - AddScmResult add( ScmRepository repository, ScmFileSet fileSet ) - throws ScmException; + AddScmResult add(ScmRepository repository, ScmFileSet fileSet) throws ScmException; /** * Adds the given files to the source control system @@ -144,8 +137,7 @@ AddScmResult add( ScmRepository repository, ScmFileSet fileSet ) * have been added * @throws ScmException if any */ - AddScmResult add( ScmRepository repository, ScmFileSet fileSet, String message ) - throws ScmException; + AddScmResult add(ScmRepository repository, ScmFileSet fileSet, String message) throws ScmException; /** * Branch (or label in some systems) will create a branch of the source file with a certain branch name @@ -157,8 +149,7 @@ AddScmResult add( ScmRepository repository, ScmFileSet fileSet, String message ) * @return TODO * @throws ScmException if any */ - BranchScmResult branch( ScmRepository repository, ScmFileSet fileSet, String branchName ) - throws ScmException; + BranchScmResult branch(ScmRepository repository, ScmFileSet fileSet, String branchName) throws ScmException; /** * Branch (or label in some systems) will create a branch of the source file with a certain branch name @@ -171,8 +162,8 @@ BranchScmResult branch( ScmRepository repository, ScmFileSet fileSet, String bra * @return TODO * @throws ScmException if any */ - BranchScmResult branch( ScmRepository repository, ScmFileSet fileSet, String branchName, String message ) - throws ScmException; + BranchScmResult branch(ScmRepository repository, ScmFileSet fileSet, String branchName, String message) + throws ScmException; /** * Returns the changes that have happend in the source control system in a certain period of time. This can be @@ -190,9 +181,9 @@ BranchScmResult branch( ScmRepository repository, ScmFileSet fileSet, String bra * @deprecated use {@link #changeLog(org.apache.maven.scm.command.changelog.ChangeLogScmRequest)} instead */ @Deprecated - ChangeLogScmResult changeLog( ScmRepository repository, ScmFileSet fileSet, Date startDate, Date endDate, - int numDays, ScmBranch branch ) - throws ScmException; + ChangeLogScmResult changeLog( + ScmRepository repository, ScmFileSet fileSet, Date startDate, Date endDate, int numDays, ScmBranch branch) + throws ScmException; /** * Returns the changes that have happend in the source control system in a certain period of time. This can be @@ -211,9 +202,15 @@ ChangeLogScmResult changeLog( ScmRepository repository, ScmFileSet fileSet, Date * @deprecated use {@link #changeLog(org.apache.maven.scm.command.changelog.ChangeLogScmRequest)} instead */ @Deprecated - ChangeLogScmResult changeLog( ScmRepository repository, ScmFileSet fileSet, Date startDate, Date endDate, - int numDays, ScmBranch branch, String datePattern ) - throws ScmException; + ChangeLogScmResult changeLog( + ScmRepository repository, + ScmFileSet fileSet, + Date startDate, + Date endDate, + int numDays, + ScmBranch branch, + String datePattern) + throws ScmException; /** * Returns the changes that have happend in the source control system in a certain period of time. This can be @@ -224,8 +221,7 @@ ChangeLogScmResult changeLog( ScmRepository repository, ScmFileSet fileSet, Date * @throws ScmException if any * @since 1.8 */ - ChangeLogScmResult changeLog( ChangeLogScmRequest scmRequest ) - throws ScmException; + ChangeLogScmResult changeLog(ChangeLogScmRequest scmRequest) throws ScmException; /** * Returns the changes that have happend in the source control system between two tags. This can be adding, @@ -241,9 +237,9 @@ ChangeLogScmResult changeLog( ChangeLogScmRequest scmRequest ) * @deprecated use {@link #changeLog(org.apache.maven.scm.command.changelog.ChangeLogScmRequest)} instead */ @Deprecated - ChangeLogScmResult changeLog( ScmRepository repository, ScmFileSet fileSet, ScmVersion startVersion, - ScmVersion endVersion ) - throws ScmException; + ChangeLogScmResult changeLog( + ScmRepository repository, ScmFileSet fileSet, ScmVersion startVersion, ScmVersion endVersion) + throws ScmException; /** * Returns the changes that have happend in the source control system between two tags. This can be adding, @@ -260,9 +256,13 @@ ChangeLogScmResult changeLog( ScmRepository repository, ScmFileSet fileSet, ScmV * @deprecated use {@link #changeLog(org.apache.maven.scm.command.changelog.ChangeLogScmRequest)} instead */ @Deprecated - ChangeLogScmResult changeLog( ScmRepository repository, ScmFileSet fileSet, ScmVersion startRevision, - ScmVersion endRevision, String datePattern ) - throws ScmException; + ChangeLogScmResult changeLog( + ScmRepository repository, + ScmFileSet fileSet, + ScmVersion startRevision, + ScmVersion endRevision, + String datePattern) + throws ScmException; /** * Save the changes you have done into the repository. This will create a new version of the file or directory in @@ -278,8 +278,7 @@ ChangeLogScmResult changeLog( ScmRepository repository, ScmFileSet fileSet, ScmV * have been checked in. * @throws ScmException if any */ - CheckInScmResult checkIn( ScmRepository repository, ScmFileSet fileSet, String message ) - throws ScmException; + CheckInScmResult checkIn(ScmRepository repository, ScmFileSet fileSet, String message) throws ScmException; /** * Save the changes you have done into the repository. This will create a new version of the file or directory in @@ -296,8 +295,8 @@ CheckInScmResult checkIn( ScmRepository repository, ScmFileSet fileSet, String m * have been checked in. * @throws ScmException if any */ - CheckInScmResult checkIn( ScmRepository repository, ScmFileSet fileSet, ScmVersion revision, String message ) - throws ScmException; + CheckInScmResult checkIn(ScmRepository repository, ScmFileSet fileSet, ScmVersion revision, String message) + throws ScmException; /** * Create a copy of the repository on your local machine @@ -307,8 +306,7 @@ CheckInScmResult checkIn( ScmRepository repository, ScmFileSet fileSet, ScmVersi * @return TODO * @throws ScmException if any */ - CheckOutScmResult checkOut( ScmRepository repository, ScmFileSet fileSet ) - throws ScmException; + CheckOutScmResult checkOut(ScmRepository repository, ScmFileSet fileSet) throws ScmException; /** * Create a copy of the repository on your local machine @@ -319,8 +317,7 @@ CheckOutScmResult checkOut( ScmRepository repository, ScmFileSet fileSet ) * @return TODO * @throws ScmException if any */ - CheckOutScmResult checkOut( ScmRepository repository, ScmFileSet fileSet, ScmVersion version ) - throws ScmException; + CheckOutScmResult checkOut(ScmRepository repository, ScmFileSet fileSet, ScmVersion version) throws ScmException; /** * Create a copy of the repository on your local machine. @@ -331,8 +328,8 @@ CheckOutScmResult checkOut( ScmRepository repository, ScmFileSet fileSet, ScmVer * @return TODO * @throws ScmException if any */ - CheckOutScmResult checkOut( ScmRepository scmRepository, ScmFileSet scmFileSet, boolean recursive ) - throws ScmException; + CheckOutScmResult checkOut(ScmRepository scmRepository, ScmFileSet scmFileSet, boolean recursive) + throws ScmException; /** * Create a copy of the repository on your local machine. @@ -344,9 +341,9 @@ CheckOutScmResult checkOut( ScmRepository scmRepository, ScmFileSet scmFileSet, * @return TODO * @throws ScmException if any */ - CheckOutScmResult checkOut( ScmRepository scmRepository, ScmFileSet scmFileSet, ScmVersion version, - boolean recursive ) - throws ScmException; + CheckOutScmResult checkOut( + ScmRepository scmRepository, ScmFileSet scmFileSet, ScmVersion version, boolean recursive) + throws ScmException; /** * Create a diff between two branch/tag/revision. @@ -358,9 +355,9 @@ CheckOutScmResult checkOut( ScmRepository scmRepository, ScmFileSet scmFileSet, * @return TODO * @throws ScmException if any */ - DiffScmResult diff( ScmRepository scmRepository, ScmFileSet scmFileSet, ScmVersion startVersion, - ScmVersion endVersion ) - throws ScmException; + DiffScmResult diff( + ScmRepository scmRepository, ScmFileSet scmFileSet, ScmVersion startVersion, ScmVersion endVersion) + throws ScmException; /** * Make a file editable. This is used in source control systems where you look at read-only files and you need to @@ -372,8 +369,7 @@ DiffScmResult diff( ScmRepository scmRepository, ScmFileSet scmFileSet, ScmVersi * @return TODO * @throws ScmException if any */ - EditScmResult edit( ScmRepository repository, ScmFileSet fileSet ) - throws ScmException; + EditScmResult edit(ScmRepository repository, ScmFileSet fileSet) throws ScmException; /** * Create an exported copy of the repository on your local machine @@ -383,8 +379,7 @@ EditScmResult edit( ScmRepository repository, ScmFileSet fileSet ) * @return TODO * @throws ScmException if any */ - ExportScmResult export( ScmRepository repository, ScmFileSet fileSet ) - throws ScmException; + ExportScmResult export(ScmRepository repository, ScmFileSet fileSet) throws ScmException; /** * Create an exported copy of the repository on your local machine @@ -395,8 +390,7 @@ ExportScmResult export( ScmRepository repository, ScmFileSet fileSet ) * @return TODO * @throws ScmException if any */ - ExportScmResult export( ScmRepository repository, ScmFileSet fileSet, ScmVersion version ) - throws ScmException; + ExportScmResult export(ScmRepository repository, ScmFileSet fileSet, ScmVersion version) throws ScmException; /** * Create an exported copy of the repository on your local machine @@ -407,8 +401,7 @@ ExportScmResult export( ScmRepository repository, ScmFileSet fileSet, ScmVersion * @return TODO * @throws ScmException if any */ - ExportScmResult export( ScmRepository repository, ScmFileSet fileSet, String outputDirectory ) - throws ScmException; + ExportScmResult export(ScmRepository repository, ScmFileSet fileSet, String outputDirectory) throws ScmException; /** * Create an exported copy of the repository on your local machine @@ -420,8 +413,8 @@ ExportScmResult export( ScmRepository repository, ScmFileSet fileSet, String out * @return TODO * @throws ScmException if any */ - ExportScmResult export( ScmRepository repository, ScmFileSet fileSet, ScmVersion version, String outputDirectory ) - throws ScmException; + ExportScmResult export(ScmRepository repository, ScmFileSet fileSet, ScmVersion version, String outputDirectory) + throws ScmException; /** * List each element (files and directories) of fileSet as they exist in the repository. @@ -433,8 +426,8 @@ ExportScmResult export( ScmRepository repository, ScmFileSet fileSet, ScmVersion * @return the list of files in the repository * @throws ScmException if any */ - ListScmResult list( ScmRepository repository, ScmFileSet fileSet, boolean recursive, ScmVersion version ) - throws ScmException; + ListScmResult list(ScmRepository repository, ScmFileSet fileSet, boolean recursive, ScmVersion version) + throws ScmException; /** * Create new directory/directories in the repository. @@ -446,8 +439,8 @@ ListScmResult list( ScmRepository repository, ScmFileSet fileSet, boolean recurs * @return TODO * @throws ScmException if any */ - MkdirScmResult mkdir( ScmRepository repository, ScmFileSet fileSet, String message, boolean createInLocal ) - throws ScmException; + MkdirScmResult mkdir(ScmRepository repository, ScmFileSet fileSet, String message, boolean createInLocal) + throws ScmException; /** * Removes the given files from the source control system @@ -459,8 +452,7 @@ MkdirScmResult mkdir( ScmRepository repository, ScmFileSet fileSet, String messa * have been removed * @throws ScmException if any */ - RemoveScmResult remove( ScmRepository repository, ScmFileSet fileSet, String message ) - throws ScmException; + RemoveScmResult remove(ScmRepository repository, ScmFileSet fileSet, String message) throws ScmException; /** * Returns the status of the files in the source control system. The state of each file can be one of the @@ -472,8 +464,7 @@ RemoveScmResult remove( ScmRepository repository, ScmFileSet fileSet, String mes * @return TODO * @throws ScmException if any */ - StatusScmResult status( ScmRepository repository, ScmFileSet fileSet ) - throws ScmException; + StatusScmResult status(ScmRepository repository, ScmFileSet fileSet) throws ScmException; /** * Tag (or label in some systems) will tag the source file with a certain tag @@ -485,8 +476,7 @@ StatusScmResult status( ScmRepository repository, ScmFileSet fileSet ) * @return TODO * @throws ScmException if any */ - TagScmResult tag( ScmRepository repository, ScmFileSet fileSet, String tagName ) - throws ScmException; + TagScmResult tag(ScmRepository repository, ScmFileSet fileSet, String tagName) throws ScmException; /** * Tag (or label in some systems) will tag the source file with a certain tag @@ -499,8 +489,7 @@ TagScmResult tag( ScmRepository repository, ScmFileSet fileSet, String tagName ) * @return TODO * @throws ScmException if any */ - TagScmResult tag( ScmRepository repository, ScmFileSet fileSet, String tagName, String message ) - throws ScmException; + TagScmResult tag(ScmRepository repository, ScmFileSet fileSet, String tagName, String message) throws ScmException; /** * Make a file no longer editable. This is the conterpart of @@ -512,8 +501,7 @@ TagScmResult tag( ScmRepository repository, ScmFileSet fileSet, String tagName, * @return TODO * @throws ScmException if any */ - UnEditScmResult unedit( ScmRepository repository, ScmFileSet fileSet ) - throws ScmException; + UnEditScmResult unedit(ScmRepository repository, ScmFileSet fileSet) throws ScmException; /** * Updates the copy on the local machine with the changes in the repository @@ -523,8 +511,7 @@ UnEditScmResult unedit( ScmRepository repository, ScmFileSet fileSet ) * @return TODO * @throws ScmException if any */ - UpdateScmResult update( ScmRepository repository, ScmFileSet fileSet ) - throws ScmException; + UpdateScmResult update(ScmRepository repository, ScmFileSet fileSet) throws ScmException; /** * Updates the copy on the local machine with the changes in the repository @@ -535,8 +522,7 @@ UpdateScmResult update( ScmRepository repository, ScmFileSet fileSet ) * @return TODO * @throws ScmException if any */ - UpdateScmResult update( ScmRepository repository, ScmFileSet fileSet, ScmVersion version ) - throws ScmException; + UpdateScmResult update(ScmRepository repository, ScmFileSet fileSet, ScmVersion version) throws ScmException; /** * Updates the copy on the local machine with the changes in the repository @@ -547,8 +533,7 @@ UpdateScmResult update( ScmRepository repository, ScmFileSet fileSet, ScmVersion * @return TODO * @throws ScmException if any */ - UpdateScmResult update( ScmRepository repository, ScmFileSet fileSet, boolean runChangelog ) - throws ScmException; + UpdateScmResult update(ScmRepository repository, ScmFileSet fileSet, boolean runChangelog) throws ScmException; /** * Updates the copy on the local machine with the changes in the repository @@ -560,8 +545,8 @@ UpdateScmResult update( ScmRepository repository, ScmFileSet fileSet, boolean ru * @return TODO * @throws ScmException if any */ - UpdateScmResult update( ScmRepository repository, ScmFileSet fileSet, ScmVersion version, boolean runChangelog ) - throws ScmException; + UpdateScmResult update(ScmRepository repository, ScmFileSet fileSet, ScmVersion version, boolean runChangelog) + throws ScmException; /** * Updates the copy on the local machine with the changes in the repository @@ -572,8 +557,7 @@ UpdateScmResult update( ScmRepository repository, ScmFileSet fileSet, ScmVersion * @return TODO * @throws ScmException if any */ - UpdateScmResult update( ScmRepository repository, ScmFileSet fileSet, String datePattern ) - throws ScmException; + UpdateScmResult update(ScmRepository repository, ScmFileSet fileSet, String datePattern) throws ScmException; /** * Updates the copy on the local machine with the changes in the repository @@ -585,8 +569,8 @@ UpdateScmResult update( ScmRepository repository, ScmFileSet fileSet, String dat * @return TODO * @throws ScmException if any */ - UpdateScmResult update( ScmRepository repository, ScmFileSet fileSet, ScmVersion version, String datePattern ) - throws ScmException; + UpdateScmResult update(ScmRepository repository, ScmFileSet fileSet, ScmVersion version, String datePattern) + throws ScmException; /** * Updates the copy on the local machine with the changes in the repository @@ -597,8 +581,7 @@ UpdateScmResult update( ScmRepository repository, ScmFileSet fileSet, ScmVersion * @return TODO * @throws ScmException if any */ - UpdateScmResult update( ScmRepository repository, ScmFileSet fileSet, Date lastUpdate ) - throws ScmException; + UpdateScmResult update(ScmRepository repository, ScmFileSet fileSet, Date lastUpdate) throws ScmException; /** * Updates the copy on the local machine with the changes in the repository @@ -610,8 +593,8 @@ UpdateScmResult update( ScmRepository repository, ScmFileSet fileSet, Date lastU * @return TODO * @throws ScmException if any */ - UpdateScmResult update( ScmRepository repository, ScmFileSet fileSet, ScmVersion version, Date lastUpdate ) - throws ScmException; + UpdateScmResult update(ScmRepository repository, ScmFileSet fileSet, ScmVersion version, Date lastUpdate) + throws ScmException; /** * Updates the copy on the local machine with the changes in the repository @@ -623,8 +606,8 @@ UpdateScmResult update( ScmRepository repository, ScmFileSet fileSet, ScmVersion * @return TODO * @throws ScmException if any */ - UpdateScmResult update( ScmRepository repository, ScmFileSet fileSet, Date lastUpdate, String datePattern ) - throws ScmException; + UpdateScmResult update(ScmRepository repository, ScmFileSet fileSet, Date lastUpdate, String datePattern) + throws ScmException; /** * Updates the copy on the local machine with the changes in the repository @@ -637,9 +620,9 @@ UpdateScmResult update( ScmRepository repository, ScmFileSet fileSet, Date lastU * @return TODO * @throws ScmException if any */ - UpdateScmResult update( ScmRepository repository, ScmFileSet fileSet, ScmVersion version, Date lastUpdate, - String datePattern ) - throws ScmException; + UpdateScmResult update( + ScmRepository repository, ScmFileSet fileSet, ScmVersion version, Date lastUpdate, String datePattern) + throws ScmException; /** * Returns the blame of specified file @@ -651,8 +634,7 @@ UpdateScmResult update( ScmRepository repository, ScmFileSet fileSet, ScmVersion * @throws ScmException if any * @since 1.4 */ - BlameScmResult blame( ScmRepository repository, ScmFileSet fileSet, String filename ) - throws ScmException; + BlameScmResult blame(ScmRepository repository, ScmFileSet fileSet, String filename) throws ScmException; /** * @param blameScmRequest TODO @@ -660,6 +642,5 @@ BlameScmResult blame( ScmRepository repository, ScmFileSet fileSet, String filen * @throws ScmException if any * @since 1.4 */ - BlameScmResult blame( BlameScmRequest blameScmRequest ) - throws ScmException; + BlameScmResult blame(BlameScmRequest blameScmRequest) throws ScmException; } diff --git a/maven-scm-api/src/main/java/org/apache/maven/scm/provider/AbstractScmProvider.java b/maven-scm-api/src/main/java/org/apache/maven/scm/provider/AbstractScmProvider.java index 102f9f998..210de4214 100644 --- a/maven-scm-api/src/main/java/org/apache/maven/scm/provider/AbstractScmProvider.java +++ b/maven-scm-api/src/main/java/org/apache/maven/scm/provider/AbstractScmProvider.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,12 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider; + +import java.io.File; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; import org.apache.maven.scm.CommandParameter; import org.apache.maven.scm.CommandParameters; @@ -58,21 +62,14 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import java.io.File; -import java.util.ArrayList; -import java.util.Date; -import java.util.List; - /** * @author Trygve Laugstøl * @author Emmanuel Venisse * @author Olivier Lamy * */ -public abstract class AbstractScmProvider - implements ScmProvider -{ - protected final Logger logger = LoggerFactory.getLogger( getClass() ); +public abstract class AbstractScmProvider implements ScmProvider { + protected final Logger logger = LoggerFactory.getLogger(getClass()); // ---------------------------------------------------------------------- // @@ -82,8 +79,7 @@ public abstract class AbstractScmProvider * {@inheritDoc} */ @Override - public String getScmSpecificFilename() - { + public String getScmSpecificFilename() { return null; } @@ -91,8 +87,7 @@ public String getScmSpecificFilename() * {@inheritDoc} */ @Override - public String sanitizeTagName( String tag ) - { + public String sanitizeTagName(String tag) { /* by default, we assume all tags are valid. */ return tag; } @@ -101,8 +96,7 @@ public String sanitizeTagName( String tag ) * {@inheritDoc} */ @Override - public boolean validateTagName( String tag ) - { + public boolean validateTagName(String tag) { /* by default, we assume all tags are valid. */ return true; } @@ -111,17 +105,13 @@ public boolean validateTagName( String tag ) * {@inheritDoc} */ @Override - public List validateScmUrl( String scmSpecificUrl, char delimiter ) - { + public List validateScmUrl(String scmSpecificUrl, char delimiter) { List messages = new ArrayList(); - try - { - makeProviderScmRepository( scmSpecificUrl, delimiter ); - } - catch ( ScmRepositoryException e ) - { - messages.add( e.getMessage() ); + try { + makeProviderScmRepository(scmSpecificUrl, delimiter); + } catch (ScmRepositoryException e) { + messages.add(e.getMessage()); } return messages; @@ -131,8 +121,7 @@ public List validateScmUrl( String scmSpecificUrl, char delimiter ) * {@inheritDoc} */ @Override - public boolean requiresEditMode() - { + public boolean requiresEditMode() { return false; } @@ -144,105 +133,91 @@ public boolean requiresEditMode() * {@inheritDoc} */ @Override - public AddScmResult add( ScmRepository repository, ScmFileSet fileSet ) - throws ScmException - { - return add( repository, fileSet, (String) null ); + public AddScmResult add(ScmRepository repository, ScmFileSet fileSet) throws ScmException { + return add(repository, fileSet, (String) null); } /** * {@inheritDoc} */ @Override - public AddScmResult add( ScmRepository repository, ScmFileSet fileSet, String message ) - throws ScmException - { - login( repository, fileSet ); + public AddScmResult add(ScmRepository repository, ScmFileSet fileSet, String message) throws ScmException { + login(repository, fileSet); CommandParameters parameters = new CommandParameters(); - parameters.setString( CommandParameter.MESSAGE, message == null ? "" : message ); + parameters.setString(CommandParameter.MESSAGE, message == null ? "" : message); // TODO: binary may be dependant on particular files though // TODO: set boolean? - parameters.setString( CommandParameter.BINARY, "false" ); + parameters.setString(CommandParameter.BINARY, "false"); - return add( repository.getProviderRepository(), fileSet, parameters ); + return add(repository.getProviderRepository(), fileSet, parameters); } @Override - public AddScmResult add( ScmRepository repository, ScmFileSet fileSet, CommandParameters parameters ) - throws ScmException - { - login( repository, fileSet ); + public AddScmResult add(ScmRepository repository, ScmFileSet fileSet, CommandParameters parameters) + throws ScmException { + login(repository, fileSet); - if ( parameters.getString( CommandParameter.BINARY , null ) == null ) - { + if (parameters.getString(CommandParameter.BINARY, null) == null) { // TODO: binary may be dependant on particular files though // TODO: set boolean? - parameters.setString( CommandParameter.BINARY, "false" ); + parameters.setString(CommandParameter.BINARY, "false"); } - return add( repository.getProviderRepository(), fileSet, parameters ); + return add(repository.getProviderRepository(), fileSet, parameters); } /** * TODO: why public? This should be protected, no? */ - public AddScmResult add( ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters ) - throws ScmException - { - throw new NoSuchCommandScmException( "add" ); + public AddScmResult add(ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters) + throws ScmException { + throw new NoSuchCommandScmException("add"); } /** * {@inheritDoc} */ @Override - public BranchScmResult branch( ScmRepository repository, ScmFileSet fileSet, String branchName ) - throws ScmException - { - return branch( repository, fileSet, branchName, new ScmBranchParameters() ); + public BranchScmResult branch(ScmRepository repository, ScmFileSet fileSet, String branchName) throws ScmException { + return branch(repository, fileSet, branchName, new ScmBranchParameters()); } /** * {@inheritDoc} */ @Override - public BranchScmResult branch( ScmRepository repository, ScmFileSet fileSet, String branchName, String message ) - throws ScmException - { + public BranchScmResult branch(ScmRepository repository, ScmFileSet fileSet, String branchName, String message) + throws ScmException { ScmBranchParameters scmBranchParameters = new ScmBranchParameters(); - if ( StringUtils.isNotEmpty( message ) ) - { - scmBranchParameters.setMessage( message ); + if (StringUtils.isNotEmpty(message)) { + scmBranchParameters.setMessage(message); } - return branch( repository, fileSet, branchName, scmBranchParameters ); + return branch(repository, fileSet, branchName, scmBranchParameters); } @Override - public BranchScmResult branch( ScmRepository repository, ScmFileSet fileSet, String branchName, - ScmBranchParameters scmBranchParameters ) - throws ScmException - { - login( repository, fileSet ); + public BranchScmResult branch( + ScmRepository repository, ScmFileSet fileSet, String branchName, ScmBranchParameters scmBranchParameters) + throws ScmException { + login(repository, fileSet); CommandParameters parameters = new CommandParameters(); - parameters.setString( CommandParameter.BRANCH_NAME, branchName ); + parameters.setString(CommandParameter.BRANCH_NAME, branchName); - parameters.setScmBranchParameters( CommandParameter.SCM_BRANCH_PARAMETERS, scmBranchParameters ); + parameters.setScmBranchParameters(CommandParameter.SCM_BRANCH_PARAMETERS, scmBranchParameters); - return branch( repository.getProviderRepository(), fileSet, parameters ); + return branch(repository.getProviderRepository(), fileSet, parameters); } - protected BranchScmResult branch( ScmProviderRepository repository, ScmFileSet fileSet, - CommandParameters parameters ) - throws ScmException - { - throw new NoSuchCommandScmException( "branch" ); + protected BranchScmResult branch(ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters) + throws ScmException { + throw new NoSuchCommandScmException("branch"); } /** @@ -252,11 +227,10 @@ protected BranchScmResult branch( ScmProviderRepository repository, ScmFileSet f */ @Deprecated @Override - public ChangeLogScmResult changeLog( ScmRepository repository, ScmFileSet fileSet, Date startDate, Date endDate, - int numDays, String branch ) - throws ScmException - { - return changeLog( repository, fileSet, startDate, endDate, numDays, branch, null ); + public ChangeLogScmResult changeLog( + ScmRepository repository, ScmFileSet fileSet, Date startDate, Date endDate, int numDays, String branch) + throws ScmException { + return changeLog(repository, fileSet, startDate, endDate, numDays, branch, null); } /** @@ -266,61 +240,65 @@ public ChangeLogScmResult changeLog( ScmRepository repository, ScmFileSet fileSe */ @Deprecated @Override - public ChangeLogScmResult changeLog( ScmRepository repository, ScmFileSet fileSet, Date startDate, Date endDate, - int numDays, String branch, String datePattern ) - throws ScmException - { + public ChangeLogScmResult changeLog( + ScmRepository repository, + ScmFileSet fileSet, + Date startDate, + Date endDate, + int numDays, + String branch, + String datePattern) + throws ScmException { ScmBranch scmBranch = null; - if ( StringUtils.isNotEmpty( branch ) ) - { - scmBranch = new ScmBranch( branch ); + if (StringUtils.isNotEmpty(branch)) { + scmBranch = new ScmBranch(branch); } - return changeLog( repository, fileSet, startDate, endDate, numDays, scmBranch, null ); - + return changeLog(repository, fileSet, startDate, endDate, numDays, scmBranch, null); } /** * {@inheritDoc} */ @Override - public ChangeLogScmResult changeLog( ScmRepository repository, ScmFileSet fileSet, Date startDate, Date endDate, - int numDays, ScmBranch branch ) - throws ScmException - { - return changeLog( repository, fileSet, startDate, endDate, numDays, branch, null ); + public ChangeLogScmResult changeLog( + ScmRepository repository, ScmFileSet fileSet, Date startDate, Date endDate, int numDays, ScmBranch branch) + throws ScmException { + return changeLog(repository, fileSet, startDate, endDate, numDays, branch, null); } /** * {@inheritDoc} */ @Override - public ChangeLogScmResult changeLog( ScmRepository repository, ScmFileSet fileSet, Date startDate, Date endDate, - int numDays, ScmBranch branch, String datePattern ) - throws ScmException - { - final ChangeLogScmRequest request = new ChangeLogScmRequest( repository, fileSet ); - request.setDateRange( startDate, endDate ); - request.setNumDays( numDays ); - request.setScmBranch( branch ); - request.setDatePattern( datePattern ); - return changeLog( request ); + public ChangeLogScmResult changeLog( + ScmRepository repository, + ScmFileSet fileSet, + Date startDate, + Date endDate, + int numDays, + ScmBranch branch, + String datePattern) + throws ScmException { + final ChangeLogScmRequest request = new ChangeLogScmRequest(repository, fileSet); + request.setDateRange(startDate, endDate); + request.setNumDays(numDays); + request.setScmBranch(branch); + request.setDatePattern(datePattern); + return changeLog(request); } /** * {@inheritDoc} */ @Override - public ChangeLogScmResult changeLog( ChangeLogScmRequest request ) - throws ScmException - { + public ChangeLogScmResult changeLog(ChangeLogScmRequest request) throws ScmException { final ScmRepository scmRepository = request.getScmRepository(); final ScmFileSet scmFileSet = request.getScmFileSet(); - login( scmRepository, scmFileSet ); - return changelog( scmRepository.getProviderRepository(), scmFileSet, request.getCommandParameters() ); + login(scmRepository, scmFileSet); + return changelog(scmRepository.getProviderRepository(), scmFileSet, request.getCommandParameters()); } - /** * {@inheritDoc} * @@ -328,10 +306,9 @@ public ChangeLogScmResult changeLog( ChangeLogScmRequest request ) */ @Deprecated @Override - public ChangeLogScmResult changeLog( ScmRepository repository, ScmFileSet fileSet, String startTag, String endTag ) - throws ScmException - { - return changeLog( repository, fileSet, startTag, endTag, null ); + public ChangeLogScmResult changeLog(ScmRepository repository, ScmFileSet fileSet, String startTag, String endTag) + throws ScmException { + return changeLog(repository, fileSet, startTag, endTag, null); } /** @@ -341,66 +318,62 @@ public ChangeLogScmResult changeLog( ScmRepository repository, ScmFileSet fileSe */ @Deprecated @Override - public ChangeLogScmResult changeLog( ScmRepository repository, ScmFileSet fileSet, String startTag, String endTag, - String datePattern ) - throws ScmException - { + public ChangeLogScmResult changeLog( + ScmRepository repository, ScmFileSet fileSet, String startTag, String endTag, String datePattern) + throws ScmException { ScmVersion startRevision = null; ScmVersion endRevision = null; - if ( StringUtils.isNotEmpty( startTag ) ) - { - startRevision = new ScmRevision( startTag ); + if (StringUtils.isNotEmpty(startTag)) { + startRevision = new ScmRevision(startTag); } - if ( StringUtils.isNotEmpty( endTag ) ) - { - endRevision = new ScmRevision( endTag ); + if (StringUtils.isNotEmpty(endTag)) { + endRevision = new ScmRevision(endTag); } - return changeLog( repository, fileSet, startRevision, endRevision, null ); + return changeLog(repository, fileSet, startRevision, endRevision, null); } /** * {@inheritDoc} */ @Override - public ChangeLogScmResult changeLog( ScmRepository repository, ScmFileSet fileSet, ScmVersion startVersion, - ScmVersion endVersion ) - throws ScmException - { - return changeLog( repository, fileSet, startVersion, endVersion, null ); + public ChangeLogScmResult changeLog( + ScmRepository repository, ScmFileSet fileSet, ScmVersion startVersion, ScmVersion endVersion) + throws ScmException { + return changeLog(repository, fileSet, startVersion, endVersion, null); } /** * {@inheritDoc} */ @Override - public ChangeLogScmResult changeLog( ScmRepository repository, ScmFileSet fileSet, ScmVersion startVersion, - ScmVersion endVersion, String datePattern ) - throws ScmException - { - login( repository, fileSet ); + public ChangeLogScmResult changeLog( + ScmRepository repository, + ScmFileSet fileSet, + ScmVersion startVersion, + ScmVersion endVersion, + String datePattern) + throws ScmException { + login(repository, fileSet); CommandParameters parameters = new CommandParameters(); - parameters.setScmVersion( CommandParameter.START_SCM_VERSION, startVersion ); + parameters.setScmVersion(CommandParameter.START_SCM_VERSION, startVersion); - parameters.setScmVersion( CommandParameter.END_SCM_VERSION, endVersion ); + parameters.setScmVersion(CommandParameter.END_SCM_VERSION, endVersion); - parameters.setString( CommandParameter.CHANGELOG_DATE_PATTERN, datePattern ); + parameters.setString(CommandParameter.CHANGELOG_DATE_PATTERN, datePattern); - return changelog( repository.getProviderRepository(), fileSet, parameters ); + return changelog(repository.getProviderRepository(), fileSet, parameters); } - protected ChangeLogScmResult changelog( ScmProviderRepository repository, ScmFileSet fileSet, - CommandParameters parameters ) - throws ScmException - { - throw new NoSuchCommandScmException( "changelog" ); + protected ChangeLogScmResult changelog( + ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters) throws ScmException { + throw new NoSuchCommandScmException("changelog"); } - /** * {@inheritDoc} * @@ -408,56 +381,47 @@ protected ChangeLogScmResult changelog( ScmProviderRepository repository, ScmFil */ @Deprecated @Override - public CheckInScmResult checkIn( ScmRepository repository, ScmFileSet fileSet, String tag, String message ) - throws ScmException - { + public CheckInScmResult checkIn(ScmRepository repository, ScmFileSet fileSet, String tag, String message) + throws ScmException { ScmVersion scmVersion = null; - if ( StringUtils.isNotEmpty( tag ) ) - { - scmVersion = new ScmBranch( tag ); + if (StringUtils.isNotEmpty(tag)) { + scmVersion = new ScmBranch(tag); } - return checkIn( repository, fileSet, scmVersion, message ); + return checkIn(repository, fileSet, scmVersion, message); } /** * {@inheritDoc} */ @Override - public CheckInScmResult checkIn( ScmRepository repository, ScmFileSet fileSet, String message ) - throws ScmException - { - return checkIn( repository, fileSet, (ScmVersion) null, message ); + public CheckInScmResult checkIn(ScmRepository repository, ScmFileSet fileSet, String message) throws ScmException { + return checkIn(repository, fileSet, (ScmVersion) null, message); } /** * {@inheritDoc} */ @Override - public CheckInScmResult checkIn( ScmRepository repository, ScmFileSet fileSet, ScmVersion scmVersion, - String message ) - throws ScmException - { - login( repository, fileSet ); + public CheckInScmResult checkIn(ScmRepository repository, ScmFileSet fileSet, ScmVersion scmVersion, String message) + throws ScmException { + login(repository, fileSet); CommandParameters parameters = new CommandParameters(); - parameters.setScmVersion( CommandParameter.SCM_VERSION, scmVersion ); + parameters.setScmVersion(CommandParameter.SCM_VERSION, scmVersion); - parameters.setString( CommandParameter.MESSAGE, message ); + parameters.setString(CommandParameter.MESSAGE, message); - return checkin( repository.getProviderRepository(), fileSet, parameters ); + return checkin(repository.getProviderRepository(), fileSet, parameters); } - protected CheckInScmResult checkin( ScmProviderRepository repository, ScmFileSet fileSet, - CommandParameters parameters ) - throws ScmException - { - throw new NoSuchCommandScmException( "checkin" ); + protected CheckInScmResult checkin( + ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters) throws ScmException { + throw new NoSuchCommandScmException("checkin"); } - /** * {@inheritDoc} * @@ -465,10 +429,8 @@ protected CheckInScmResult checkin( ScmProviderRepository repository, ScmFileSet */ @Deprecated @Override - public CheckOutScmResult checkOut( ScmRepository repository, ScmFileSet fileSet, String tag ) - throws ScmException - { - return checkOut( repository, fileSet, tag, true ); + public CheckOutScmResult checkOut(ScmRepository repository, ScmFileSet fileSet, String tag) throws ScmException { + return checkOut(repository, fileSet, tag, true); } /** @@ -478,87 +440,76 @@ public CheckOutScmResult checkOut( ScmRepository repository, ScmFileSet fileSet, */ @Deprecated @Override - public CheckOutScmResult checkOut( ScmRepository repository, ScmFileSet fileSet, String tag, boolean recursive ) - throws ScmException - { + public CheckOutScmResult checkOut(ScmRepository repository, ScmFileSet fileSet, String tag, boolean recursive) + throws ScmException { ScmVersion scmVersion = null; - if ( StringUtils.isNotEmpty( tag ) ) - { - scmVersion = new ScmBranch( tag ); + if (StringUtils.isNotEmpty(tag)) { + scmVersion = new ScmBranch(tag); } - return checkOut( repository, fileSet, scmVersion, recursive ); + return checkOut(repository, fileSet, scmVersion, recursive); } /** * {@inheritDoc} */ @Override - public CheckOutScmResult checkOut( ScmRepository repository, ScmFileSet fileSet ) - throws ScmException - { - return checkOut( repository, fileSet, (ScmVersion) null, true ); + public CheckOutScmResult checkOut(ScmRepository repository, ScmFileSet fileSet) throws ScmException { + return checkOut(repository, fileSet, (ScmVersion) null, true); } /** * {@inheritDoc} */ @Override - public CheckOutScmResult checkOut( ScmRepository repository, ScmFileSet fileSet, ScmVersion scmVersion ) - throws ScmException - { - return checkOut( repository, fileSet, scmVersion, true ); + public CheckOutScmResult checkOut(ScmRepository repository, ScmFileSet fileSet, ScmVersion scmVersion) + throws ScmException { + return checkOut(repository, fileSet, scmVersion, true); } /** * {@inheritDoc} */ @Override - public CheckOutScmResult checkOut( ScmRepository repository, ScmFileSet fileSet, boolean recursive ) - throws ScmException - { - return checkOut( repository, fileSet, (ScmVersion) null, recursive ); + public CheckOutScmResult checkOut(ScmRepository repository, ScmFileSet fileSet, boolean recursive) + throws ScmException { + return checkOut(repository, fileSet, (ScmVersion) null, recursive); } /** * {@inheritDoc} */ @Override - public CheckOutScmResult checkOut( ScmRepository repository, ScmFileSet fileSet, ScmVersion scmVersion, - boolean recursive ) - throws ScmException - { - login( repository, fileSet ); + public CheckOutScmResult checkOut( + ScmRepository repository, ScmFileSet fileSet, ScmVersion scmVersion, boolean recursive) + throws ScmException { + login(repository, fileSet); CommandParameters parameters = new CommandParameters(); - parameters.setScmVersion( CommandParameter.SCM_VERSION, scmVersion ); + parameters.setScmVersion(CommandParameter.SCM_VERSION, scmVersion); - parameters.setString( CommandParameter.RECURSIVE, Boolean.toString( recursive ) ); + parameters.setString(CommandParameter.RECURSIVE, Boolean.toString(recursive)); - return checkout( repository.getProviderRepository(), fileSet, parameters ); + return checkout(repository.getProviderRepository(), fileSet, parameters); } @Override - public CheckOutScmResult checkOut( ScmRepository repository, ScmFileSet fileSet, ScmVersion scmVersion, - CommandParameters commandParameters ) - throws ScmException - { - login( repository, fileSet ); - if ( scmVersion != null && commandParameters.getScmVersion( CommandParameter.SCM_VERSION, null ) == null ) - { - commandParameters.setScmVersion( CommandParameter.SCM_VERSION, scmVersion ); + public CheckOutScmResult checkOut( + ScmRepository repository, ScmFileSet fileSet, ScmVersion scmVersion, CommandParameters commandParameters) + throws ScmException { + login(repository, fileSet); + if (scmVersion != null && commandParameters.getScmVersion(CommandParameter.SCM_VERSION, null) == null) { + commandParameters.setScmVersion(CommandParameter.SCM_VERSION, scmVersion); } - return checkout( repository.getProviderRepository(), fileSet, commandParameters ); + return checkout(repository.getProviderRepository(), fileSet, commandParameters); } - protected CheckOutScmResult checkout( ScmProviderRepository repository, ScmFileSet fileSet, - CommandParameters parameters ) - throws ScmException - { - throw new NoSuchCommandScmException( "checkout" ); + protected CheckOutScmResult checkout( + ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters) throws ScmException { + throw new NoSuchCommandScmException("checkout"); } /** @@ -568,73 +519,64 @@ protected CheckOutScmResult checkout( ScmProviderRepository repository, ScmFileS */ @Deprecated @Override - public DiffScmResult diff( ScmRepository repository, ScmFileSet fileSet, String startRevision, String endRevision ) - throws ScmException - { + public DiffScmResult diff(ScmRepository repository, ScmFileSet fileSet, String startRevision, String endRevision) + throws ScmException { ScmVersion startVersion = null; ScmVersion endVersion = null; - if ( StringUtils.isNotEmpty( startRevision ) ) - { - startVersion = new ScmRevision( startRevision ); + if (StringUtils.isNotEmpty(startRevision)) { + startVersion = new ScmRevision(startRevision); } - if ( StringUtils.isNotEmpty( endRevision ) ) - { - endVersion = new ScmRevision( endRevision ); + if (StringUtils.isNotEmpty(endRevision)) { + endVersion = new ScmRevision(endRevision); } - return diff( repository, fileSet, startVersion, endVersion ); + return diff(repository, fileSet, startVersion, endVersion); } /** * {@inheritDoc} */ @Override - public DiffScmResult diff( ScmRepository repository, ScmFileSet fileSet, ScmVersion startVersion, - ScmVersion endVersion ) - throws ScmException - { - login( repository, fileSet ); + public DiffScmResult diff( + ScmRepository repository, ScmFileSet fileSet, ScmVersion startVersion, ScmVersion endVersion) + throws ScmException { + login(repository, fileSet); CommandParameters parameters = new CommandParameters(); - parameters.setScmVersion( CommandParameter.START_SCM_VERSION, startVersion ); + parameters.setScmVersion(CommandParameter.START_SCM_VERSION, startVersion); - parameters.setScmVersion( CommandParameter.END_SCM_VERSION, endVersion ); + parameters.setScmVersion(CommandParameter.END_SCM_VERSION, endVersion); - return diff( repository.getProviderRepository(), fileSet, parameters ); + return diff(repository.getProviderRepository(), fileSet, parameters); } - protected DiffScmResult diff( ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters ) - throws ScmException - { - throw new NoSuchCommandScmException( "diff" ); + protected DiffScmResult diff(ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters) + throws ScmException { + throw new NoSuchCommandScmException("diff"); } /** * {@inheritDoc} */ @Override - public EditScmResult edit( ScmRepository repository, ScmFileSet fileSet ) - throws ScmException - { - login( repository, fileSet ); + public EditScmResult edit(ScmRepository repository, ScmFileSet fileSet) throws ScmException { + login(repository, fileSet); CommandParameters parameters = new CommandParameters(); - return edit( repository.getProviderRepository(), fileSet, parameters ); + return edit(repository.getProviderRepository(), fileSet, parameters); } - protected EditScmResult edit( ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters ) - throws ScmException - { - if ( logger.isWarnEnabled() ) - { - logger.warn( "Provider " + this.getScmType() + " does not support edit operation." ); + protected EditScmResult edit(ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters) + throws ScmException { + if (logger.isWarnEnabled()) { + logger.warn("Provider " + this.getScmType() + " does not support edit operation."); } - return new EditScmResult( "", null, null, true ); + return new EditScmResult("", null, null, true); } /** @@ -644,10 +586,8 @@ protected EditScmResult edit( ScmProviderRepository repository, ScmFileSet fileS */ @Deprecated @Override - public ExportScmResult export( ScmRepository repository, ScmFileSet fileSet, String tag ) - throws ScmException - { - return export( repository, fileSet, tag, null ); + public ExportScmResult export(ScmRepository repository, ScmFileSet fileSet, String tag) throws ScmException { + return export(repository, fileSet, tag, null); } /** @@ -657,101 +597,89 @@ public ExportScmResult export( ScmRepository repository, ScmFileSet fileSet, Str */ @Deprecated @Override - public ExportScmResult export( ScmRepository repository, ScmFileSet fileSet, String tag, String outputDirectory ) - throws ScmException - { + public ExportScmResult export(ScmRepository repository, ScmFileSet fileSet, String tag, String outputDirectory) + throws ScmException { ScmVersion scmVersion = null; - if ( StringUtils.isNotEmpty( tag ) ) - { - scmVersion = new ScmRevision( tag ); + if (StringUtils.isNotEmpty(tag)) { + scmVersion = new ScmRevision(tag); } - return export( repository, fileSet, scmVersion, outputDirectory ); + return export(repository, fileSet, scmVersion, outputDirectory); } /** * {@inheritDoc} */ @Override - public ExportScmResult export( ScmRepository repository, ScmFileSet fileSet ) - throws ScmException - { - return export( repository, fileSet, (ScmVersion) null, null ); + public ExportScmResult export(ScmRepository repository, ScmFileSet fileSet) throws ScmException { + return export(repository, fileSet, (ScmVersion) null, null); } /** * {@inheritDoc} */ @Override - public ExportScmResult export( ScmRepository repository, ScmFileSet fileSet, ScmVersion scmVersion ) - throws ScmException - { - return export( repository, fileSet, scmVersion, null ); + public ExportScmResult export(ScmRepository repository, ScmFileSet fileSet, ScmVersion scmVersion) + throws ScmException { + return export(repository, fileSet, scmVersion, null); } /** * {@inheritDoc} */ @Override - public ExportScmResult export( ScmRepository repository, ScmFileSet fileSet, ScmVersion scmVersion, - String outputDirectory ) - throws ScmException - { - login( repository, fileSet ); + public ExportScmResult export( + ScmRepository repository, ScmFileSet fileSet, ScmVersion scmVersion, String outputDirectory) + throws ScmException { + login(repository, fileSet); CommandParameters parameters = new CommandParameters(); - parameters.setScmVersion( CommandParameter.SCM_VERSION, scmVersion ); + parameters.setScmVersion(CommandParameter.SCM_VERSION, scmVersion); - parameters.setString( CommandParameter.OUTPUT_DIRECTORY, outputDirectory ); + parameters.setString(CommandParameter.OUTPUT_DIRECTORY, outputDirectory); - return export( repository.getProviderRepository(), fileSet, parameters ); + return export(repository.getProviderRepository(), fileSet, parameters); } - protected ExportScmResult export( ScmProviderRepository repository, ScmFileSet fileSet, - CommandParameters parameters ) - throws ScmException - { - throw new NoSuchCommandScmException( "export" ); + protected ExportScmResult export(ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters) + throws ScmException { + throw new NoSuchCommandScmException("export"); } /** * {@inheritDoc} */ @Override - public ListScmResult list( ScmRepository repository, ScmFileSet fileSet, boolean recursive, String tag ) - throws ScmException - { + public ListScmResult list(ScmRepository repository, ScmFileSet fileSet, boolean recursive, String tag) + throws ScmException { ScmVersion scmVersion = null; - if ( StringUtils.isNotEmpty( tag ) ) - { - scmVersion = new ScmRevision( tag ); + if (StringUtils.isNotEmpty(tag)) { + scmVersion = new ScmRevision(tag); } - return list( repository, fileSet, recursive, scmVersion ); + return list(repository, fileSet, recursive, scmVersion); } /** * {@inheritDoc} */ @Override - public ListScmResult list( ScmRepository repository, ScmFileSet fileSet, boolean recursive, ScmVersion scmVersion ) - throws ScmException - { - login( repository, fileSet ); + public ListScmResult list(ScmRepository repository, ScmFileSet fileSet, boolean recursive, ScmVersion scmVersion) + throws ScmException { + login(repository, fileSet); CommandParameters parameters = new CommandParameters(); - parameters.setString( CommandParameter.RECURSIVE, Boolean.toString( recursive ) ); + parameters.setString(CommandParameter.RECURSIVE, Boolean.toString(recursive)); - if ( scmVersion != null ) - { - parameters.setScmVersion( CommandParameter.SCM_VERSION, scmVersion ); + if (scmVersion != null) { + parameters.setScmVersion(CommandParameter.SCM_VERSION, scmVersion); } - return list( repository.getProviderRepository(), fileSet, parameters ); + return list(repository.getProviderRepository(), fileSet, parameters); } /** @@ -764,37 +692,33 @@ public ListScmResult list( ScmRepository repository, ScmFileSet fileSet, boolean * @throws NoSuchCommandScmException unless overriden by subclass * @throws ScmException if any */ - protected ListScmResult list( ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters ) - throws ScmException - { - throw new NoSuchCommandScmException( "list" ); + protected ListScmResult list(ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters) + throws ScmException { + throw new NoSuchCommandScmException("list"); } /** * {@inheritDoc} */ @Override - public MkdirScmResult mkdir( ScmRepository repository, ScmFileSet fileSet, String message, boolean createInLocal ) - throws ScmException - { - login( repository, fileSet ); + public MkdirScmResult mkdir(ScmRepository repository, ScmFileSet fileSet, String message, boolean createInLocal) + throws ScmException { + login(repository, fileSet); CommandParameters parameters = new CommandParameters(); - if ( message == null ) - { + if (message == null) { message = ""; - if ( !createInLocal ) - { - logger.warn( "Commit message is empty!" ); + if (!createInLocal) { + logger.warn("Commit message is empty!"); } } - parameters.setString( CommandParameter.MESSAGE, message ); + parameters.setString(CommandParameter.MESSAGE, message); - parameters.setString( CommandParameter.SCM_MKDIR_CREATE_IN_LOCAL, Boolean.toString( createInLocal ) ); + parameters.setString(CommandParameter.SCM_MKDIR_CREATE_IN_LOCAL, Boolean.toString(createInLocal)); - return mkdir( repository.getProviderRepository(), fileSet, parameters ); + return mkdir(repository.getProviderRepository(), fileSet, parameters); } /** @@ -806,169 +730,143 @@ public MkdirScmResult mkdir( ScmRepository repository, ScmFileSet fileSet, Strin * @return TODO * @throws ScmException if any */ - protected MkdirScmResult mkdir( ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters ) - throws ScmException - { - throw new NoSuchCommandScmException( "mkdir" ); + protected MkdirScmResult mkdir(ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters) + throws ScmException { + throw new NoSuchCommandScmException("mkdir"); } - private void login( ScmRepository repository, ScmFileSet fileSet ) - throws ScmException - { - LoginScmResult result = login( repository.getProviderRepository(), fileSet, new CommandParameters() ); + private void login(ScmRepository repository, ScmFileSet fileSet) throws ScmException { + LoginScmResult result = login(repository.getProviderRepository(), fileSet, new CommandParameters()); - if ( !result.isSuccess() ) - { - throw new ScmException( "Can't login.\n" + result.getCommandOutput() ); + if (!result.isSuccess()) { + throw new ScmException("Can't login.\n" + result.getCommandOutput()); } } - protected LoginScmResult login( ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters ) - throws ScmException - { - return new LoginScmResult( null, null, null, true ); + protected LoginScmResult login(ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters) + throws ScmException { + return new LoginScmResult(null, null, null, true); } /** * {@inheritDoc} */ @Override - public RemoveScmResult remove( ScmRepository repository, ScmFileSet fileSet, String message ) - throws ScmException - { - login( repository, fileSet ); + public RemoveScmResult remove(ScmRepository repository, ScmFileSet fileSet, String message) throws ScmException { + login(repository, fileSet); CommandParameters parameters = new CommandParameters(); - parameters.setString( CommandParameter.MESSAGE, message == null ? "" : message ); + parameters.setString(CommandParameter.MESSAGE, message == null ? "" : message); - return remove( repository.getProviderRepository(), fileSet, parameters ); + return remove(repository.getProviderRepository(), fileSet, parameters); } - protected RemoveScmResult remove( ScmProviderRepository repository, ScmFileSet fileSet, - CommandParameters parameters ) - throws ScmException - { - throw new NoSuchCommandScmException( "remove" ); + protected RemoveScmResult remove(ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters) + throws ScmException { + throw new NoSuchCommandScmException("remove"); } /** * {@inheritDoc} */ @Override - public StatusScmResult status( ScmRepository repository, ScmFileSet fileSet ) - throws ScmException - { - login( repository, fileSet ); + public StatusScmResult status(ScmRepository repository, ScmFileSet fileSet) throws ScmException { + login(repository, fileSet); CommandParameters parameters = new CommandParameters(); - return status( repository.getProviderRepository(), fileSet, parameters ); + return status(repository.getProviderRepository(), fileSet, parameters); } - protected StatusScmResult status( ScmProviderRepository repository, ScmFileSet fileSet, - CommandParameters parameters ) - throws ScmException - { - throw new NoSuchCommandScmException( "status" ); + protected StatusScmResult status(ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters) + throws ScmException { + throw new NoSuchCommandScmException("status"); } /** * {@inheritDoc} */ @Override - public TagScmResult tag( ScmRepository repository, ScmFileSet fileSet, String tagName ) - throws ScmException - { - return tag( repository, fileSet, tagName, new ScmTagParameters() ); + public TagScmResult tag(ScmRepository repository, ScmFileSet fileSet, String tagName) throws ScmException { + return tag(repository, fileSet, tagName, new ScmTagParameters()); } /** * {@inheritDoc} */ @Override - public TagScmResult tag( ScmRepository repository, ScmFileSet fileSet, String tagName, String message ) - throws ScmException - { - login( repository, fileSet ); + public TagScmResult tag(ScmRepository repository, ScmFileSet fileSet, String tagName, String message) + throws ScmException { + login(repository, fileSet); CommandParameters parameters = new CommandParameters(); - parameters.setString( CommandParameter.TAG_NAME, tagName ); + parameters.setString(CommandParameter.TAG_NAME, tagName); - if ( StringUtils.isNotEmpty( message ) ) - { - parameters.setString( CommandParameter.MESSAGE, message ); + if (StringUtils.isNotEmpty(message)) { + parameters.setString(CommandParameter.MESSAGE, message); } - ScmTagParameters scmTagParameters = new ScmTagParameters( message ); + ScmTagParameters scmTagParameters = new ScmTagParameters(message); - parameters.setScmTagParameters( CommandParameter.SCM_TAG_PARAMETERS, scmTagParameters ); + parameters.setScmTagParameters(CommandParameter.SCM_TAG_PARAMETERS, scmTagParameters); - return tag( repository.getProviderRepository(), fileSet, parameters ); + return tag(repository.getProviderRepository(), fileSet, parameters); } /** * {@inheritDoc} */ @Override - public TagScmResult tag( ScmRepository repository, ScmFileSet fileSet, String tagName, - ScmTagParameters scmTagParameters ) - throws ScmException - { - login( repository, fileSet ); + public TagScmResult tag( + ScmRepository repository, ScmFileSet fileSet, String tagName, ScmTagParameters scmTagParameters) + throws ScmException { + login(repository, fileSet); CommandParameters parameters = new CommandParameters(); - parameters.setString( CommandParameter.TAG_NAME, tagName ); + parameters.setString(CommandParameter.TAG_NAME, tagName); - parameters.setScmTagParameters( CommandParameter.SCM_TAG_PARAMETERS, scmTagParameters ); + parameters.setScmTagParameters(CommandParameter.SCM_TAG_PARAMETERS, scmTagParameters); - return tag( repository.getProviderRepository(), fileSet, parameters ); + return tag(repository.getProviderRepository(), fileSet, parameters); } - protected TagScmResult tag( ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters ) - throws ScmException - { - throw new NoSuchCommandScmException( "tag" ); + protected TagScmResult tag(ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters) + throws ScmException { + throw new NoSuchCommandScmException("tag"); } /** * {@inheritDoc} */ @Override - public UnEditScmResult unedit( ScmRepository repository, ScmFileSet fileSet ) - throws ScmException - { - login( repository, fileSet ); + public UnEditScmResult unedit(ScmRepository repository, ScmFileSet fileSet) throws ScmException { + login(repository, fileSet); CommandParameters parameters = new CommandParameters(); - return unedit( repository.getProviderRepository(), fileSet, parameters ); + return unedit(repository.getProviderRepository(), fileSet, parameters); } - protected UnEditScmResult unedit( ScmProviderRepository repository, ScmFileSet fileSet, - CommandParameters parameters ) - throws ScmException - { - if ( logger.isWarnEnabled() ) - { - logger.warn( "Provider " + this.getScmType() + " does not support unedit operation." ); + protected UnEditScmResult unedit(ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters) + throws ScmException { + if (logger.isWarnEnabled()) { + logger.warn("Provider " + this.getScmType() + " does not support unedit operation."); } - return new UnEditScmResult( "", null, null, true ); + return new UnEditScmResult("", null, null, true); } /** * {@inheritDoc} */ @Override - public UntagScmResult untag( ScmRepository repository, ScmFileSet fileSet, - CommandParameters parameters ) - throws ScmException - { - logger.warn( "Provider " + this.getScmType() + " does not support untag operation." ); - return new UntagScmResult( "", null, null, true ); + public UntagScmResult untag(ScmRepository repository, ScmFileSet fileSet, CommandParameters parameters) + throws ScmException { + logger.warn("Provider " + this.getScmType() + " does not support untag operation."); + return new UntagScmResult("", null, null, true); } /** @@ -978,10 +876,8 @@ public UntagScmResult untag( ScmRepository repository, ScmFileSet fileSet, */ @Deprecated @Override - public UpdateScmResult update( ScmRepository repository, ScmFileSet fileSet, String tag ) - throws ScmException - { - return update( repository, fileSet, tag, true ); + public UpdateScmResult update(ScmRepository repository, ScmFileSet fileSet, String tag) throws ScmException { + return update(repository, fileSet, tag, true); } /** @@ -991,51 +887,45 @@ public UpdateScmResult update( ScmRepository repository, ScmFileSet fileSet, Str */ @Deprecated @Override - public UpdateScmResult update( ScmRepository repository, ScmFileSet fileSet, String tag, boolean runChangelog ) - throws ScmException - { - return update( repository, fileSet, tag, "", runChangelog ); + public UpdateScmResult update(ScmRepository repository, ScmFileSet fileSet, String tag, boolean runChangelog) + throws ScmException { + return update(repository, fileSet, tag, "", runChangelog); } /** * {@inheritDoc} */ @Override - public UpdateScmResult update( ScmRepository repository, ScmFileSet fileSet ) - throws ScmException - { - return update( repository, fileSet, (ScmVersion) null, true ); + public UpdateScmResult update(ScmRepository repository, ScmFileSet fileSet) throws ScmException { + return update(repository, fileSet, (ScmVersion) null, true); } /** * {@inheritDoc} */ @Override - public UpdateScmResult update( ScmRepository repository, ScmFileSet fileSet, ScmVersion scmVersion ) - throws ScmException - { - return update( repository, fileSet, scmVersion, true ); + public UpdateScmResult update(ScmRepository repository, ScmFileSet fileSet, ScmVersion scmVersion) + throws ScmException { + return update(repository, fileSet, scmVersion, true); } /** * {@inheritDoc} */ @Override - public UpdateScmResult update( ScmRepository repository, ScmFileSet fileSet, boolean runChangelog ) - throws ScmException - { - return update( repository, fileSet, (ScmVersion) null, "", runChangelog ); + public UpdateScmResult update(ScmRepository repository, ScmFileSet fileSet, boolean runChangelog) + throws ScmException { + return update(repository, fileSet, (ScmVersion) null, "", runChangelog); } /** * {@inheritDoc} */ @Override - public UpdateScmResult update( ScmRepository repository, ScmFileSet fileSet, ScmVersion scmVersion, - boolean runChangelog ) - throws ScmException - { - return update( repository, fileSet, scmVersion, "", runChangelog ); + public UpdateScmResult update( + ScmRepository repository, ScmFileSet fileSet, ScmVersion scmVersion, boolean runChangelog) + throws ScmException { + return update(repository, fileSet, scmVersion, "", runChangelog); } /** @@ -1044,55 +934,54 @@ public UpdateScmResult update( ScmRepository repository, ScmFileSet fileSet, Scm * @deprecated */ @Override - public UpdateScmResult update( ScmRepository repository, ScmFileSet fileSet, String tag, String datePattern ) - throws ScmException - { - return update( repository, fileSet, tag, datePattern, true ); + public UpdateScmResult update(ScmRepository repository, ScmFileSet fileSet, String tag, String datePattern) + throws ScmException { + return update(repository, fileSet, tag, datePattern, true); } /** * {@inheritDoc} */ @Override - public UpdateScmResult update( ScmRepository repository, ScmFileSet fileSet, ScmVersion scmVersion, - String datePattern ) - throws ScmException - { - return update( repository, fileSet, scmVersion, datePattern, true ); + public UpdateScmResult update( + ScmRepository repository, ScmFileSet fileSet, ScmVersion scmVersion, String datePattern) + throws ScmException { + return update(repository, fileSet, scmVersion, datePattern, true); } /** * @deprecated */ - private UpdateScmResult update( ScmRepository repository, ScmFileSet fileSet, String tag, String datePattern, - boolean runChangelog ) - throws ScmException - { + private UpdateScmResult update( + ScmRepository repository, ScmFileSet fileSet, String tag, String datePattern, boolean runChangelog) + throws ScmException { ScmBranch scmBranch = null; - if ( StringUtils.isNotEmpty( tag ) ) - { - scmBranch = new ScmBranch( tag ); + if (StringUtils.isNotEmpty(tag)) { + scmBranch = new ScmBranch(tag); } - return update( repository, fileSet, scmBranch, datePattern, runChangelog ); + return update(repository, fileSet, scmBranch, datePattern, runChangelog); } - private UpdateScmResult update( ScmRepository repository, ScmFileSet fileSet, ScmVersion scmVersion, - String datePattern, boolean runChangelog ) - throws ScmException - { - login( repository, fileSet ); + private UpdateScmResult update( + ScmRepository repository, + ScmFileSet fileSet, + ScmVersion scmVersion, + String datePattern, + boolean runChangelog) + throws ScmException { + login(repository, fileSet); CommandParameters parameters = new CommandParameters(); - parameters.setScmVersion( CommandParameter.SCM_VERSION, scmVersion ); + parameters.setScmVersion(CommandParameter.SCM_VERSION, scmVersion); - parameters.setString( CommandParameter.CHANGELOG_DATE_PATTERN, datePattern ); + parameters.setString(CommandParameter.CHANGELOG_DATE_PATTERN, datePattern); - parameters.setString( CommandParameter.RUN_CHANGELOG_WITH_UPDATE, String.valueOf( runChangelog ) ); + parameters.setString(CommandParameter.RUN_CHANGELOG_WITH_UPDATE, String.valueOf(runChangelog)); - return update( repository.getProviderRepository(), fileSet, parameters ); + return update(repository.getProviderRepository(), fileSet, parameters); } /** @@ -1102,21 +991,18 @@ private UpdateScmResult update( ScmRepository repository, ScmFileSet fileSet, Sc */ @Deprecated @Override - public UpdateScmResult update( ScmRepository repository, ScmFileSet fileSet, String tag, Date lastUpdate ) - throws ScmException - { - return update( repository, fileSet, tag, lastUpdate, null ); + public UpdateScmResult update(ScmRepository repository, ScmFileSet fileSet, String tag, Date lastUpdate) + throws ScmException { + return update(repository, fileSet, tag, lastUpdate, null); } /** * {@inheritDoc} */ @Override - public UpdateScmResult update( ScmRepository repository, ScmFileSet fileSet, ScmVersion scmVersion, - Date lastUpdate ) - throws ScmException - { - return update( repository, fileSet, scmVersion, lastUpdate, null ); + public UpdateScmResult update(ScmRepository repository, ScmFileSet fileSet, ScmVersion scmVersion, Date lastUpdate) + throws ScmException { + return update(repository, fileSet, scmVersion, lastUpdate, null); } /** @@ -1126,95 +1012,83 @@ public UpdateScmResult update( ScmRepository repository, ScmFileSet fileSet, Scm */ @Deprecated @Override - public UpdateScmResult update( ScmRepository repository, ScmFileSet fileSet, String tag, Date lastUpdate, - String datePattern ) - throws ScmException - { + public UpdateScmResult update( + ScmRepository repository, ScmFileSet fileSet, String tag, Date lastUpdate, String datePattern) + throws ScmException { ScmBranch scmBranch = null; - if ( StringUtils.isNotEmpty( tag ) ) - { - scmBranch = new ScmBranch( tag ); + if (StringUtils.isNotEmpty(tag)) { + scmBranch = new ScmBranch(tag); } - return update( repository, fileSet, scmBranch, lastUpdate, datePattern ); + return update(repository, fileSet, scmBranch, lastUpdate, datePattern); } /** * {@inheritDoc} */ @Override - public UpdateScmResult update( ScmRepository repository, ScmFileSet fileSet, ScmVersion scmVersion, Date lastUpdate, - String datePattern ) - throws ScmException - { - login( repository, fileSet ); + public UpdateScmResult update( + ScmRepository repository, ScmFileSet fileSet, ScmVersion scmVersion, Date lastUpdate, String datePattern) + throws ScmException { + login(repository, fileSet); CommandParameters parameters = new CommandParameters(); - parameters.setScmVersion( CommandParameter.SCM_VERSION, scmVersion ); + parameters.setScmVersion(CommandParameter.SCM_VERSION, scmVersion); - if ( lastUpdate != null ) - { - parameters.setDate( CommandParameter.START_DATE, lastUpdate ); + if (lastUpdate != null) { + parameters.setDate(CommandParameter.START_DATE, lastUpdate); } - parameters.setString( CommandParameter.CHANGELOG_DATE_PATTERN, datePattern ); + parameters.setString(CommandParameter.CHANGELOG_DATE_PATTERN, datePattern); - parameters.setString( CommandParameter.RUN_CHANGELOG_WITH_UPDATE, "true" ); + parameters.setString(CommandParameter.RUN_CHANGELOG_WITH_UPDATE, "true"); - return update( repository.getProviderRepository(), fileSet, parameters ); + return update(repository.getProviderRepository(), fileSet, parameters); } - protected UpdateScmResult update( ScmProviderRepository repository, ScmFileSet fileSet, - CommandParameters parameters ) - throws ScmException - { - throw new NoSuchCommandScmException( "update" ); + protected UpdateScmResult update(ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters) + throws ScmException { + throw new NoSuchCommandScmException("update"); } /** * {@inheritDoc} */ @Override - public BlameScmResult blame( ScmRepository repository, ScmFileSet fileSet, String filename ) - throws ScmException - { - login( repository, fileSet ); + public BlameScmResult blame(ScmRepository repository, ScmFileSet fileSet, String filename) throws ScmException { + login(repository, fileSet); CommandParameters parameters = new CommandParameters(); - parameters.setString( CommandParameter.FILE, filename ); + parameters.setString(CommandParameter.FILE, filename); - return blame( repository.getProviderRepository(), fileSet, parameters ); + return blame(repository.getProviderRepository(), fileSet, parameters); } - protected BlameScmResult blame( ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters ) - throws ScmException - { - throw new NoSuchCommandScmException( "blame" ); + protected BlameScmResult blame(ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters) + throws ScmException { + throw new NoSuchCommandScmException("blame"); } @Override - public BlameScmResult blame( BlameScmRequest blameScmRequest ) - throws ScmException - { - return blame( blameScmRequest.getScmRepository().getProviderRepository(), blameScmRequest.getScmFileSet(), - blameScmRequest.getCommandParameters() ); + public BlameScmResult blame(BlameScmRequest blameScmRequest) throws ScmException { + return blame( + blameScmRequest.getScmRepository().getProviderRepository(), + blameScmRequest.getScmFileSet(), + blameScmRequest.getCommandParameters()); } @Override - public InfoScmResult info( ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters ) - throws ScmException - { + public InfoScmResult info(ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters) + throws ScmException { return null; } @Override - public RemoteInfoScmResult remoteInfo( ScmProviderRepository repository, ScmFileSet fileSet, - CommandParameters parameters ) - throws ScmException - { + public RemoteInfoScmResult remoteInfo( + ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters) throws ScmException { return null; } @@ -1222,9 +1096,8 @@ public RemoteInfoScmResult remoteInfo( ScmProviderRepository repository, ScmFile * {@inheritDoc} */ @Override - public ScmProviderRepository makeProviderScmRepository( File path ) - throws ScmRepositoryException, UnknownRepositoryStructure - { + public ScmProviderRepository makeProviderScmRepository(File path) + throws ScmRepositoryException, UnknownRepositoryStructure { throw new UnknownRepositoryStructure(); } } diff --git a/maven-scm-api/src/main/java/org/apache/maven/scm/provider/ScmProvider.java b/maven-scm-api/src/main/java/org/apache/maven/scm/provider/ScmProvider.java index 5abf8b990..72593d5ef 100644 --- a/maven-scm-api/src/main/java/org/apache/maven/scm/provider/ScmProvider.java +++ b/maven-scm-api/src/main/java/org/apache/maven/scm/provider/ScmProvider.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,11 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider; + +import java.io.File; +import java.util.Date; +import java.util.List; import org.apache.maven.scm.CommandParameters; import org.apache.maven.scm.ScmBranch; @@ -51,25 +54,20 @@ import org.apache.maven.scm.repository.ScmRepositoryException; import org.apache.maven.scm.repository.UnknownRepositoryStructure; -import java.io.File; -import java.util.Date; -import java.util.List; - /** * @author Emmanuel Venisse * */ -public interface ScmProvider -{ +public interface ScmProvider { String getScmType(); boolean requiresEditMode(); - ScmProviderRepository makeProviderScmRepository( String scmSpecificUrl, char delimiter ) - throws ScmRepositoryException; + ScmProviderRepository makeProviderScmRepository(String scmSpecificUrl, char delimiter) + throws ScmRepositoryException; - ScmProviderRepository makeProviderScmRepository( File path ) - throws ScmRepositoryException, UnknownRepositoryStructure; + ScmProviderRepository makeProviderScmRepository(File path) + throws ScmRepositoryException, UnknownRepositoryStructure; /** * Sets the interactive mode. @@ -77,9 +75,7 @@ ScmProviderRepository makeProviderScmRepository( File path ) * @param interactive either {@code true} in case user may be prompted for information, otherwise {@code false} * @since 2.0.0-M2 */ - default void setInteractive( boolean interactive ) - { - } + default void setInteractive(boolean interactive) {} /** * Validate the scm url. @@ -88,7 +84,7 @@ default void setInteractive( boolean interactive ) * @param delimiter The delimiter used in the SCM url * @return Returns a list of messages if the validation failed */ - List validateScmUrl( String scmSpecificUrl, char delimiter ); + List validateScmUrl(String scmSpecificUrl, char delimiter); /** * Returns the scm reserved file name where the SCM stores information like '.git', '.svn'. @@ -103,7 +99,7 @@ default void setInteractive( boolean interactive ) * @param tag tag name to check * @return true if tag is valid */ - boolean validateTagName( String tag ); + boolean validateTagName(String tag); /** * Given a tag name, make it suitable for this SCM provider. @@ -111,7 +107,7 @@ default void setInteractive( boolean interactive ) * @param tag input tag name * @return sanitized tag name */ - String sanitizeTagName( String tag ); + String sanitizeTagName(String tag); /** * Adds the given files to the source control system @@ -121,8 +117,7 @@ default void setInteractive( boolean interactive ) * @return an {@link AddScmResult} that contains the files that have been added * @throws ScmException if any */ - AddScmResult add( ScmRepository repository, ScmFileSet fileSet ) - throws ScmException; + AddScmResult add(ScmRepository repository, ScmFileSet fileSet) throws ScmException; /** * Adds the given files to the source control system @@ -133,8 +128,7 @@ AddScmResult add( ScmRepository repository, ScmFileSet fileSet ) * @return an {@link AddScmResult} that contains the files that have been added * @throws ScmException if any */ - AddScmResult add( ScmRepository repository, ScmFileSet fileSet, String message ) - throws ScmException; + AddScmResult add(ScmRepository repository, ScmFileSet fileSet, String message) throws ScmException; /** * Adds the given files to the source control system @@ -145,8 +139,8 @@ AddScmResult add( ScmRepository repository, ScmFileSet fileSet, String message ) * @return an {@link AddScmResult} that contains the files that have been added * @throws ScmException if any */ - AddScmResult add( ScmRepository repository, ScmFileSet fileSet, CommandParameters commandParameters ) - throws ScmException; + AddScmResult add(ScmRepository repository, ScmFileSet fileSet, CommandParameters commandParameters) + throws ScmException; /** * Branch (or label in some systems) will create a branch of the source file with a certain branch name @@ -159,8 +153,7 @@ AddScmResult add( ScmRepository repository, ScmFileSet fileSet, CommandParameter * @throws ScmException if any * @deprecated use {@link #branch(ScmRepository, ScmFileSet, String, ScmBranchParameters)} */ - BranchScmResult branch( ScmRepository repository, ScmFileSet fileSet, String branchName ) - throws ScmException; + BranchScmResult branch(ScmRepository repository, ScmFileSet fileSet, String branchName) throws ScmException; /** * Branch (or label in some systems) will create a branch of the source file with a certain branch name @@ -174,8 +167,8 @@ BranchScmResult branch( ScmRepository repository, ScmFileSet fileSet, String bra * @throws ScmException if any * @deprecated use {@link #branch(ScmRepository, ScmFileSet, String, ScmBranchParameters)} */ - BranchScmResult branch( ScmRepository repository, ScmFileSet fileSet, String branchName, String message ) - throws ScmException; + BranchScmResult branch(ScmRepository repository, ScmFileSet fileSet, String branchName, String message) + throws ScmException; /** * Branch (or label in some systems) will create a branch of the source file with a certain @@ -190,9 +183,9 @@ BranchScmResult branch( ScmRepository repository, ScmFileSet fileSet, String bra * @throws ScmException if any * @since 1.3 */ - BranchScmResult branch( ScmRepository repository, ScmFileSet fileSet, String branchName, - ScmBranchParameters scmBranchParameters ) - throws ScmException; + BranchScmResult branch( + ScmRepository repository, ScmFileSet fileSet, String branchName, ScmBranchParameters scmBranchParameters) + throws ScmException; /** * Returns the changes that have happened in the source control system in a certain period of time. @@ -211,9 +204,9 @@ BranchScmResult branch( ScmRepository repository, ScmFileSet fileSet, String bra * org.apache.maven.scm.ScmFileSet, java.util.Date, java.util.Date, int, * org.apache.maven.scm.ScmBranch)} */ - ChangeLogScmResult changeLog( ScmRepository repository, ScmFileSet fileSet, Date startDate, Date endDate, - int numDays, String branch ) - throws ScmException; + ChangeLogScmResult changeLog( + ScmRepository repository, ScmFileSet fileSet, Date startDate, Date endDate, int numDays, String branch) + throws ScmException; /** * Returns the changes that have happened in the source control system in a certain period of time. @@ -231,9 +224,9 @@ ChangeLogScmResult changeLog( ScmRepository repository, ScmFileSet fileSet, Date * @deprecated use {@link #changeLog(org.apache.maven.scm.command.changelog.ChangeLogScmRequest)} instead */ @Deprecated - ChangeLogScmResult changeLog( ScmRepository repository, ScmFileSet fileSet, Date startDate, Date endDate, - int numDays, ScmBranch branch ) - throws ScmException; + ChangeLogScmResult changeLog( + ScmRepository repository, ScmFileSet fileSet, Date startDate, Date endDate, int numDays, ScmBranch branch) + throws ScmException; /** * Returns the changes that have happened in the source control system in a certain period of time. @@ -252,9 +245,15 @@ ChangeLogScmResult changeLog( ScmRepository repository, ScmFileSet fileSet, Date * @deprecated use {@link #changeLog(org.apache.maven.scm.command.changelog.ChangeLogScmRequest)} instead */ @Deprecated - ChangeLogScmResult changeLog( ScmRepository repository, ScmFileSet fileSet, Date startDate, Date endDate, - int numDays, String branch, String datePattern ) - throws ScmException; + ChangeLogScmResult changeLog( + ScmRepository repository, + ScmFileSet fileSet, + Date startDate, + Date endDate, + int numDays, + String branch, + String datePattern) + throws ScmException; /** * Returns the changes that have happened in the source control system in a certain period of time. @@ -272,9 +271,15 @@ ChangeLogScmResult changeLog( ScmRepository repository, ScmFileSet fileSet, Date * @throws ScmException if any * @deprecated use {@link #changeLog(org.apache.maven.scm.command.changelog.ChangeLogScmRequest)} instead */ - ChangeLogScmResult changeLog( ScmRepository repository, ScmFileSet fileSet, Date startDate, Date endDate, - int numDays, ScmBranch branch, String datePattern ) - throws ScmException; + ChangeLogScmResult changeLog( + ScmRepository repository, + ScmFileSet fileSet, + Date startDate, + Date endDate, + int numDays, + ScmBranch branch, + String datePattern) + throws ScmException; /** * Returns the changes that have happened in the source control system in a certain period of time. @@ -285,8 +290,7 @@ ChangeLogScmResult changeLog( ScmRepository repository, ScmFileSet fileSet, Date * @throws ScmException if any * @since 1.8 */ - ChangeLogScmResult changeLog( ChangeLogScmRequest scmRequest ) - throws ScmException; + ChangeLogScmResult changeLog(ChangeLogScmRequest scmRequest) throws ScmException; /** * Returns the changes that have happened in the source control system between two tags. @@ -302,8 +306,8 @@ ChangeLogScmResult changeLog( ChangeLogScmRequest scmRequest ) * @deprecated use {@link #changeLog(org.apache.maven.scm.command.changelog.ChangeLogScmRequest)} instead */ @Deprecated - ChangeLogScmResult changeLog( ScmRepository repository, ScmFileSet fileSet, String startTag, String endTag ) - throws ScmException; + ChangeLogScmResult changeLog(ScmRepository repository, ScmFileSet fileSet, String startTag, String endTag) + throws ScmException; /** * Returns the changes that have happened in the source control system between two tags. @@ -319,9 +323,9 @@ ChangeLogScmResult changeLog( ScmRepository repository, ScmFileSet fileSet, Stri * @deprecated use {@link #changeLog(org.apache.maven.scm.command.changelog.ChangeLogScmRequest)} instead */ @Deprecated - ChangeLogScmResult changeLog( ScmRepository repository, ScmFileSet fileSet, ScmVersion startVersion, - ScmVersion endVersion ) - throws ScmException; + ChangeLogScmResult changeLog( + ScmRepository repository, ScmFileSet fileSet, ScmVersion startVersion, ScmVersion endVersion) + throws ScmException; /** * Returns the changes that have happened in the source control system between two tags. @@ -338,9 +342,9 @@ ChangeLogScmResult changeLog( ScmRepository repository, ScmFileSet fileSet, ScmV * @deprecated use {@link #changeLog(org.apache.maven.scm.command.changelog.ChangeLogScmRequest)} instead */ @Deprecated - ChangeLogScmResult changeLog( ScmRepository repository, ScmFileSet fileSet, String startTag, String endTag, - String datePattern ) - throws ScmException; + ChangeLogScmResult changeLog( + ScmRepository repository, ScmFileSet fileSet, String startTag, String endTag, String datePattern) + throws ScmException; /** * Returns the changes that have happened in the source control system between two tags. @@ -357,9 +361,13 @@ ChangeLogScmResult changeLog( ScmRepository repository, ScmFileSet fileSet, Stri * @deprecated use {@link #changeLog(org.apache.maven.scm.command.changelog.ChangeLogScmRequest)} instead */ @Deprecated - ChangeLogScmResult changeLog( ScmRepository repository, ScmFileSet fileSet, ScmVersion startRevision, - ScmVersion endRevision, String datePattern ) - throws ScmException; + ChangeLogScmResult changeLog( + ScmRepository repository, + ScmFileSet fileSet, + ScmVersion startRevision, + ScmVersion endRevision, + String datePattern) + throws ScmException; /** * Save the changes you have done into the repository. This will create a new version of the file or @@ -378,8 +386,8 @@ ChangeLogScmResult changeLog( ScmRepository repository, ScmFileSet fileSet, ScmV * @deprecated you must use {@link ScmProvider#checkIn(org.apache.maven.scm.repository.ScmRepository, * org.apache.maven.scm.ScmFileSet, org.apache.maven.scm.ScmVersion, String)} */ - CheckInScmResult checkIn( ScmRepository repository, ScmFileSet fileSet, String tag, String message ) - throws ScmException; + CheckInScmResult checkIn(ScmRepository repository, ScmFileSet fileSet, String tag, String message) + throws ScmException; /** * Save the changes you have done into the repository. This will create a new version of the file or @@ -395,8 +403,7 @@ CheckInScmResult checkIn( ScmRepository repository, ScmFileSet fileSet, String t * @return TODO * @throws ScmException if any */ - CheckInScmResult checkIn( ScmRepository repository, ScmFileSet fileSet, String message ) - throws ScmException; + CheckInScmResult checkIn(ScmRepository repository, ScmFileSet fileSet, String message) throws ScmException; /** * Save the changes you have done into the repository. This will create a new version of the file or @@ -413,8 +420,8 @@ CheckInScmResult checkIn( ScmRepository repository, ScmFileSet fileSet, String m * @return TODO * @throws ScmException if any */ - CheckInScmResult checkIn( ScmRepository repository, ScmFileSet fileSet, ScmVersion revision, String message ) - throws ScmException; + CheckInScmResult checkIn(ScmRepository repository, ScmFileSet fileSet, ScmVersion revision, String message) + throws ScmException; /** * Create a copy of the repository on your local machine @@ -427,8 +434,7 @@ CheckInScmResult checkIn( ScmRepository repository, ScmFileSet fileSet, ScmVersi * @deprecated you must use {@link ScmProvider#checkOut(org.apache.maven.scm.repository.ScmRepository, * org.apache.maven.scm.ScmFileSet, org.apache.maven.scm.ScmVersion)} */ - CheckOutScmResult checkOut( ScmRepository repository, ScmFileSet fileSet, String tag ) - throws ScmException; + CheckOutScmResult checkOut(ScmRepository repository, ScmFileSet fileSet, String tag) throws ScmException; /** * Create a copy of the repository on your local machine @@ -438,8 +444,7 @@ CheckOutScmResult checkOut( ScmRepository repository, ScmFileSet fileSet, String * @return TODO * @throws ScmException if any */ - CheckOutScmResult checkOut( ScmRepository repository, ScmFileSet fileSet ) - throws ScmException; + CheckOutScmResult checkOut(ScmRepository repository, ScmFileSet fileSet) throws ScmException; /** * Create a copy of the repository on your local machine @@ -450,8 +455,7 @@ CheckOutScmResult checkOut( ScmRepository repository, ScmFileSet fileSet ) * @return TODO * @throws ScmException if any */ - CheckOutScmResult checkOut( ScmRepository repository, ScmFileSet fileSet, ScmVersion version ) - throws ScmException; + CheckOutScmResult checkOut(ScmRepository repository, ScmFileSet fileSet, ScmVersion version) throws ScmException; /** * Create a copy of the repository on your local machine. @@ -465,8 +469,8 @@ CheckOutScmResult checkOut( ScmRepository repository, ScmFileSet fileSet, ScmVer * @deprecated you must use {@link ScmProvider#checkOut(org.apache.maven.scm.repository.ScmRepository, * org.apache.maven.scm.ScmFileSet, org.apache.maven.scm.ScmVersion, boolean)} */ - CheckOutScmResult checkOut( ScmRepository scmRepository, ScmFileSet scmFileSet, String tag, boolean recursive ) - throws ScmException; + CheckOutScmResult checkOut(ScmRepository scmRepository, ScmFileSet scmFileSet, String tag, boolean recursive) + throws ScmException; /** * Create a copy of the repository on your local machine. @@ -477,8 +481,8 @@ CheckOutScmResult checkOut( ScmRepository scmRepository, ScmFileSet scmFileSet, * @return TODO * @throws ScmException if any */ - CheckOutScmResult checkOut( ScmRepository scmRepository, ScmFileSet scmFileSet, boolean recursive ) - throws ScmException; + CheckOutScmResult checkOut(ScmRepository scmRepository, ScmFileSet scmFileSet, boolean recursive) + throws ScmException; /** * Create a copy of the repository on your local machine. @@ -490,9 +494,9 @@ CheckOutScmResult checkOut( ScmRepository scmRepository, ScmFileSet scmFileSet, * @return TODO * @throws ScmException if any */ - CheckOutScmResult checkOut( ScmRepository scmRepository, ScmFileSet scmFileSet, ScmVersion version, - boolean recursive ) - throws ScmException; + CheckOutScmResult checkOut( + ScmRepository scmRepository, ScmFileSet scmFileSet, ScmVersion version, boolean recursive) + throws ScmException; /** * Create a copy of the repository on your local machine. @@ -506,9 +510,12 @@ CheckOutScmResult checkOut( ScmRepository scmRepository, ScmFileSet scmFileSet, * @throws ScmException if any * @since 1.9.6 */ - CheckOutScmResult checkOut( ScmRepository scmRepository, ScmFileSet scmFileSet, ScmVersion version , // - CommandParameters commandParameters ) - throws ScmException; + CheckOutScmResult checkOut( + ScmRepository scmRepository, + ScmFileSet scmFileSet, + ScmVersion version, // + CommandParameters commandParameters) + throws ScmException; /** * Create a diff between two branch/tag/revision. @@ -522,8 +529,8 @@ CheckOutScmResult checkOut( ScmRepository scmRepository, ScmFileSet scmFileSet, * @deprecated you must use {@link ScmProvider#diff(org.apache.maven.scm.repository.ScmRepository, * org.apache.maven.scm.ScmFileSet, org.apache.maven.scm.ScmVersion, org.apache.maven.scm.ScmVersion)} */ - DiffScmResult diff( ScmRepository scmRepository, ScmFileSet scmFileSet, String startRevision, String endRevision ) - throws ScmException; + DiffScmResult diff(ScmRepository scmRepository, ScmFileSet scmFileSet, String startRevision, String endRevision) + throws ScmException; /** * Create a diff between two branch/tag/revision. @@ -535,9 +542,9 @@ DiffScmResult diff( ScmRepository scmRepository, ScmFileSet scmFileSet, String s * @return TODO * @throws ScmException if any */ - DiffScmResult diff( ScmRepository scmRepository, ScmFileSet scmFileSet, ScmVersion startVersion, - ScmVersion endVersion ) - throws ScmException; + DiffScmResult diff( + ScmRepository scmRepository, ScmFileSet scmFileSet, ScmVersion startVersion, ScmVersion endVersion) + throws ScmException; /** * Create an exported copy of the repository on your local machine @@ -550,8 +557,7 @@ DiffScmResult diff( ScmRepository scmRepository, ScmFileSet scmFileSet, ScmVersi * @deprecated you must use {@link ScmProvider#export(org.apache.maven.scm.repository.ScmRepository, * org.apache.maven.scm.ScmFileSet, org.apache.maven.scm.ScmVersion)} */ - ExportScmResult export( ScmRepository repository, ScmFileSet fileSet, String tag ) - throws ScmException; + ExportScmResult export(ScmRepository repository, ScmFileSet fileSet, String tag) throws ScmException; /** * Create an exported copy of the repository on your local machine @@ -561,8 +567,7 @@ ExportScmResult export( ScmRepository repository, ScmFileSet fileSet, String tag * @return TODO * @throws ScmException if any */ - ExportScmResult export( ScmRepository repository, ScmFileSet fileSet ) - throws ScmException; + ExportScmResult export(ScmRepository repository, ScmFileSet fileSet) throws ScmException; /** * Create an exported copy of the repository on your local machine @@ -573,8 +578,7 @@ ExportScmResult export( ScmRepository repository, ScmFileSet fileSet ) * @return TODO * @throws ScmException if any */ - ExportScmResult export( ScmRepository repository, ScmFileSet fileSet, ScmVersion version ) - throws ScmException; + ExportScmResult export(ScmRepository repository, ScmFileSet fileSet, ScmVersion version) throws ScmException; /** * Create an exported copy of the repository on your local machine @@ -588,8 +592,8 @@ ExportScmResult export( ScmRepository repository, ScmFileSet fileSet, ScmVersion * @deprecated you must use {@link ScmProvider#export(org.apache.maven.scm.repository.ScmRepository, * org.apache.maven.scm.ScmFileSet, org.apache.maven.scm.ScmVersion, String)} */ - ExportScmResult export( ScmRepository repository, ScmFileSet fileSet, String tag, String outputDirectory ) - throws ScmException; + ExportScmResult export(ScmRepository repository, ScmFileSet fileSet, String tag, String outputDirectory) + throws ScmException; /** * Create an exported copy of the repository on your local machine @@ -601,8 +605,8 @@ ExportScmResult export( ScmRepository repository, ScmFileSet fileSet, String tag * @return TODO * @throws ScmException if any */ - ExportScmResult export( ScmRepository repository, ScmFileSet fileSet, ScmVersion version, String outputDirectory ) - throws ScmException; + ExportScmResult export(ScmRepository repository, ScmFileSet fileSet, ScmVersion version, String outputDirectory) + throws ScmException; /** * Removes the given files from the source control system @@ -613,8 +617,7 @@ ExportScmResult export( ScmRepository repository, ScmFileSet fileSet, ScmVersion * @return TODO * @throws ScmException if any */ - RemoveScmResult remove( ScmRepository repository, ScmFileSet fileSet, String message ) - throws ScmException; + RemoveScmResult remove(ScmRepository repository, ScmFileSet fileSet, String message) throws ScmException; /** * Returns the status of the files in the source control system. The state of each file can be one @@ -626,8 +629,7 @@ RemoveScmResult remove( ScmRepository repository, ScmFileSet fileSet, String mes * @return TODO * @throws ScmException if any */ - StatusScmResult status( ScmRepository repository, ScmFileSet fileSet ) - throws ScmException; + StatusScmResult status(ScmRepository repository, ScmFileSet fileSet) throws ScmException; /** * Tag (or label in some systems) will tag the source file with a certain tag @@ -640,8 +642,7 @@ StatusScmResult status( ScmRepository repository, ScmFileSet fileSet ) * @throws ScmException if any * @deprecated use {@link #tag(ScmRepository, ScmFileSet, String, ScmTagParameters)} */ - TagScmResult tag( ScmRepository repository, ScmFileSet fileSet, String tagName ) - throws ScmException; + TagScmResult tag(ScmRepository repository, ScmFileSet fileSet, String tagName) throws ScmException; /** * Deletes a tag. @@ -652,8 +653,8 @@ TagScmResult tag( ScmRepository repository, ScmFileSet fileSet, String tagName ) * @return TODO * @throws ScmException if any */ - UntagScmResult untag( ScmRepository repository, ScmFileSet fileSet, CommandParameters parameters ) - throws ScmException; + UntagScmResult untag(ScmRepository repository, ScmFileSet fileSet, CommandParameters parameters) + throws ScmException; /** * Tag (or label in some systems) will tag the source file with a certain tag @@ -667,8 +668,7 @@ UntagScmResult untag( ScmRepository repository, ScmFileSet fileSet, CommandParam * @throws ScmException if any * @deprecated use {@link #tag(ScmRepository, ScmFileSet, String, ScmTagParameters)} */ - TagScmResult tag( ScmRepository repository, ScmFileSet fileSet, String tagName, String message ) - throws ScmException; + TagScmResult tag(ScmRepository repository, ScmFileSet fileSet, String tagName, String message) throws ScmException; /** * Tag (or label in some systems) will tag the source file with a certain tag @@ -682,8 +682,8 @@ TagScmResult tag( ScmRepository repository, ScmFileSet fileSet, String tagName, * @throws ScmException if any * @since 1.2 */ - TagScmResult tag( ScmRepository repository, ScmFileSet fileSet, String tagName, ScmTagParameters scmTagParameters ) - throws ScmException; + TagScmResult tag(ScmRepository repository, ScmFileSet fileSet, String tagName, ScmTagParameters scmTagParameters) + throws ScmException; /** * Updates the copy on the local machine with the changes in the repository @@ -693,8 +693,7 @@ TagScmResult tag( ScmRepository repository, ScmFileSet fileSet, String tagName, * @return TODO * @throws ScmException if any */ - UpdateScmResult update( ScmRepository repository, ScmFileSet fileSet ) - throws ScmException; + UpdateScmResult update(ScmRepository repository, ScmFileSet fileSet) throws ScmException; /** * Updates the copy on the local machine with the changes in the repository @@ -707,8 +706,7 @@ UpdateScmResult update( ScmRepository repository, ScmFileSet fileSet ) * @deprecated you must use {@link ScmProvider#update(org.apache.maven.scm.repository.ScmRepository, * org.apache.maven.scm.ScmFileSet, org.apache.maven.scm.ScmVersion)} */ - UpdateScmResult update( ScmRepository repository, ScmFileSet fileSet, String tag ) - throws ScmException; + UpdateScmResult update(ScmRepository repository, ScmFileSet fileSet, String tag) throws ScmException; /** * Updates the copy on the local machine with the changes in the repository @@ -719,8 +717,7 @@ UpdateScmResult update( ScmRepository repository, ScmFileSet fileSet, String tag * @return TODO * @throws ScmException if any */ - UpdateScmResult update( ScmRepository repository, ScmFileSet fileSet, ScmVersion version ) - throws ScmException; + UpdateScmResult update(ScmRepository repository, ScmFileSet fileSet, ScmVersion version) throws ScmException; /** * Updates the copy on the local machine with the changes in the repository @@ -734,8 +731,8 @@ UpdateScmResult update( ScmRepository repository, ScmFileSet fileSet, ScmVersion * @deprecated you must use {@link ScmProvider#update(org.apache.maven.scm.repository.ScmRepository, * org.apache.maven.scm.ScmFileSet, org.apache.maven.scm.ScmVersion, boolean)} */ - UpdateScmResult update( ScmRepository repository, ScmFileSet fileSet, String tag, boolean runChangelog ) - throws ScmException; + UpdateScmResult update(ScmRepository repository, ScmFileSet fileSet, String tag, boolean runChangelog) + throws ScmException; /** * Updates the copy on the local machine with the changes in the repository @@ -746,8 +743,7 @@ UpdateScmResult update( ScmRepository repository, ScmFileSet fileSet, String tag * @return TODO * @throws ScmException if any */ - UpdateScmResult update( ScmRepository repository, ScmFileSet fileSet, boolean runChangelog ) - throws ScmException; + UpdateScmResult update(ScmRepository repository, ScmFileSet fileSet, boolean runChangelog) throws ScmException; /** * Updates the copy on the local machine with the changes in the repository @@ -759,8 +755,8 @@ UpdateScmResult update( ScmRepository repository, ScmFileSet fileSet, boolean ru * @return TODO * @throws ScmException if any */ - UpdateScmResult update( ScmRepository repository, ScmFileSet fileSet, ScmVersion version, boolean runChangelog ) - throws ScmException; + UpdateScmResult update(ScmRepository repository, ScmFileSet fileSet, ScmVersion version, boolean runChangelog) + throws ScmException; /** * Updates the copy on the local machine with the changes in the repository @@ -774,8 +770,8 @@ UpdateScmResult update( ScmRepository repository, ScmFileSet fileSet, ScmVersion * @deprecated you must use {@link ScmProvider#update(org.apache.maven.scm.repository.ScmRepository, * org.apache.maven.scm.ScmFileSet, org.apache.maven.scm.ScmVersion, String)} */ - UpdateScmResult update( ScmRepository repository, ScmFileSet fileSet, String tag, String datePattern ) - throws ScmException; + UpdateScmResult update(ScmRepository repository, ScmFileSet fileSet, String tag, String datePattern) + throws ScmException; /** * Updates the copy on the local machine with the changes in the repository @@ -787,8 +783,8 @@ UpdateScmResult update( ScmRepository repository, ScmFileSet fileSet, String tag * @return TODO * @throws ScmException if any */ - UpdateScmResult update( ScmRepository repository, ScmFileSet fileSet, ScmVersion version, String datePattern ) - throws ScmException; + UpdateScmResult update(ScmRepository repository, ScmFileSet fileSet, ScmVersion version, String datePattern) + throws ScmException; /** * Updates the copy on the local machine with the changes in the repository @@ -802,8 +798,8 @@ UpdateScmResult update( ScmRepository repository, ScmFileSet fileSet, ScmVersion * @deprecated you must use {@link ScmProvider#update(org.apache.maven.scm.repository.ScmRepository, * org.apache.maven.scm.ScmFileSet, org.apache.maven.scm.ScmVersion, java.util.Date)} */ - UpdateScmResult update( ScmRepository repository, ScmFileSet fileSet, String tag, Date lastUpdate ) - throws ScmException; + UpdateScmResult update(ScmRepository repository, ScmFileSet fileSet, String tag, Date lastUpdate) + throws ScmException; /** * Updates the copy on the local machine with the changes in the repository @@ -815,8 +811,8 @@ UpdateScmResult update( ScmRepository repository, ScmFileSet fileSet, String tag * @return TODO * @throws ScmException if any */ - UpdateScmResult update( ScmRepository repository, ScmFileSet fileSet, ScmVersion version, Date lastUpdate ) - throws ScmException; + UpdateScmResult update(ScmRepository repository, ScmFileSet fileSet, ScmVersion version, Date lastUpdate) + throws ScmException; /** * Updates the copy on the local machine with the changes in the repository @@ -831,9 +827,9 @@ UpdateScmResult update( ScmRepository repository, ScmFileSet fileSet, ScmVersion * @deprecated you must use {@link ScmProvider#update(org.apache.maven.scm.repository.ScmRepository, * org.apache.maven.scm.ScmFileSet, org.apache.maven.scm.ScmVersion, java.util.Date, String)} */ - UpdateScmResult update( ScmRepository repository, ScmFileSet fileSet, String tag, Date lastUpdate, - String datePattern ) - throws ScmException; + UpdateScmResult update( + ScmRepository repository, ScmFileSet fileSet, String tag, Date lastUpdate, String datePattern) + throws ScmException; /** * Updates the copy on the local machine with the changes in the repository @@ -846,9 +842,9 @@ UpdateScmResult update( ScmRepository repository, ScmFileSet fileSet, String tag * @return TODO * @throws ScmException if any */ - UpdateScmResult update( ScmRepository repository, ScmFileSet fileSet, ScmVersion version, Date lastUpdate, - String datePattern ) - throws ScmException; + UpdateScmResult update( + ScmRepository repository, ScmFileSet fileSet, ScmVersion version, Date lastUpdate, String datePattern) + throws ScmException; /** * Make a file editable. This is used in source control systems where you look at read-only files @@ -860,8 +856,7 @@ UpdateScmResult update( ScmRepository repository, ScmFileSet fileSet, ScmVersion * @return TODO * @throws ScmException if any */ - EditScmResult edit( ScmRepository repository, ScmFileSet fileSet ) - throws ScmException; + EditScmResult edit(ScmRepository repository, ScmFileSet fileSet) throws ScmException; /** * Make a file no longer editable. This is the conterpart of {@link #edit( @@ -873,8 +868,7 @@ EditScmResult edit( ScmRepository repository, ScmFileSet fileSet ) * @return TODO * @throws ScmException if any */ - UnEditScmResult unedit( ScmRepository repository, ScmFileSet fileSet ) - throws ScmException; + UnEditScmResult unedit(ScmRepository repository, ScmFileSet fileSet) throws ScmException; /** * List each element (files and directories) of fileSet as they exist in the repository. @@ -888,8 +882,7 @@ UnEditScmResult unedit( ScmRepository repository, ScmFileSet fileSet ) * @deprecated you must use {@link ScmProvider#list(org.apache.maven.scm.repository.ScmRepository, * org.apache.maven.scm.ScmFileSet, boolean, org.apache.maven.scm.ScmVersion)} */ - ListScmResult list( ScmRepository repository, ScmFileSet fileSet, boolean recursive, String tag ) - throws ScmException; + ListScmResult list(ScmRepository repository, ScmFileSet fileSet, boolean recursive, String tag) throws ScmException; /** * List each element (files and directories) of fileSet as they exist in the repository. @@ -901,8 +894,8 @@ ListScmResult list( ScmRepository repository, ScmFileSet fileSet, boolean recurs * @return the list of files in the repository * @throws ScmException if any */ - ListScmResult list( ScmRepository repository, ScmFileSet fileSet, boolean recursive, ScmVersion version ) - throws ScmException; + ListScmResult list(ScmRepository repository, ScmFileSet fileSet, boolean recursive, ScmVersion version) + throws ScmException; /** * Returns the blame of specified file @@ -915,8 +908,7 @@ ListScmResult list( ScmRepository repository, ScmFileSet fileSet, boolean recurs * @since 1.4 * @deprecated use blame with {@link BlameScmRequest} parameter */ - BlameScmResult blame( ScmRepository repository, ScmFileSet fileSet, String filename ) - throws ScmException; + BlameScmResult blame(ScmRepository repository, ScmFileSet fileSet, String filename) throws ScmException; /** * @@ -925,9 +917,7 @@ BlameScmResult blame( ScmRepository repository, ScmFileSet fileSet, String filen * @throws ScmException if any * @since 1.8 */ - BlameScmResult blame( BlameScmRequest blameScmRequest ) - throws ScmException; - + BlameScmResult blame(BlameScmRequest blameScmRequest) throws ScmException; /** * Create directory/directories in the repository. @@ -939,8 +929,8 @@ BlameScmResult blame( BlameScmRequest blameScmRequest ) * @return TODO * @throws ScmException if any */ - MkdirScmResult mkdir( ScmRepository repository, ScmFileSet fileSet, String message, boolean createInLocal ) - throws ScmException; + MkdirScmResult mkdir(ScmRepository repository, ScmFileSet fileSet, String message, boolean createInLocal) + throws ScmException; /** * @param repository the source control system @@ -950,8 +940,8 @@ MkdirScmResult mkdir( ScmRepository repository, ScmFileSet fileSet, String messa * @throws ScmException if any * @since 1.5 */ - InfoScmResult info( ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters ) - throws ScmException; + InfoScmResult info(ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters) + throws ScmException; /** * @param repository the source control system @@ -961,6 +951,6 @@ InfoScmResult info( ScmProviderRepository repository, ScmFileSet fileSet, Comman * @throws ScmException if any * @since 1.6 */ - RemoteInfoScmResult remoteInfo( ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters ) - throws ScmException; + RemoteInfoScmResult remoteInfo(ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters) + throws ScmException; } diff --git a/maven-scm-api/src/main/java/org/apache/maven/scm/provider/ScmProviderRepository.java b/maven-scm-api/src/main/java/org/apache/maven/scm/provider/ScmProviderRepository.java index a32e76a1c..ff16e74b7 100644 --- a/maven-scm-api/src/main/java/org/apache/maven/scm/provider/ScmProviderRepository.java +++ b/maven-scm-api/src/main/java/org/apache/maven/scm/provider/ScmProviderRepository.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider; /** * @author Trygve Laugstøl @@ -25,8 +24,7 @@ * @author Chris Graham * */ -public abstract class ScmProviderRepository -{ +public abstract class ScmProviderRepository { private String user; private String password; @@ -68,8 +66,7 @@ public abstract class ScmProviderRepository /** * @return The user. */ - public String getUser() - { + public String getUser() { return user; } @@ -78,16 +75,14 @@ public String getUser() * * @param user The user */ - public void setUser( String user ) - { + public void setUser(String user) { this.user = user; } /** * @return The password. */ - public String getPassword() - { + public String getPassword() { return password; } @@ -96,8 +91,7 @@ public String getPassword() * * @param password The user password */ - public void setPassword( String password ) - { + public void setPassword(String password) { this.password = password; } @@ -109,8 +103,7 @@ public void setPassword( String password ) * @return TODO * @since 1.4 */ - public boolean isPushChanges() - { + public boolean isPushChanges() { return pushChanges; } @@ -118,8 +111,7 @@ public boolean isPushChanges() * @since 1.4 * @param pushChanges TODO */ - public void setPushChanges( boolean pushChanges ) - { + public void setPushChanges(boolean pushChanges) { this.pushChanges = pushChanges; } @@ -128,8 +120,7 @@ public void setPushChanges( boolean pushChanges ) * @since 1.9.5 */ @Deprecated - public String getWorkItem() - { + public String getWorkItem() { return workItem; } @@ -140,8 +131,7 @@ public String getWorkItem() * @since 1.9.5 */ @Deprecated - public void setWorkItem( String workItem ) - { + public void setWorkItem(String workItem) { this.workItem = workItem; } @@ -160,19 +150,16 @@ public void setWorkItem( String workItem ) * @return TODO */ @Deprecated - public boolean isPersistCheckout() - { - String persist = System.getProperty( "maven.scm.persistcheckout" ); - if ( persist != null ) - { - return Boolean.valueOf( persist ).booleanValue(); + public boolean isPersistCheckout() { + String persist = System.getProperty("maven.scm.persistcheckout"); + if (persist != null) { + return Boolean.valueOf(persist).booleanValue(); } return persistCheckout; } @Deprecated - public void setPersistCheckout( boolean persistCheckout ) - { + public void setPersistCheckout(boolean persistCheckout) { this.persistCheckout = persistCheckout; } @@ -183,8 +170,7 @@ public void setPersistCheckout( boolean persistCheckout ) * @return the parent repository * @throws UnsupportedOperationException unless overridden by subclass */ - public ScmProviderRepository getParent() - { + public ScmProviderRepository getParent() { throw new UnsupportedOperationException(); } @@ -195,8 +181,7 @@ public ScmProviderRepository getParent() * @return the relative path or null if it can't be resolved * @throws UnsupportedOperationException unless overridden by subclass */ - public String getRelativePath( ScmProviderRepository ancestor ) - { + public String getRelativePath(ScmProviderRepository ancestor) { throw new UnsupportedOperationException(); } } diff --git a/maven-scm-api/src/main/java/org/apache/maven/scm/provider/ScmProviderRepositoryWithHost.java b/maven-scm-api/src/main/java/org/apache/maven/scm/provider/ScmProviderRepositoryWithHost.java index bdc7d18d3..0930117ad 100644 --- a/maven-scm-api/src/main/java/org/apache/maven/scm/provider/ScmProviderRepositoryWithHost.java +++ b/maven-scm-api/src/main/java/org/apache/maven/scm/provider/ScmProviderRepositoryWithHost.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,14 +16,13 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider; /** * @author Emmanuel Venisse * */ -public abstract class ScmProviderRepositoryWithHost - extends ScmProviderRepository -{ +public abstract class ScmProviderRepositoryWithHost extends ScmProviderRepository { private String host; private int port; @@ -34,43 +31,35 @@ public abstract class ScmProviderRepositoryWithHost private String passphrase; - public String getHost() - { + public String getHost() { return host; } - public void setHost( String host ) - { + public void setHost(String host) { this.host = host; } - public int getPort() - { + public int getPort() { return port; } - public void setPort( int port ) - { + public void setPort(int port) { this.port = port; } - public String getPrivateKey() - { + public String getPrivateKey() { return privateKey; } - public void setPrivateKey( String privateKey ) - { + public void setPrivateKey(String privateKey) { this.privateKey = privateKey; } - public String getPassphrase() - { + public String getPassphrase() { return passphrase; } - public void setPassphrase( String passphrase ) - { + public void setPassphrase(String passphrase) { this.passphrase = passphrase; } } diff --git a/maven-scm-api/src/main/java/org/apache/maven/scm/provider/ScmUrlUtils.java b/maven-scm-api/src/main/java/org/apache/maven/scm/provider/ScmUrlUtils.java index e1bef9ee1..39a6cb248 100644 --- a/maven-scm-api/src/main/java/org/apache/maven/scm/provider/ScmUrlUtils.java +++ b/maven-scm-api/src/main/java/org/apache/maven/scm/provider/ScmUrlUtils.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider; import java.util.ArrayList; import java.util.List; @@ -34,11 +33,10 @@ * @author Dennis Lundberg * */ -public abstract class ScmUrlUtils -{ +public abstract class ScmUrlUtils { private static final String ILLEGAL_SCM_URL = - "The scm url must be on the form 'scm:' " - + "where can be either ':' or '|'."; + "The scm url must be on the form 'scm:' " + + "where can be either ':' or '|'."; /** * Get the delimiter used in the scm url. @@ -46,23 +44,20 @@ public abstract class ScmUrlUtils * @param scmUrl A valid scm url to parse * @return The delimiter used in the scm url */ - public static String getDelimiter( String scmUrl ) - { - scmUrl = scmUrl.substring( 4 ); + public static String getDelimiter(String scmUrl) { + scmUrl = scmUrl.substring(4); - int index = scmUrl.indexOf( '|' ); + int index = scmUrl.indexOf('|'); - if ( index == -1 ) - { - index = scmUrl.indexOf( ':' ); + if (index == -1) { + index = scmUrl.indexOf(':'); - if ( index == -1 ) - { - throw new IllegalArgumentException( "The scm url does not contain a valid delimiter." ); + if (index == -1) { + throw new IllegalArgumentException("The scm url does not contain a valid delimiter."); } } - return scmUrl.substring( index, index + 1 ); + return scmUrl.substring(index, index + 1); } /** @@ -71,15 +66,14 @@ public static String getDelimiter( String scmUrl ) * @param scmUrl A valid scm url to parse * @return The scm provider from the scm url */ - public static String getProvider( String scmUrl ) - { - String delimiter = getDelimiter( scmUrl ); + public static String getProvider(String scmUrl) { + String delimiter = getDelimiter(scmUrl); - scmUrl = scmUrl.substring( 4 ); + scmUrl = scmUrl.substring(4); - int firstDelimiterIndex = scmUrl.indexOf( delimiter ); + int firstDelimiterIndex = scmUrl.indexOf(delimiter); - return scmUrl.substring( 0, firstDelimiterIndex ); + return scmUrl.substring(0, firstDelimiterIndex); } /** @@ -88,15 +82,14 @@ public static String getProvider( String scmUrl ) * @param scmUrl A valid scm url to parse * @return The provider specific part of the scm url */ - public static String getProviderSpecificPart( String scmUrl ) - { - String delimiter = getDelimiter( scmUrl ); + public static String getProviderSpecificPart(String scmUrl) { + String delimiter = getDelimiter(scmUrl); - scmUrl = scmUrl.substring( 4 ); + scmUrl = scmUrl.substring(4); - int firstDelimiterIndex = scmUrl.indexOf( delimiter ); + int firstDelimiterIndex = scmUrl.indexOf(delimiter); - return scmUrl.substring( firstDelimiterIndex + 1 ); + return scmUrl.substring(firstDelimiterIndex + 1); } /** @@ -109,9 +102,8 @@ public static String getProviderSpecificPart( String scmUrl ) * @return true if the scm url is in the correct format, * otherwise false */ - public static boolean isValid( String scmUrl ) - { - List messages = validate( scmUrl ); + public static boolean isValid(String scmUrl) { + List messages = validate(scmUrl); return messages.isEmpty(); } @@ -125,38 +117,31 @@ public static boolean isValid( String scmUrl ) * @param scmUrl The scm url to validate * @return A List that contains the errors that occured */ - public static List validate( String scmUrl ) - { + public static List validate(String scmUrl) { List messages = new ArrayList(); - if ( scmUrl == null ) - { - messages.add( "The scm url cannot be null." ); + if (scmUrl == null) { + messages.add("The scm url cannot be null."); return messages; } - if ( !scmUrl.startsWith( "scm:" ) ) - { - messages.add( "The scm url must start with 'scm:'." ); + if (!scmUrl.startsWith("scm:")) { + messages.add("The scm url must start with 'scm:'."); return messages; } - if ( scmUrl.length() < 6 ) - { - messages.add( ILLEGAL_SCM_URL ); + if (scmUrl.length() < 6) { + messages.add(ILLEGAL_SCM_URL); return messages; } - try - { - getDelimiter( scmUrl ); - } - catch ( IllegalArgumentException e ) - { - messages.add( e.getMessage() ); + try { + getDelimiter(scmUrl); + } catch (IllegalArgumentException e) { + messages.add(e.getMessage()); } return messages; diff --git a/maven-scm-api/src/main/java/org/apache/maven/scm/repository/ScmRepository.java b/maven-scm-api/src/main/java/org/apache/maven/scm/repository/ScmRepository.java index 1b511797b..2b4efcec6 100644 --- a/maven-scm-api/src/main/java/org/apache/maven/scm/repository/ScmRepository.java +++ b/maven-scm-api/src/main/java/org/apache/maven/scm/repository/ScmRepository.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.repository; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.repository; import org.apache.maven.scm.provider.ScmProviderRepository; @@ -26,16 +25,14 @@ * * TODO clarify need - should be able to merge with ScmProviderRepository? */ -public class ScmRepository -{ +public class ScmRepository { /** */ private String provider; /** */ private ScmProviderRepository providerRepository; - public ScmRepository( String provider, ScmProviderRepository providerRepository ) - { + public ScmRepository(String provider, ScmProviderRepository providerRepository) { this.provider = provider; this.providerRepository = providerRepository; @@ -44,23 +41,19 @@ public ScmRepository( String provider, ScmProviderRepository providerRepository /** * @return Returns the provider. */ - public String getProvider() - { + public String getProvider() { return provider; } /** * @return Returns the provider repository. */ - public ScmProviderRepository getProviderRepository() - { + public ScmProviderRepository getProviderRepository() { return providerRepository; } /** {@inheritDoc} */ - public String toString() - { + public String toString() { return provider.toString() + ":" + providerRepository.toString(); } } - diff --git a/maven-scm-api/src/main/java/org/apache/maven/scm/repository/ScmRepositoryException.java b/maven-scm-api/src/main/java/org/apache/maven/scm/repository/ScmRepositoryException.java index 670bf113f..7ac9c9710 100644 --- a/maven-scm-api/src/main/java/org/apache/maven/scm/repository/ScmRepositoryException.java +++ b/maven-scm-api/src/main/java/org/apache/maven/scm/repository/ScmRepositoryException.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.repository; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,43 +16,38 @@ * specific language governing permissions and limitations * under the License. */ - -import org.apache.maven.scm.ScmException; +package org.apache.maven.scm.repository; import java.util.Collections; import java.util.List; +import org.apache.maven.scm.ScmException; + /** * @author Trygve Laugstøl * @author Olivier Lamy * */ -public class ScmRepositoryException - extends ScmException -{ +public class ScmRepositoryException extends ScmException { static final long serialVersionUID = -2191549774722212492L; private List validationMessages = Collections.emptyList(); - public ScmRepositoryException( String msg ) - { - super( msg ); + public ScmRepositoryException(String msg) { + super(msg); } - public ScmRepositoryException( String msg, Throwable cause ) - { - super( msg, cause ); + public ScmRepositoryException(String msg, Throwable cause) { + super(msg, cause); } - public ScmRepositoryException( String msg, List validationMessages ) - { - super( msg ); + public ScmRepositoryException(String msg, List validationMessages) { + super(msg); this.validationMessages = validationMessages; } - public List getValidationMessages() - { + public List getValidationMessages() { return validationMessages; } } diff --git a/maven-scm-api/src/main/java/org/apache/maven/scm/repository/UnknownRepositoryStructure.java b/maven-scm-api/src/main/java/org/apache/maven/scm/repository/UnknownRepositoryStructure.java index bbcf8f257..1c76aa851 100644 --- a/maven-scm-api/src/main/java/org/apache/maven/scm/repository/UnknownRepositoryStructure.java +++ b/maven-scm-api/src/main/java/org/apache/maven/scm/repository/UnknownRepositoryStructure.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.repository; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,13 +16,12 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.repository; /** * @author Emmanuel Venisse * */ -public class UnknownRepositoryStructure - extends Exception -{ +public class UnknownRepositoryStructure extends Exception { private static final long serialVersionUID = -7767277520687595055L; } diff --git a/maven-scm-api/src/main/java/org/apache/maven/scm/util/AbstractConsumer.java b/maven-scm-api/src/main/java/org/apache/maven/scm/util/AbstractConsumer.java index bfb954979..4cd2065ae 100644 --- a/maven-scm-api/src/main/java/org/apache/maven/scm/util/AbstractConsumer.java +++ b/maven-scm-api/src/main/java/org/apache/maven/scm/util/AbstractConsumer.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.util; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,11 +16,7 @@ * specific language governing permissions and limitations * under the License. */ - -import org.codehaus.plexus.util.StringUtils; -import org.codehaus.plexus.util.cli.StreamConsumer; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +package org.apache.maven.scm.util; import java.text.DateFormat; import java.text.ParseException; @@ -30,14 +24,17 @@ import java.util.Date; import java.util.Locale; +import org.codehaus.plexus.util.StringUtils; +import org.codehaus.plexus.util.cli.StreamConsumer; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + /** * @author Emmanuel Venisse * */ -public abstract class AbstractConsumer - implements StreamConsumer -{ - protected final Logger logger = LoggerFactory.getLogger( getClass() ); +public abstract class AbstractConsumer implements StreamConsumer { + protected final Logger logger = LoggerFactory.getLogger(getClass()); /** * Converts the date timestamp from the output into a date object. @@ -47,9 +44,8 @@ public abstract class AbstractConsumer * @param defaultPattern TODO * @return A date representing the timestamp of the log entry. */ - protected Date parseDate( String date, String userPattern, String defaultPattern ) - { - return parseDate( date, userPattern, defaultPattern, null ); + protected Date parseDate(String date, String userPattern, String defaultPattern) { + return parseDate(date, userPattern, defaultPattern, null); } /** @@ -61,64 +57,48 @@ protected Date parseDate( String date, String userPattern, String defaultPattern * @param locale TODO * @return A date representing the timestamp of the log entry. */ - protected Date parseDate( String date, String userPattern, String defaultPattern, Locale locale ) - { + protected Date parseDate(String date, String userPattern, String defaultPattern, Locale locale) { DateFormat format; String patternUsed = null; Locale localeUsed = null; - if ( StringUtils.isNotEmpty( userPattern ) ) - { - if ( locale != null ) - { - format = new SimpleDateFormat( userPattern, locale ); + if (StringUtils.isNotEmpty(userPattern)) { + if (locale != null) { + format = new SimpleDateFormat(userPattern, locale); localeUsed = locale; - } - else - { - format = new SimpleDateFormat( userPattern ); + } else { + format = new SimpleDateFormat(userPattern); localeUsed = Locale.getDefault(); } patternUsed = userPattern; - } - else - { - if ( StringUtils.isNotEmpty( defaultPattern ) ) - { - if ( locale != null ) - { - format = new SimpleDateFormat( defaultPattern, locale ); + } else { + if (StringUtils.isNotEmpty(defaultPattern)) { + if (locale != null) { + format = new SimpleDateFormat(defaultPattern, locale); localeUsed = locale; - } - else - { - format = new SimpleDateFormat( defaultPattern ); + } else { + format = new SimpleDateFormat(defaultPattern); localeUsed = Locale.getDefault(); } patternUsed = defaultPattern; - } - else - { + } else { // Use the English short date pattern if no pattern is specified - format = DateFormat.getDateInstance( DateFormat.SHORT, Locale.ENGLISH ); + format = DateFormat.getDateInstance(DateFormat.SHORT, Locale.ENGLISH); patternUsed = "DateFormat.SHORT"; localeUsed = Locale.ENGLISH; } } - try - { - return format.parse( date ); - } - catch ( ParseException e ) - { - if ( logger.isWarnEnabled() ) - { + try { + return format.parse(date); + } catch (ParseException e) { + if (logger.isWarnEnabled()) { logger.warn( - "skip ParseException: " + e.getMessage() + " during parsing date '" + date - + "' with pattern '" + patternUsed + "' and locale '" - + localeUsed + "'", e ); + "skip ParseException: " + e.getMessage() + " during parsing date '" + date + + "' with pattern '" + patternUsed + "' and locale '" + + localeUsed + "'", + e); } return null; diff --git a/maven-scm-api/src/main/java/org/apache/maven/scm/util/ConsumerUtils.java b/maven-scm-api/src/main/java/org/apache/maven/scm/util/ConsumerUtils.java index 9272ae50d..ed9117f87 100644 --- a/maven-scm-api/src/main/java/org/apache/maven/scm/util/ConsumerUtils.java +++ b/maven-scm-api/src/main/java/org/apache/maven/scm/util/ConsumerUtils.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.util; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.util; import java.io.BufferedReader; import java.io.File; @@ -29,12 +28,9 @@ /** * @author Davide Angelocola */ -public class ConsumerUtils -{ +public class ConsumerUtils { - private ConsumerUtils() - { - } + private ConsumerUtils() {} /** * Read file f, sending each line to the consumer. @@ -43,21 +39,16 @@ private ConsumerUtils() * @param consumer TODO * @throws IOException if any */ - public static void consumeFile( File f, StreamConsumer consumer ) throws IOException - { - BufferedReader r = new BufferedReader( new FileReader( f ) ); + public static void consumeFile(File f, StreamConsumer consumer) throws IOException { + BufferedReader r = new BufferedReader(new FileReader(f)); - try - { + try { String line; - while ( ( line = r.readLine() ) != null ) - { - consumer.consumeLine( line ); + while ((line = r.readLine()) != null) { + consumer.consumeLine(line); } - } - finally - { + } finally { r.close(); } } diff --git a/maven-scm-api/src/main/java/org/apache/maven/scm/util/FilenameUtils.java b/maven-scm-api/src/main/java/org/apache/maven/scm/util/FilenameUtils.java index 907149a8e..c5b28ca23 100644 --- a/maven-scm-api/src/main/java/org/apache/maven/scm/util/FilenameUtils.java +++ b/maven-scm-api/src/main/java/org/apache/maven/scm/util/FilenameUtils.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.util; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,33 +16,29 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.util; import java.io.File; import org.codehaus.plexus.util.StringUtils; /** - * + * */ -public final class FilenameUtils -{ - private FilenameUtils() - { - } +public final class FilenameUtils { + private FilenameUtils() {} - public static String normalizeFilename( File file ) - { - return normalizeFilename( file.getName() ); + public static String normalizeFilename(File file) { + return normalizeFilename(file.getName()); } /** * Replace duplicated [back]slash to slash. - * + * * @param filename TODO * @return TODO */ - public static String normalizeFilename( String filename ) - { - return StringUtils.replace( StringUtils.replace( filename, "\\", "/" ), "//", "/" ); + public static String normalizeFilename(String filename) { + return StringUtils.replace(StringUtils.replace(filename, "\\", "/"), "//", "/"); } } diff --git a/maven-scm-api/src/main/java/org/apache/maven/scm/util/ThreadSafeDateFormat.java b/maven-scm-api/src/main/java/org/apache/maven/scm/util/ThreadSafeDateFormat.java index 46bb4c1d9..0aa377aa0 100644 --- a/maven-scm-api/src/main/java/org/apache/maven/scm/util/ThreadSafeDateFormat.java +++ b/maven-scm-api/src/main/java/org/apache/maven/scm/util/ThreadSafeDateFormat.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.util; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.util; import java.lang.ref.SoftReference; import java.text.DateFormat; @@ -34,45 +33,36 @@ * private static final ThreadSafeDateFormat DATE_FORMAT = new ThreadSafeDateFormat( DATE_PATTERN ); * */ -public class ThreadSafeDateFormat - extends DateFormat -{ +public class ThreadSafeDateFormat extends DateFormat { private static final long serialVersionUID = 3786090697869963812L; private final String dateFormat; - public ThreadSafeDateFormat( String sDateFormat ) - { + public ThreadSafeDateFormat(String sDateFormat) { dateFormat = sDateFormat; } private final ThreadLocal> formatCache = - new ThreadLocal>() - { - public SoftReference get() - { - SoftReference softRef = super.get(); - if ( softRef == null || softRef.get() == null ) - { - softRef = new SoftReference( new SimpleDateFormat( dateFormat ) ); - super.set( softRef ); - } - return softRef; - } - }; + new ThreadLocal>() { + public SoftReference get() { + SoftReference softRef = super.get(); + if (softRef == null || softRef.get() == null) { + softRef = new SoftReference(new SimpleDateFormat(dateFormat)); + super.set(softRef); + } + return softRef; + } + }; - private DateFormat getDateFormat() - { + private DateFormat getDateFormat() { return formatCache.get().get(); } - public StringBuffer format( Date date, StringBuffer toAppendTo, FieldPosition fieldPosition ) - { - return getDateFormat().format( date, toAppendTo, fieldPosition ); + public StringBuffer format(Date date, StringBuffer toAppendTo, FieldPosition fieldPosition) { + return getDateFormat().format(date, toAppendTo, fieldPosition); } - public Date parse( String source, ParsePosition pos ) - { - return getDateFormat().parse( source, pos ); + public Date parse(String source, ParsePosition pos) { + return getDateFormat().parse(source, pos); } } diff --git a/maven-scm-api/src/test/java/org/apache/maven/scm/ChangeFileTest.java b/maven-scm-api/src/test/java/org/apache/maven/scm/ChangeFileTest.java index dab0baabe..809f3f69d 100644 --- a/maven-scm-api/src/test/java/org/apache/maven/scm/ChangeFileTest.java +++ b/maven-scm-api/src/test/java/org/apache/maven/scm/ChangeFileTest.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm; import org.junit.Test; @@ -27,32 +26,28 @@ /** * @author Emmanuel Venisse */ -public class ChangeFileTest -{ +public class ChangeFileTest { @Test - public void testNewFile() - { - ChangeFile f = new ChangeFile( "test.java" ); - assertEquals( "test.java", f.getName() ); - assertNull( f.getRevision() ); - assertEquals( "test.java", f.toString() ); + public void testNewFile() { + ChangeFile f = new ChangeFile("test.java"); + assertEquals("test.java", f.getName()); + assertNull(f.getRevision()); + assertEquals("test.java", f.toString()); } @Test - public void testNewFileRevision() - { - ChangeFile f = new ChangeFile( "test.java", "1.2.3" ); - assertEquals( "test.java", f.getName() ); - assertEquals( "1.2.3", f.getRevision() ); - assertEquals( "test.java, 1.2.3", f.toString() ); + public void testNewFileRevision() { + ChangeFile f = new ChangeFile("test.java", "1.2.3"); + assertEquals("test.java", f.getName()); + assertEquals("1.2.3", f.getRevision()); + assertEquals("test.java, 1.2.3", f.toString()); } @Test - public void testNewRevisionFile() - { - ChangeFile f = new ChangeFile( "test.java", "revision1" ); - assertEquals( "test.java", f.getName() ); - assertEquals( "revision1", f.getRevision() ); - assertEquals( "test.java, revision1", f.toString() ); + public void testNewRevisionFile() { + ChangeFile f = new ChangeFile("test.java", "revision1"); + assertEquals("test.java", f.getName()); + assertEquals("revision1", f.getRevision()); + assertEquals("test.java, revision1", f.toString()); } } diff --git a/maven-scm-api/src/test/java/org/apache/maven/scm/ChangeSetTest.java b/maven-scm-api/src/test/java/org/apache/maven/scm/ChangeSetTest.java index 77caae9b8..46e0fc874 100644 --- a/maven-scm-api/src/test/java/org/apache/maven/scm/ChangeSetTest.java +++ b/maven-scm-api/src/test/java/org/apache/maven/scm/ChangeSetTest.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm; import java.util.Arrays; import java.util.Calendar; @@ -38,8 +37,7 @@ * @author dion * */ -public class ChangeSetTest -{ +public class ChangeSetTest { /** * the {@link ChangeSet} used for testing */ @@ -49,18 +47,16 @@ public class ChangeSetTest * Initialize per test data */ @Before - public void setUp() - { + public void setUp() { instance = createInstance(); } - private static ChangeSet createInstance() - { + private static ChangeSet createInstance() { ChangeSet instance = new ChangeSet(); - instance.setAuthor( "dion" ); - instance.setComment( "comment" ); - instance.setDate( "2002/04/01 00:00:00" ); - instance.setTags( Arrays.asList( "v3.14", "v2.7]]1828", ".7]]1828", "c") ); - assertEquals( "'&;<>"", ChangeSet.escapeValue("'&;<>\"") ); + public void testEscapeValue() { + assertEquals("", ChangeSet.escapeValue("")); + assertEquals("'", ChangeSet.escapeValue("'")); + assertEquals("a", ChangeSet.escapeValue("a")); + assertEquals("a'", ChangeSet.escapeValue("a'")); + assertEquals("'a'", ChangeSet.escapeValue("'a'")); + + assertEquals("a<b>c", ChangeSet.escapeValue("ac")); + assertEquals("'&;<>"", ChangeSet.escapeValue("'&;<>\"")); } @Test - public void testEquals() - { + public void testEquals() { ChangeSet instance2 = createInstance(); assertEquals(instance, instance2); instance2.setComment("another comment"); - assertNotEquals( instance2, instance ); + assertNotEquals(instance2, instance); instance2.setComment("comment"); assertEquals(instance, instance2); } @Test - public void testHashCode() - { + public void testHashCode() { int hashCode1 = instance.hashCode(); instance.setAuthor("anotherAuthor"); - assertFalse( hashCode1 == instance.hashCode() ); - instance.setAuthor( "dion" ); - assertEquals( hashCode1, instance.hashCode() ); + assertFalse(hashCode1 == instance.hashCode()); + instance.setAuthor("dion"); + assertEquals(hashCode1, instance.hashCode()); } @Test - public void testToXml() - { + public void testToXml() { String sXml = instance.toXML(); assertNotNull(sXml); @@ -240,10 +219,9 @@ public void testToXml() } @Test - public void testToXmlWithFiles() - { - instance.addFile( new ChangeFile( "maven1:dummy" ) ); - instance.addFile( new ChangeFile( "maven2:dummy2" ) ); + public void testToXmlWithFiles() { + instance.addFile(new ChangeFile("maven1:dummy")); + instance.addFile(new ChangeFile("maven2:dummy2")); String sXml = instance.toXML(); assertNotNull(sXml); @@ -255,5 +233,4 @@ public void testToXmlWithFiles() assertTrue(sXml.indexOf("maven1:dummy") > -1); assertTrue(sXml.indexOf("maven2:dummy2") > -1); } - } diff --git a/maven-scm-api/src/test/java/org/apache/maven/scm/ScmFileSetTest.java b/maven-scm-api/src/test/java/org/apache/maven/scm/ScmFileSetTest.java index ca123268c..b42a5bf42 100644 --- a/maven-scm-api/src/test/java/org/apache/maven/scm/ScmFileSetTest.java +++ b/maven-scm-api/src/test/java/org/apache/maven/scm/ScmFileSetTest.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm; import java.io.File; import java.io.IOException; @@ -33,87 +32,71 @@ /** * @author dtran */ -public class ScmFileSetTest -{ +public class ScmFileSetTest { private static String basedirPath; - public static String getBasedir() - { - if ( basedirPath != null ) - { + public static String getBasedir() { + if (basedirPath != null) { return basedirPath; } - basedirPath = System.getProperty( "basedir" ); + basedirPath = System.getProperty("basedir"); - if ( basedirPath == null ) - { - basedirPath = new File( "" ).getAbsolutePath(); + if (basedirPath == null) { + basedirPath = new File("").getAbsolutePath(); } return basedirPath; } - private String removeBasedir( String filename ) - { - return filename.substring( getBasedir().length(), filename.length() ); + private String removeBasedir(String filename) { + return filename.substring(getBasedir().length(), filename.length()); } @Test - public void testFilesList() - throws IOException - { - ScmFileSet fileSet = new ScmFileSet( new File( getBasedir(), "src" ), "**/**" ); - assertEquals( "src", fileSet.getBasedir().getName() ); - assertEquals( "**/**", fileSet.getIncludes() ); + public void testFilesList() throws IOException { + ScmFileSet fileSet = new ScmFileSet(new File(getBasedir(), "src"), "**/**"); + assertEquals("src", fileSet.getBasedir().getName()); + assertEquals("**/**", fileSet.getIncludes()); // assertEquals( ScmFileSet.DEFAULT_EXCLUDES, fileSet.getExcludes() ); - assertTrue( "List of files should be longer than 10 elements, but received: " + fileSet.getFileList().size(), - fileSet.getFileList().size() > 10 ); + assertTrue( + "List of files should be longer than 10 elements, but received: " + + fileSet.getFileList().size(), + fileSet.getFileList().size() > 10); } @Test - public void testFilesListWithoutIncludesResultsEmptyList() - throws IOException - { - ScmFileSet fileSet = new ScmFileSet( new File( getBasedir(), "src" ) ); - assertEquals( 0, fileSet.getFileList().size() ); + public void testFilesListWithoutIncludesResultsEmptyList() throws IOException { + ScmFileSet fileSet = new ScmFileSet(new File(getBasedir(), "src")); + assertEquals(0, fileSet.getFileList().size()); } @Test - public void testFilesListExcludes() - throws IOException - { - ScmFileSet fileSet = new ScmFileSet( new File( getBasedir(), "src" ), "**/**", "**/exclude/**" ); + public void testFilesListExcludes() throws IOException { + ScmFileSet fileSet = new ScmFileSet(new File(getBasedir(), "src"), "**/**", "**/exclude/**"); List files = fileSet.getFileList(); Iterator it = files.iterator(); - while ( it.hasNext() ) - { + while (it.hasNext()) { File file = (File) it.next(); - if ( removeBasedir( file.getAbsolutePath() ).indexOf( "exclude" ) != -1 ) - { - fail( "Found excludes in file set: " + file ); + if (removeBasedir(file.getAbsolutePath()).indexOf("exclude") != -1) { + fail("Found excludes in file set: " + file); } } } @Test - public void testFilesListExcludes2() - throws IOException - { - ScmFileSet fileSet = new ScmFileSet( new File( getBasedir(), "src" ), "**/scmfileset/**", "**/exclude/**" ); + public void testFilesListExcludes2() throws IOException { + ScmFileSet fileSet = new ScmFileSet(new File(getBasedir(), "src"), "**/scmfileset/**", "**/exclude/**"); - assertEquals( 2, fileSet.getFileList().size() ); + assertEquals(2, fileSet.getFileList().size()); } @Test - public void testFilesListNoExcludes() - throws IOException - { - ScmFileSet fileSet = new ScmFileSet( new File( getBasedir(), "src" ), "**/scmfileset/**" ); + public void testFilesListNoExcludes() throws IOException { + ScmFileSet fileSet = new ScmFileSet(new File(getBasedir(), "src"), "**/scmfileset/**"); - assertEquals( 4, fileSet.getFileList().size() ); + assertEquals(4, fileSet.getFileList().size()); } - } diff --git a/maven-scm-api/src/test/java/org/apache/maven/scm/ScmResultTest.java b/maven-scm-api/src/test/java/org/apache/maven/scm/ScmResultTest.java index 2a8619923..b7d80fd16 100644 --- a/maven-scm-api/src/test/java/org/apache/maven/scm/ScmResultTest.java +++ b/maven-scm-api/src/test/java/org/apache/maven/scm/ScmResultTest.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,34 +16,33 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm; import org.junit.Test; import static org.junit.Assert.assertNotSame; import static org.junit.Assert.assertTrue; -public class ScmResultTest -{ +public class ScmResultTest { private static final String PASSWORD = "secr$t"; - private static final String SCM_URL_GIT_COLON = "scm:git:https://username:" + PASSWORD + "@github.com/username/repo.git"; + private static final String SCM_URL_GIT_COLON = + "scm:git:https://username:" + PASSWORD + "@github.com/username/repo.git"; private static final String MOCK_ERROR_OUTPUT = "fatal: repository '" + SCM_URL_GIT_COLON + "' not found"; - private static final String MOCK_ERROR_MULTILINE_OUTPUT = "remote: Invalid username or password." + System.lineSeparator() + "fatal: Authentication failed for '" + SCM_URL_GIT_COLON + "'"; + private static final String MOCK_ERROR_MULTILINE_OUTPUT = "remote: Invalid username or password." + + System.lineSeparator() + "fatal: Authentication failed for '" + SCM_URL_GIT_COLON + "'"; @Test - public void testPasswordsAreMaskedInOutput() - throws Exception - { - ScmResult result = new ScmResult( "git push", "git-push failed", MOCK_ERROR_OUTPUT, false ); - assertNotSame( "Command output contains password", MOCK_ERROR_OUTPUT, result.getCommandOutput() ); - assertTrue( "Command output not masked", result.getCommandOutput().contains( ScmResult.PASSWORD_PLACE_HOLDER ) ); - - result = new ScmResult( "git push", "git-push failed", MOCK_ERROR_MULTILINE_OUTPUT, false ); - assertNotSame( "Command output contains password", MOCK_ERROR_MULTILINE_OUTPUT, result.getCommandOutput() ); - assertTrue( "Command output not masked", result.getCommandOutput().contains( ScmResult.PASSWORD_PLACE_HOLDER ) ); + public void testPasswordsAreMaskedInOutput() throws Exception { + ScmResult result = new ScmResult("git push", "git-push failed", MOCK_ERROR_OUTPUT, false); + assertNotSame("Command output contains password", MOCK_ERROR_OUTPUT, result.getCommandOutput()); + assertTrue("Command output not masked", result.getCommandOutput().contains(ScmResult.PASSWORD_PLACE_HOLDER)); + + result = new ScmResult("git push", "git-push failed", MOCK_ERROR_MULTILINE_OUTPUT, false); + assertNotSame("Command output contains password", MOCK_ERROR_MULTILINE_OUTPUT, result.getCommandOutput()); + assertTrue("Command output not masked", result.getCommandOutput().contains(ScmResult.PASSWORD_PLACE_HOLDER)); } - } diff --git a/maven-scm-api/src/test/java/org/apache/maven/scm/manager/ScmManagerTest.java b/maven-scm-api/src/test/java/org/apache/maven/scm/manager/ScmManagerTest.java index 04ee3c7ef..a5d94af2a 100644 --- a/maven-scm-api/src/test/java/org/apache/maven/scm/manager/ScmManagerTest.java +++ b/maven-scm-api/src/test/java/org/apache/maven/scm/manager/ScmManagerTest.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.manager; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.manager; import org.junit.Test; @@ -27,23 +26,24 @@ * @author Emmanuel Venisse * */ -public class ScmManagerTest -{ +public class ScmManagerTest { @Test - public void testCleanScmUrl() - throws Exception - { + public void testCleanScmUrl() throws Exception { BasicScmManager manager = new BasicScmManager(); - assertEquals( "https://svn.apache.org/repos/asf/maven/scm/trunk/maven-scm-api", - manager.cleanScmUrl( "https://svn.apache.org/repos/asf/maven/scm/trunk/maven-scm-api" ) ); - assertEquals( "https://svn.apache.org/repos/asf/maven/scm/trunk/maven-scm-manager", manager.cleanScmUrl( - "https://svn.apache.org/repos/asf/maven/scm/trunk/maven-scm-api/../maven-scm-manager" ) ); - assertEquals( "https://svn.apache.org/repos/asf/maven/scm/trunk/", - manager.cleanScmUrl( "https://svn.apache.org/repos/asf/maven/scm/trunk/maven-scm-api/../" ) ); - assertEquals( "d:\\myrepo\\mydir", manager.cleanScmUrl( "d:\\myrepo\\mydir" ) ); - assertEquals( "d:\\myrepo\\mydir2", manager.cleanScmUrl( "d:\\myrepo\\mydir\\..\\mydir2" ) ); - assertEquals( "//depot/repos/...", manager.cleanScmUrl( "//depot/repos/..." ) ); - assertEquals( "//depot/repo2/...", manager.cleanScmUrl( "//depot/repos/../repo2/..." ) ); + assertEquals( + "https://svn.apache.org/repos/asf/maven/scm/trunk/maven-scm-api", + manager.cleanScmUrl("https://svn.apache.org/repos/asf/maven/scm/trunk/maven-scm-api")); + assertEquals( + "https://svn.apache.org/repos/asf/maven/scm/trunk/maven-scm-manager", + manager.cleanScmUrl( + "https://svn.apache.org/repos/asf/maven/scm/trunk/maven-scm-api/../maven-scm-manager")); + assertEquals( + "https://svn.apache.org/repos/asf/maven/scm/trunk/", + manager.cleanScmUrl("https://svn.apache.org/repos/asf/maven/scm/trunk/maven-scm-api/../")); + assertEquals("d:\\myrepo\\mydir", manager.cleanScmUrl("d:\\myrepo\\mydir")); + assertEquals("d:\\myrepo\\mydir2", manager.cleanScmUrl("d:\\myrepo\\mydir\\..\\mydir2")); + assertEquals("//depot/repos/...", manager.cleanScmUrl("//depot/repos/...")); + assertEquals("//depot/repo2/...", manager.cleanScmUrl("//depot/repos/../repo2/...")); } } diff --git a/maven-scm-api/src/test/java/org/apache/maven/scm/provider/ScmUrlUtilsTest.java b/maven-scm-api/src/test/java/org/apache/maven/scm/provider/ScmUrlUtilsTest.java index 6ec5f93da..507071b11 100644 --- a/maven-scm-api/src/test/java/org/apache/maven/scm/provider/ScmUrlUtilsTest.java +++ b/maven-scm-api/src/test/java/org/apache/maven/scm/provider/ScmUrlUtilsTest.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider; import org.junit.Test; @@ -29,8 +28,7 @@ * @author Dennis Lundberg * */ -public class ScmUrlUtilsTest -{ +public class ScmUrlUtilsTest { private static final String SCM_URL_INVALID_1 = null; private static final String SCM_URL_INVALID_2 = "scm"; @@ -48,35 +46,29 @@ public class ScmUrlUtilsTest private static final String SCM_URL_VALID_4 = "scm:a|provider-specific-part"; @Test - public void testGetProvider() - throws Exception - { - assertEquals( "a", ScmUrlUtils.getProvider( SCM_URL_VALID_1 ) ); - assertEquals( "a", ScmUrlUtils.getProvider( SCM_URL_VALID_2 ) ); - assertEquals( "a", ScmUrlUtils.getProvider( SCM_URL_VALID_3 ) ); - assertEquals( "a", ScmUrlUtils.getProvider( SCM_URL_VALID_4 ) ); + public void testGetProvider() throws Exception { + assertEquals("a", ScmUrlUtils.getProvider(SCM_URL_VALID_1)); + assertEquals("a", ScmUrlUtils.getProvider(SCM_URL_VALID_2)); + assertEquals("a", ScmUrlUtils.getProvider(SCM_URL_VALID_3)); + assertEquals("a", ScmUrlUtils.getProvider(SCM_URL_VALID_4)); } @Test - public void testGetProviderSpecificPart() - throws Exception - { - assertEquals( "", ScmUrlUtils.getProviderSpecificPart( SCM_URL_VALID_1 ) ); - assertEquals( "", ScmUrlUtils.getProviderSpecificPart( SCM_URL_VALID_2 ) ); - assertEquals( "provider-specific-part", ScmUrlUtils.getProviderSpecificPart( SCM_URL_VALID_3 ) ); - assertEquals( "provider-specific-part", ScmUrlUtils.getProviderSpecificPart( SCM_URL_VALID_4 ) ); + public void testGetProviderSpecificPart() throws Exception { + assertEquals("", ScmUrlUtils.getProviderSpecificPart(SCM_URL_VALID_1)); + assertEquals("", ScmUrlUtils.getProviderSpecificPart(SCM_URL_VALID_2)); + assertEquals("provider-specific-part", ScmUrlUtils.getProviderSpecificPart(SCM_URL_VALID_3)); + assertEquals("provider-specific-part", ScmUrlUtils.getProviderSpecificPart(SCM_URL_VALID_4)); } @Test - public void testIsValid() - throws Exception - { - assertTrue( ScmUrlUtils.isValid( SCM_URL_VALID_1 ) ); - assertTrue( ScmUrlUtils.isValid( SCM_URL_VALID_2 ) ); - assertTrue( ScmUrlUtils.isValid( SCM_URL_VALID_3 ) ); - assertFalse( ScmUrlUtils.isValid( SCM_URL_INVALID_1 ) ); - assertFalse( ScmUrlUtils.isValid( SCM_URL_INVALID_2 ) ); - assertFalse( ScmUrlUtils.isValid( SCM_URL_INVALID_3 ) ); - assertFalse( ScmUrlUtils.isValid( SCM_URL_INVALID_4 ) ); + public void testIsValid() throws Exception { + assertTrue(ScmUrlUtils.isValid(SCM_URL_VALID_1)); + assertTrue(ScmUrlUtils.isValid(SCM_URL_VALID_2)); + assertTrue(ScmUrlUtils.isValid(SCM_URL_VALID_3)); + assertFalse(ScmUrlUtils.isValid(SCM_URL_INVALID_1)); + assertFalse(ScmUrlUtils.isValid(SCM_URL_INVALID_2)); + assertFalse(ScmUrlUtils.isValid(SCM_URL_INVALID_3)); + assertFalse(ScmUrlUtils.isValid(SCM_URL_INVALID_4)); } } diff --git a/maven-scm-api/src/test/java/org/apache/maven/scm/util/FilenameUtilsTest.java b/maven-scm-api/src/test/java/org/apache/maven/scm/util/FilenameUtilsTest.java index 98be80522..ae40fc8e7 100644 --- a/maven-scm-api/src/test/java/org/apache/maven/scm/util/FilenameUtilsTest.java +++ b/maven-scm-api/src/test/java/org/apache/maven/scm/util/FilenameUtilsTest.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.util; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,26 +16,25 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.util; import org.junit.Test; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNull; -public class FilenameUtilsTest -{ +public class FilenameUtilsTest { @Test - public void testNormalize() - { - assertNull( FilenameUtils.normalizeFilename( (String) null ) ); - assertEquals( "", FilenameUtils.normalizeFilename( "" ) ); + public void testNormalize() { + assertNull(FilenameUtils.normalizeFilename((String) null)); + assertEquals("", FilenameUtils.normalizeFilename("")); - assertEquals( "c:", FilenameUtils.normalizeFilename( "c:" ) ); - assertEquals( "c:/", FilenameUtils.normalizeFilename( "c:\\" ) ); - assertEquals( "c:/", FilenameUtils.normalizeFilename( "c:/" ) ); - assertEquals( "c:/", FilenameUtils.normalizeFilename( "c://" ) ); + assertEquals("c:", FilenameUtils.normalizeFilename("c:")); + assertEquals("c:/", FilenameUtils.normalizeFilename("c:\\")); + assertEquals("c:/", FilenameUtils.normalizeFilename("c:/")); + assertEquals("c:/", FilenameUtils.normalizeFilename("c://")); - assertEquals( "c:/", FilenameUtils.normalizeFilename( "c:\\/" ) ); + assertEquals("c:/", FilenameUtils.normalizeFilename("c:\\/")); } } diff --git a/maven-scm-client/pom.xml b/maven-scm-client/pom.xml index 79ddde8e6..760dc56cd 100644 --- a/maven-scm-client/pom.xml +++ b/maven-scm-client/pom.xml @@ -1,5 +1,4 @@ - - 4.0.0 @@ -112,10 +110,10 @@ - package single + package diff --git a/maven-scm-client/src/main/java/org/apache/maven/scm/client/cli/MavenScmCli.java b/maven-scm-client/src/main/java/org/apache/maven/scm/client/cli/MavenScmCli.java index c27911fcd..c41bd9316 100644 --- a/maven-scm-client/src/main/java/org/apache/maven/scm/client/cli/MavenScmCli.java +++ b/maven-scm-client/src/main/java/org/apache/maven/scm/client/cli/MavenScmCli.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.client.cli; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.client.cli; import java.io.File; import java.util.List; @@ -52,8 +51,7 @@ * @author Emmanuel Venisse * */ -public class MavenScmCli -{ +public class MavenScmCli { private PlexusContainer plexus; private ScmManager scmManager; @@ -62,46 +60,36 @@ public class MavenScmCli // Lifecycle // ---------------------------------------------------------------------- - public MavenScmCli() - throws Exception - { + public MavenScmCli() throws Exception { plexus = createPlexusContainer(); - scmManager = plexus.lookup( ScmManager.class ); + scmManager = plexus.lookup(ScmManager.class); } - private PlexusContainer createPlexusContainer() - { + private PlexusContainer createPlexusContainer() { final Context context = new DefaultContext(); - String path = System.getProperty( "basedir" ); - if ( path == null ) - { - path = new File( "" ).getAbsolutePath(); + String path = System.getProperty("basedir"); + if (path == null) { + path = new File("").getAbsolutePath(); } - context.put( "basedir", path ); + context.put("basedir", path); ContainerConfiguration plexusConfiguration = new DefaultContainerConfiguration(); - plexusConfiguration.setName( "maven-scm-cli" ) - .setContext( context.getContextData() ) - .setClassPathScanning( PlexusConstants.SCANNING_CACHE ) - .setAutoWiring( true ); - try - { - return new DefaultPlexusContainer( plexusConfiguration ); - } - catch ( PlexusContainerException e ) - { - throw new IllegalStateException( "Could not create Plexus container", e ); + plexusConfiguration + .setName("maven-scm-cli") + .setContext(context.getContextData()) + .setClassPathScanning(PlexusConstants.SCANNING_CACHE) + .setAutoWiring(true); + try { + return new DefaultPlexusContainer(plexusConfiguration); + } catch (PlexusContainerException e) { + throw new IllegalStateException("Could not create Plexus container", e); } } - public void stop() - { - try - { + public void stop() { + try { plexus.dispose(); - } - catch ( Exception ex ) - { + } catch (Exception ex) { // ignore } } @@ -110,19 +98,15 @@ public void stop() // // ---------------------------------------------------------------------- - public static void main( String[] args ) - { + public static void main(String[] args) { MavenScmCli cli; - try - { + try { cli = new MavenScmCli(); - } - catch ( Exception ex ) - { - System.err.println( "Error while starting Maven SCM." ); + } catch (Exception ex) { + System.err.println("Error while starting Maven SCM."); - ex.printStackTrace( System.err ); + ex.printStackTrace(System.err); return; } @@ -131,13 +115,12 @@ public static void main( String[] args ) String command; - if ( args.length < 3 ) - { + if (args.length < 3) { + System.err.println( + "Usage: maven-scm-client [ []]"); + System.err.println("scmVersion is a branch name/tag name/revision number."); System.err.println( - "Usage: maven-scm-client [ []]" ); - System.err.println( "scmVersion is a branch name/tag name/revision number." ); - System.err.println( "scmVersionType can be 'branch', 'tag', 'revision'. " - + "The default value is 'revision'." ); + "scmVersionType can be 'branch', 'tag', 'revision'. " + "The default value is 'revision'."); return; } @@ -145,43 +128,32 @@ public static void main( String[] args ) command = args[0]; // SCM-641 - File workingDirectory = new File( args[1] ).getAbsoluteFile(); + File workingDirectory = new File(args[1]).getAbsoluteFile(); scmUrl = args[2]; ScmVersion scmVersion = null; - if ( args.length > 3 ) - { + if (args.length > 3) { String version = args[3]; - if ( args.length > 4 ) - { + if (args.length > 4) { String type = args[4]; - if ( "tag".equals( type ) ) - { - scmVersion = new ScmTag( version ); - } - else if ( "branch".equals( type ) ) - { - scmVersion = new ScmBranch( version ); - } - else if ( "revision".equals( type ) ) - { - scmVersion = new ScmRevision( version ); + if ("tag".equals(type)) { + scmVersion = new ScmTag(version); + } else if ("branch".equals(type)) { + scmVersion = new ScmBranch(version); + } else if ("revision".equals(type)) { + scmVersion = new ScmRevision(version); + } else { + throw new IllegalArgumentException("'" + type + "' version type isn't known."); } - else - { - throw new IllegalArgumentException( "'" + type + "' version type isn't known." ); - } - } - else - { - scmVersion = new ScmRevision( args[3] ); + } else { + scmVersion = new ScmRevision(args[3]); } } - cli.execute( scmUrl, command, workingDirectory, scmVersion ); + cli.execute(scmUrl, command, workingDirectory, scmVersion); cli.stop(); } @@ -190,53 +162,37 @@ else if ( "revision".equals( type ) ) // // ---------------------------------------------------------------------- - public void execute( String scmUrl, String command, File workingDirectory, ScmVersion version ) - { + public void execute(String scmUrl, String command, File workingDirectory, ScmVersion version) { ScmRepository repository; - try - { - repository = scmManager.makeScmRepository( scmUrl ); - } - catch ( NoSuchScmProviderException ex ) - { - System.err.println( "Could not find a provider." ); + try { + repository = scmManager.makeScmRepository(scmUrl); + } catch (NoSuchScmProviderException ex) { + System.err.println("Could not find a provider."); return; - } - catch ( ScmRepositoryException ex ) - { - System.err.println( "Error while connecting to the repository" ); + } catch (ScmRepositoryException ex) { + System.err.println("Error while connecting to the repository"); - ex.printStackTrace( System.err ); + ex.printStackTrace(System.err); return; } - try - { - if ( command.equals( "checkout" ) ) - { - checkOut( repository, workingDirectory, version ); - } - else if ( command.equals( "checkin" ) ) - { - checkIn( repository, workingDirectory, version ); + try { + if (command.equals("checkout")) { + checkOut(repository, workingDirectory, version); + } else if (command.equals("checkin")) { + checkIn(repository, workingDirectory, version); + } else if (command.equals("update")) { + update(repository, workingDirectory, version); + } else { + System.err.println("Unknown SCM command '" + command + "'."); } - else if ( command.equals( "update" ) ) - { - update( repository, workingDirectory, version ); - } - else - { - System.err.println( "Unknown SCM command '" + command + "'." ); - } - } - catch ( ScmException ex ) - { - System.err.println( "Error while executing the SCM command." ); + } catch (ScmException ex) { + System.err.println("Error while executing the SCM command."); - ex.printStackTrace( System.err ); + ex.printStackTrace(System.err); return; } @@ -246,104 +202,84 @@ else if ( command.equals( "update" ) ) // // ---------------------------------------------------------------------- - private void checkOut( ScmRepository scmRepository, File workingDirectory, ScmVersion version ) - throws ScmException - { - if ( workingDirectory.exists() ) - { - System.err.println( "The working directory already exist: '" + workingDirectory.getAbsolutePath() - + "'." ); + private void checkOut(ScmRepository scmRepository, File workingDirectory, ScmVersion version) throws ScmException { + if (workingDirectory.exists()) { + System.err.println("The working directory already exist: '" + workingDirectory.getAbsolutePath() + "'."); return; } - if ( !workingDirectory.mkdirs() ) - { + if (!workingDirectory.mkdirs()) { System.err.println( - "Error while making the working directory: '" + workingDirectory.getAbsolutePath() + "'." ); + "Error while making the working directory: '" + workingDirectory.getAbsolutePath() + "'."); return; } - CheckOutScmResult result = scmManager.checkOut( scmRepository, new ScmFileSet( workingDirectory ), version ); + CheckOutScmResult result = scmManager.checkOut(scmRepository, new ScmFileSet(workingDirectory), version); - if ( !result.isSuccess() ) - { - showError( result ); + if (!result.isSuccess()) { + showError(result); return; } List checkedOutFiles = result.getCheckedOutFiles(); - System.out.println( "Checked out these files: " ); + System.out.println("Checked out these files: "); - for ( ScmFile file : checkedOutFiles ) - { - System.out.println( " " + file.getPath() ); + for (ScmFile file : checkedOutFiles) { + System.out.println(" " + file.getPath()); } } - private void checkIn( ScmRepository scmRepository, File workingDirectory, ScmVersion version ) - throws ScmException - { - if ( !workingDirectory.exists() ) - { - System.err.println( "The working directory doesn't exist: '" + workingDirectory.getAbsolutePath() - + "'." ); + private void checkIn(ScmRepository scmRepository, File workingDirectory, ScmVersion version) throws ScmException { + if (!workingDirectory.exists()) { + System.err.println("The working directory doesn't exist: '" + workingDirectory.getAbsolutePath() + "'."); return; } String message = ""; - CheckInScmResult result = - scmManager.checkIn( scmRepository, new ScmFileSet( workingDirectory ), version, message ); + CheckInScmResult result = scmManager.checkIn(scmRepository, new ScmFileSet(workingDirectory), version, message); - if ( !result.isSuccess() ) - { - showError( result ); + if (!result.isSuccess()) { + showError(result); return; } List checkedInFiles = result.getCheckedInFiles(); - System.out.println( "Checked in these files: " ); + System.out.println("Checked in these files: "); - for ( ScmFile file : checkedInFiles ) - { - System.out.println( " " + file.getPath() ); + for (ScmFile file : checkedInFiles) { + System.out.println(" " + file.getPath()); } } - private void update( ScmRepository scmRepository, File workingDirectory, ScmVersion version ) - throws ScmException - { - if ( !workingDirectory.exists() ) - { - System.err.println( "The working directory doesn't exist: '" + workingDirectory.getAbsolutePath() - + "'." ); + private void update(ScmRepository scmRepository, File workingDirectory, ScmVersion version) throws ScmException { + if (!workingDirectory.exists()) { + System.err.println("The working directory doesn't exist: '" + workingDirectory.getAbsolutePath() + "'."); return; } - UpdateScmResult result = scmManager.update( scmRepository, new ScmFileSet( workingDirectory ), version ); + UpdateScmResult result = scmManager.update(scmRepository, new ScmFileSet(workingDirectory), version); - if ( !result.isSuccess() ) - { - showError( result ); + if (!result.isSuccess()) { + showError(result); return; } List updatedFiles = result.getUpdatedFiles(); - System.out.println( "Updated these files: " ); + System.out.println("Updated these files: "); - for ( ScmFile file : updatedFiles ) - { - System.out.println( " " + file.getPath() ); + for (ScmFile file : updatedFiles) { + System.out.println(" " + file.getPath()); } } @@ -351,28 +287,23 @@ private void update( ScmRepository scmRepository, File workingDirectory, ScmVers // // ---------------------------------------------------------------------- - private void showError( ScmResult result ) - { - System.err.println( "There was a error while executing the SCM command." ); + private void showError(ScmResult result) { + System.err.println("There was a error while executing the SCM command."); String providerMessage = result.getProviderMessage(); - if ( !StringUtils.isEmpty( providerMessage ) ) - { - System.err.println( "Error message from the provider: " + providerMessage ); - } - else - { - System.err.println( "The provider didn't give a error message." ); + if (!StringUtils.isEmpty(providerMessage)) { + System.err.println("Error message from the provider: " + providerMessage); + } else { + System.err.println("The provider didn't give a error message."); } String output = result.getCommandOutput(); - if ( !StringUtils.isEmpty( output ) ) - { - System.err.println( "Command output:" ); + if (!StringUtils.isEmpty(output)) { + System.err.println("Command output:"); - System.err.println( output ); + System.err.println(output); } } } diff --git a/maven-scm-managers/maven-scm-manager-plexus/pom.xml b/maven-scm-managers/maven-scm-manager-plexus/pom.xml index 97412970a..cc668c4c5 100644 --- a/maven-scm-managers/maven-scm-manager-plexus/pom.xml +++ b/maven-scm-managers/maven-scm-manager-plexus/pom.xml @@ -1,5 +1,4 @@ - - 4.0.0 diff --git a/maven-scm-managers/maven-scm-manager-plexus/src/main/java/org/apache/maven/scm/manager/plexus/DefaultScmManager.java b/maven-scm-managers/maven-scm-manager-plexus/src/main/java/org/apache/maven/scm/manager/plexus/DefaultScmManager.java index aa462b073..e8c81dbae 100644 --- a/maven-scm-managers/maven-scm-manager-plexus/src/main/java/org/apache/maven/scm/manager/plexus/DefaultScmManager.java +++ b/maven-scm-managers/maven-scm-manager-plexus/src/main/java/org/apache/maven/scm/manager/plexus/DefaultScmManager.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.manager.plexus; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,16 +16,17 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.manager.plexus; import javax.inject.Inject; import javax.inject.Named; import javax.inject.Singleton; +import java.util.Map; + import org.apache.maven.scm.manager.AbstractScmManager; import org.apache.maven.scm.provider.ScmProvider; -import java.util.Map; - import static java.util.Objects.requireNonNull; /** @@ -38,18 +37,14 @@ */ @Singleton @Named -public class DefaultScmManager - extends AbstractScmManager -{ +public class DefaultScmManager extends AbstractScmManager { @Inject - public DefaultScmManager( Map scmProviders ) - { - requireNonNull( scmProviders ); - if ( scmProviders.isEmpty() ) - { - logger.warn( "No SCM providers configured." ); + public DefaultScmManager(Map scmProviders) { + requireNonNull(scmProviders); + if (scmProviders.isEmpty()) { + logger.warn("No SCM providers configured."); } - setScmProviders( scmProviders ); + setScmProviders(scmProviders); } } diff --git a/maven-scm-managers/pom.xml b/maven-scm-managers/pom.xml index f5db60040..05af40d5a 100644 --- a/maven-scm-managers/pom.xml +++ b/maven-scm-managers/pom.xml @@ -1,4 +1,5 @@ - - 4.0.0 - maven-scm org.apache.maven.scm + maven-scm 2.0.0-M4-SNAPSHOT diff --git a/maven-scm-plugin/pom.xml b/maven-scm-plugin/pom.xml index ce4dc783e..2790ce2d7 100644 --- a/maven-scm-plugin/pom.xml +++ b/maven-scm-plugin/pom.xml @@ -1,5 +1,4 @@ - - 4.0.0 @@ -40,14 +38,14 @@ Maven SCM Plugin Maven Plugin that allows accessing different SCMs. - - 3.2.5 - - ${mavenVersion} + + 3.2.5 + + org.apache.maven @@ -162,13 +160,44 @@ test - org.apache.maven.scm - maven-scm-provider-gittest - test + org.apache.maven.scm + maven-scm-provider-gittest + test + + + + org.apache.maven.plugins + maven-surefire-plugin + + + + settings.security + ${project.build.testOutputDirectory}/settings-security.xml + + + + + + org.apache.maven.plugins + maven-plugin-plugin + + true + + + + help-goal + + helpmojo + + + + + + org.apache.maven.plugins @@ -192,7 +221,7 @@ run - + org.apache.rat @@ -203,38 +232,7 @@ - - - - - org.apache.maven.plugins - maven-surefire-plugin - - - - settings.security - ${project.build.testOutputDirectory}/settings-security.xml - - - - - - org.apache.maven.plugins - maven-plugin-plugin - - true - - - - help-goal - - helpmojo - - - - - - + diff --git a/maven-scm-plugin/src/main/java/org/apache/maven/scm/plugin/AbstractScmMojo.java b/maven-scm-plugin/src/main/java/org/apache/maven/scm/plugin/AbstractScmMojo.java index f1ecfeddc..bb1b701a0 100644 --- a/maven-scm-plugin/src/main/java/org/apache/maven/scm/plugin/AbstractScmMojo.java +++ b/maven-scm-plugin/src/main/java/org/apache/maven/scm/plugin/AbstractScmMojo.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.plugin; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.plugin; import java.io.File; import java.io.IOException; @@ -60,9 +59,7 @@ * @author Emmanuel Venisse * @author Olivier Lamy */ -public abstract class AbstractScmMojo - extends AbstractMojo -{ +public abstract class AbstractScmMojo extends AbstractMojo { protected static final String VERSION_TYPE_BRANCH = "branch"; @@ -70,55 +67,55 @@ public abstract class AbstractScmMojo protected static final String VERSION_TYPE_TAG = "tag"; - protected static final String[] VALID_VERSION_TYPES = { VERSION_TYPE_BRANCH, - VERSION_TYPE_REVISION, VERSION_TYPE_TAG }; + protected static final String[] VALID_VERSION_TYPES = {VERSION_TYPE_BRANCH, VERSION_TYPE_REVISION, VERSION_TYPE_TAG + }; /** * The SCM connection URL. */ - @Parameter( property = "connectionUrl", defaultValue = "${project.scm.connection}" ) + @Parameter(property = "connectionUrl", defaultValue = "${project.scm.connection}") private String connectionUrl; /** * The SCM connection URL for developers. */ - @Parameter( property = "developerConnectionUrl", defaultValue = "${project.scm.developerConnection}" ) + @Parameter(property = "developerConnectionUrl", defaultValue = "${project.scm.developerConnection}") private String developerConnectionUrl; /** * The type of connection to use (connection or developerConnection). */ - @Parameter( property = "connectionType", defaultValue = "connection" ) + @Parameter(property = "connectionType", defaultValue = "connection") private String connectionType; /** * The working directory. */ - @Parameter( property = "workingDirectory" ) + @Parameter(property = "workingDirectory") private File workingDirectory; /** * The user name. */ - @Parameter( property = "username" ) + @Parameter(property = "username") private String username; /** * The user password. */ - @Parameter( property = "password" ) + @Parameter(property = "password") private String password; /** * The private key. */ - @Parameter( property = "privateKey" ) + @Parameter(property = "privateKey") private String privateKey; /** * The passphrase. */ - @Parameter( property = "passphrase" ) + @Parameter(property = "passphrase") private String passphrase; /** @@ -126,19 +123,19 @@ public abstract class AbstractScmMojo * necessary to set it if you use the standard svn layout * (branches/tags/trunk). */ - @Parameter( property = "tagBase" ) + @Parameter(property = "tagBase") private String tagBase; /** * Comma separated list of includes file pattern. */ - @Parameter( property = "includes" ) + @Parameter(property = "includes") private String includes; /** * Comma separated list of excludes file pattern. */ - @Parameter( property = "excludes" ) + @Parameter(property = "excludes") private String excludes; @Component @@ -150,10 +147,10 @@ public abstract class AbstractScmMojo /** * The base directory. */ - @Parameter( property = "basedir", required = true ) + @Parameter(property = "basedir", required = true) private File basedir; - @Parameter( defaultValue = "${settings}", readonly = true ) + @Parameter(defaultValue = "${settings}", readonly = true) private Settings settings; /** @@ -176,7 +173,7 @@ public abstract class AbstractScmMojo * * @since 1.4 */ - @Parameter( property = "pushChanges", defaultValue = "true" ) + @Parameter(property = "pushChanges", defaultValue = "true") private boolean pushChanges; /** @@ -185,189 +182,145 @@ public abstract class AbstractScmMojo * * @since 1.9.5 */ - @Parameter( property = "workItem" ) + @Parameter(property = "workItem") @Deprecated private String workItem; /** {@inheritDoc} */ - public void execute() - throws MojoExecutionException - { - if ( systemProperties != null ) - { + public void execute() throws MojoExecutionException { + if (systemProperties != null) { // Add all system properties configured by the user Iterator iter = systemProperties.keySet().iterator(); - while ( iter.hasNext() ) - { + while (iter.hasNext()) { String key = (String) iter.next(); - String value = systemProperties.getProperty( key ); + String value = systemProperties.getProperty(key); - System.setProperty( key, value ); + System.setProperty(key, value); } } - if ( providerImplementations != null && !providerImplementations.isEmpty() ) - { - for ( Entry entry : providerImplementations.entrySet() ) - { + if (providerImplementations != null && !providerImplementations.isEmpty()) { + for (Entry entry : providerImplementations.entrySet()) { String providerType = entry.getKey(); String providerImplementation = entry.getValue(); - getLog().info( - "Change the default '" + providerType + "' provider implementation to '" - + providerImplementation + "'." ); - getScmManager().setScmProviderImplementation( providerType, providerImplementation ); + getLog().info("Change the default '" + providerType + "' provider implementation to '" + + providerImplementation + "'."); + getScmManager().setScmProviderImplementation(providerType, providerImplementation); } } } - protected void setConnectionType( String connectionType ) - { + protected void setConnectionType(String connectionType) { this.connectionType = connectionType; } - public String getConnectionUrl() - { - boolean requireDeveloperConnection = !"connection".equals( connectionType.toLowerCase() ); - if ( StringUtils.isNotEmpty( connectionUrl ) && !requireDeveloperConnection ) - { + public String getConnectionUrl() { + boolean requireDeveloperConnection = !"connection".equals(connectionType.toLowerCase()); + if (StringUtils.isNotEmpty(connectionUrl) && !requireDeveloperConnection) { return connectionUrl; - } - else if ( StringUtils.isNotEmpty( developerConnectionUrl ) ) - { + } else if (StringUtils.isNotEmpty(developerConnectionUrl)) { return developerConnectionUrl; } - if ( requireDeveloperConnection ) - { - throw new NullPointerException( "You need to define a developerConnectionUrl parameter" ); - } - else - { - throw new NullPointerException( "You need to define a connectionUrl parameter" ); + if (requireDeveloperConnection) { + throw new NullPointerException("You need to define a developerConnectionUrl parameter"); + } else { + throw new NullPointerException("You need to define a connectionUrl parameter"); } } - public void setConnectionUrl( String connectionUrl ) - { + public void setConnectionUrl(String connectionUrl) { this.connectionUrl = connectionUrl; } - public File getWorkingDirectory() - { - if ( workingDirectory == null ) - { + public File getWorkingDirectory() { + if (workingDirectory == null) { return basedir; } return workingDirectory; } - public File getBasedir() - { + public File getBasedir() { return this.basedir; } - public void setWorkingDirectory( File workingDirectory ) - { + public void setWorkingDirectory(File workingDirectory) { this.workingDirectory = workingDirectory; } - public ScmManager getScmManager() - { + public ScmManager getScmManager() { return manager; } - public ScmFileSet getFileSet() - throws IOException - { - if ( includes != null || excludes != null ) - { - return new ScmFileSet( getWorkingDirectory(), includes, excludes ); - } - else - { - return new ScmFileSet( getWorkingDirectory() ); + public ScmFileSet getFileSet() throws IOException { + if (includes != null || excludes != null) { + return new ScmFileSet(getWorkingDirectory(), includes, excludes); + } else { + return new ScmFileSet(getWorkingDirectory()); } } - public ScmRepository getScmRepository() - throws ScmException - { + public ScmRepository getScmRepository() throws ScmException { ScmRepository repository; - try - { - repository = getScmManager().makeScmRepository( getConnectionUrl() ); + try { + repository = getScmManager().makeScmRepository(getConnectionUrl()); ScmProviderRepository providerRepo = repository.getProviderRepository(); - providerRepo.setPushChanges( pushChanges ); + providerRepo.setPushChanges(pushChanges); - if ( !StringUtils.isEmpty( workItem ) ) - { - providerRepo.setWorkItem( workItem ); + if (!StringUtils.isEmpty(workItem)) { + providerRepo.setWorkItem(workItem); } - if ( !StringUtils.isEmpty( username ) ) - { - providerRepo.setUser( username ); + if (!StringUtils.isEmpty(username)) { + providerRepo.setUser(username); } - if ( !StringUtils.isEmpty( password ) ) - { - providerRepo.setPassword( password ); + if (!StringUtils.isEmpty(password)) { + providerRepo.setPassword(password); } - if ( repository.getProviderRepository() instanceof ScmProviderRepositoryWithHost ) - { + if (repository.getProviderRepository() instanceof ScmProviderRepositoryWithHost) { ScmProviderRepositoryWithHost repo = (ScmProviderRepositoryWithHost) repository.getProviderRepository(); - loadInfosFromSettings( repo ); + loadInfosFromSettings(repo); - if ( !StringUtils.isEmpty( username ) ) - { - repo.setUser( username ); + if (!StringUtils.isEmpty(username)) { + repo.setUser(username); } - if ( !StringUtils.isEmpty( password ) ) - { - repo.setPassword( password ); + if (!StringUtils.isEmpty(password)) { + repo.setPassword(password); } - if ( !StringUtils.isEmpty( privateKey ) ) - { - repo.setPrivateKey( privateKey ); + if (!StringUtils.isEmpty(privateKey)) { + repo.setPrivateKey(privateKey); } - if ( !StringUtils.isEmpty( passphrase ) ) - { - repo.setPassphrase( passphrase ); + if (!StringUtils.isEmpty(passphrase)) { + repo.setPassphrase(passphrase); } } - if ( !StringUtils.isEmpty( tagBase ) && repository.getProvider().equals( "svn" ) ) - { + if (!StringUtils.isEmpty(tagBase) && repository.getProvider().equals("svn")) { SvnScmProviderRepository svnRepo = (SvnScmProviderRepository) repository.getProviderRepository(); - svnRepo.setTagBase( tagBase ); + svnRepo.setTagBase(tagBase); } - } - catch ( ScmRepositoryException e ) - { - if ( !e.getValidationMessages().isEmpty() ) - { - for ( String message : e.getValidationMessages() ) - { - getLog().error( message ); + } catch (ScmRepositoryException e) { + if (!e.getValidationMessages().isEmpty()) { + for (String message : e.getValidationMessages()) { + getLog().error(message); } } - throw new ScmException( "Can't load the scm provider.", e ); - } - catch ( Exception e ) - { - throw new ScmException( "Can't load the scm provider.", e ); + throw new ScmException("Can't load the scm provider.", e); + } catch (Exception e) { + throw new ScmException("Can't load the scm provider.", e); } return repository; @@ -378,175 +331,139 @@ public ScmRepository getScmRepository() * * @param repo not null */ - private void loadInfosFromSettings( ScmProviderRepositoryWithHost repo ) - { - if ( username == null || password == null ) - { + private void loadInfosFromSettings(ScmProviderRepositoryWithHost repo) { + if (username == null || password == null) { String host = repo.getHost(); int port = repo.getPort(); - if ( port > 0 ) - { + if (port > 0) { host += ":" + port; } - Server server = this.settings.getServer( host ); + Server server = this.settings.getServer(host); - if ( server != null ) - { - server = decrypt( server ); + if (server != null) { + server = decrypt(server); - if ( username == null ) - { + if (username == null) { username = server.getUsername(); } - if ( password == null ) - { + if (password == null) { password = server.getPassword(); } - if ( privateKey == null ) - { + if (privateKey == null) { privateKey = server.getPrivateKey(); } - if ( passphrase == null ) - { + if (passphrase == null) { passphrase = server.getPassphrase(); } } } } - private Server decrypt( Server server ) - { - SettingsDecryptionResult result = settingsDecrypter.decrypt( new DefaultSettingsDecryptionRequest( server ) ); - for ( SettingsProblem problem : result.getProblems() ) - { - getLog().error( problem.getMessage(), problem.getException() ); + private Server decrypt(Server server) { + SettingsDecryptionResult result = settingsDecrypter.decrypt(new DefaultSettingsDecryptionRequest(server)); + for (SettingsProblem problem : result.getProblems()) { + getLog().error(problem.getMessage(), problem.getException()); } return result.getServer(); } - public void checkResult( ScmResult result ) - throws MojoExecutionException - { - if ( !result.isSuccess() ) - { - getLog().error( "Provider message:" ); + public void checkResult(ScmResult result) throws MojoExecutionException { + if (!result.isSuccess()) { + getLog().error("Provider message:"); - getLog().error( result.getProviderMessage() == null ? "" : result.getProviderMessage() ); + getLog().error(result.getProviderMessage() == null ? "" : result.getProviderMessage()); - getLog().error( "Command output:" ); + getLog().error("Command output:"); - getLog().error( result.getCommandOutput() == null ? "" : result.getCommandOutput() ); + getLog().error(result.getCommandOutput() == null ? "" : result.getCommandOutput()); - throw new MojoExecutionException( - "Command failed: " + Objects.toString( result.getProviderMessage() ) ); + throw new MojoExecutionException("Command failed: " + Objects.toString(result.getProviderMessage())); } } - public String getIncludes() - { + public String getIncludes() { return includes; } - public void setIncludes( String includes ) - { + public void setIncludes(String includes) { this.includes = includes; } - public String getExcludes() - { + public String getExcludes() { return excludes; } - public void setExcludes( String excludes ) - { + public void setExcludes(String excludes) { this.excludes = excludes; } - public ScmVersion getScmVersion( String versionType, String version ) - throws MojoExecutionException - { - if ( StringUtils.isEmpty( versionType ) && StringUtils.isNotEmpty( version ) ) - { - throw new MojoExecutionException( "You must specify the version type." ); + public ScmVersion getScmVersion(String versionType, String version) throws MojoExecutionException { + if (StringUtils.isEmpty(versionType) && StringUtils.isNotEmpty(version)) { + throw new MojoExecutionException("You must specify the version type."); } - if ( StringUtils.isEmpty( version ) ) - { + if (StringUtils.isEmpty(version)) { return null; } - if ( VERSION_TYPE_BRANCH.equals( versionType ) ) - { - return new ScmBranch( version ); + if (VERSION_TYPE_BRANCH.equals(versionType)) { + return new ScmBranch(version); } - if ( VERSION_TYPE_TAG.equals( versionType ) ) - { - return new ScmTag( version ); + if (VERSION_TYPE_TAG.equals(versionType)) { + return new ScmTag(version); } - if ( VERSION_TYPE_REVISION.equals( versionType ) ) - { - return new ScmRevision( version ); + if (VERSION_TYPE_REVISION.equals(versionType)) { + return new ScmRevision(version); } - throw new MojoExecutionException( "Unknown '" + versionType + "' version type." ); + throw new MojoExecutionException("Unknown '" + versionType + "' version type."); } - protected void handleExcludesIncludesAfterCheckoutAndExport( File checkoutDirectory ) - throws MojoExecutionException - { + protected void handleExcludesIncludesAfterCheckoutAndExport(File checkoutDirectory) throws MojoExecutionException { List includes = new ArrayList(); - if ( ! StringUtils.isBlank( this.getIncludes() ) ) - { - String[] tokens = StringUtils.split( this.getIncludes(), "," ); - for ( int i = 0; i < tokens.length; ++i ) - { - includes.add( tokens[i] ); + if (!StringUtils.isBlank(this.getIncludes())) { + String[] tokens = StringUtils.split(this.getIncludes(), ","); + for (int i = 0; i < tokens.length; ++i) { + includes.add(tokens[i]); } } List excludes = new ArrayList(); - if ( ! StringUtils.isBlank( this.getExcludes() ) ) - { - String[] tokens = StringUtils.split( this.getExcludes(), "," ); - for ( int i = 0; i < tokens.length; ++i ) - { - excludes.add( tokens[i] ); + if (!StringUtils.isBlank(this.getExcludes())) { + String[] tokens = StringUtils.split(this.getExcludes(), ","); + for (int i = 0; i < tokens.length; ++i) { + excludes.add(tokens[i]); } } - if ( includes.isEmpty() && excludes.isEmpty() ) - { + if (includes.isEmpty() && excludes.isEmpty()) { return; } FileSetManager fileSetManager = new FileSetManager(); FileSet fileset = new FileSet(); - fileset.setDirectory( checkoutDirectory.getAbsolutePath() ); - fileset.setIncludes( excludes ); // revert the order to do the delete - fileset.setExcludes( includes ); - fileset.setUseDefaultExcludes( false ); - - try - { - fileSetManager.delete( fileset ); - } - catch ( IOException e ) - { - throw new MojoExecutionException( "Error found while cleaning up output directory base on " - + "excludes/includes configurations.", e ); + fileset.setDirectory(checkoutDirectory.getAbsolutePath()); + fileset.setIncludes(excludes); // revert the order to do the delete + fileset.setExcludes(includes); + fileset.setUseDefaultExcludes(false); + + try { + fileSetManager.delete(fileset); + } catch (IOException e) { + throw new MojoExecutionException( + "Error found while cleaning up output directory base on " + "excludes/includes configurations.", e); } - } } diff --git a/maven-scm-plugin/src/main/java/org/apache/maven/scm/plugin/AddMojo.java b/maven-scm-plugin/src/main/java/org/apache/maven/scm/plugin/AddMojo.java index b96e04683..9ce8675fc 100644 --- a/maven-scm-plugin/src/main/java/org/apache/maven/scm/plugin/AddMojo.java +++ b/maven-scm-plugin/src/main/java/org/apache/maven/scm/plugin/AddMojo.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.plugin; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,9 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.plugin; + +import java.io.IOException; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugins.annotations.Mojo; @@ -25,37 +26,28 @@ import org.apache.maven.scm.command.add.AddScmResult; import org.apache.maven.scm.repository.ScmRepository; -import java.io.IOException; - /** * Add a file set to the project. * * @author Julien Henry */ -@Mojo( name = "add", aggregator = true ) -public class AddMojo - extends AbstractScmMojo -{ +@Mojo(name = "add", aggregator = true) +public class AddMojo extends AbstractScmMojo { /** {@inheritDoc} */ - public void execute() - throws MojoExecutionException - { + public void execute() throws MojoExecutionException { super.execute(); - try - { + try { ScmRepository repository = getScmRepository(); - AddScmResult result = getScmManager().add( repository, getFileSet() ); + AddScmResult result = getScmManager().add(repository, getFileSet()); - checkResult( result ); + checkResult(result); - getLog().info( "" + result.getAddedFiles().size() + " files successfully added." ); + getLog().info("" + result.getAddedFiles().size() + " files successfully added."); - } - catch ( IOException | ScmException e ) - { - throw new MojoExecutionException( "Cannot run add command : ", e ); + } catch (IOException | ScmException e) { + throw new MojoExecutionException("Cannot run add command : ", e); } } } diff --git a/maven-scm-plugin/src/main/java/org/apache/maven/scm/plugin/BootstrapMojo.java b/maven-scm-plugin/src/main/java/org/apache/maven/scm/plugin/BootstrapMojo.java index e146b1c69..93d545276 100644 --- a/maven-scm-plugin/src/main/java/org/apache/maven/scm/plugin/BootstrapMojo.java +++ b/maven-scm-plugin/src/main/java/org/apache/maven/scm/plugin/BootstrapMojo.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.plugin; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,28 +16,10 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.plugin; import java.io.File; -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.plugins.annotations.Parameter; @@ -58,23 +38,21 @@ * * @author Dan T. Tran */ -@Mojo( name = "bootstrap", requiresProject = false ) -public class BootstrapMojo - extends CheckoutMojo -{ +@Mojo(name = "bootstrap", requiresProject = false) +public class BootstrapMojo extends CheckoutMojo { /** * The goals to run on the clean checkout of a project for the bootstrap goal. * If none are specified, then the default goal for the project is executed. * Multiple goals should be comma separated. */ - @Parameter( property = "goals" ) + @Parameter(property = "goals") private String goals; /** * A list of profiles to run with the goals. * Multiple profiles must be comma separated with no spaces. */ - @Parameter( property = "profiles" ) + @Parameter(property = "profiles") private String profiles; /** @@ -82,35 +60,31 @@ public class BootstrapMojo * The project directory is the same as the checkout directory in most cases, * but for some SCMs, it is a subdirectory of the checkout directory. */ - @Parameter( property = "goalsDirectory" ) + @Parameter(property = "goalsDirectory") private String goalsDirectory; /** * The path where your maven is installed */ - @Parameter( property = "mavenHome", defaultValue = "${maven.home}" ) + @Parameter(property = "mavenHome", defaultValue = "${maven.home}") private File mavenHome; /** {@inheritDoc} */ - public void execute() - throws MojoExecutionException - { + public void execute() throws MojoExecutionException { super.execute(); - if ( this.getCheckoutResult() != null ) - { + if (this.getCheckoutResult() != null) { ScmResult checkoutResult = this.getCheckoutResult(); - //At the time of useExport feature is requested only SVN has export command implemented + // At the time of useExport feature is requested only SVN has export command implemented // add relativePathProjectDirectory support to ExportScmResult String relativePathProjectDirectory = ""; - if ( checkoutResult instanceof CheckOutScmResult ) - { - relativePathProjectDirectory = ( (CheckOutScmResult) checkoutResult ).getRelativePathProjectDirectory(); + if (checkoutResult instanceof CheckOutScmResult) { + relativePathProjectDirectory = ((CheckOutScmResult) checkoutResult).getRelativePathProjectDirectory(); } - runGoals( relativePathProjectDirectory ); + runGoals(relativePathProjectDirectory); } } @@ -119,71 +93,56 @@ public void execute() * directory; or "" if they are the same * @throws MojoExecutionException if any */ - private void runGoals( String relativePathProjectDirectory ) - throws MojoExecutionException - { + private void runGoals(String relativePathProjectDirectory) throws MojoExecutionException { Commandline cl = new Commandline(); - try - { + try { cl.addSystemEnvironment(); + } catch (Exception e) { + throw new MojoExecutionException("Can't add system environment variables to mvn command line.", e); } - catch ( Exception e ) - { - throw new MojoExecutionException( "Can't add system environment variables to mvn command line.", e ); - } - cl.addEnvironment( "MAVEN_TERMINATE_CMD", "on" ); + cl.addEnvironment("MAVEN_TERMINATE_CMD", "on"); - if ( this.mavenHome == null ) - { - cl.setExecutable( "mvn" ); // none windows only - } - else - { + if (this.mavenHome == null) { + cl.setExecutable("mvn"); // none windows only + } else { String mvnPath = this.mavenHome.getAbsolutePath() + "/bin/mvn"; - if ( Os.isFamily( "windows" ) ) - { + if (Os.isFamily("windows")) { String winMvnPath = mvnPath + ".cmd"; - if ( !new File( winMvnPath ).exists() ) - { + if (!new File(winMvnPath).exists()) { winMvnPath = mvnPath + ".bat"; } mvnPath = winMvnPath; } - cl.setExecutable( mvnPath ); + cl.setExecutable(mvnPath); } - cl.setWorkingDirectory( determineWorkingDirectoryPath( this.getCheckoutDirectory(), // - relativePathProjectDirectory, goalsDirectory ) ); + cl.setWorkingDirectory(determineWorkingDirectoryPath( + this.getCheckoutDirectory(), // + relativePathProjectDirectory, + goalsDirectory)); - if ( this.goals != null ) - { - String[] tokens = StringUtils.split( this.goals, ", " ); + if (this.goals != null) { + String[] tokens = StringUtils.split(this.goals, ", "); - for ( int i = 0; i < tokens.length; ++i ) - { - cl.createArg().setValue( tokens[i] ); + for (int i = 0; i < tokens.length; ++i) { + cl.createArg().setValue(tokens[i]); } } - if ( ! StringUtils.isEmpty( this.profiles ) ) - { - cl.createArg().setValue( "-P" + this.profiles ); + if (!StringUtils.isEmpty(this.profiles)) { + cl.createArg().setValue("-P" + this.profiles); } StreamConsumer consumer = new DefaultConsumer(); - try - { - int result = CommandLineUtils.executeCommandLine( cl, consumer, consumer ); + try { + int result = CommandLineUtils.executeCommandLine(cl, consumer, consumer); - if ( result != 0 ) - { - throw new MojoExecutionException( "Result of mvn execution is: \'" + result + "\'. Release failed." ); + if (result != 0) { + throw new MojoExecutionException("Result of mvn execution is: \'" + result + "\'. Release failed."); } - } - catch ( CommandLineException e ) - { - throw new MojoExecutionException( "Can't run goal " + goals, e ); + } catch (CommandLineException e) { + throw new MojoExecutionException("Can't run goal " + goals, e); } } @@ -197,24 +156,19 @@ private void runGoals( String relativePathProjectDirectory ) * @param goalsDirectory * @return TODO */ - protected String determineWorkingDirectoryPath( File checkoutDirectory, String relativePathProjectDirectory, - String goalsDirectory ) - { + protected String determineWorkingDirectoryPath( + File checkoutDirectory, String relativePathProjectDirectory, String goalsDirectory) { File projectDirectory; - if ( StringUtils.isNotEmpty( relativePathProjectDirectory ) ) - { - projectDirectory = new File( checkoutDirectory, relativePathProjectDirectory ); - } - else - { + if (StringUtils.isNotEmpty(relativePathProjectDirectory)) { + projectDirectory = new File(checkoutDirectory, relativePathProjectDirectory); + } else { projectDirectory = checkoutDirectory; } - if ( StringUtils.isEmpty( goalsDirectory ) ) - { + if (StringUtils.isEmpty(goalsDirectory)) { return projectDirectory.getPath(); } - return new File( projectDirectory, goalsDirectory ).getPath(); + return new File(projectDirectory, goalsDirectory).getPath(); } } diff --git a/maven-scm-plugin/src/main/java/org/apache/maven/scm/plugin/BranchMojo.java b/maven-scm-plugin/src/main/java/org/apache/maven/scm/plugin/BranchMojo.java index e3c0957e4..c3efdd152 100644 --- a/maven-scm-plugin/src/main/java/org/apache/maven/scm/plugin/BranchMojo.java +++ b/maven-scm-plugin/src/main/java/org/apache/maven/scm/plugin/BranchMojo.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.plugin; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,9 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.plugin; + +import java.io.IOException; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugins.annotations.Mojo; @@ -28,37 +29,33 @@ import org.apache.maven.scm.provider.ScmProvider; import org.apache.maven.scm.repository.ScmRepository; -import java.io.IOException; - /** * Branch the project. * * @author Emmanuel Venisse */ -@Mojo( name = "branch", aggregator = true ) -public class BranchMojo - extends AbstractScmMojo -{ +@Mojo(name = "branch", aggregator = true) +public class BranchMojo extends AbstractScmMojo { /** * The branch name. */ - @Parameter( property = "branch", required = true ) + @Parameter(property = "branch", required = true) private String branch; /** * The message applied to the tag creation. */ - @Parameter( property = "message" ) + @Parameter(property = "message") private String message; - + /** - * currently only implemented with svn scm. Enable a workaround to prevent issue + * currently only implemented with svn scm. Enable a workaround to prevent issue * due to svn client > 1.5.0 (https://issues.apache.org/jira/browse/SCM-406) * * @since 1.3 - */ - @Parameter( property = "remoteBranching", defaultValue = "true" ) - private boolean remoteBranching; + */ + @Parameter(property = "remoteBranching", defaultValue = "true") + private boolean remoteBranching; /** * Currently only implemented with Subversion. Enable the "--pin-externals" @@ -68,34 +65,29 @@ public class BranchMojo * * @see https://subversion.apache.org/docs/release-notes/1.9.html */ - @Parameter( property = "pinExternals", defaultValue = "false" ) + @Parameter(property = "pinExternals", defaultValue = "false") private boolean pinExternals; /** {@inheritDoc} */ - public void execute() - throws MojoExecutionException - { + public void execute() throws MojoExecutionException { super.execute(); - try - { + try { ScmRepository repository = getScmRepository(); - ScmProvider provider = getScmManager().getProviderByRepository( repository ); + ScmProvider provider = getScmManager().getProviderByRepository(repository); - String finalBranch = provider.sanitizeTagName( branch ); - getLog().info( "Final Branch Name: '" + finalBranch + "'" ); + String finalBranch = provider.sanitizeTagName(branch); + getLog().info("Final Branch Name: '" + finalBranch + "'"); - ScmBranchParameters scmBranchParameters = new ScmBranchParameters( message ); - scmBranchParameters.setRemoteBranching( remoteBranching ); - scmBranchParameters.setPinExternals( pinExternals ); - - BranchScmResult result = provider.branch( repository, getFileSet(), finalBranch, scmBranchParameters ); + ScmBranchParameters scmBranchParameters = new ScmBranchParameters(message); + scmBranchParameters.setRemoteBranching(remoteBranching); + scmBranchParameters.setPinExternals(pinExternals); - checkResult( result ); - } - catch ( IOException | ScmException e ) - { - throw new MojoExecutionException( "Cannot run branch command", e ); + BranchScmResult result = provider.branch(repository, getFileSet(), finalBranch, scmBranchParameters); + + checkResult(result); + } catch (IOException | ScmException e) { + throw new MojoExecutionException("Cannot run branch command", e); } } } diff --git a/maven-scm-plugin/src/main/java/org/apache/maven/scm/plugin/ChangeLogMojo.java b/maven-scm-plugin/src/main/java/org/apache/maven/scm/plugin/ChangeLogMojo.java index 1123023b8..412fca4d7 100644 --- a/maven-scm-plugin/src/main/java/org/apache/maven/scm/plugin/ChangeLogMojo.java +++ b/maven-scm-plugin/src/main/java/org/apache/maven/scm/plugin/ChangeLogMojo.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.plugin; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,12 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.plugin; + +import java.io.IOException; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.Date; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugins.annotations.Mojo; @@ -33,183 +37,162 @@ import org.apache.maven.scm.repository.ScmRepository; import org.codehaus.plexus.util.StringUtils; -import java.io.IOException; -import java.text.ParseException; -import java.text.SimpleDateFormat; -import java.util.Date; - /** * Dump changelog contents to console. It is mainly used to test maven-scm-api's changelog command. * * @author Dan Tran * @author Olivier Lamy */ -@Mojo( name = "changelog", aggregator = true ) -public class ChangeLogMojo - extends AbstractScmMojo -{ +@Mojo(name = "changelog", aggregator = true) +public class ChangeLogMojo extends AbstractScmMojo { private static final String DEFAULT_DATE_FORMAT = "yyyy-MM-dd"; /** * Start Date. */ - @Parameter( property = "startDate" ) + @Parameter(property = "startDate") private String startDate; /** * End Date. */ - @Parameter( property = "endDate" ) + @Parameter(property = "endDate") private String endDate; /** * Start Scm Version. */ - @Parameter( property = "startScmVersion" ) + @Parameter(property = "startScmVersion") private String startScmVersion; /** * End Scm Version. */ - @Parameter( property = "endScmVersion" ) + @Parameter(property = "endScmVersion") private String endScmVersion; /** * Start Scm Version Type. */ - @Parameter( property = "startScmVersionType" ) + @Parameter(property = "startScmVersionType") private String startScmVersionType; /** * End Scm Version Type. */ - @Parameter( property = "endScmVersionType" ) + @Parameter(property = "endScmVersionType") private String endScmVersionType; /** * Date Format in changelog output of scm tool. */ - @Parameter( property = "dateFormat" ) + @Parameter(property = "dateFormat") private String dateFormat; /** * Date format to use for the specified startDate and/or endDate. */ - @Parameter( property = "userDateFormat", defaultValue = "yyyy-MM-dd" ) + @Parameter(property = "userDateFormat", defaultValue = "yyyy-MM-dd") private String userDateFormat = DEFAULT_DATE_FORMAT; /** * The version type (branch/tag) of scmVersion. */ - @Parameter( property = "scmVersionType" ) + @Parameter(property = "scmVersionType") private String scmVersionType; /** * The version (revision number/branch name/tag name). */ - @Parameter( property = "scmVersion" ) + @Parameter(property = "scmVersion") private String scmVersion; /** * The branch name (TODO find out what this is for). */ - @Parameter( property = "scmBranch" ) + @Parameter(property = "scmBranch") private String scmBranch; /** * The number of change log items to return. */ - @Parameter( property = "limit" ) + @Parameter(property = "limit") private Integer limit; /** * The number of days to look back for change log items to return. */ - @Parameter( property = "numDays" ) + @Parameter(property = "numDays") private Integer numDays; /** * {@inheritDoc} */ - public void execute() - throws MojoExecutionException - { + public void execute() throws MojoExecutionException { super.execute(); - SimpleDateFormat localFormat = new SimpleDateFormat( userDateFormat ); + SimpleDateFormat localFormat = new SimpleDateFormat(userDateFormat); - try - { + try { ScmRepository repository = getScmRepository(); - ScmProvider provider = getScmManager().getProviderByRepository( repository ); + ScmProvider provider = getScmManager().getProviderByRepository(repository); - ChangeLogScmRequest request = new ChangeLogScmRequest( repository, getFileSet() ); + ChangeLogScmRequest request = new ChangeLogScmRequest(repository, getFileSet()); - request.setDatePattern( dateFormat ); + request.setDatePattern(dateFormat); - if ( StringUtils.isNotEmpty( startDate ) ) - { - request.setStartDate( parseDate( localFormat, startDate ) ); + if (StringUtils.isNotEmpty(startDate)) { + request.setStartDate(parseDate(localFormat, startDate)); } - if ( StringUtils.isNotEmpty( endDate ) ) - { - request.setEndDate( parseDate( localFormat, endDate ) ); + if (StringUtils.isNotEmpty(endDate)) { + request.setEndDate(parseDate(localFormat, endDate)); } - if ( StringUtils.isNotEmpty( startScmVersion ) ) - { - ScmVersion startRev = - getScmVersion( StringUtils.isEmpty( startScmVersionType ) ? VERSION_TYPE_REVISION - : startScmVersionType, startScmVersion ); - request.setStartRevision( startRev ); + if (StringUtils.isNotEmpty(startScmVersion)) { + ScmVersion startRev = getScmVersion( + StringUtils.isEmpty(startScmVersionType) ? VERSION_TYPE_REVISION : startScmVersionType, + startScmVersion); + request.setStartRevision(startRev); } - if ( StringUtils.isNotEmpty( endScmVersion ) ) - { - ScmVersion endRev = - getScmVersion( StringUtils.isEmpty( endScmVersionType ) ? VERSION_TYPE_REVISION - : endScmVersionType, endScmVersion ); - request.setEndRevision( endRev ); + if (StringUtils.isNotEmpty(endScmVersion)) { + ScmVersion endRev = getScmVersion( + StringUtils.isEmpty(endScmVersionType) ? VERSION_TYPE_REVISION : endScmVersionType, + endScmVersion); + request.setEndRevision(endRev); } - request.setLimit( limit ); + request.setLimit(limit); - if ( numDays != null ) - { - request.setNumDays( numDays ); + if (numDays != null) { + request.setNumDays(numDays); } - if ( StringUtils.isNotEmpty( scmVersion ) ) - { - ScmVersion rev = - getScmVersion( StringUtils.isEmpty( scmVersionType ) ? VERSION_TYPE_REVISION - : scmVersionType, scmVersion ); - request.setRevision( rev ); + if (StringUtils.isNotEmpty(scmVersion)) { + ScmVersion rev = getScmVersion( + StringUtils.isEmpty(scmVersionType) ? VERSION_TYPE_REVISION : scmVersionType, scmVersion); + request.setRevision(rev); } - if ( StringUtils.isNotEmpty( scmBranch ) ) - { - request.setScmBranch( new ScmBranch( scmBranch ) ); + if (StringUtils.isNotEmpty(scmBranch)) { + request.setScmBranch(new ScmBranch(scmBranch)); } - ChangeLogScmResult result = provider.changeLog( request ); + ChangeLogScmResult result = provider.changeLog(request); - checkResult( result ); + checkResult(result); ChangeLogSet changeLogSet = result.getChangeLog(); - for ( ChangeSet changeSet : changeLogSet.getChangeSets() ) - { - getLog().info( changeSet.toString() ); + for (ChangeSet changeSet : changeLogSet.getChangeSets()) { + getLog().info(changeSet.toString()); } - } - catch ( IOException | ScmException e ) - { - throw new MojoExecutionException( "Cannot run changelog command : ", e ); + } catch (IOException | ScmException e) { + throw new MojoExecutionException("Cannot run changelog command : ", e); } } @@ -218,22 +201,18 @@ public void execute() * * @return A date */ - private Date parseDate( SimpleDateFormat format, String date ) - throws MojoExecutionException - { - if ( date == null || date.trim().length() == 0 ) - { + private Date parseDate(SimpleDateFormat format, String date) throws MojoExecutionException { + if (date == null || date.trim().length() == 0) { return null; } - try - { - return format.parse( date.toString() ); - } - catch ( ParseException e ) - { - throw new MojoExecutionException( "Please use this date pattern: " + format.toLocalizedPattern().toString(), - e ); + try { + return format.parse(date.toString()); + } catch (ParseException e) { + throw new MojoExecutionException( + "Please use this date pattern: " + + format.toLocalizedPattern().toString(), + e); } } } diff --git a/maven-scm-plugin/src/main/java/org/apache/maven/scm/plugin/CheckLocalModificationsMojo.java b/maven-scm-plugin/src/main/java/org/apache/maven/scm/plugin/CheckLocalModificationsMojo.java index c48569d0c..32500c438 100644 --- a/maven-scm-plugin/src/main/java/org/apache/maven/scm/plugin/CheckLocalModificationsMojo.java +++ b/maven-scm-plugin/src/main/java/org/apache/maven/scm/plugin/CheckLocalModificationsMojo.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.plugin; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.plugin; import java.io.IOException; @@ -34,58 +33,47 @@ * @author Olivier Lamy * @since 1.2 */ -@Mojo( name = "check-local-modification" ) -public class CheckLocalModificationsMojo - extends AbstractScmMojo -{ +@Mojo(name = "check-local-modification") +public class CheckLocalModificationsMojo extends AbstractScmMojo { /** * Custom error message */ - @Parameter( property = "scm.checkLocalModification.errorMessage", - defaultValue = "The build will stop as there is local modifications" ) + @Parameter( + property = "scm.checkLocalModification.errorMessage", + defaultValue = "The build will stop as there is local modifications") private String errorMessage; /** * Skip the check for local modifications if set to {@code true}. */ - @Parameter( property = "scm.checkLocalModification.skip", defaultValue = "false" ) + @Parameter(property = "scm.checkLocalModification.skip", defaultValue = "false") private boolean skip; - public void execute() - throws MojoExecutionException - { - if ( skip ) - { - getLog().info( "check-local-modification execution has been skipped" ); + public void execute() throws MojoExecutionException { + if (skip) { + getLog().info("check-local-modification execution has been skipped"); return; } super.execute(); StatusScmResult result = null; - try - { + try { ScmRepository repository = getScmRepository(); - result = getScmManager().status( repository, getFileSet() ); - } - catch ( IOException | ScmException e ) - { - throw new MojoExecutionException( e.getMessage(), e ); + result = getScmManager().status(repository, getFileSet()); + } catch (IOException | ScmException e) { + throw new MojoExecutionException(e.getMessage(), e); } - if ( !result.isSuccess() ) - { - throw new MojoExecutionException( "Unable to check for local modifications : " - + result.getProviderMessage() ); + if (!result.isSuccess()) { + throw new MojoExecutionException( + "Unable to check for local modifications : " + result.getProviderMessage()); } - if ( !result.getChangedFiles().isEmpty() ) - { - getLog().error( errorMessage ); - throw new MojoExecutionException( errorMessage ); + if (!result.getChangedFiles().isEmpty()) { + getLog().error(errorMessage); + throw new MojoExecutionException(errorMessage); } - } - } diff --git a/maven-scm-plugin/src/main/java/org/apache/maven/scm/plugin/CheckinMojo.java b/maven-scm-plugin/src/main/java/org/apache/maven/scm/plugin/CheckinMojo.java index 3eec84ca1..508303d16 100644 --- a/maven-scm-plugin/src/main/java/org/apache/maven/scm/plugin/CheckinMojo.java +++ b/maven-scm-plugin/src/main/java/org/apache/maven/scm/plugin/CheckinMojo.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.plugin; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,9 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.plugin; + +import java.io.IOException; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugins.annotations.Mojo; @@ -26,61 +27,52 @@ import org.apache.maven.scm.command.checkin.CheckInScmResult; import org.apache.maven.scm.repository.ScmRepository; -import java.io.IOException; - /** * Commit changes to the configured scm url. * * @author Emmanuel Venisse */ -@Mojo( name = "checkin", aggregator = true ) -public class CheckinMojo - extends AbstractScmMojo -{ +@Mojo(name = "checkin", aggregator = true) +public class CheckinMojo extends AbstractScmMojo { /** * Commit log. */ - @Parameter( property = "message" ) + @Parameter(property = "message") private String message; /** * The configured scm url to use. */ - @Parameter( property = "connectionType", defaultValue = "developerConnection" ) + @Parameter(property = "connectionType", defaultValue = "developerConnection") private String connectionType; /** * The version type (branch/tag/revision) of scmVersion. */ - @Parameter( property = "scmVersionType" ) + @Parameter(property = "scmVersionType") private String scmVersionType; /** * The version (revision number/branch name/tag name). */ - @Parameter( property = "scmVersion" ) + @Parameter(property = "scmVersion") private String scmVersion; /** {@inheritDoc} */ - public void execute() - throws MojoExecutionException - { + public void execute() throws MojoExecutionException { super.execute(); - setConnectionType( connectionType ); + setConnectionType(connectionType); - try - { + try { ScmRepository repository = getScmRepository(); - CheckInScmResult result = getScmManager().checkIn( repository, getFileSet(), - getScmVersion( scmVersionType, scmVersion ), message ); + CheckInScmResult result = getScmManager() + .checkIn(repository, getFileSet(), getScmVersion(scmVersionType, scmVersion), message); - checkResult( result ); - } - catch ( IOException | ScmException e ) - { - throw new MojoExecutionException( "Cannot run checkin command : ", e ); + checkResult(result); + } catch (IOException | ScmException e) { + throw new MojoExecutionException("Cannot run checkin command : ", e); } } } diff --git a/maven-scm-plugin/src/main/java/org/apache/maven/scm/plugin/CheckoutMojo.java b/maven-scm-plugin/src/main/java/org/apache/maven/scm/plugin/CheckoutMojo.java index 4fd5cd69f..a736326e1 100644 --- a/maven-scm-plugin/src/main/java/org/apache/maven/scm/plugin/CheckoutMojo.java +++ b/maven-scm-plugin/src/main/java/org/apache/maven/scm/plugin/CheckoutMojo.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.plugin; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.plugin; import java.io.File; import java.io.IOException; @@ -36,38 +35,36 @@ * * @author Emmanuel Venisse */ -@Mojo( name = "checkout", requiresProject = false ) -public class CheckoutMojo - extends AbstractScmMojo -{ +@Mojo(name = "checkout", requiresProject = false) +public class CheckoutMojo extends AbstractScmMojo { /** * Use Export instead of checkout */ - @Parameter( property = "useExport", defaultValue = "false" ) + @Parameter(property = "useExport", defaultValue = "false") private boolean useExport; /** * The directory to checkout the sources to for the bootstrap and checkout goals. */ - @Parameter( property = "checkoutDirectory", defaultValue = "${project.build.directory}/checkout" ) + @Parameter(property = "checkoutDirectory", defaultValue = "${project.build.directory}/checkout") private File checkoutDirectory; /** * Skip checkout if checkoutDirectory exists. */ - @Parameter( property = "skipCheckoutIfExists", defaultValue = "false" ) + @Parameter(property = "skipCheckoutIfExists", defaultValue = "false") private boolean skipCheckoutIfExists = false; /** * The version type (branch/tag/revision) of scmVersion. */ - @Parameter( property = "scmVersionType" ) + @Parameter(property = "scmVersionType") private String scmVersionType; /** * The version (revision number/branch name/tag name). */ - @Parameter( property = "scmVersion" ) + @Parameter(property = "scmVersion") private String scmVersion; /** @@ -76,91 +73,68 @@ public class CheckoutMojo private ScmResult checkoutResult; /** {@inheritDoc} */ - public void execute() - throws MojoExecutionException - { + public void execute() throws MojoExecutionException { super.execute(); - //skip checkout if checkout directory is already created. See SCM-201 + // skip checkout if checkout directory is already created. See SCM-201 checkoutResult = null; - if ( !getCheckoutDirectory().isDirectory() || !this.skipCheckoutIfExists ) - { + if (!getCheckoutDirectory().isDirectory() || !this.skipCheckoutIfExists) { checkoutResult = checkout(); } } - protected File getCheckoutDirectory() - { - if ( this.checkoutDirectory.getPath().contains( "${project.basedir}" ) ) - { - //project.basedir is not set under maven 3.x when run without a project - this.checkoutDirectory = new File( this.getBasedir(), "target/checkout" ); + protected File getCheckoutDirectory() { + if (this.checkoutDirectory.getPath().contains("${project.basedir}")) { + // project.basedir is not set under maven 3.x when run without a project + this.checkoutDirectory = new File(this.getBasedir(), "target/checkout"); } return this.checkoutDirectory; } - public void setCheckoutDirectory( File checkoutDirectory ) - { + public void setCheckoutDirectory(File checkoutDirectory) { this.checkoutDirectory = checkoutDirectory; } - protected ScmResult checkout() - throws MojoExecutionException - { - try - { + protected ScmResult checkout() throws MojoExecutionException { + try { ScmRepository repository = getScmRepository(); - this.prepareOutputDirectory( getCheckoutDirectory() ); + this.prepareOutputDirectory(getCheckoutDirectory()); ScmResult result = null; - ScmFileSet fileSet = new ScmFileSet( getCheckoutDirectory().getAbsoluteFile() ); - if ( useExport ) - { - result = getScmManager().export( repository, fileSet, getScmVersion( scmVersionType, scmVersion ) ); - } - else - { - result = getScmManager().checkOut( repository, fileSet, getScmVersion( scmVersionType, scmVersion ) ); + ScmFileSet fileSet = new ScmFileSet(getCheckoutDirectory().getAbsoluteFile()); + if (useExport) { + result = getScmManager().export(repository, fileSet, getScmVersion(scmVersionType, scmVersion)); + } else { + result = getScmManager().checkOut(repository, fileSet, getScmVersion(scmVersionType, scmVersion)); } - checkResult( result ); + checkResult(result); - handleExcludesIncludesAfterCheckoutAndExport( this.checkoutDirectory ); + handleExcludesIncludesAfterCheckoutAndExport(this.checkoutDirectory); return result; - } - catch ( ScmException e ) - { - throw new MojoExecutionException( "Cannot run checkout command : ", e ); + } catch (ScmException e) { + throw new MojoExecutionException("Cannot run checkout command : ", e); } } - private void prepareOutputDirectory( File ouputDirectory ) - throws MojoExecutionException - { - try - { - this.getLog().info( "Removing " + ouputDirectory ); + private void prepareOutputDirectory(File ouputDirectory) throws MojoExecutionException { + try { + this.getLog().info("Removing " + ouputDirectory); - FileUtils.deleteDirectory( getCheckoutDirectory() ); - } - catch ( IOException e ) - { - throw new MojoExecutionException( "Cannot remove " + ouputDirectory ); + FileUtils.deleteDirectory(getCheckoutDirectory()); + } catch (IOException e) { + throw new MojoExecutionException("Cannot remove " + ouputDirectory); } - if ( !getCheckoutDirectory().mkdirs() ) - { - throw new MojoExecutionException( "Cannot create " + ouputDirectory ); + if (!getCheckoutDirectory().mkdirs()) { + throw new MojoExecutionException("Cannot create " + ouputDirectory); } } - protected ScmResult getCheckoutResult() - { + protected ScmResult getCheckoutResult() { return checkoutResult; } - - } diff --git a/maven-scm-plugin/src/main/java/org/apache/maven/scm/plugin/DiffMojo.java b/maven-scm-plugin/src/main/java/org/apache/maven/scm/plugin/DiffMojo.java index 3ff53e784..b8eeea54d 100644 --- a/maven-scm-plugin/src/main/java/org/apache/maven/scm/plugin/DiffMojo.java +++ b/maven-scm-plugin/src/main/java/org/apache/maven/scm/plugin/DiffMojo.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.plugin; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,10 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.plugin; + +import java.io.File; +import java.io.IOException; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugins.annotations.Mojo; @@ -27,81 +29,70 @@ import org.apache.maven.scm.repository.ScmRepository; import org.codehaus.plexus.util.FileUtils; -import java.io.File; -import java.io.IOException; - /** * Display the difference of the working copy with the latest copy in the configured scm url. * * @author Emmanuel Venisse */ -@Mojo( name = "diff", aggregator = true ) -public class DiffMojo - extends AbstractScmMojo -{ +@Mojo(name = "diff", aggregator = true) +public class DiffMojo extends AbstractScmMojo { /** * The version type (branch/tag/revision) of scmVersion. */ - @Parameter( property = "startScmVersionType" ) + @Parameter(property = "startScmVersionType") private String startScmVersionType; /** * The version (revision number/branch name/tag name). */ - @Parameter( property = "startScmVersion" ) + @Parameter(property = "startScmVersion") private String startScmVersion; /** * The version type (branch/tag/revision) of scmVersion. */ - @Parameter( property = "endScmVersionType" ) + @Parameter(property = "endScmVersionType") private String endScmVersionType; /** * The version (revision number/branch name/tag name). */ - @Parameter( property = "endScmVersion" ) + @Parameter(property = "endScmVersion") private String endScmVersion; /** * Output file name. */ - @Parameter( property = "outputFile", defaultValue = "${project.artifactId}.diff" ) + @Parameter(property = "outputFile", defaultValue = "${project.artifactId}.diff") private File outputFile; /** {@inheritDoc} */ - public void execute() - throws MojoExecutionException - { + public void execute() throws MojoExecutionException { super.execute(); - try - { + try { ScmRepository repository = getScmRepository(); - DiffScmResult result = getScmManager().diff( repository, getFileSet(), - getScmVersion( startScmVersionType, startScmVersion ), - getScmVersion( endScmVersionType, endScmVersion ) ); + DiffScmResult result = getScmManager() + .diff( + repository, + getFileSet(), + getScmVersion(startScmVersionType, startScmVersion), + getScmVersion(endScmVersionType, endScmVersion)); - checkResult( result ); + checkResult(result); - getLog().info( result.getPatch() ); + getLog().info(result.getPatch()); - try - { - if ( outputFile != null ) - { - FileUtils.fileWrite( outputFile.getAbsolutePath(), result.getPatch() ); + try { + if (outputFile != null) { + FileUtils.fileWrite(outputFile.getAbsolutePath(), result.getPatch()); } + } catch (IOException e) { + throw new MojoExecutionException("Can't write patch file.", e); } - catch ( IOException e ) - { - throw new MojoExecutionException( "Can't write patch file.", e ); - } - } - catch ( IOException | ScmException e ) - { - throw new MojoExecutionException( "Cannot run diff command : ", e ); + } catch (IOException | ScmException e) { + throw new MojoExecutionException("Cannot run diff command : ", e); } } } diff --git a/maven-scm-plugin/src/main/java/org/apache/maven/scm/plugin/EditMojo.java b/maven-scm-plugin/src/main/java/org/apache/maven/scm/plugin/EditMojo.java index 9ad6be42d..f6c560556 100644 --- a/maven-scm-plugin/src/main/java/org/apache/maven/scm/plugin/EditMojo.java +++ b/maven-scm-plugin/src/main/java/org/apache/maven/scm/plugin/EditMojo.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.plugin; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,9 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.plugin; + +import java.io.IOException; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugins.annotations.Mojo; @@ -25,34 +26,25 @@ import org.apache.maven.scm.command.edit.EditScmResult; import org.apache.maven.scm.repository.ScmRepository; -import java.io.IOException; - /** * Edit/lock a set of files. * * @author Dan Tran */ -@Mojo( name = "edit", aggregator = true ) -public class EditMojo - extends AbstractScmMojo -{ +@Mojo(name = "edit", aggregator = true) +public class EditMojo extends AbstractScmMojo { /** {@inheritDoc} */ - public void execute() - throws MojoExecutionException - { + public void execute() throws MojoExecutionException { super.execute(); - try - { + try { ScmRepository repository = getScmRepository(); - EditScmResult result = getScmManager().edit( repository, getFileSet() ); + EditScmResult result = getScmManager().edit(repository, getFileSet()); - checkResult( result ); - } - catch ( IOException | ScmException e ) - { - throw new MojoExecutionException( "Cannot run edit command : ", e ); + checkResult(result); + } catch (IOException | ScmException e) { + throw new MojoExecutionException("Cannot run edit command : ", e); } } } diff --git a/maven-scm-plugin/src/main/java/org/apache/maven/scm/plugin/ExportMojo.java b/maven-scm-plugin/src/main/java/org/apache/maven/scm/plugin/ExportMojo.java index 485534509..b4e446bf0 100644 --- a/maven-scm-plugin/src/main/java/org/apache/maven/scm/plugin/ExportMojo.java +++ b/maven-scm-plugin/src/main/java/org/apache/maven/scm/plugin/ExportMojo.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.plugin; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.plugin; import java.io.File; import java.io.IOException; @@ -36,101 +35,84 @@ * * @author Emmanuel Venisse */ -@Mojo( name = "export", requiresProject = false ) -public class ExportMojo - extends AbstractScmMojo -{ +@Mojo(name = "export", requiresProject = false) +public class ExportMojo extends AbstractScmMojo { /** * The version type (branch/tag/revision) of scmVersion. */ - @Parameter( property = "scmVersionType" ) + @Parameter(property = "scmVersionType") private String scmVersionType; /** * The version (revision number/branch name/tag name). */ - @Parameter( property = "scmVersion" ) + @Parameter(property = "scmVersion") private String scmVersion; /** * The directory to export the sources to. */ - @Parameter( property = "exportDirectory", defaultValue = "${project.build.directory}/export", required = true ) + @Parameter(property = "exportDirectory", defaultValue = "${project.build.directory}/export", required = true) private File exportDirectory; /** * Skip export if exportDirectory exists. */ - @Parameter( property = "skipExportIfExists", defaultValue = "false" ) + @Parameter(property = "skipExportIfExists", defaultValue = "false") private boolean skipExportIfExists = false; - /** {@inheritDoc} */ - public void execute() - throws MojoExecutionException - { + public void execute() throws MojoExecutionException { super.execute(); - if ( this.skipExportIfExists && this.exportDirectory.isDirectory() ) - { + if (this.skipExportIfExists && this.exportDirectory.isDirectory()) { return; } export(); } - protected File getExportDirectory() - { + protected File getExportDirectory() { return this.exportDirectory; } - public void setExportDirectory( File exportDirectory ) - { + public void setExportDirectory(File exportDirectory) { this.exportDirectory = exportDirectory; } - protected void export() - throws MojoExecutionException - { - if ( this.exportDirectory.getPath().contains( "${project.basedir}" ) ) - { - //project.basedir is not set under maven 3.x when run without a project - this.exportDirectory = new File( this.getBasedir(), "target/export" ); + protected void export() throws MojoExecutionException { + if (this.exportDirectory.getPath().contains("${project.basedir}")) { + // project.basedir is not set under maven 3.x when run without a project + this.exportDirectory = new File(this.getBasedir(), "target/export"); } - try - { + try { ScmRepository repository = getScmRepository(); - try - { - if ( this.exportDirectory.exists() ) - { - this.getLog().info( "Removing " + this.exportDirectory ); + try { + if (this.exportDirectory.exists()) { + this.getLog().info("Removing " + this.exportDirectory); - FileUtils.deleteDirectory( this.exportDirectory ); + FileUtils.deleteDirectory(this.exportDirectory); } - } - catch ( IOException e ) - { - throw new MojoExecutionException( "Cannot remove " + getExportDirectory() ); + } catch (IOException e) { + throw new MojoExecutionException("Cannot remove " + getExportDirectory()); } - if ( !this.exportDirectory.mkdirs() ) - { - throw new MojoExecutionException( "Cannot create " + this.exportDirectory ); + if (!this.exportDirectory.mkdirs()) { + throw new MojoExecutionException("Cannot create " + this.exportDirectory); } - ExportScmResult result = getScmManager().export( repository, - new ScmFileSet( this.exportDirectory.getAbsoluteFile() ), - getScmVersion( scmVersionType, scmVersion ) ); + ExportScmResult result = getScmManager() + .export( + repository, + new ScmFileSet(this.exportDirectory.getAbsoluteFile()), + getScmVersion(scmVersionType, scmVersion)); - checkResult( result ); + checkResult(result); - handleExcludesIncludesAfterCheckoutAndExport( this.exportDirectory ); - } - catch ( ScmException e ) - { - throw new MojoExecutionException( "Cannot run export command : ", e ); + handleExcludesIncludesAfterCheckoutAndExport(this.exportDirectory); + } catch (ScmException e) { + throw new MojoExecutionException("Cannot run export command : ", e); } } } diff --git a/maven-scm-plugin/src/main/java/org/apache/maven/scm/plugin/ListMojo.java b/maven-scm-plugin/src/main/java/org/apache/maven/scm/plugin/ListMojo.java index d933e78f3..b0c65dd37 100644 --- a/maven-scm-plugin/src/main/java/org/apache/maven/scm/plugin/ListMojo.java +++ b/maven-scm-plugin/src/main/java/org/apache/maven/scm/plugin/ListMojo.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.plugin; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.plugin; import java.io.IOException; @@ -34,55 +33,44 @@ * * @author Emmanuel Venisse */ -@Mojo( name = "list", aggregator = true ) -public class ListMojo - extends AbstractScmMojo -{ +@Mojo(name = "list", aggregator = true) +public class ListMojo extends AbstractScmMojo { /** * The version type (branch/tag/revision) of scmVersion. */ - @Parameter( property = "scmVersionType" ) + @Parameter(property = "scmVersionType") private String scmVersionType; /** * The version (revision number/branch name/tag name). */ - @Parameter( property = "scmVersion" ) + @Parameter(property = "scmVersion") private String scmVersion; /** * Use recursive mode. */ - @Parameter( property = "recursive", defaultValue = "true" ) + @Parameter(property = "recursive", defaultValue = "true") private boolean recursive = true; /** {@inheritDoc} */ - public void execute() - throws MojoExecutionException - { + public void execute() throws MojoExecutionException { super.execute(); - try - { + try { ScmRepository repository = getScmRepository(); - ListScmResult result = getScmManager().list( repository, getFileSet(), recursive, - getScmVersion( scmVersionType, scmVersion ) ); + ListScmResult result = getScmManager() + .list(repository, getFileSet(), recursive, getScmVersion(scmVersionType, scmVersion)); - checkResult( result ); + checkResult(result); - if ( result.getFiles() != null ) - { - for ( ScmFile scmFile : result.getFiles() ) - { - getLog().info( scmFile.getPath() ); + if (result.getFiles() != null) { + for (ScmFile scmFile : result.getFiles()) { + getLog().info(scmFile.getPath()); } } - } - catch ( ScmException | IOException e ) - { - throw new MojoExecutionException( "Cannot run list command : ", e ); + } catch (ScmException | IOException e) { + throw new MojoExecutionException("Cannot run list command : ", e); } } - } - diff --git a/maven-scm-plugin/src/main/java/org/apache/maven/scm/plugin/RemoveMojo.java b/maven-scm-plugin/src/main/java/org/apache/maven/scm/plugin/RemoveMojo.java index f50a566cf..ee9b89bed 100644 --- a/maven-scm-plugin/src/main/java/org/apache/maven/scm/plugin/RemoveMojo.java +++ b/maven-scm-plugin/src/main/java/org/apache/maven/scm/plugin/RemoveMojo.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.plugin; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,9 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.plugin; + +import java.io.IOException; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugins.annotations.Mojo; @@ -26,40 +27,31 @@ import org.apache.maven.scm.command.remove.RemoveScmResult; import org.apache.maven.scm.repository.ScmRepository; -import java.io.IOException; - /** * Mark a set of files for deletion. * * @author Paul Mackinlay */ -@Mojo( name = "remove", aggregator = true ) -public class RemoveMojo - extends AbstractScmMojo -{ +@Mojo(name = "remove", aggregator = true) +public class RemoveMojo extends AbstractScmMojo { /** * The commit message. */ - @Parameter( property = "message" ) + @Parameter(property = "message") private String message; /** * {@inheritDoc} */ - public void execute() - throws MojoExecutionException - { + public void execute() throws MojoExecutionException { super.execute(); - try - { + try { ScmRepository repository = getScmRepository(); - RemoveScmResult result = getScmManager().remove( repository, getFileSet(), message ); - checkResult( result ); - } - catch ( IOException | ScmException e ) - { - throw new MojoExecutionException( "Cannot run remove command : " + e.getMessage(), e ); + RemoveScmResult result = getScmManager().remove(repository, getFileSet(), message); + checkResult(result); + } catch (IOException | ScmException e) { + throw new MojoExecutionException("Cannot run remove command : " + e.getMessage(), e); } } } diff --git a/maven-scm-plugin/src/main/java/org/apache/maven/scm/plugin/StatusMojo.java b/maven-scm-plugin/src/main/java/org/apache/maven/scm/plugin/StatusMojo.java index 166b5d1d6..dfd0459f8 100644 --- a/maven-scm-plugin/src/main/java/org/apache/maven/scm/plugin/StatusMojo.java +++ b/maven-scm-plugin/src/main/java/org/apache/maven/scm/plugin/StatusMojo.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.plugin; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.plugin; import java.io.File; import java.io.IOException; @@ -36,45 +35,35 @@ * @author Emmanuel Venisse * @author Olivier Lamy */ -@Mojo( name = "status", aggregator = true ) -public class StatusMojo - extends AbstractScmMojo -{ +@Mojo(name = "status", aggregator = true) +public class StatusMojo extends AbstractScmMojo { /** {@inheritDoc} */ - public void execute() - throws MojoExecutionException - { + public void execute() throws MojoExecutionException { super.execute(); - try - { + try { ScmRepository repository = getScmRepository(); - StatusScmResult result = getScmManager().status( repository, getFileSet() ); + StatusScmResult result = getScmManager().status(repository, getFileSet()); - checkResult( result ); + checkResult(result); File baseDir = getFileSet().getBasedir(); // Determine the maximum length of the status column int maxLen = 0; - for ( ScmFile file : result.getChangedFiles() ) - { - maxLen = Math.max( maxLen, file.getStatus().toString().length() ); + for (ScmFile file : result.getChangedFiles()) { + maxLen = Math.max(maxLen, file.getStatus().toString().length()); } - for ( ScmFile file : result.getChangedFiles() ) - { + for (ScmFile file : result.getChangedFiles()) { // right align all of the statuses - getLog().info( - StringUtils.leftPad( file.getStatus().toString(), maxLen ) + " status for " - + getRelativePath( baseDir, file.getPath() ) ); + getLog().info(StringUtils.leftPad(file.getStatus().toString(), maxLen) + " status for " + + getRelativePath(baseDir, file.getPath())); } - } - catch ( IOException | ScmException e ) - { - throw new MojoExecutionException( "Cannot run status command : ", e ); + } catch (IOException | ScmException e) { + throw new MojoExecutionException("Cannot run status command : ", e); } } @@ -85,19 +74,13 @@ public void execute() * @param path * @return The relative path */ - protected String getRelativePath( File baseDir, String path ) - { - if ( path.equals( baseDir.getAbsolutePath() ) ) - { + protected String getRelativePath(File baseDir, String path) { + if (path.equals(baseDir.getAbsolutePath())) { return "."; - } - else if ( path.indexOf( baseDir.getAbsolutePath() ) == 0 ) - { + } else if (path.indexOf(baseDir.getAbsolutePath()) == 0) { // the + 1 gets rid of a leading file separator - return path.substring( baseDir.getAbsolutePath().length() + 1 ); - } - else - { + return path.substring(baseDir.getAbsolutePath().length() + 1); + } else { return path; } } diff --git a/maven-scm-plugin/src/main/java/org/apache/maven/scm/plugin/TagMojo.java b/maven-scm-plugin/src/main/java/org/apache/maven/scm/plugin/TagMojo.java index 5f64dd083..548381cf3 100644 --- a/maven-scm-plugin/src/main/java/org/apache/maven/scm/plugin/TagMojo.java +++ b/maven-scm-plugin/src/main/java/org/apache/maven/scm/plugin/TagMojo.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.plugin; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,11 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.plugin; + +import java.io.IOException; +import java.text.SimpleDateFormat; +import java.util.Date; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugins.annotations.Mojo; @@ -28,64 +31,58 @@ import org.apache.maven.scm.provider.ScmProvider; import org.apache.maven.scm.repository.ScmRepository; -import java.io.IOException; -import java.text.SimpleDateFormat; -import java.util.Date; - /** * Tag the project. * * @author Emmanuel Venisse * @author Sharmarke Aden */ -@Mojo( name = "tag", aggregator = true ) -public class TagMojo - extends AbstractScmMojo -{ +@Mojo(name = "tag", aggregator = true) +public class TagMojo extends AbstractScmMojo { /** * The tag name. */ - @Parameter( property = "tag", required = true ) + @Parameter(property = "tag", required = true) private String tag; /** * The message applied to the tag creation. */ - @Parameter( property = "message" ) + @Parameter(property = "message") private String message; /** * Set the timestamp format. */ - @Parameter( property = "timestampFormat", defaultValue = "yyyyMMddHHmmss" ) + @Parameter(property = "timestampFormat", defaultValue = "yyyyMMddHHmmss") private String timestampFormat; /** * Use timestamp tagging. */ - @Parameter( property = "addTimestamp", defaultValue = "false" ) + @Parameter(property = "addTimestamp", defaultValue = "false") private boolean addTimestamp; /** * Define the timestamp position (end or begin). */ - @Parameter( property = "timestampPosition", defaultValue = "end" ) + @Parameter(property = "timestampPosition", defaultValue = "end") private String timestampPosition; /** * Timestamp tag prefix. */ - @Parameter( property = "timestampPrefix", defaultValue = "-" ) + @Parameter(property = "timestampPrefix", defaultValue = "-") private String timestampPrefix; - + /** - * currently only implemented with svn scm. Enable a workaround to prevent issue + * currently only implemented with svn scm. Enable a workaround to prevent issue * due to svn client > 1.5.0 (https://issues.apache.org/jira/browse/SCM-406) - * + * * @since 1.2 - */ - @Parameter( property = "remoteTagging", defaultValue = "true" ) - private boolean remoteTagging; + */ + @Parameter(property = "remoteTagging", defaultValue = "true") + private boolean remoteTagging; /** * Currently only implemented with Subversion. Enable the "--pin-externals" @@ -95,7 +92,7 @@ public class TagMojo * * @see https://subversion.apache.org/docs/release-notes/1.9.html */ - @Parameter( property = "pinExternals", defaultValue = "false" ) + @Parameter(property = "pinExternals", defaultValue = "false") private boolean pinExternals; /** @@ -103,65 +100,53 @@ public class TagMojo * * @since 1.11.0 */ - @Parameter( property = "sign", defaultValue = "false" ) + @Parameter(property = "sign", defaultValue = "false") private boolean sign; /** {@inheritDoc} */ - public void execute() - throws MojoExecutionException - { + public void execute() throws MojoExecutionException { super.execute(); - try - { + try { SimpleDateFormat dateFormat = null; String tagTimestamp = ""; String finalTag = tag; - if ( addTimestamp ) - { - try - { - getLog().info( "Using timestamp pattern '" + timestampFormat + "'" ); - dateFormat = new SimpleDateFormat( timestampFormat ); - tagTimestamp = dateFormat.format( new Date() ); - getLog().info( "Using timestamp '" + tagTimestamp + "'" ); - } - catch ( IllegalArgumentException e ) - { + if (addTimestamp) { + try { + getLog().info("Using timestamp pattern '" + timestampFormat + "'"); + dateFormat = new SimpleDateFormat(timestampFormat); + tagTimestamp = dateFormat.format(new Date()); + getLog().info("Using timestamp '" + tagTimestamp + "'"); + } catch (IllegalArgumentException e) { String msg = "The timestamp format '" + timestampFormat + "' is invalid."; - getLog().error( msg, e ); - throw new MojoExecutionException( msg, e ); + getLog().error(msg, e); + throw new MojoExecutionException(msg, e); } - if ( "end".equals( timestampPosition ) ) - { + if ("end".equals(timestampPosition)) { finalTag += timestampPrefix + tagTimestamp; - } - else - { + } else { finalTag = tagTimestamp + timestampPrefix + finalTag; } } ScmRepository repository = getScmRepository(); - ScmProvider provider = getScmManager().getProviderByRepository( repository ); + ScmProvider provider = getScmManager().getProviderByRepository(repository); - finalTag = provider.sanitizeTagName( finalTag ); - getLog().info( "Final Tag Name: '" + finalTag + "'" ); + finalTag = provider.sanitizeTagName(finalTag); + getLog().info("Final Tag Name: '" + finalTag + "'"); - ScmTagParameters scmTagParameters = new ScmTagParameters( message ); - scmTagParameters.setRemoteTagging( remoteTagging ); - scmTagParameters.setPinExternals( pinExternals ); - scmTagParameters.setSign( sign ); + ScmTagParameters scmTagParameters = new ScmTagParameters(message); + scmTagParameters.setRemoteTagging(remoteTagging); + scmTagParameters.setPinExternals(pinExternals); + scmTagParameters.setSign(sign); - TagScmResult result = provider.tag( repository, getFileSet(), finalTag, scmTagParameters ); + TagScmResult result = provider.tag(repository, getFileSet(), finalTag, scmTagParameters); - checkResult( result ); - } - catch ( IOException | ScmException e ) - { - throw new MojoExecutionException( "Cannot run tag command : ", e ); + checkResult(result); + } catch (IOException | ScmException e) { + throw new MojoExecutionException("Cannot run tag command : ", e); } } } diff --git a/maven-scm-plugin/src/main/java/org/apache/maven/scm/plugin/UnEditMojo.java b/maven-scm-plugin/src/main/java/org/apache/maven/scm/plugin/UnEditMojo.java index a98be2a76..4a7614397 100644 --- a/maven-scm-plugin/src/main/java/org/apache/maven/scm/plugin/UnEditMojo.java +++ b/maven-scm-plugin/src/main/java/org/apache/maven/scm/plugin/UnEditMojo.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.plugin; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,9 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.plugin; + +import java.io.IOException; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugins.annotations.Mojo; @@ -25,34 +26,25 @@ import org.apache.maven.scm.command.unedit.UnEditScmResult; import org.apache.maven.scm.repository.ScmRepository; -import java.io.IOException; - /** * Unedit/unlock a set of files. * * @author Dan Tran */ -@Mojo( name = "unedit", aggregator = true ) -public class UnEditMojo - extends AbstractScmMojo -{ +@Mojo(name = "unedit", aggregator = true) +public class UnEditMojo extends AbstractScmMojo { /** {@inheritDoc} */ - public void execute() - throws MojoExecutionException - { + public void execute() throws MojoExecutionException { super.execute(); - try - { + try { ScmRepository repository = getScmRepository(); - UnEditScmResult result = getScmManager().unedit( repository, getFileSet() ); + UnEditScmResult result = getScmManager().unedit(repository, getFileSet()); - checkResult( result ); - } - catch ( IOException | ScmException e ) - { - throw new MojoExecutionException( "Cannot run unedit command : ", e ); + checkResult(result); + } catch (IOException | ScmException e) { + throw new MojoExecutionException("Cannot run unedit command : ", e); } } } diff --git a/maven-scm-plugin/src/main/java/org/apache/maven/scm/plugin/UntagMojo.java b/maven-scm-plugin/src/main/java/org/apache/maven/scm/plugin/UntagMojo.java index f8371e62e..a712dac6a 100644 --- a/maven-scm-plugin/src/main/java/org/apache/maven/scm/plugin/UntagMojo.java +++ b/maven-scm-plugin/src/main/java/org/apache/maven/scm/plugin/UntagMojo.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.plugin; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,8 +16,10 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.plugin; import java.io.IOException; + import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.plugins.annotations.Parameter; @@ -33,47 +33,40 @@ /** * Untag the project. */ -@Mojo( name = "untag", aggregator = true ) -public class UntagMojo - extends AbstractScmMojo -{ +@Mojo(name = "untag", aggregator = true) +public class UntagMojo extends AbstractScmMojo { /** * The tag name. */ - @Parameter( property = "tag", required = true ) + @Parameter(property = "tag", required = true) private String tag; /** * The commit message. */ - @Parameter( property = "message", required = false ) + @Parameter(property = "message", required = false) private String message; /** {@inheritDoc} */ - public void execute() - throws MojoExecutionException - { + public void execute() throws MojoExecutionException { super.execute(); - try - { + try { ScmRepository repository = getScmRepository(); - ScmProvider provider = getScmManager().getProviderByRepository( repository ); + ScmProvider provider = getScmManager().getProviderByRepository(repository); - String finalTag = provider.sanitizeTagName( tag ); - getLog().info( "Final Tag Name: '" + finalTag + "'" ); + String finalTag = provider.sanitizeTagName(tag); + getLog().info("Final Tag Name: '" + finalTag + "'"); CommandParameters parameters = new CommandParameters(); - parameters.setString( CommandParameter.TAG_NAME, finalTag ); - parameters.setString( CommandParameter.MESSAGE, message ); + parameters.setString(CommandParameter.TAG_NAME, finalTag); + parameters.setString(CommandParameter.MESSAGE, message); - UntagScmResult result = provider.untag( repository, getFileSet(), parameters ); + UntagScmResult result = provider.untag(repository, getFileSet(), parameters); - checkResult( result ); - } - catch ( IOException | ScmException e ) - { - throw new MojoExecutionException( "Cannot run untag command", e ); + checkResult(result); + } catch (IOException | ScmException e) { + throw new MojoExecutionException("Cannot run untag command", e); } } } diff --git a/maven-scm-plugin/src/main/java/org/apache/maven/scm/plugin/UpdateMojo.java b/maven-scm-plugin/src/main/java/org/apache/maven/scm/plugin/UpdateMojo.java index 520ab5aab..f15090ef0 100644 --- a/maven-scm-plugin/src/main/java/org/apache/maven/scm/plugin/UpdateMojo.java +++ b/maven-scm-plugin/src/main/java/org/apache/maven/scm/plugin/UpdateMojo.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.plugin; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,9 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.plugin; + +import java.io.IOException; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugins.annotations.Mojo; @@ -28,80 +29,69 @@ import org.apache.maven.scm.command.update.UpdateScmResultWithRevision; import org.apache.maven.scm.repository.ScmRepository; -import java.io.IOException; - /** * Update the local working copy with the latest source from the configured scm url. * * @author Emmanuel Venisse */ -@Mojo( name = "update", aggregator = true ) -public class UpdateMojo - extends AbstractScmMojo -{ +@Mojo(name = "update", aggregator = true) +public class UpdateMojo extends AbstractScmMojo { /** * The version type (branch/tag/revision) of scmVersion. */ - @Parameter( property = "scmVersionType" ) + @Parameter(property = "scmVersionType") private String scmVersionType; /** * The version (revision number/branch name/tag name). */ - @Parameter( property = "scmVersion" ) + @Parameter(property = "scmVersion") private String scmVersion; /** * The project property where to store the revision name. */ - @Parameter( property = "revisionKey", defaultValue = "scm.revision" ) + @Parameter(property = "revisionKey", defaultValue = "scm.revision") private String revisionKey; /** * The Maven project. */ - @Parameter( defaultValue = "${project}", required = true, readonly = true ) + @Parameter(defaultValue = "${project}", required = true, readonly = true) private MavenProject project; /** * Run Changelog after update. */ - @Parameter( property = "runChangelog", defaultValue = "false" ) + @Parameter(property = "runChangelog", defaultValue = "false") private boolean runChangelog = false; /** {@inheritDoc} */ - public void execute() - throws MojoExecutionException - { + public void execute() throws MojoExecutionException { super.execute(); - try - { + try { ScmRepository repository = getScmRepository(); - UpdateScmResult result = getScmManager().update( repository, getFileSet(), - getScmVersion( scmVersionType, scmVersion ), - runChangelog ); + UpdateScmResult result = getScmManager() + .update(repository, getFileSet(), getScmVersion(scmVersionType, scmVersion), runChangelog); - checkResult( result ); + checkResult(result); - if ( result instanceof UpdateScmResultWithRevision ) - { - String revision = ( (UpdateScmResultWithRevision) result ).getRevision(); + if (result instanceof UpdateScmResultWithRevision) { + String revision = ((UpdateScmResultWithRevision) result).getRevision(); - getLog().info( "Storing revision in '" + revisionKey + "' project property." ); + getLog().info("Storing revision in '" + revisionKey + "' project property."); - if ( project.getProperties() != null ) // Remove the test when we'll use plugin-test-harness 1.0-alpha-2 + if (project.getProperties() != null) // Remove the test when we'll use plugin-test-harness 1.0-alpha-2 { - project.getProperties().put( revisionKey, revision ); + project.getProperties().put(revisionKey, revision); } - getLog().info( "Project at revision " + revision ); + getLog().info("Project at revision " + revision); } - } - catch ( IOException | ScmException e ) - { - throw new MojoExecutionException( "Cannot run update command : ", e ); + } catch (IOException | ScmException e) { + throw new MojoExecutionException("Cannot run update command : ", e); } } } diff --git a/maven-scm-plugin/src/main/java/org/apache/maven/scm/plugin/UpdateSubprojectsMojo.java b/maven-scm-plugin/src/main/java/org/apache/maven/scm/plugin/UpdateSubprojectsMojo.java index 853162511..00e6b0c76 100644 --- a/maven-scm-plugin/src/main/java/org/apache/maven/scm/plugin/UpdateSubprojectsMojo.java +++ b/maven-scm-plugin/src/main/java/org/apache/maven/scm/plugin/UpdateSubprojectsMojo.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.plugin; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,9 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.plugin; + +import java.io.IOException; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugins.annotations.Mojo; @@ -28,68 +29,58 @@ import org.apache.maven.scm.command.update.UpdateScmResultWithRevision; import org.apache.maven.scm.repository.ScmRepository; -import java.io.IOException; - /** * Updates all projects in a multi project build. This is useful for users who have adopted the flat project structure * where the aggregator project is a sibling of the sub projects rather than sitting in the parent directory. */ -@Mojo( name = "update-subprojects" ) -public class UpdateSubprojectsMojo - extends AbstractScmMojo -{ +@Mojo(name = "update-subprojects") +public class UpdateSubprojectsMojo extends AbstractScmMojo { /** * The version type (branch/tag/revision) of scmVersion. */ - @Parameter( property = "scmVersionType" ) + @Parameter(property = "scmVersionType") private String scmVersionType; /** * The version (revision number/branch name/tag name). */ - @Parameter( property = "scmVersion" ) + @Parameter(property = "scmVersion") private String scmVersion; /** * The project property where to store the revision name. */ - @Parameter( property = "revisionKey", defaultValue = "scm.revision" ) + @Parameter(property = "revisionKey", defaultValue = "scm.revision") private String revisionKey; /** * The Maven project. */ - @Parameter( defaultValue = "${project}", required = true, readonly = true ) + @Parameter(defaultValue = "${project}", required = true, readonly = true) private MavenProject project; /** {@inheritDoc} */ - public void execute() - throws MojoExecutionException - { + public void execute() throws MojoExecutionException { super.execute(); - try - { + try { ScmRepository repository = getScmRepository(); UpdateScmResult result = - getScmManager().update( repository, getFileSet(), getScmVersion( scmVersionType, scmVersion ) ); + getScmManager().update(repository, getFileSet(), getScmVersion(scmVersionType, scmVersion)); - checkResult( result ); + checkResult(result); - if ( result instanceof UpdateScmResultWithRevision ) - { - getLog().info( "Storing revision in '" + revisionKey + "' project property." ); + if (result instanceof UpdateScmResultWithRevision) { + getLog().info("Storing revision in '" + revisionKey + "' project property."); - if ( project.getProperties() != null ) // Remove the test when we'll use plugin-test-harness 1.0-alpha-2 + if (project.getProperties() != null) // Remove the test when we'll use plugin-test-harness 1.0-alpha-2 { - project.getProperties().put( revisionKey, ( (UpdateScmResultWithRevision) result ).getRevision() ); + project.getProperties().put(revisionKey, ((UpdateScmResultWithRevision) result).getRevision()); } } - } - catch ( IOException | ScmException e ) - { - throw new MojoExecutionException( "Cannot run update command : ", e ); + } catch (IOException | ScmException e) { + throw new MojoExecutionException("Cannot run update command : ", e); } } } diff --git a/maven-scm-plugin/src/main/java/org/apache/maven/scm/plugin/ValidateMojo.java b/maven-scm-plugin/src/main/java/org/apache/maven/scm/plugin/ValidateMojo.java index e3f38241e..a5bfbc506 100644 --- a/maven-scm-plugin/src/main/java/org/apache/maven/scm/plugin/ValidateMojo.java +++ b/maven-scm-plugin/src/main/java/org/apache/maven/scm/plugin/ValidateMojo.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.plugin; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,10 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.plugin; + +import java.util.Iterator; +import java.util.List; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugins.annotations.Execute; @@ -27,33 +29,28 @@ import org.apache.maven.project.MavenProject; import org.apache.maven.scm.provider.svn.AbstractSvnScmProvider; -import java.util.Iterator; -import java.util.List; - /** * Validate scm connection string. * * @author Emmanuel Venisse * @author Olivier Lamy */ -@Mojo( name = "validate", requiresProject = false ) -@Execute( phase = LifecyclePhase.VALIDATE ) -public class ValidateMojo - extends AbstractScmMojo -{ +@Mojo(name = "validate", requiresProject = false) +@Execute(phase = LifecyclePhase.VALIDATE) +public class ValidateMojo extends AbstractScmMojo { /** * The scm connection url. */ - @Parameter( property = "scmConnection", defaultValue = "${project.scm.connection}" ) + @Parameter(property = "scmConnection", defaultValue = "${project.scm.connection}") private String scmConnection; - @Parameter( defaultValue = "${project}", readonly = true ) + @Parameter(defaultValue = "${project}", readonly = true) private MavenProject project; /** * The scm connection url for developers. */ - @Parameter( property = "scmDeveloperConnection", defaultValue = "${project.scm.developerConnection}" ) + @Parameter(property = "scmDeveloperConnection", defaultValue = "${project.scm.developerConnection}") private String scmDeveloperConnection; /** @@ -61,69 +58,55 @@ public class ValidateMojo * specified under the scm tag. * @see AbstractSvnScmProvider#CURRENT_WORKING_DIRECTORY */ - @Parameter( property = "scmCheckWorkingDirectoryUrl", defaultValue = "false" ) + @Parameter(property = "scmCheckWorkingDirectoryUrl", defaultValue = "false") private boolean scmCheckWorkingDirectoryUrl; /** * {@inheritDoc} */ - public void execute() - throws MojoExecutionException - { + public void execute() throws MojoExecutionException { super.execute(); - //check connectionUrl provided with cli - try - { - validateConnection( getConnectionUrl(), "connectionUrl" ); - } - catch ( NullPointerException e ) - { + // check connectionUrl provided with cli + try { + validateConnection(getConnectionUrl(), "connectionUrl"); + } catch (NullPointerException e) { // nothing to do. connectionUrl isn't defined } - //check scm connection - if ( scmConnection != null ) - { - validateConnection( scmConnection, "project.scm.connection" ); + // check scm connection + if (scmConnection != null) { + validateConnection(scmConnection, "project.scm.connection"); } // Check scm developerConnection - if ( scmDeveloperConnection != null ) - { - validateConnection( scmDeveloperConnection, "project.scm.developerConnection" ); + if (scmDeveloperConnection != null) { + validateConnection(scmDeveloperConnection, "project.scm.developerConnection"); } - } - private void validateConnection( String connectionString, String type ) - throws MojoExecutionException - { - if ( scmCheckWorkingDirectoryUrl ) - { - System.setProperty( AbstractSvnScmProvider.CURRENT_WORKING_DIRECTORY, - project.getFile().getParentFile().getAbsolutePath() ); + private void validateConnection(String connectionString, String type) throws MojoExecutionException { + if (scmCheckWorkingDirectoryUrl) { + System.setProperty( + AbstractSvnScmProvider.CURRENT_WORKING_DIRECTORY, + project.getFile().getParentFile().getAbsolutePath()); } - List messages = getScmManager().validateScmRepository( connectionString ); + List messages = getScmManager().validateScmRepository(connectionString); - if ( !messages.isEmpty() ) - { - getLog().error( "Validation of scm url connection (" + type + ") failed :" ); + if (!messages.isEmpty()) { + getLog().error("Validation of scm url connection (" + type + ") failed :"); Iterator iter = messages.iterator(); - while ( iter.hasNext() ) - { - getLog().error( iter.next().toString() ); + while (iter.hasNext()) { + getLog().error(iter.next().toString()); } - getLog().error( "The invalid scm url connection: '" + connectionString + "'." ); + getLog().error("The invalid scm url connection: '" + connectionString + "'."); - throw new MojoExecutionException( "Command failed. Bad Scm URL." ); - } - else - { - getLog().info( type + " scm connection string is valid." ); + throw new MojoExecutionException("Command failed. Bad Scm URL."); + } else { + getLog().info(type + " scm connection string is valid."); } } } diff --git a/maven-scm-plugin/src/main/java/org/apache/maven/scm/plugin/ValidateRecursively.java b/maven-scm-plugin/src/main/java/org/apache/maven/scm/plugin/ValidateRecursively.java index 82f0f730d..cd85acf4b 100644 --- a/maven-scm-plugin/src/main/java/org/apache/maven/scm/plugin/ValidateRecursively.java +++ b/maven-scm-plugin/src/main/java/org/apache/maven/scm/plugin/ValidateRecursively.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.plugin; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.plugin; import org.apache.maven.plugins.annotations.Execute; import org.apache.maven.plugins.annotations.LifecyclePhase; @@ -26,10 +25,8 @@ /** * Validate scm connection string recursively for all projects */ -@Mojo( name = "validate-recursively", requiresProject = true ) -@Execute( phase = LifecyclePhase.VALIDATE ) -public class ValidateRecursively - extends ValidateMojo -{ +@Mojo(name = "validate-recursively", requiresProject = true) +@Execute(phase = LifecyclePhase.VALIDATE) +public class ValidateRecursively extends ValidateMojo { // no op } diff --git a/maven-scm-plugin/src/test/java/org/apache/maven/scm/plugin/BootstrapMojoTest.java b/maven-scm-plugin/src/test/java/org/apache/maven/scm/plugin/BootstrapMojoTest.java index 64f04ce61..440b5d626 100644 --- a/maven-scm-plugin/src/test/java/org/apache/maven/scm/plugin/BootstrapMojoTest.java +++ b/maven-scm-plugin/src/test/java/org/apache/maven/scm/plugin/BootstrapMojoTest.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.plugin; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,21 +16,20 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.plugin; + +import java.io.File; import org.apache.maven.plugin.testing.AbstractMojoTestCase; import org.codehaus.plexus.util.FileUtils; -import java.io.File; - /** * Unit Test for BootstrapMojo * * @author Arne Degenring * */ -public class BootstrapMojoTest - extends AbstractMojoTestCase -{ +public class BootstrapMojoTest extends AbstractMojoTestCase { File checkoutDir; File projectDir; @@ -41,53 +38,48 @@ public class BootstrapMojoTest BootstrapMojo bootstrapMojo; - protected void setUp() - throws Exception - { + protected void setUp() throws Exception { super.setUp(); - checkoutDir = getTestFile( "target/checkout" ); - FileUtils.forceDelete( checkoutDir ); + checkoutDir = getTestFile("target/checkout"); + FileUtils.forceDelete(checkoutDir); checkoutDir.mkdirs(); - projectDir = getTestFile( "target/checkout/my/project" ); + projectDir = getTestFile("target/checkout/my/project"); projectDir.mkdirs(); - goalDir = getTestFile( "target/checkout/my/project/modules/1" ); + goalDir = getTestFile("target/checkout/my/project/modules/1"); goalDir.mkdirs(); bootstrapMojo = new BootstrapMojo(); } - public void testDetermineWorkingDirectoryPath() - throws Exception - { + public void testDetermineWorkingDirectoryPath() throws Exception { // only checkout dir - assertEquals( checkoutDir.getPath(), bootstrapMojo.determineWorkingDirectoryPath( checkoutDir, "", "" ) ); - assertEquals( checkoutDir.getPath(), bootstrapMojo.determineWorkingDirectoryPath( checkoutDir, null, null ) ); + assertEquals(checkoutDir.getPath(), bootstrapMojo.determineWorkingDirectoryPath(checkoutDir, "", "")); + assertEquals(checkoutDir.getPath(), bootstrapMojo.determineWorkingDirectoryPath(checkoutDir, null, null)); // checkout dir and goal dir - assertEquals( projectDir.getPath(), - bootstrapMojo.determineWorkingDirectoryPath( checkoutDir, "", "my/project" ) ); + assertEquals(projectDir.getPath(), bootstrapMojo.determineWorkingDirectoryPath(checkoutDir, "", "my/project")); // checkout dir and relative path project dir - assertEquals( projectDir.getPath(), - bootstrapMojo.determineWorkingDirectoryPath( checkoutDir, "my/project", null ) ); - assertEquals( projectDir.getPath(), - bootstrapMojo.determineWorkingDirectoryPath( checkoutDir, "my/project/", null ) ); - assertEquals( projectDir.getPath(), bootstrapMojo.determineWorkingDirectoryPath( checkoutDir, "my" + File - .separator + "project", null ) ); + assertEquals( + projectDir.getPath(), bootstrapMojo.determineWorkingDirectoryPath(checkoutDir, "my/project", null)); + assertEquals( + projectDir.getPath(), bootstrapMojo.determineWorkingDirectoryPath(checkoutDir, "my/project/", null)); + assertEquals( + projectDir.getPath(), + bootstrapMojo.determineWorkingDirectoryPath(checkoutDir, "my" + File.separator + "project", null)); // checkout dir, relative path project dir and goal dir have been set - assertEquals( goalDir.getPath(), - bootstrapMojo.determineWorkingDirectoryPath( checkoutDir, "my/project", "modules/1" ) ); - assertEquals( goalDir.getPath(), - bootstrapMojo.determineWorkingDirectoryPath( checkoutDir, "my/project/", "modules/1/" ) ); - assertEquals( goalDir.getPath(), bootstrapMojo.determineWorkingDirectoryPath( checkoutDir, - "my" + File.separator + "project", - "modules" + File.separator + - "1" ) ); + assertEquals( + goalDir.getPath(), bootstrapMojo.determineWorkingDirectoryPath(checkoutDir, "my/project", "modules/1")); + assertEquals( + goalDir.getPath(), + bootstrapMojo.determineWorkingDirectoryPath(checkoutDir, "my/project/", "modules/1/")); + assertEquals( + goalDir.getPath(), + bootstrapMojo.determineWorkingDirectoryPath( + checkoutDir, "my" + File.separator + "project", "modules" + File.separator + "1")); } - - } diff --git a/maven-scm-plugin/src/test/java/org/apache/maven/scm/plugin/BranchMojoTest.java b/maven-scm-plugin/src/test/java/org/apache/maven/scm/plugin/BranchMojoTest.java index d8be9105a..654f1a404 100644 --- a/maven-scm-plugin/src/test/java/org/apache/maven/scm/plugin/BranchMojoTest.java +++ b/maven-scm-plugin/src/test/java/org/apache/maven/scm/plugin/BranchMojoTest.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.plugin; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,9 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.plugin; + +import java.io.File; import org.apache.maven.plugin.testing.AbstractMojoTestCase; import org.apache.maven.scm.ScmTestCase; @@ -25,98 +26,85 @@ import org.codehaus.plexus.util.FileUtils; import org.codehaus.plexus.util.StringUtils; -import java.io.File; - /** * @author Emmanuel Venisse * */ -public class BranchMojoTest - extends AbstractMojoTestCase -{ +public class BranchMojoTest extends AbstractMojoTestCase { File checkoutDir; File repository; - protected void setUp() - throws Exception - { + protected void setUp() throws Exception { super.setUp(); - checkoutDir = getTestFile( "target/checkout" ); + checkoutDir = getTestFile("target/checkout"); - FileUtils.forceDelete( checkoutDir ); + FileUtils.forceDelete(checkoutDir); - repository = getTestFile( "target/repository" ); + repository = getTestFile("target/repository"); - FileUtils.forceDelete( repository ); + FileUtils.forceDelete(repository); - if ( !ScmTestCase.isSystemCmd( SvnScmTestUtils.SVNADMIN_COMMAND_LINE ) ) - { - ScmTestCase.printSystemCmdUnavail( SvnScmTestUtils.SVNADMIN_COMMAND_LINE, "setUp" ); + if (!ScmTestCase.isSystemCmd(SvnScmTestUtils.SVNADMIN_COMMAND_LINE)) { + ScmTestCase.printSystemCmdUnavail(SvnScmTestUtils.SVNADMIN_COMMAND_LINE, "setUp"); return; } - SvnScmTestUtils.initializeRepository( repository ); + SvnScmTestUtils.initializeRepository(repository); - if ( !ScmTestCase.isSystemCmd( SvnScmTestUtils.SVN_COMMAND_LINE ) ) - { - ScmTestCase.printSystemCmdUnavail( SvnScmTestUtils.SVN_COMMAND_LINE, "setUp" ); + if (!ScmTestCase.isSystemCmd(SvnScmTestUtils.SVN_COMMAND_LINE)) { + ScmTestCase.printSystemCmdUnavail(SvnScmTestUtils.SVN_COMMAND_LINE, "setUp"); return; } - CheckoutMojo checkoutMojo = (CheckoutMojo) lookupMojo( "checkout", getTestFile( - "src/test/resources/mojos/checkout/checkoutWithConnectionUrl.xml" ) ); - checkoutMojo.setWorkingDirectory( new File( getBasedir() ) ); + CheckoutMojo checkoutMojo = (CheckoutMojo) + lookupMojo("checkout", getTestFile("src/test/resources/mojos/checkout/checkoutWithConnectionUrl.xml")); + checkoutMojo.setWorkingDirectory(new File(getBasedir())); String connectionUrl = checkoutMojo.getConnectionUrl(); - connectionUrl = StringUtils.replace( connectionUrl, "${basedir}", getBasedir() ); - connectionUrl = StringUtils.replace( connectionUrl, "\\", "/" ); - checkoutMojo.setConnectionUrl( connectionUrl ); + connectionUrl = StringUtils.replace(connectionUrl, "${basedir}", getBasedir()); + connectionUrl = StringUtils.replace(connectionUrl, "\\", "/"); + checkoutMojo.setConnectionUrl(connectionUrl); - checkoutMojo.setCheckoutDirectory( checkoutDir ); + checkoutMojo.setCheckoutDirectory(checkoutDir); checkoutMojo.execute(); } - public void testBranch() - throws Exception - { - if ( !ScmTestCase.isSystemCmd( SvnScmTestUtils.SVN_COMMAND_LINE ) ) - { - ScmTestCase.printSystemCmdUnavail( SvnScmTestUtils.SVN_COMMAND_LINE, getName() ); + public void testBranch() throws Exception { + if (!ScmTestCase.isSystemCmd(SvnScmTestUtils.SVN_COMMAND_LINE)) { + ScmTestCase.printSystemCmdUnavail(SvnScmTestUtils.SVN_COMMAND_LINE, getName()); return; } - BranchMojo mojo = - (BranchMojo) lookupMojo( "branch", getTestFile( "src/test/resources/mojos/branch/branch.xml" ) ); - mojo.setWorkingDirectory( checkoutDir ); + BranchMojo mojo = (BranchMojo) lookupMojo("branch", getTestFile("src/test/resources/mojos/branch/branch.xml")); + mojo.setWorkingDirectory(checkoutDir); String connectionUrl = mojo.getConnectionUrl(); - connectionUrl = StringUtils.replace( connectionUrl, "${basedir}", getBasedir() ); - connectionUrl = StringUtils.replace( connectionUrl, "\\", "/" ); - mojo.setConnectionUrl( connectionUrl ); + connectionUrl = StringUtils.replace(connectionUrl, "${basedir}", getBasedir()); + connectionUrl = StringUtils.replace(connectionUrl, "\\", "/"); + mojo.setConnectionUrl(connectionUrl); mojo.execute(); CheckoutMojo checkoutMojo = - (CheckoutMojo) lookupMojo( "checkout", getTestFile( "src/test/resources/mojos/branch/checkout.xml" ) ); - checkoutMojo.setWorkingDirectory( new File( getBasedir() ) ); + (CheckoutMojo) lookupMojo("checkout", getTestFile("src/test/resources/mojos/branch/checkout.xml")); + checkoutMojo.setWorkingDirectory(new File(getBasedir())); connectionUrl = checkoutMojo.getConnectionUrl(); - connectionUrl = StringUtils.replace( connectionUrl, "${basedir}", getBasedir() ); - connectionUrl = StringUtils.replace( connectionUrl, "\\", "/" ); - checkoutMojo.setConnectionUrl( connectionUrl ); - - File branchCheckoutDir = getTestFile( "target/branches/mybranch" ); - if ( branchCheckoutDir.exists() ) - { - FileUtils.deleteDirectory( branchCheckoutDir ); + connectionUrl = StringUtils.replace(connectionUrl, "${basedir}", getBasedir()); + connectionUrl = StringUtils.replace(connectionUrl, "\\", "/"); + checkoutMojo.setConnectionUrl(connectionUrl); + + File branchCheckoutDir = getTestFile("target/branches/mybranch"); + if (branchCheckoutDir.exists()) { + FileUtils.deleteDirectory(branchCheckoutDir); } - checkoutMojo.setCheckoutDirectory( branchCheckoutDir ); + checkoutMojo.setCheckoutDirectory(branchCheckoutDir); - assertFalse( new File( branchCheckoutDir, "pom.xml" ).exists() ); + assertFalse(new File(branchCheckoutDir, "pom.xml").exists()); checkoutMojo.execute(); - assertTrue( new File( branchCheckoutDir, "pom.xml" ).exists() ); + assertTrue(new File(branchCheckoutDir, "pom.xml").exists()); } } diff --git a/maven-scm-plugin/src/test/java/org/apache/maven/scm/plugin/ChangeLogMojoTest.java b/maven-scm-plugin/src/test/java/org/apache/maven/scm/plugin/ChangeLogMojoTest.java index 3fc881ebf..8b19625ec 100644 --- a/maven-scm-plugin/src/test/java/org/apache/maven/scm/plugin/ChangeLogMojoTest.java +++ b/maven-scm-plugin/src/test/java/org/apache/maven/scm/plugin/ChangeLogMojoTest.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.plugin; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,9 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.plugin; + +import java.io.File; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.testing.AbstractMojoTestCase; @@ -26,126 +27,103 @@ import org.codehaus.plexus.util.FileUtils; import org.codehaus.plexus.util.StringUtils; -import java.io.File; - /** * @author Emmanuel Venisse * */ -public class ChangeLogMojoTest - extends AbstractMojoTestCase -{ +public class ChangeLogMojoTest extends AbstractMojoTestCase { File repository; - protected void setUp() - throws Exception - { + protected void setUp() throws Exception { super.setUp(); - repository = getTestFile( "target/repository" ); + repository = getTestFile("target/repository"); - FileUtils.forceDelete( repository ); + FileUtils.forceDelete(repository); - if ( !ScmTestCase.isSystemCmd( SvnScmTestUtils.SVNADMIN_COMMAND_LINE ) ) - { - ScmTestCase.printSystemCmdUnavail( SvnScmTestUtils.SVNADMIN_COMMAND_LINE, "setUp" ); + if (!ScmTestCase.isSystemCmd(SvnScmTestUtils.SVNADMIN_COMMAND_LINE)) { + ScmTestCase.printSystemCmdUnavail(SvnScmTestUtils.SVNADMIN_COMMAND_LINE, "setUp"); return; } - SvnScmTestUtils.initializeRepository( repository ); + SvnScmTestUtils.initializeRepository(repository); } - public void testChangeLog() - throws Exception - { - if ( !ScmTestCase.isSystemCmd( SvnScmTestUtils.SVN_COMMAND_LINE ) ) - { - ScmTestCase.printSystemCmdUnavail( SvnScmTestUtils.SVN_COMMAND_LINE, getName() ); + public void testChangeLog() throws Exception { + if (!ScmTestCase.isSystemCmd(SvnScmTestUtils.SVN_COMMAND_LINE)) { + ScmTestCase.printSystemCmdUnavail(SvnScmTestUtils.SVN_COMMAND_LINE, getName()); return; } - ChangeLogMojo mojo = (ChangeLogMojo) lookupMojo( "changelog", getTestFile( - "src/test/resources/mojos/changelog/changelog.xml" ) ); + ChangeLogMojo mojo = (ChangeLogMojo) + lookupMojo("changelog", getTestFile("src/test/resources/mojos/changelog/changelog.xml")); String connectionUrl = mojo.getConnectionUrl(); - connectionUrl = StringUtils.replace( connectionUrl, "${basedir}", getBasedir() ); - connectionUrl = StringUtils.replace( connectionUrl, "\\", "/" ); - mojo.setConnectionUrl( connectionUrl ); - mojo.setWorkingDirectory( new File( getBasedir() ) ); - mojo.setConnectionType( "connection" ); + connectionUrl = StringUtils.replace(connectionUrl, "${basedir}", getBasedir()); + connectionUrl = StringUtils.replace(connectionUrl, "\\", "/"); + mojo.setConnectionUrl(connectionUrl); + mojo.setWorkingDirectory(new File(getBasedir())); + mojo.setConnectionType("connection"); mojo.execute(); } - public void testChangeLogWithParameters() - throws Exception - { - if ( !ScmTestCase.isSystemCmd( SvnScmTestUtils.SVN_COMMAND_LINE ) ) - { - ScmTestCase.printSystemCmdUnavail( SvnScmTestUtils.SVN_COMMAND_LINE, getName() ); + public void testChangeLogWithParameters() throws Exception { + if (!ScmTestCase.isSystemCmd(SvnScmTestUtils.SVN_COMMAND_LINE)) { + ScmTestCase.printSystemCmdUnavail(SvnScmTestUtils.SVN_COMMAND_LINE, getName()); return; } - ChangeLogMojo mojo = (ChangeLogMojo) lookupMojo( "changelog", getTestFile( - "src/test/resources/mojos/changelog/changelogWithParameters.xml" ) ); + ChangeLogMojo mojo = (ChangeLogMojo) + lookupMojo("changelog", getTestFile("src/test/resources/mojos/changelog/changelogWithParameters.xml")); String connectionUrl = mojo.getConnectionUrl(); - connectionUrl = StringUtils.replace( connectionUrl, "${basedir}", getBasedir() ); - connectionUrl = StringUtils.replace( connectionUrl, "\\", "/" ); - mojo.setConnectionUrl( connectionUrl ); - mojo.setWorkingDirectory( new File( getBasedir() ) ); - mojo.setConnectionType( "connection" ); + connectionUrl = StringUtils.replace(connectionUrl, "${basedir}", getBasedir()); + connectionUrl = StringUtils.replace(connectionUrl, "\\", "/"); + mojo.setConnectionUrl(connectionUrl); + mojo.setWorkingDirectory(new File(getBasedir())); + mojo.setConnectionType("connection"); mojo.execute(); } - public void testChangeLogWithBadUserDateFormat() - throws Exception - { - ChangeLogMojo mojo = (ChangeLogMojo) lookupMojo( "changelog", getTestFile( - "src/test/resources/mojos/changelog/changelogWithBadUserDateFormat.xml" ) ); + public void testChangeLogWithBadUserDateFormat() throws Exception { + ChangeLogMojo mojo = (ChangeLogMojo) lookupMojo( + "changelog", getTestFile("src/test/resources/mojos/changelog/changelogWithBadUserDateFormat.xml")); String connectionUrl = mojo.getConnectionUrl(); - connectionUrl = StringUtils.replace( connectionUrl, "${basedir}", getBasedir() ); - connectionUrl = StringUtils.replace( connectionUrl, "\\", "/" ); - mojo.setConnectionUrl( connectionUrl ); - mojo.setWorkingDirectory( new File( getBasedir() ) ); - mojo.setConnectionType( "connection" ); - - try - { + connectionUrl = StringUtils.replace(connectionUrl, "${basedir}", getBasedir()); + connectionUrl = StringUtils.replace(connectionUrl, "\\", "/"); + mojo.setConnectionUrl(connectionUrl); + mojo.setWorkingDirectory(new File(getBasedir())); + mojo.setConnectionType("connection"); + + try { mojo.execute(); - fail( "mojo execution must fail." ); - } - catch ( MojoExecutionException e ) - { - assertTrue( true ); + fail("mojo execution must fail."); + } catch (MojoExecutionException e) { + assertTrue(true); } } - public void testChangeLogWithBadConnectionUrl() - throws Exception - { - ChangeLogMojo mojo = (ChangeLogMojo) lookupMojo( "changelog", getTestFile( - "src/test/resources/mojos/changelog/changelogWithBadConnectionUrl.xml" ) ); + public void testChangeLogWithBadConnectionUrl() throws Exception { + ChangeLogMojo mojo = (ChangeLogMojo) lookupMojo( + "changelog", getTestFile("src/test/resources/mojos/changelog/changelogWithBadConnectionUrl.xml")); String connectionUrl = mojo.getConnectionUrl(); - connectionUrl = StringUtils.replace( connectionUrl, "${basedir}", getBasedir() ); - connectionUrl = StringUtils.replace( connectionUrl, "\\", "/" ); - mojo.setConnectionUrl( connectionUrl ); - mojo.setWorkingDirectory( new File( getBasedir() ) ); - mojo.setConnectionType( "connection" ); - - try - { + connectionUrl = StringUtils.replace(connectionUrl, "${basedir}", getBasedir()); + connectionUrl = StringUtils.replace(connectionUrl, "\\", "/"); + mojo.setConnectionUrl(connectionUrl); + mojo.setWorkingDirectory(new File(getBasedir())); + mojo.setConnectionType("connection"); + + try { mojo.execute(); - fail( "mojo execution must fail." ); - } - catch ( MojoExecutionException e ) - { - assertTrue( true ); + fail("mojo execution must fail."); + } catch (MojoExecutionException e) { + assertTrue(true); } } } diff --git a/maven-scm-plugin/src/test/java/org/apache/maven/scm/plugin/CheckoutMojoTest.java b/maven-scm-plugin/src/test/java/org/apache/maven/scm/plugin/CheckoutMojoTest.java index 89fd93784..9fb22c2d2 100644 --- a/maven-scm-plugin/src/test/java/org/apache/maven/scm/plugin/CheckoutMojoTest.java +++ b/maven-scm-plugin/src/test/java/org/apache/maven/scm/plugin/CheckoutMojoTest.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.plugin; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,9 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.plugin; + +import java.io.File; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.testing.AbstractMojoTestCase; @@ -27,176 +28,149 @@ import org.codehaus.plexus.util.FileUtils; import org.codehaus.plexus.util.StringUtils; -import java.io.File; - /** * @author Emmanuel Venisse * */ -public class CheckoutMojoTest - extends AbstractMojoTestCase -{ +public class CheckoutMojoTest extends AbstractMojoTestCase { File checkoutDir; File repository; - protected void setUp() - throws Exception - { + protected void setUp() throws Exception { super.setUp(); - checkoutDir = getTestFile( "target/checkout" ); + checkoutDir = getTestFile("target/checkout"); - repository = getTestFile( "target/repository" ); + repository = getTestFile("target/repository"); - FileUtils.forceDelete( checkoutDir ); + FileUtils.forceDelete(checkoutDir); } - public void testSkipCheckoutWhenCheckoutDirectoryExistsAndSkip() - throws Exception - { - FileUtils.forceDelete( checkoutDir ); + public void testSkipCheckoutWhenCheckoutDirectoryExistsAndSkip() throws Exception { + FileUtils.forceDelete(checkoutDir); checkoutDir.mkdirs(); - CheckoutMojo mojo = (CheckoutMojo) lookupMojo( "checkout", getTestFile( - "src/test/resources/mojos/checkout/checkoutWhenCheckoutDirectoryExistsAndSkip.xml" ) ); + CheckoutMojo mojo = (CheckoutMojo) lookupMojo( + "checkout", + getTestFile("src/test/resources/mojos/checkout/checkoutWhenCheckoutDirectoryExistsAndSkip.xml")); - mojo.setCheckoutDirectory( checkoutDir ); + mojo.setCheckoutDirectory(checkoutDir); mojo.execute(); - assertEquals( 0, checkoutDir.listFiles().length ); + assertEquals(0, checkoutDir.listFiles().length); } - public void testSkipCheckoutWithConnectionUrl() - throws Exception - { - if ( !ScmTestCase.isSystemCmd( SvnScmTestUtils.SVNADMIN_COMMAND_LINE ) ) - { - ScmTestCase.printSystemCmdUnavail( SvnScmTestUtils.SVNADMIN_COMMAND_LINE, getName() ); + public void testSkipCheckoutWithConnectionUrl() throws Exception { + if (!ScmTestCase.isSystemCmd(SvnScmTestUtils.SVNADMIN_COMMAND_LINE)) { + ScmTestCase.printSystemCmdUnavail(SvnScmTestUtils.SVNADMIN_COMMAND_LINE, getName()); return; } - FileUtils.forceDelete( checkoutDir ); + FileUtils.forceDelete(checkoutDir); - SvnScmTestUtils.initializeRepository( repository ); + SvnScmTestUtils.initializeRepository(repository); - if ( !ScmTestCase.isSystemCmd( SvnScmTestUtils.SVN_COMMAND_LINE ) ) - { - ScmTestCase.printSystemCmdUnavail( SvnScmTestUtils.SVN_COMMAND_LINE, getName() ); + if (!ScmTestCase.isSystemCmd(SvnScmTestUtils.SVN_COMMAND_LINE)) { + ScmTestCase.printSystemCmdUnavail(SvnScmTestUtils.SVN_COMMAND_LINE, getName()); return; } - CheckoutMojo mojo = (CheckoutMojo) lookupMojo( "checkout", getTestFile( - "src/test/resources/mojos/checkout/checkoutWithConnectionUrl.xml" ) ); - mojo.setWorkingDirectory( new File( getBasedir() ) ); + CheckoutMojo mojo = (CheckoutMojo) + lookupMojo("checkout", getTestFile("src/test/resources/mojos/checkout/checkoutWithConnectionUrl.xml")); + mojo.setWorkingDirectory(new File(getBasedir())); String connectionUrl = mojo.getConnectionUrl(); - connectionUrl = StringUtils.replace( connectionUrl, "${basedir}", getBasedir() ); - connectionUrl = StringUtils.replace( connectionUrl, "\\", "/" ); - mojo.setConnectionUrl( connectionUrl ); + connectionUrl = StringUtils.replace(connectionUrl, "${basedir}", getBasedir()); + connectionUrl = StringUtils.replace(connectionUrl, "\\", "/"); + mojo.setConnectionUrl(connectionUrl); - mojo.setCheckoutDirectory( checkoutDir ); + mojo.setCheckoutDirectory(checkoutDir); mojo.execute(); } - public void testSkipCheckoutWithoutConnectionUrl() - throws Exception - { - FileUtils.forceDelete( checkoutDir ); + public void testSkipCheckoutWithoutConnectionUrl() throws Exception { + FileUtils.forceDelete(checkoutDir); checkoutDir.mkdirs(); - CheckoutMojo mojo = (CheckoutMojo) lookupMojo( "checkout", getTestFile( - "src/test/resources/mojos/checkout/checkoutWithoutConnectionUrl.xml" ) ); + CheckoutMojo mojo = (CheckoutMojo) lookupMojo( + "checkout", getTestFile("src/test/resources/mojos/checkout/checkoutWithoutConnectionUrl.xml")); - try - { + try { mojo.execute(); - fail( "mojo execution must fail." ); - } - catch ( MojoExecutionException e ) - { - assertTrue( true ); + fail("mojo execution must fail."); + } catch (MojoExecutionException e) { + assertTrue(true); } } - public void testUseExport() - throws Exception - { - if ( !ScmTestCase.isSystemCmd( SvnScmTestUtils.SVN_COMMAND_LINE ) ) - { - ScmTestCase.printSystemCmdUnavail( SvnScmTestUtils.SVN_COMMAND_LINE, getName() ); + public void testUseExport() throws Exception { + if (!ScmTestCase.isSystemCmd(SvnScmTestUtils.SVN_COMMAND_LINE)) { + ScmTestCase.printSystemCmdUnavail(SvnScmTestUtils.SVN_COMMAND_LINE, getName()); return; } - FileUtils.forceDelete( checkoutDir ); + FileUtils.forceDelete(checkoutDir); checkoutDir.mkdirs(); - CheckoutMojo mojo = (CheckoutMojo) lookupMojo( "checkout", getTestFile( - "src/test/resources/mojos/checkout/checkoutUsingExport.xml" ) ); + CheckoutMojo mojo = (CheckoutMojo) + lookupMojo("checkout", getTestFile("src/test/resources/mojos/checkout/checkoutUsingExport.xml")); - mojo.setCheckoutDirectory( checkoutDir ); + mojo.setCheckoutDirectory(checkoutDir); mojo.execute(); - assertTrue( checkoutDir.listFiles().length > 0 ); - assertFalse( new File( checkoutDir, ".svn" ).exists() ); + assertTrue(checkoutDir.listFiles().length > 0); + assertFalse(new File(checkoutDir, ".svn").exists()); } - public void testExcludeInclude() - throws Exception - { - if ( !ScmTestCase.isSystemCmd( SvnScmTestUtils.SVNADMIN_COMMAND_LINE ) ) - { - ScmTestCase.printSystemCmdUnavail( SvnScmTestUtils.SVNADMIN_COMMAND_LINE, getName() ); + public void testExcludeInclude() throws Exception { + if (!ScmTestCase.isSystemCmd(SvnScmTestUtils.SVNADMIN_COMMAND_LINE)) { + ScmTestCase.printSystemCmdUnavail(SvnScmTestUtils.SVNADMIN_COMMAND_LINE, getName()); return; } - FileUtils.forceDelete( checkoutDir ); + FileUtils.forceDelete(checkoutDir); checkoutDir.mkdirs(); - SvnScmTestUtils.initializeRepository( repository ); + SvnScmTestUtils.initializeRepository(repository); - if ( !ScmTestCase.isSystemCmd( SvnScmTestUtils.SVN_COMMAND_LINE ) ) - { - ScmTestCase.printSystemCmdUnavail( SvnScmTestUtils.SVN_COMMAND_LINE, getName() ); + if (!ScmTestCase.isSystemCmd(SvnScmTestUtils.SVN_COMMAND_LINE)) { + ScmTestCase.printSystemCmdUnavail(SvnScmTestUtils.SVN_COMMAND_LINE, getName()); return; } CheckoutMojo mojo = (CheckoutMojo) lookupMojo( - "checkout", - getTestFile( "src/test/resources/mojos/checkout/checkoutWithExcludesIncludes.xml" ) ); + "checkout", getTestFile("src/test/resources/mojos/checkout/checkoutWithExcludesIncludes.xml")); - mojo.setCheckoutDirectory( checkoutDir ); + mojo.setCheckoutDirectory(checkoutDir); mojo.execute(); - assertTrue( checkoutDir.listFiles().length > 0 ); - assertTrue( new File( checkoutDir, ".svn").exists() ); - assertTrue( new File( checkoutDir, "pom.xml" ).exists() ); - assertFalse( new File( checkoutDir, "readme.txt" ).exists() ); - assertFalse( new File( checkoutDir, "src/test" ).exists() ); - assertTrue( new File( checkoutDir, "src/main/java" ).exists() ); + assertTrue(checkoutDir.listFiles().length > 0); + assertTrue(new File(checkoutDir, ".svn").exists()); + assertTrue(new File(checkoutDir, "pom.xml").exists()); + assertFalse(new File(checkoutDir, "readme.txt").exists()); + assertFalse(new File(checkoutDir, "src/test").exists()); + assertTrue(new File(checkoutDir, "src/main/java").exists()); // olamy those files not exists anymore with svn 1.7 - //assertTrue( new File( checkoutDir, "src/main/java/.svn" ).exists() ); - //assertTrue( new File( checkoutDir, "src/main/.svn" ).exists() ); + // assertTrue( new File( checkoutDir, "src/main/java/.svn" ).exists() ); + // assertTrue( new File( checkoutDir, "src/main/.svn" ).exists() ); } - public void testEncryptedPasswordFromSettings() - throws Exception - { - File pom = getTestFile( "src/test/resources/mojos/checkout/checkoutEncryptedPasswordFromSettings.xml" ); - CheckoutMojo mojo = (CheckoutMojo) lookupMojo( "checkout", pom ); + public void testEncryptedPasswordFromSettings() throws Exception { + File pom = getTestFile("src/test/resources/mojos/checkout/checkoutEncryptedPasswordFromSettings.xml"); + CheckoutMojo mojo = (CheckoutMojo) lookupMojo("checkout", pom); ScmProviderRepositoryWithHost repo = - (ScmProviderRepositoryWithHost) mojo.getScmRepository().getProviderRepository(); + (ScmProviderRepositoryWithHost) mojo.getScmRepository().getProviderRepository(); - assertEquals( "testuser", repo.getUser() ); - assertEquals( "testpass", repo.getPassword() ); - assertEquals( "testphrase", repo.getPassphrase() ); + assertEquals("testuser", repo.getUser()); + assertEquals("testpass", repo.getPassword()); + assertEquals("testphrase", repo.getPassphrase()); } - } diff --git a/maven-scm-plugin/src/test/java/org/apache/maven/scm/plugin/ExportMojoTest.java b/maven-scm-plugin/src/test/java/org/apache/maven/scm/plugin/ExportMojoTest.java index f0aa46647..6138a9db2 100644 --- a/maven-scm-plugin/src/test/java/org/apache/maven/scm/plugin/ExportMojoTest.java +++ b/maven-scm-plugin/src/test/java/org/apache/maven/scm/plugin/ExportMojoTest.java @@ -1,19 +1,22 @@ -package org.apache.maven.scm.plugin; - /* - * Licensed to the Apache Software Foundation (ASF) under one or more contributor license - * agreements. See the NOTICE file distributed with this work for additional information regarding - * copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance with the License. You may obtain a - * copy of the License at + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software distributed under the License - * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express - * or implied. See the License for the specific language governing permissions and limitations under - * the License. + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. */ +package org.apache.maven.scm.plugin; import java.io.File; @@ -25,99 +28,82 @@ /** * */ -public class ExportMojoTest - extends AbstractMojoTestCase -{ +public class ExportMojoTest extends AbstractMojoTestCase { File exportDir; File repository; - protected void setUp() - throws Exception - { + protected void setUp() throws Exception { super.setUp(); - exportDir = getTestFile( "target/export" ); + exportDir = getTestFile("target/export"); - repository = getTestFile( "target/repository" ); + repository = getTestFile("target/repository"); - FileUtils.forceDelete( exportDir ); + FileUtils.forceDelete(exportDir); } - public void testExport() - throws Exception - { - if ( !ScmTestCase.isSystemCmd( SvnScmTestUtils.SVNADMIN_COMMAND_LINE ) ) - { - ScmTestCase.printSystemCmdUnavail( SvnScmTestUtils.SVNADMIN_COMMAND_LINE, getName() ); + public void testExport() throws Exception { + if (!ScmTestCase.isSystemCmd(SvnScmTestUtils.SVNADMIN_COMMAND_LINE)) { + ScmTestCase.printSystemCmdUnavail(SvnScmTestUtils.SVNADMIN_COMMAND_LINE, getName()); return; } - SvnScmTestUtils.initializeRepository( repository ); + SvnScmTestUtils.initializeRepository(repository); - if ( !ScmTestCase.isSystemCmd( SvnScmTestUtils.SVN_COMMAND_LINE ) ) - { - ScmTestCase.printSystemCmdUnavail( SvnScmTestUtils.SVN_COMMAND_LINE, getName() ); + if (!ScmTestCase.isSystemCmd(SvnScmTestUtils.SVN_COMMAND_LINE)) { + ScmTestCase.printSystemCmdUnavail(SvnScmTestUtils.SVN_COMMAND_LINE, getName()); return; } - ExportMojo mojo = (ExportMojo) lookupMojo( "export", getTestFile( "src/test/resources/mojos/export/export.xml" ) ); + ExportMojo mojo = (ExportMojo) lookupMojo("export", getTestFile("src/test/resources/mojos/export/export.xml")); - mojo.setExportDirectory( exportDir.getAbsoluteFile() ); + mojo.setExportDirectory(exportDir.getAbsoluteFile()); mojo.execute(); - assertTrue( exportDir.listFiles().length > 0 ); - assertFalse( new File( exportDir, ".svn" ).exists() ); + assertTrue(exportDir.listFiles().length > 0); + assertFalse(new File(exportDir, ".svn").exists()); } - public void testSkipExportIfExists() - throws Exception - { + public void testSkipExportIfExists() throws Exception { exportDir.mkdirs(); ExportMojo mojo = (ExportMojo) lookupMojo( - "export", - getTestFile( "src/test/resources/mojos/export/exportWhenExportDirectoryExistsAndSkip.xml" ) ); + "export", getTestFile("src/test/resources/mojos/export/exportWhenExportDirectoryExistsAndSkip.xml")); - mojo.setExportDirectory( exportDir ); + mojo.setExportDirectory(exportDir); mojo.execute(); - assertEquals( 0, exportDir.listFiles().length ); + assertEquals(0, exportDir.listFiles().length); } - public void testExcludeInclude() - throws Exception - { - if ( !ScmTestCase.isSystemCmd( SvnScmTestUtils.SVNADMIN_COMMAND_LINE ) ) - { - ScmTestCase.printSystemCmdUnavail( SvnScmTestUtils.SVNADMIN_COMMAND_LINE, getName() ); + public void testExcludeInclude() throws Exception { + if (!ScmTestCase.isSystemCmd(SvnScmTestUtils.SVNADMIN_COMMAND_LINE)) { + ScmTestCase.printSystemCmdUnavail(SvnScmTestUtils.SVNADMIN_COMMAND_LINE, getName()); return; } - SvnScmTestUtils.initializeRepository( repository ); + SvnScmTestUtils.initializeRepository(repository); exportDir.mkdirs(); - if ( !ScmTestCase.isSystemCmd( SvnScmTestUtils.SVN_COMMAND_LINE ) ) - { - ScmTestCase.printSystemCmdUnavail( SvnScmTestUtils.SVN_COMMAND_LINE, getName() ); + if (!ScmTestCase.isSystemCmd(SvnScmTestUtils.SVN_COMMAND_LINE)) { + ScmTestCase.printSystemCmdUnavail(SvnScmTestUtils.SVN_COMMAND_LINE, getName()); return; } - ExportMojo mojo = (ExportMojo) lookupMojo( - "export", - getTestFile( "src/test/resources/mojos/export/exportWithExcludesIncludes.xml" ) ); + ExportMojo mojo = (ExportMojo) + lookupMojo("export", getTestFile("src/test/resources/mojos/export/exportWithExcludesIncludes.xml")); - mojo.setExportDirectory( exportDir ); + mojo.setExportDirectory(exportDir); mojo.execute(); - assertTrue( exportDir.listFiles().length > 0 ); - assertTrue( new File( exportDir, "pom.xml" ).exists() ); - assertFalse( new File( exportDir, "readme.txt" ).exists() ); - assertFalse( new File( exportDir, "src/test" ).exists() ); + assertTrue(exportDir.listFiles().length > 0); + assertTrue(new File(exportDir, "pom.xml").exists()); + assertFalse(new File(exportDir, "readme.txt").exists()); + assertFalse(new File(exportDir, "src/test").exists()); } - } diff --git a/maven-scm-plugin/src/test/java/org/apache/maven/scm/plugin/StatusMojoTest.java b/maven-scm-plugin/src/test/java/org/apache/maven/scm/plugin/StatusMojoTest.java index 37b401ec8..12fa0945f 100644 --- a/maven-scm-plugin/src/test/java/org/apache/maven/scm/plugin/StatusMojoTest.java +++ b/maven-scm-plugin/src/test/java/org/apache/maven/scm/plugin/StatusMojoTest.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.plugin; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,33 +16,28 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.plugin; + +import java.io.File; import org.apache.maven.plugin.testing.AbstractMojoTestCase; import org.apache.maven.scm.ScmTestCase; import org.apache.maven.scm.provider.svn.SvnScmTestUtils; -import java.io.File; - /** * @author Emmanuel Venisse * */ -public class StatusMojoTest - extends AbstractMojoTestCase -{ - public void testStatusMojo() - throws Exception - { - if ( !ScmTestCase.isSystemCmd( SvnScmTestUtils.SVN_COMMAND_LINE ) ) - { - ScmTestCase.printSystemCmdUnavail( SvnScmTestUtils.SVN_COMMAND_LINE, getName() ); +public class StatusMojoTest extends AbstractMojoTestCase { + public void testStatusMojo() throws Exception { + if (!ScmTestCase.isSystemCmd(SvnScmTestUtils.SVN_COMMAND_LINE)) { + ScmTestCase.printSystemCmdUnavail(SvnScmTestUtils.SVN_COMMAND_LINE, getName()); return; } - StatusMojo mojo = - (StatusMojo) lookupMojo( "status", getTestFile( "src/test/resources/mojos/status/status.xml" ) ); + StatusMojo mojo = (StatusMojo) lookupMojo("status", getTestFile("src/test/resources/mojos/status/status.xml")); - mojo.setWorkingDirectory( new File( getBasedir() ) ); + mojo.setWorkingDirectory(new File(getBasedir())); mojo.execute(); } } diff --git a/maven-scm-plugin/src/test/java/org/apache/maven/scm/plugin/TagMojoTest.java b/maven-scm-plugin/src/test/java/org/apache/maven/scm/plugin/TagMojoTest.java index f21afb219..b7a81f0cd 100644 --- a/maven-scm-plugin/src/test/java/org/apache/maven/scm/plugin/TagMojoTest.java +++ b/maven-scm-plugin/src/test/java/org/apache/maven/scm/plugin/TagMojoTest.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.plugin; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,121 +16,105 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.plugin; + +import java.io.File; import org.apache.maven.plugin.testing.AbstractMojoTestCase; import org.apache.maven.scm.ScmTestCase; -import org.apache.maven.scm.provider.git.GitScmTestUtils; import org.apache.maven.scm.provider.svn.SvnScmTestUtils; import org.codehaus.plexus.util.FileUtils; -import org.junit.Assume; - -import java.io.File; /** * @author Emmanuel Venisse * */ -public class TagMojoTest - extends AbstractMojoTestCase -{ +public class TagMojoTest extends AbstractMojoTestCase { File checkoutDir; File repository; - protected void setUp() - throws Exception - { + protected void setUp() throws Exception { super.setUp(); - checkoutDir = getTestFile( "target/checkout" ); + checkoutDir = getTestFile("target/checkout"); - FileUtils.forceDelete( checkoutDir ); + FileUtils.forceDelete(checkoutDir); - repository = getTestFile( "target/repository" ); + repository = getTestFile("target/repository"); - FileUtils.forceDelete( repository ); + FileUtils.forceDelete(repository); - if ( !ScmTestCase.isSystemCmd( SvnScmTestUtils.SVNADMIN_COMMAND_LINE ) ) - { - ScmTestCase.printSystemCmdUnavail( SvnScmTestUtils.SVNADMIN_COMMAND_LINE, "setUp" ); + if (!ScmTestCase.isSystemCmd(SvnScmTestUtils.SVNADMIN_COMMAND_LINE)) { + ScmTestCase.printSystemCmdUnavail(SvnScmTestUtils.SVNADMIN_COMMAND_LINE, "setUp"); return; } - SvnScmTestUtils.initializeRepository( repository ); + SvnScmTestUtils.initializeRepository(repository); - if ( !ScmTestCase.isSystemCmd( SvnScmTestUtils.SVN_COMMAND_LINE ) ) - { - ScmTestCase.printSystemCmdUnavail( SvnScmTestUtils.SVN_COMMAND_LINE, "setUp" ); + if (!ScmTestCase.isSystemCmd(SvnScmTestUtils.SVN_COMMAND_LINE)) { + ScmTestCase.printSystemCmdUnavail(SvnScmTestUtils.SVN_COMMAND_LINE, "setUp"); return; } - CheckoutMojo checkoutMojo = (CheckoutMojo) lookupMojo( "checkout", getTestFile( - "src/test/resources/mojos/checkout/checkoutWithConnectionUrl.xml" ) ); - checkoutMojo.setWorkingDirectory( new File( getBasedir() ) ); + CheckoutMojo checkoutMojo = (CheckoutMojo) + lookupMojo("checkout", getTestFile("src/test/resources/mojos/checkout/checkoutWithConnectionUrl.xml")); + checkoutMojo.setWorkingDirectory(new File(getBasedir())); - setupConnectionUrl( checkoutMojo ); + setupConnectionUrl(checkoutMojo); - checkoutMojo.setCheckoutDirectory( checkoutDir ); + checkoutMojo.setCheckoutDirectory(checkoutDir); checkoutMojo.execute(); } - private static void setupConnectionUrl( AbstractScmMojo mojo ) - { + private static void setupConnectionUrl(AbstractScmMojo mojo) { String connectionUrl = mojo.getConnectionUrl(); - connectionUrl = connectionUrl.replace( "${basedir}", getBasedir() ); - connectionUrl = connectionUrl.replace( '\\', '/' ); - mojo.setConnectionUrl( connectionUrl ); + connectionUrl = connectionUrl.replace("${basedir}", getBasedir()); + connectionUrl = connectionUrl.replace('\\', '/'); + mojo.setConnectionUrl(connectionUrl); } - public void testTag() - throws Exception - { - if ( !ScmTestCase.isSystemCmd( SvnScmTestUtils.SVN_COMMAND_LINE ) ) - { - ScmTestCase.printSystemCmdUnavail( SvnScmTestUtils.SVN_COMMAND_LINE, getName() ); + public void testTag() throws Exception { + if (!ScmTestCase.isSystemCmd(SvnScmTestUtils.SVN_COMMAND_LINE)) { + ScmTestCase.printSystemCmdUnavail(SvnScmTestUtils.SVN_COMMAND_LINE, getName()); return; } - TagMojo mojo = (TagMojo) lookupMojo( "tag", getTestFile( "src/test/resources/mojos/tag/tag.xml" ) ); - mojo.setWorkingDirectory( checkoutDir ); + TagMojo mojo = (TagMojo) lookupMojo("tag", getTestFile("src/test/resources/mojos/tag/tag.xml")); + mojo.setWorkingDirectory(checkoutDir); - setupConnectionUrl( mojo ); + setupConnectionUrl(mojo); mojo.execute(); CheckoutMojo checkoutMojo = - (CheckoutMojo) lookupMojo( "checkout", getTestFile( "src/test/resources/mojos/tag/checkout.xml" ) ); - checkoutMojo.setWorkingDirectory( new File( getBasedir() ) ); + (CheckoutMojo) lookupMojo("checkout", getTestFile("src/test/resources/mojos/tag/checkout.xml")); + checkoutMojo.setWorkingDirectory(new File(getBasedir())); - setupConnectionUrl( checkoutMojo ); + setupConnectionUrl(checkoutMojo); - File tagCheckoutDir = getTestFile( "target/tags/mytag" ); - if ( tagCheckoutDir.exists() ) - { - FileUtils.deleteDirectory( tagCheckoutDir ); + File tagCheckoutDir = getTestFile("target/tags/mytag"); + if (tagCheckoutDir.exists()) { + FileUtils.deleteDirectory(tagCheckoutDir); } - checkoutMojo.setCheckoutDirectory( tagCheckoutDir ); + checkoutMojo.setCheckoutDirectory(tagCheckoutDir); - assertFalse( new File( tagCheckoutDir, "pom.xml" ).exists() ); + assertFalse(new File(tagCheckoutDir, "pom.xml").exists()); checkoutMojo.execute(); - assertTrue( new File( tagCheckoutDir, "pom.xml" ).exists() ); + assertTrue(new File(tagCheckoutDir, "pom.xml").exists()); } - public void testTagWithTimestamp() - throws Exception - { - if ( !ScmTestCase.isSystemCmd( SvnScmTestUtils.SVN_COMMAND_LINE ) ) - { - ScmTestCase.printSystemCmdUnavail( SvnScmTestUtils.SVN_COMMAND_LINE, getName() ); + public void testTagWithTimestamp() throws Exception { + if (!ScmTestCase.isSystemCmd(SvnScmTestUtils.SVN_COMMAND_LINE)) { + ScmTestCase.printSystemCmdUnavail(SvnScmTestUtils.SVN_COMMAND_LINE, getName()); return; } - TagMojo mojo = - (TagMojo) lookupMojo( "tag", getTestFile( "src/test/resources/mojos/tag/tagWithTimestamp.xml" ) ); - mojo.setWorkingDirectory( checkoutDir ); + TagMojo mojo = (TagMojo) lookupMojo("tag", getTestFile("src/test/resources/mojos/tag/tagWithTimestamp.xml")); + mojo.setWorkingDirectory(checkoutDir); - setupConnectionUrl( mojo ); + setupConnectionUrl(mojo); mojo.execute(); } diff --git a/maven-scm-plugin/src/test/java/org/apache/maven/scm/plugin/UntagMojoTest.java b/maven-scm-plugin/src/test/java/org/apache/maven/scm/plugin/UntagMojoTest.java index b5c418940..00ffd826d 100644 --- a/maven-scm-plugin/src/test/java/org/apache/maven/scm/plugin/UntagMojoTest.java +++ b/maven-scm-plugin/src/test/java/org/apache/maven/scm/plugin/UntagMojoTest.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.plugin; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.plugin; import java.io.File; @@ -28,101 +27,88 @@ import org.codehaus.plexus.util.FileUtils; import org.codehaus.plexus.util.StringUtils; -public class UntagMojoTest - extends AbstractMojoTestCase -{ +public class UntagMojoTest extends AbstractMojoTestCase { File checkoutDir; File repository; - protected void setUp() - throws Exception - { + protected void setUp() throws Exception { super.setUp(); - checkoutDir = getTestFile( "target/checkout" ); + checkoutDir = getTestFile("target/checkout"); - repository = getTestFile( "target/repository" ); + repository = getTestFile("target/repository"); - if ( !ScmTestCase.isSystemCmd( GitScmTestUtils.GIT_COMMAND_LINE ) ) - { - ScmTestCase.printSystemCmdUnavail( GitScmTestUtils.GIT_COMMAND_LINE, "setUp" ); + if (!ScmTestCase.isSystemCmd(GitScmTestUtils.GIT_COMMAND_LINE)) { + ScmTestCase.printSystemCmdUnavail(GitScmTestUtils.GIT_COMMAND_LINE, "setUp"); return; } - GitScmTestUtils.initRepo( "src/test/resources/git", repository, checkoutDir ); + GitScmTestUtils.initRepo("src/test/resources/git", repository, checkoutDir); - CheckoutMojo checkoutMojo = (CheckoutMojo) lookupMojo( "checkout", getTestFile( - "src/test/resources/mojos/untag/checkout.xml" ) ); - checkoutMojo.setWorkingDirectory( checkoutDir ); + CheckoutMojo checkoutMojo = + (CheckoutMojo) lookupMojo("checkout", getTestFile("src/test/resources/mojos/untag/checkout.xml")); + checkoutMojo.setWorkingDirectory(checkoutDir); String connectionUrl = checkoutMojo.getConnectionUrl(); - connectionUrl = StringUtils.replace( connectionUrl, "${basedir}", getBasedir() ); - connectionUrl = StringUtils.replace( connectionUrl, "\\", "/" ); - checkoutMojo.setConnectionUrl( connectionUrl ); + connectionUrl = StringUtils.replace(connectionUrl, "${basedir}", getBasedir()); + connectionUrl = StringUtils.replace(connectionUrl, "\\", "/"); + checkoutMojo.setConnectionUrl(connectionUrl); - checkoutMojo.setCheckoutDirectory( checkoutDir ); + checkoutMojo.setCheckoutDirectory(checkoutDir); checkoutMojo.execute(); // Add a default user to the config - GitScmTestUtils.setDefaultUser( checkoutDir ); + GitScmTestUtils.setDefaultUser(checkoutDir); } - public void testUntag() - throws Exception - { - if ( !ScmTestCase.isSystemCmd( GitScmTestUtils.GIT_COMMAND_LINE ) ) - { - ScmTestCase.printSystemCmdUnavail( GitScmTestUtils.GIT_COMMAND_LINE, getName() ); + public void testUntag() throws Exception { + if (!ScmTestCase.isSystemCmd(GitScmTestUtils.GIT_COMMAND_LINE)) { + ScmTestCase.printSystemCmdUnavail(GitScmTestUtils.GIT_COMMAND_LINE, getName()); return; } - TagMojo tagMojo = (TagMojo) lookupMojo( "tag", getTestFile( "src/test/resources/mojos/untag/tag.xml" ) ); - tagMojo.setWorkingDirectory( checkoutDir ); - tagMojo.setConnectionUrl( getConnectionLocalAddress( tagMojo ) ); + TagMojo tagMojo = (TagMojo) lookupMojo("tag", getTestFile("src/test/resources/mojos/untag/tag.xml")); + tagMojo.setWorkingDirectory(checkoutDir); + tagMojo.setConnectionUrl(getConnectionLocalAddress(tagMojo)); tagMojo.execute(); CheckoutMojo checkoutMojo = - (CheckoutMojo) lookupMojo( "checkout", getTestFile( "src/test/resources/mojos/untag/checkout-tag.xml" ) ); - checkoutMojo.setWorkingDirectory( new File( getBasedir() ) ); - checkoutMojo.setConnectionUrl( getConnectionLocalAddress( checkoutMojo ) ); + (CheckoutMojo) lookupMojo("checkout", getTestFile("src/test/resources/mojos/untag/checkout-tag.xml")); + checkoutMojo.setWorkingDirectory(new File(getBasedir())); + checkoutMojo.setConnectionUrl(getConnectionLocalAddress(checkoutMojo)); - File tagCheckoutDir = getTestFile( "target/tags/mytag" ); + File tagCheckoutDir = getTestFile("target/tags/mytag"); - if ( tagCheckoutDir.exists() ) - { - FileUtils.deleteDirectory( tagCheckoutDir ); + if (tagCheckoutDir.exists()) { + FileUtils.deleteDirectory(tagCheckoutDir); } - checkoutMojo.setCheckoutDirectory( tagCheckoutDir ); + checkoutMojo.setCheckoutDirectory(tagCheckoutDir); checkoutMojo.execute(); - UntagMojo mojo = (UntagMojo) lookupMojo( "untag", getTestFile( "src/test/resources/mojos/untag/untag.xml" ) ); - mojo.setWorkingDirectory( checkoutDir ); - mojo.setConnectionUrl( getConnectionLocalAddress( mojo ) ); + UntagMojo mojo = (UntagMojo) lookupMojo("untag", getTestFile("src/test/resources/mojos/untag/untag.xml")); + mojo.setWorkingDirectory(checkoutDir); + mojo.setConnectionUrl(getConnectionLocalAddress(mojo)); mojo.execute(); - FileUtils.deleteDirectory( tagCheckoutDir ); + FileUtils.deleteDirectory(tagCheckoutDir); - try - { + try { checkoutMojo.execute(); - fail( "mojo execution must fail." ); - } - catch ( MojoExecutionException e ) - { - assertTrue( true ); + fail("mojo execution must fail."); + } catch (MojoExecutionException e) { + assertTrue(true); } } - private String getConnectionLocalAddress( AbstractScmMojo mojo ) - { + private String getConnectionLocalAddress(AbstractScmMojo mojo) { String connectionUrl = mojo.getConnectionUrl(); - connectionUrl = StringUtils.replace( connectionUrl, "${basedir}", getBasedir() ); - connectionUrl = StringUtils.replace( connectionUrl, "\\", "/" ); + connectionUrl = StringUtils.replace(connectionUrl, "${basedir}", getBasedir()); + connectionUrl = StringUtils.replace(connectionUrl, "\\", "/"); return connectionUrl; } } diff --git a/maven-scm-plugin/src/test/java/org/apache/maven/scm/plugin/UpdateMojoTest.java b/maven-scm-plugin/src/test/java/org/apache/maven/scm/plugin/UpdateMojoTest.java index bc88ccb4c..8802d3de1 100644 --- a/maven-scm-plugin/src/test/java/org/apache/maven/scm/plugin/UpdateMojoTest.java +++ b/maven-scm-plugin/src/test/java/org/apache/maven/scm/plugin/UpdateMojoTest.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.plugin; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,9 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.plugin; + +import java.io.File; import org.apache.maven.plugin.testing.AbstractMojoTestCase; import org.apache.maven.scm.ScmTestCase; @@ -25,68 +26,56 @@ import org.codehaus.plexus.util.FileUtils; import org.codehaus.plexus.util.StringUtils; -import java.io.File; - /** * @author Emmanuel Venisse * */ -public class UpdateMojoTest - extends AbstractMojoTestCase -{ +public class UpdateMojoTest extends AbstractMojoTestCase { File checkoutDir; File repository; - protected void setUp() - throws Exception - { + protected void setUp() throws Exception { super.setUp(); - checkoutDir = getTestFile( "target/checkout" ); + checkoutDir = getTestFile("target/checkout"); - repository = getTestFile( "target/repository" ); + repository = getTestFile("target/repository"); - FileUtils.forceDelete( checkoutDir ); + FileUtils.forceDelete(checkoutDir); } - public void testSkipCheckoutWithConnectionUrl() - throws Exception - { - if ( !ScmTestCase.isSystemCmd( SvnScmTestUtils.SVNADMIN_COMMAND_LINE ) ) - { - ScmTestCase.printSystemCmdUnavail( SvnScmTestUtils.SVNADMIN_COMMAND_LINE, getName() ); + public void testSkipCheckoutWithConnectionUrl() throws Exception { + if (!ScmTestCase.isSystemCmd(SvnScmTestUtils.SVNADMIN_COMMAND_LINE)) { + ScmTestCase.printSystemCmdUnavail(SvnScmTestUtils.SVNADMIN_COMMAND_LINE, getName()); return; } - SvnScmTestUtils.initializeRepository( repository ); + SvnScmTestUtils.initializeRepository(repository); - if ( !ScmTestCase.isSystemCmd( SvnScmTestUtils.SVN_COMMAND_LINE ) ) - { - ScmTestCase.printSystemCmdUnavail( SvnScmTestUtils.SVN_COMMAND_LINE, getName() ); + if (!ScmTestCase.isSystemCmd(SvnScmTestUtils.SVN_COMMAND_LINE)) { + ScmTestCase.printSystemCmdUnavail(SvnScmTestUtils.SVN_COMMAND_LINE, getName()); return; } - CheckoutMojo checkoutMojo = (CheckoutMojo) lookupMojo( "checkout", getTestFile( - "src/test/resources/mojos/checkout/checkoutWithConnectionUrl.xml" ) ); + CheckoutMojo checkoutMojo = (CheckoutMojo) + lookupMojo("checkout", getTestFile("src/test/resources/mojos/checkout/checkoutWithConnectionUrl.xml")); String connectionUrl = checkoutMojo.getConnectionUrl(); - connectionUrl = StringUtils.replace( connectionUrl, "${basedir}", getBasedir() ); - connectionUrl = StringUtils.replace( connectionUrl, "\\", "/" ); - checkoutMojo.setConnectionUrl( connectionUrl ); + connectionUrl = StringUtils.replace(connectionUrl, "${basedir}", getBasedir()); + connectionUrl = StringUtils.replace(connectionUrl, "\\", "/"); + checkoutMojo.setConnectionUrl(connectionUrl); checkoutMojo.execute(); - UpdateMojo updateMojo = (UpdateMojo) lookupMojo( "update", getTestFile( - "src/test/resources/mojos/update/updateWithConnectionUrl.xml" ) ); + UpdateMojo updateMojo = (UpdateMojo) + lookupMojo("update", getTestFile("src/test/resources/mojos/update/updateWithConnectionUrl.xml")); connectionUrl = updateMojo.getConnectionUrl(); - connectionUrl = StringUtils.replace( connectionUrl, "${basedir}", getBasedir() ); - connectionUrl = StringUtils.replace( connectionUrl, "\\", "/" ); - updateMojo.setConnectionUrl( connectionUrl ); + connectionUrl = StringUtils.replace(connectionUrl, "${basedir}", getBasedir()); + connectionUrl = StringUtils.replace(connectionUrl, "\\", "/"); + updateMojo.setConnectionUrl(connectionUrl); updateMojo.execute(); - } - } diff --git a/maven-scm-plugin/src/test/java/org/apache/maven/scm/plugin/ValidateMojoTest.java b/maven-scm-plugin/src/test/java/org/apache/maven/scm/plugin/ValidateMojoTest.java index 572b5ba76..9cd8b0e88 100644 --- a/maven-scm-plugin/src/test/java/org/apache/maven/scm/plugin/ValidateMojoTest.java +++ b/maven-scm-plugin/src/test/java/org/apache/maven/scm/plugin/ValidateMojoTest.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.plugin; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.plugin; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.testing.AbstractMojoTestCase; @@ -26,39 +25,28 @@ * @author Emmanuel Venisse * */ -public class ValidateMojoTest - extends AbstractMojoTestCase -{ - public void testValidateWithoutScmUrl() - throws Exception - { - ValidateMojo mojo = (ValidateMojo) lookupMojo( "validate", getTestFile( - "src/test/resources/mojos/validate/validateWithoutScmUrl.xml" ) ); +public class ValidateMojoTest extends AbstractMojoTestCase { + public void testValidateWithoutScmUrl() throws Exception { + ValidateMojo mojo = (ValidateMojo) + lookupMojo("validate", getTestFile("src/test/resources/mojos/validate/validateWithoutScmUrl.xml")); mojo.execute(); } - public void testValidateWithValidScmUrls() - throws Exception - { - ValidateMojo mojo = (ValidateMojo) lookupMojo( "validate", getTestFile( - "src/test/resources/mojos/validate/validateWithValidScmUrls.xml" ) ); + public void testValidateWithValidScmUrls() throws Exception { + ValidateMojo mojo = (ValidateMojo) + lookupMojo("validate", getTestFile("src/test/resources/mojos/validate/validateWithValidScmUrls.xml")); mojo.execute(); } - public void testValidateWithInvalidScmUrls() - throws Exception - { - ValidateMojo mojo = (ValidateMojo) lookupMojo( "validate", getTestFile( - "src/test/resources/mojos/validate/validateWithInvalidScmUrls.xml" ) ); - try - { + public void testValidateWithInvalidScmUrls() throws Exception { + ValidateMojo mojo = (ValidateMojo) + lookupMojo("validate", getTestFile("src/test/resources/mojos/validate/validateWithInvalidScmUrls.xml")); + try { mojo.execute(); - fail( "mojo execution must fail." ); - } - catch ( MojoExecutionException e ) - { - assertTrue( true ); + fail("mojo execution must fail."); + } catch (MojoExecutionException e) { + assertTrue(true); } } } diff --git a/maven-scm-providers/maven-scm-provider-hg/pom.xml b/maven-scm-providers/maven-scm-provider-hg/pom.xml index 7fcd06631..18c5f0571 100644 --- a/maven-scm-providers/maven-scm-provider-hg/pom.xml +++ b/maven-scm-providers/maven-scm-provider-hg/pom.xml @@ -1,5 +1,4 @@ - - 4.0.0 @@ -35,16 +33,16 @@ - Thurner Rupert - thurner.rupert@ymono.net + Thurner Rupert + thurner.rupert@ymono.net Alain Hoang hoanga@alum.rpi.edu - Ryan Daum - ryan@darksleep.com + Ryan Daum + ryan@darksleep.com diff --git a/maven-scm-providers/maven-scm-provider-hg/src/main/java/org/apache/maven/scm/provider/hg/HgConfig.java b/maven-scm-providers/maven-scm-provider-hg/src/main/java/org/apache/maven/scm/provider/hg/HgConfig.java index c715fbe3c..64177710d 100644 --- a/maven-scm-providers/maven-scm-provider-hg/src/main/java/org/apache/maven/scm/provider/hg/HgConfig.java +++ b/maven-scm-providers/maven-scm-provider-hg/src/main/java/org/apache/maven/scm/provider/hg/HgConfig.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.hg; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,9 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider.hg; + +import java.io.File; import org.apache.maven.scm.ScmException; import org.apache.maven.scm.ScmFileStatus; @@ -25,8 +26,6 @@ import org.apache.maven.scm.provider.hg.command.HgConsumer; import org.codehaus.plexus.util.cli.Commandline; -import java.io.File; - /** * Check hg installation. * @@ -34,9 +33,8 @@ * @author ryan daum * */ -public class HgConfig -{ - //Minimum version for the Hg SCM +public class HgConfig { + // Minimum version for the Hg SCM private static final String HG_REQ = "0.9.2"; // The string which indicates the beginning of the Mercurial line @@ -45,55 +43,45 @@ public class HgConfig // URL to download mercurial from private static final String HG_INSTALL_URL = "'http://www.selenic.com/mercurial/wiki/index.cgi/Download'"; - //Configuration to check with default values (not installed) - private HgVersionConsumer hgVersion = new HgVersionConsumer( null ); + // Configuration to check with default values (not installed) + private HgVersionConsumer hgVersion = new HgVersionConsumer(null); - HgConfig( File workingDir ) - { - try - { - hgVersion = getHgVersion( workingDir ); - } - catch ( ScmException e ) - { - //Ignore - is not installed. - //This is already recorded thus we do not generate more info. + HgConfig(File workingDir) { + try { + hgVersion = getHgVersion(workingDir); + } catch (ScmException e) { + // Ignore - is not installed. + // This is already recorded thus we do not generate more info. } - } /** * @return True if one can run basic hg commands */ - private boolean isInstalled() - { - return hgVersion.isVersionOk( HG_REQ ); + private boolean isInstalled() { + return hgVersion.isVersionOk(HG_REQ); } /** * @return True if all modules for hg are installed. */ - private boolean isComplete() - { + private boolean isComplete() { return isInstalled(); } // Consumer to find the Mercurial version - public static HgVersionConsumer getHgVersion( File workingDir ) - throws ScmException - { - String[] versionCmd = new String[]{ HgCommandConstants.VERSION }; - HgVersionConsumer consumer = new HgVersionConsumer( HG_VERSION_TAG ); - Commandline cmd = HgUtils.buildCmd( workingDir, versionCmd ); + public static HgVersionConsumer getHgVersion(File workingDir) throws ScmException { + String[] versionCmd = new String[] {HgCommandConstants.VERSION}; + HgVersionConsumer consumer = new HgVersionConsumer(HG_VERSION_TAG); + Commandline cmd = HgUtils.buildCmd(workingDir, versionCmd); // Execute command - HgUtils.executeCmd( consumer, cmd ); + HgUtils.executeCmd(consumer, cmd); // Return result return consumer; } - /** * Iterate through two dot-notation version strings, normalize them to the same length, then * do alphabetic comparison @@ -102,8 +90,7 @@ public static HgVersionConsumer getHgVersion( File workingDir ) * @param version2 * @return true if version2 is greater than version1 */ - private static boolean compareVersion( String version1, String version2 ) - { + private static boolean compareVersion(String version1, String version2) { int l1, l2; String v1, v2; @@ -112,78 +99,63 @@ private static boolean compareVersion( String version1, String version2 ) l1 = version1.length(); l2 = version2.length(); - if ( l1 > l2 ) - { - for ( int x = l2; x >= l1; x-- ) - { + if (l1 > l2) { + for (int x = l2; x >= l1; x--) { v2 += ' '; } } - if ( l2 > l1 ) - { - for ( int x = l1; x <= l2; x++ ) - { + if (l2 > l1) { + for (int x = l1; x <= l2; x++) { v1 += ' '; } } - return v2.compareTo( v1 ) >= 0; + return v2.compareTo(v1) >= 0; } - /** * Get version of the executable. * Version is resolved by splitting the line starting with the version tag and finding * the second last word. */ - private static class HgVersionConsumer - extends HgConsumer - { + private static class HgVersionConsumer extends HgConsumer { private String versionStr = "NA"; private String versionTag; - HgVersionConsumer( String versionTag ) - { + HgVersionConsumer(String versionTag) { this.versionTag = versionTag; } - public void doConsume( ScmFileStatus status, String line ) - { - if ( line.startsWith( versionTag ) ) - { - String[] elements = line.split( " " ); - versionStr = elements[elements.length - 1].split( "\\)" )[0]; + public void doConsume(ScmFileStatus status, String line) { + if (line.startsWith(versionTag)) { + String[] elements = line.split(" "); + versionStr = elements[elements.length - 1].split("\\)")[0]; } } - String getVersion() - { + String getVersion() { return versionStr; } - boolean isVersionOk( String version ) - { + boolean isVersionOk(String version) { // build one number out of the whole version # - return compareVersion( version, versionStr ); + return compareVersion(version, versionStr); } } - private String getInstalledStr() - { - if ( isComplete() ) - { + private String getInstalledStr() { + if (isComplete()) { return "valid and complete."; } - return ( isInstalled() ? "incomplete. " : "invalid. " ) + "Consult " + HG_INSTALL_URL; + return (isInstalled() ? "incomplete. " : "invalid. ") + "Consult " + HG_INSTALL_URL; } - public String toString( File workingDir ) - { - boolean hgOk = hgVersion.isVersionOk( HG_REQ ); + public String toString(File workingDir) { + boolean hgOk = hgVersion.isVersionOk(HG_REQ); return "\n Your Hg installation seems to be " + getInstalledStr() + "\n Hg version: " - + hgVersion.getVersion() + ( hgOk ? " (OK)" : " (May be INVALID)" ) + "\n"; + + hgVersion.getVersion() + (hgOk ? " (OK)" : " (May be INVALID)") + "\n"; } } diff --git a/maven-scm-providers/maven-scm-provider-hg/src/main/java/org/apache/maven/scm/provider/hg/HgScmProvider.java b/maven-scm-providers/maven-scm-provider-hg/src/main/java/org/apache/maven/scm/provider/hg/HgScmProvider.java index a10ca74a5..9747ac547 100644 --- a/maven-scm-providers/maven-scm-provider-hg/src/main/java/org/apache/maven/scm/provider/hg/HgScmProvider.java +++ b/maven-scm-providers/maven-scm-provider-hg/src/main/java/org/apache/maven/scm/provider/hg/HgScmProvider.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.hg; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider.hg; import javax.inject.Named; import javax.inject.Singleton; @@ -68,248 +67,201 @@ * @author thurner rupert */ @Singleton -@Named( "hg" ) -public class HgScmProvider - extends AbstractScmProvider -{ +@Named("hg") +public class HgScmProvider extends AbstractScmProvider { /** {@inheritDoc} */ - public String getScmSpecificFilename() - { + public String getScmSpecificFilename() { return ".hg"; } - private static class HgUrlParserResult - { + private static class HgUrlParserResult { private final List messages = new ArrayList<>(); private ScmProviderRepository repository; } /** {@inheritDoc} */ - public ScmProviderRepository makeProviderScmRepository( String scmSpecificUrl, char delimiter ) - throws ScmRepositoryException - { - HgUrlParserResult result = parseScmUrl( scmSpecificUrl ); - - if ( result.messages.size() > 0 ) - { - throw new ScmRepositoryException( "The scm url is invalid.", result.messages ); + public ScmProviderRepository makeProviderScmRepository(String scmSpecificUrl, char delimiter) + throws ScmRepositoryException { + HgUrlParserResult result = parseScmUrl(scmSpecificUrl); + + if (result.messages.size() > 0) { + throw new ScmRepositoryException("The scm url is invalid.", result.messages); } return result.repository; } - private HgUrlParserResult parseScmUrl( String scmSpecificUrl ) - { + private HgUrlParserResult parseScmUrl(String scmSpecificUrl) { HgUrlParserResult result = new HgUrlParserResult(); // ---------------------------------------------------------------------- // Do some sanity checking of the SVN url // ---------------------------------------------------------------------- - if ( scmSpecificUrl.startsWith( "file" ) ) - { - if ( !scmSpecificUrl.startsWith( "file:///" ) && !scmSpecificUrl.startsWith( "file://localhost/" ) ) - { - result.messages.add( "An hg 'file' url must be on the form 'file:///' or 'file://localhost/'." ); + if (scmSpecificUrl.startsWith("file")) { + if (!scmSpecificUrl.startsWith("file:///") && !scmSpecificUrl.startsWith("file://localhost/")) { + result.messages.add("An hg 'file' url must be on the form 'file:///' or 'file://localhost/'."); return result; } - } - else if ( scmSpecificUrl.startsWith( "https" ) ) - { - if ( !scmSpecificUrl.startsWith( "https://" ) ) - { - result.messages.add( "An hg 'http' url must be on the form 'https://'." ); + } else if (scmSpecificUrl.startsWith("https")) { + if (!scmSpecificUrl.startsWith("https://")) { + result.messages.add("An hg 'http' url must be on the form 'https://'."); return result; } - } - else if ( scmSpecificUrl.startsWith( "http" ) ) - { - if ( !scmSpecificUrl.startsWith( "http://" ) ) - { - result.messages.add( "An hg 'http' url must be on the form 'http://'." ); + } else if (scmSpecificUrl.startsWith("http")) { + if (!scmSpecificUrl.startsWith("http://")) { + result.messages.add("An hg 'http' url must be on the form 'http://'."); return result; } - } - else - { - try - { - @SuppressWarnings( "unused" ) - File file = new File( scmSpecificUrl ); - } - catch ( Throwable e ) - { - result.messages.add( "The filename provided is not valid" ); + } else { + try { + @SuppressWarnings("unused") + File file = new File(scmSpecificUrl); + } catch (Throwable e) { + result.messages.add("The filename provided is not valid"); return result; } - } - result.repository = new HgScmProviderRepository( scmSpecificUrl ); + result.repository = new HgScmProviderRepository(scmSpecificUrl); return result; } /** {@inheritDoc} */ - public ScmProviderRepository makeProviderScmRepository( File path ) - throws ScmRepositoryException, UnknownRepositoryStructure - { - if ( path == null ) - { - throw new NullPointerException( "Path argument is null" ); + public ScmProviderRepository makeProviderScmRepository(File path) + throws ScmRepositoryException, UnknownRepositoryStructure { + if (path == null) { + throw new NullPointerException("Path argument is null"); } - if ( !path.isDirectory() ) - { - throw new ScmRepositoryException( path.getAbsolutePath() + " isn't a valid directory." ); + if (!path.isDirectory()) { + throw new ScmRepositoryException(path.getAbsolutePath() + " isn't a valid directory."); } - File hgDir = new File( path, ".hg" ); + File hgDir = new File(path, ".hg"); - if ( !hgDir.exists() ) - { - throw new ScmRepositoryException( path.getAbsolutePath() + " isn't a hg directory." ); + if (!hgDir.exists()) { + throw new ScmRepositoryException(path.getAbsolutePath() + " isn't a hg directory."); } - return makeProviderScmRepository( path.getAbsolutePath(), ':' ); + return makeProviderScmRepository(path.getAbsolutePath(), ':'); } /** {@inheritDoc} */ - public List validateScmUrl( String scmSpecificUrl, char delimiter ) - { - HgUrlParserResult result = parseScmUrl( scmSpecificUrl ); + public List validateScmUrl(String scmSpecificUrl, char delimiter) { + HgUrlParserResult result = parseScmUrl(scmSpecificUrl); return result.messages; } /** {@inheritDoc} */ - public String getScmType() - { + public String getScmType() { return "hg"; } /** {@inheritDoc} */ - public AddScmResult add( ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters ) - throws ScmException - { + public AddScmResult add(ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters) + throws ScmException { HgAddCommand command = new HgAddCommand(); - return (AddScmResult) command.execute( repository, fileSet, parameters ); + return (AddScmResult) command.execute(repository, fileSet, parameters); } /** {@inheritDoc} */ - public ChangeLogScmResult changelog( ScmProviderRepository repository, ScmFileSet fileSet, - CommandParameters parameters ) - throws ScmException - { + public ChangeLogScmResult changelog( + ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters) throws ScmException { HgChangeLogCommand command = new HgChangeLogCommand(); - return (ChangeLogScmResult) command.execute( repository, fileSet, parameters ); + return (ChangeLogScmResult) command.execute(repository, fileSet, parameters); } /** {@inheritDoc} */ - public CheckInScmResult checkin( ScmProviderRepository repository, ScmFileSet fileSet, - CommandParameters parameters ) - throws ScmException - { + public CheckInScmResult checkin(ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters) + throws ScmException { HgCheckInCommand command = new HgCheckInCommand(); - return (CheckInScmResult) command.execute( repository, fileSet, parameters ); + return (CheckInScmResult) command.execute(repository, fileSet, parameters); } /** {@inheritDoc} */ - public CheckOutScmResult checkout( ScmProviderRepository repository, ScmFileSet fileSet, - CommandParameters parameters ) - throws ScmException - { + public CheckOutScmResult checkout( + ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters) throws ScmException { HgCheckOutCommand command = new HgCheckOutCommand(); - return (CheckOutScmResult) command.execute( repository, fileSet, parameters ); + return (CheckOutScmResult) command.execute(repository, fileSet, parameters); } /** {@inheritDoc} */ - public TagScmResult tag( ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters ) - throws ScmException - { + public TagScmResult tag(ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters) + throws ScmException { HgTagCommand command = new HgTagCommand(); - return (TagScmResult) command.execute( repository, fileSet, parameters ); + return (TagScmResult) command.execute(repository, fileSet, parameters); } /** {@inheritDoc} */ - public DiffScmResult diff( ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters ) - throws ScmException - { + public DiffScmResult diff(ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters) + throws ScmException { HgDiffCommand command = new HgDiffCommand(); - return (DiffScmResult) command.execute( repository, fileSet, parameters ); + return (DiffScmResult) command.execute(repository, fileSet, parameters); } /** {@inheritDoc} */ - public RemoveScmResult remove( ScmProviderRepository repository, ScmFileSet fileSet, - CommandParameters parameters ) - throws ScmException - { + public RemoveScmResult remove(ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters) + throws ScmException { HgRemoveCommand command = new HgRemoveCommand(); - return (RemoveScmResult) command.execute( repository, fileSet, parameters ); + return (RemoveScmResult) command.execute(repository, fileSet, parameters); } /** {@inheritDoc} */ - public StatusScmResult status( ScmProviderRepository repository, ScmFileSet fileSet, - CommandParameters parameters ) - throws ScmException - { + public StatusScmResult status(ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters) + throws ScmException { HgStatusCommand command = new HgStatusCommand(); - return (StatusScmResult) command.execute( repository, fileSet, parameters ); + return (StatusScmResult) command.execute(repository, fileSet, parameters); } /** {@inheritDoc} */ - public UpdateScmResult update( ScmProviderRepository repository, ScmFileSet fileSet, - CommandParameters parameters ) - throws ScmException - { + public UpdateScmResult update(ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters) + throws ScmException { HgUpdateCommand command = new HgUpdateCommand(); - return (UpdateScmResult) command.execute( repository, fileSet, parameters ); + return (UpdateScmResult) command.execute(repository, fileSet, parameters); } /** {@inheritDoc} */ - protected BlameScmResult blame( ScmProviderRepository repository, ScmFileSet fileSet, - CommandParameters parameters ) - throws ScmException - { + protected BlameScmResult blame(ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters) + throws ScmException { HgBlameCommand command = new HgBlameCommand(); - return (BlameScmResult) command.execute( repository, fileSet, parameters ); + return (BlameScmResult) command.execute(repository, fileSet, parameters); } /** {@inheritDoc} */ - public BranchScmResult branch( ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters ) - throws ScmException - { + public BranchScmResult branch(ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters) + throws ScmException { HgBranchCommand command = new HgBranchCommand(); - return (BranchScmResult) command.execute( repository, fileSet, parameters ); + return (BranchScmResult) command.execute(repository, fileSet, parameters); } /** * @since 1.5 */ @Override - protected ListScmResult list( ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters ) - throws ScmException - { + protected ListScmResult list(ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters) + throws ScmException { HgListCommand hgListCommand = new HgListCommand(); - return (ListScmResult) hgListCommand.executeCommand( repository, fileSet, parameters ); - + return (ListScmResult) hgListCommand.executeCommand(repository, fileSet, parameters); } /** @@ -318,11 +270,10 @@ protected ListScmResult list( ScmProviderRepository repository, ScmFileSet fileS * @see org.apache.maven.scm.provider.AbstractScmProvider#info(org.apache.maven.scm.provider.ScmProviderRepository, org.apache.maven.scm.ScmFileSet, org.apache.maven.scm.CommandParameters) */ @Override - public InfoScmResult info( ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters ) - throws ScmException - { + public InfoScmResult info(ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters) + throws ScmException { HgInfoCommand infoCommand = new HgInfoCommand(); - return (InfoScmResult) infoCommand.execute( repository, fileSet, parameters ); + return (InfoScmResult) infoCommand.execute(repository, fileSet, parameters); } } diff --git a/maven-scm-providers/maven-scm-provider-hg/src/main/java/org/apache/maven/scm/provider/hg/HgUtils.java b/maven-scm-providers/maven-scm-provider-hg/src/main/java/org/apache/maven/scm/provider/hg/HgUtils.java index 0694c15da..9f879be44 100644 --- a/maven-scm-providers/maven-scm-provider-hg/src/main/java/org/apache/maven/scm/provider/hg/HgUtils.java +++ b/maven-scm-providers/maven-scm-provider-hg/src/main/java/org/apache/maven/scm/provider/hg/HgUtils.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.hg; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,13 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider.hg; + +import java.io.File; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; import org.apache.maven.scm.ScmException; import org.apache.maven.scm.ScmFileSet; @@ -33,26 +38,18 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import java.io.File; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - /** * Common code for executing hg commands. * * @author thurner rupert * */ -public final class HgUtils -{ - private static final Logger LOGGER = LoggerFactory.getLogger( HgUtils.class ); +public final class HgUtils { + private static final Logger LOGGER = LoggerFactory.getLogger(HgUtils.class); public static final String DEFAULT = "default"; - private HgUtils() - { + private HgUtils() { // no op } @@ -67,141 +64,114 @@ private HgUtils() private static final List DEFAULT_EXIT_CODES = new ArrayList(); /** Setup exit codes*/ - static - { - DEFAULT_EXIT_CODES.add( Integer.valueOf( 0 ) ); - - //Diff is different - List diffExitCodes = new ArrayList( 3 ); - diffExitCodes.add( Integer.valueOf( 0 ) ); //No difference - diffExitCodes.add( Integer.valueOf( 1 ) ); //Conflicts in merge-like or changes in diff-like - diffExitCodes.add( Integer.valueOf( 2 ) ); //Unrepresentable diff changes - EXIT_CODE_MAP.put( HgCommandConstants.DIFF_CMD, diffExitCodes ); - //Outgoing is different - List outgoingExitCodes = new ArrayList( 2 ); - outgoingExitCodes.add( Integer.valueOf( 0 ) ); //There are changes - outgoingExitCodes.add( Integer.valueOf( 1 ) ); //No changes - EXIT_CODE_MAP.put( HgCommandConstants.OUTGOING_CMD, outgoingExitCodes ); + static { + DEFAULT_EXIT_CODES.add(Integer.valueOf(0)); + + // Diff is different + List diffExitCodes = new ArrayList(3); + diffExitCodes.add(Integer.valueOf(0)); // No difference + diffExitCodes.add(Integer.valueOf(1)); // Conflicts in merge-like or changes in diff-like + diffExitCodes.add(Integer.valueOf(2)); // Unrepresentable diff changes + EXIT_CODE_MAP.put(HgCommandConstants.DIFF_CMD, diffExitCodes); + // Outgoing is different + List outgoingExitCodes = new ArrayList(2); + outgoingExitCodes.add(Integer.valueOf(0)); // There are changes + outgoingExitCodes.add(Integer.valueOf(1)); // No changes + EXIT_CODE_MAP.put(HgCommandConstants.OUTGOING_CMD, outgoingExitCodes); } - public static ScmResult execute( HgConsumer consumer, File workingDir, String[] cmdAndArgs ) - throws ScmException - { - try - { - //Build commandline - Commandline cmd = buildCmd( workingDir, cmdAndArgs ); - if ( LOGGER.isInfoEnabled() ) - { - LOGGER.info( "EXECUTING: " + maskPassword( cmd ) ); + public static ScmResult execute(HgConsumer consumer, File workingDir, String[] cmdAndArgs) throws ScmException { + try { + // Build commandline + Commandline cmd = buildCmd(workingDir, cmdAndArgs); + if (LOGGER.isInfoEnabled()) { + LOGGER.info("EXECUTING: " + maskPassword(cmd)); } - //Execute command - int exitCode = executeCmd( consumer, cmd ); + // Execute command + int exitCode = executeCmd(consumer, cmd); - //Return result + // Return result List exitCodes = DEFAULT_EXIT_CODES; - if ( EXIT_CODE_MAP.containsKey( cmdAndArgs[0] ) ) - { - exitCodes = EXIT_CODE_MAP.get( cmdAndArgs[0] ); + if (EXIT_CODE_MAP.containsKey(cmdAndArgs[0])) { + exitCodes = EXIT_CODE_MAP.get(cmdAndArgs[0]); } - boolean success = exitCodes.contains( Integer.valueOf( exitCode ) ); + boolean success = exitCodes.contains(Integer.valueOf(exitCode)); - //On failure (and not due to exceptions) - run diagnostics + // On failure (and not due to exceptions) - run diagnostics String providerMsg = "Execution of hg command succeded"; - if ( !success ) - { - HgConfig config = new HgConfig( workingDir ); - providerMsg = - "\nEXECUTION FAILED" + "\n Execution of cmd : " + cmdAndArgs[0] + " failed with exit code: " + if (!success) { + HgConfig config = new HgConfig(workingDir); + providerMsg = "\nEXECUTION FAILED" + "\n Execution of cmd : " + cmdAndArgs[0] + + " failed with exit code: " + exitCode + "." + "\n Working directory was: " + "\n " + workingDir.getAbsolutePath() - + config.toString( workingDir ) + "\n"; - if ( LOGGER.isErrorEnabled() ) - { - LOGGER.error( providerMsg ); + + config.toString(workingDir) + "\n"; + if (LOGGER.isErrorEnabled()) { + LOGGER.error(providerMsg); } } - return new ScmResult( cmd.toString(), providerMsg, consumer.getStdErr(), success ); - } - catch ( ScmException se ) - { - String msg = - "EXECUTION FAILED" + "\n Execution failed before invoking the Hg command. Last exception:" + "\n " - + se.getMessage(); - - //Add nested cause if any - if ( se.getCause() != null ) - { + return new ScmResult(cmd.toString(), providerMsg, consumer.getStdErr(), success); + } catch (ScmException se) { + String msg = "EXECUTION FAILED" + "\n Execution failed before invoking the Hg command. Last exception:" + + "\n " + se.getMessage(); + + // Add nested cause if any + if (se.getCause() != null) { msg += "\n Nested exception:" + "\n " + se.getCause().getMessage(); } - //log and return - if ( LOGGER.isErrorEnabled() ) - { - LOGGER.error( msg ); + // log and return + if (LOGGER.isErrorEnabled()) { + LOGGER.error(msg); } throw se; } } - static Commandline buildCmd( File workingDir, String[] cmdAndArgs ) - throws ScmException - { + static Commandline buildCmd(File workingDir, String[] cmdAndArgs) throws ScmException { Commandline cmd = new Commandline(); - cmd.setExecutable( HgCommandConstants.EXEC ); - cmd.addArguments( cmdAndArgs ); - if ( workingDir != null ) - { - cmd.setWorkingDirectory( workingDir.getAbsolutePath() ); - - if ( !workingDir.exists() ) - { + cmd.setExecutable(HgCommandConstants.EXEC); + cmd.addArguments(cmdAndArgs); + if (workingDir != null) { + cmd.setWorkingDirectory(workingDir.getAbsolutePath()); + + if (!workingDir.exists()) { boolean success = workingDir.mkdirs(); - if ( !success ) - { + if (!success) { String msg = "Working directory did not exist" + " and it couldn't be created: " + workingDir; - throw new ScmException( msg ); + throw new ScmException(msg); } } } return cmd; } - static int executeCmd( HgConsumer consumer, Commandline cmd ) - throws ScmException - { + static int executeCmd(HgConsumer consumer, Commandline cmd) throws ScmException { final int exitCode; - try - { - exitCode = CommandLineUtils.executeCommandLine( cmd, consumer, consumer ); - } - catch ( CommandLineException ex ) - { - throw new ScmException( "Command could not be executed: " + cmd, ex ); + try { + exitCode = CommandLineUtils.executeCommandLine(cmd, consumer, consumer); + } catch (CommandLineException ex) { + throw new ScmException("Command could not be executed: " + cmd, ex); } return exitCode; } - public static ScmResult execute( File workingDir, String[] cmdAndArgs ) - throws ScmException - { - return execute( new HgConsumer(), workingDir, cmdAndArgs ); + public static ScmResult execute(File workingDir, String[] cmdAndArgs) throws ScmException { + return execute(new HgConsumer(), workingDir, cmdAndArgs); } - public static String[] expandCommandLine( String[] cmdAndArgs, ScmFileSet additionalFiles ) - { + public static String[] expandCommandLine(String[] cmdAndArgs, ScmFileSet additionalFiles) { List filesList = additionalFiles.getFileList(); String[] cmd = new String[filesList.size() + cmdAndArgs.length]; // Copy command into array - System.arraycopy( cmdAndArgs, 0, cmd, 0, cmdAndArgs.length ); + System.arraycopy(cmdAndArgs, 0, cmd, 0, cmdAndArgs.length); // Add files as additional parameter into the array int i = 0; - for ( File scmFile : filesList ) - { - String file = scmFile.getPath().replace( '\\', File.separatorChar ); + for (File scmFile : filesList) { + String file = scmFile.getPath().replace('\\', File.separatorChar); cmd[i + cmdAndArgs.length] = file; i++; } @@ -209,23 +179,19 @@ public static String[] expandCommandLine( String[] cmdAndArgs, ScmFileSet additi return cmd; } - public static int getCurrentRevisionNumber( File workingDir ) - throws ScmException - { + public static int getCurrentRevisionNumber(File workingDir) throws ScmException { - String[] revCmd = new String[]{ HgCommandConstants.REVNO_CMD }; + String[] revCmd = new String[] {HgCommandConstants.REVNO_CMD}; HgRevNoConsumer consumer = new HgRevNoConsumer(); - HgUtils.execute( consumer, workingDir, revCmd ); + HgUtils.execute(consumer, workingDir, revCmd); return consumer.getCurrentRevisionNumber(); } - public static String getCurrentBranchName( File workingDir ) - throws ScmException - { - String[] branchnameCmd = new String[]{ HgCommandConstants.BRANCH_NAME_CMD }; + public static String getCurrentBranchName(File workingDir) throws ScmException { + String[] branchnameCmd = new String[] {HgCommandConstants.BRANCH_NAME_CMD}; HgBranchnameConsumer consumer = new HgBranchnameConsumer(); - HgUtils.execute( consumer, workingDir, branchnameCmd ); + HgUtils.execute(consumer, workingDir, branchnameCmd); return consumer.getBranchName(); } @@ -234,26 +200,19 @@ public static String getCurrentBranchName( File workingDir ) *

* Resolve revision to the last integer found in the command output. */ - private static class HgRevNoConsumer - extends HgConsumer - { + private static class HgRevNoConsumer extends HgConsumer { private int revNo; - public void doConsume( ScmFileStatus status, String line ) - { - try - { - revNo = Integer.valueOf( line ).intValue(); - } - catch ( NumberFormatException e ) - { + public void doConsume(ScmFileStatus status, String line) { + try { + revNo = Integer.valueOf(line).intValue(); + } catch (NumberFormatException e) { // ignore } } - int getCurrentRevisionNumber() - { + int getCurrentRevisionNumber() { return revNo; } } @@ -261,36 +220,29 @@ int getCurrentRevisionNumber() /** * Get current (working) branch name */ - private static class HgBranchnameConsumer - extends HgConsumer - { + private static class HgBranchnameConsumer extends HgConsumer { private String branchName; - public void doConsume( ScmFileStatus status, String trimmedLine ) - { - branchName = String.valueOf( trimmedLine ); + public void doConsume(ScmFileStatus status, String trimmedLine) { + branchName = String.valueOf(trimmedLine); } - String getBranchName() - { + String getBranchName() { return branchName; } /** {@inheritDoc} */ - public void consumeLine( String line ) - { - if ( logger.isDebugEnabled() ) - { - logger.debug( line ); + public void consumeLine(String line) { + if (logger.isDebugEnabled()) { + logger.debug(line); } String trimmedLine = line.trim(); - doConsume( null, trimmedLine ); + doConsume(null, trimmedLine); } } - /** * Check if there are outgoing changes on a different branch. If so, Mercurial default behaviour * is to block the push and warn using a 'push creates new remote branch !' message. @@ -304,22 +256,17 @@ public void consumeLine( String line ) * @return true if a different outgoing branch was found * @throws ScmException on outgoing command error */ - public static boolean differentOutgoingBranchFound( File workingDir, String workingbranchName ) - throws ScmException - { - String[] outCmd = new String[]{ HgCommandConstants.OUTGOING_CMD }; + public static boolean differentOutgoingBranchFound(File workingDir, String workingbranchName) throws ScmException { + String[] outCmd = new String[] {HgCommandConstants.OUTGOING_CMD}; HgOutgoingConsumer outConsumer = new HgOutgoingConsumer(); - ScmResult outResult = HgUtils.execute( outConsumer, workingDir, outCmd ); + ScmResult outResult = HgUtils.execute(outConsumer, workingDir, outCmd); List changes = outConsumer.getChanges(); - if ( outResult.isSuccess() ) - { - for ( HgChangeSet set : changes ) - { - if ( !getBranchName( workingbranchName ).equals( getBranchName( set.getBranch() ) ) ) - { - LOGGER.warn( "A different branch than " + getBranchName( workingbranchName ) - + " was found in outgoing changes, branch name was " + getBranchName( set.getBranch() ) - + ". Only local branch named " + getBranchName( workingbranchName ) + " will be pushed." ); + if (outResult.isSuccess()) { + for (HgChangeSet set : changes) { + if (!getBranchName(workingbranchName).equals(getBranchName(set.getBranch()))) { + LOGGER.warn("A different branch than " + getBranchName(workingbranchName) + + " was found in outgoing changes, branch name was " + getBranchName(set.getBranch()) + + ". Only local branch named " + getBranchName(workingbranchName) + " will be pushed."); return true; } } @@ -327,20 +274,17 @@ public static boolean differentOutgoingBranchFound( File workingDir, String work return false; } - private static String getBranchName( String branch ) - { + private static String getBranchName(String branch) { return branch == null ? DEFAULT : branch; } - public static String maskPassword( Commandline cl ) - { + public static String maskPassword(Commandline cl) { String clString = cl.toString(); - int pos = clString.indexOf( '@' ); + int pos = clString.indexOf('@'); - if ( pos > 0 ) - { - clString = clString.replaceAll( ":\\w+@", ":*****@" ); + if (pos > 0) { + clString = clString.replaceAll(":\\w+@", ":*****@"); } return clString; diff --git a/maven-scm-providers/maven-scm-provider-hg/src/main/java/org/apache/maven/scm/provider/hg/command/HgCommandConstants.java b/maven-scm-providers/maven-scm-provider-hg/src/main/java/org/apache/maven/scm/provider/hg/command/HgCommandConstants.java index ede3501ee..416f60c29 100644 --- a/maven-scm-providers/maven-scm-provider-hg/src/main/java/org/apache/maven/scm/provider/hg/command/HgCommandConstants.java +++ b/maven-scm-providers/maven-scm-provider-hg/src/main/java/org/apache/maven/scm/provider/hg/command/HgCommandConstants.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.hg.command; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ - +package org.apache.maven.scm.provider.hg.command; /** * Available/Used hg commands. @@ -28,11 +26,9 @@ * * @author thurner rupert */ -public final class HgCommandConstants -{ +public final class HgCommandConstants { - private HgCommandConstants() - { + private HgCommandConstants() { // no o } @@ -164,6 +160,6 @@ private HgCommandConstants() * verbose format for log command. */ public static final String TEMPLATE_FORMAT = - "changeset: {rev}:{node|short}\\nbranch: {branch}\\nuser: {author}\\n" - + "date: {date|isodatesec}\\ntag: {tags}\\nfiles: {files}\\ndescription:\\n{desc}\\n"; + "changeset: {rev}:{node|short}\\nbranch: {branch}\\nuser: {author}\\n" + + "date: {date|isodatesec}\\ntag: {tags}\\nfiles: {files}\\ndescription:\\n{desc}\\n"; } diff --git a/maven-scm-providers/maven-scm-provider-hg/src/main/java/org/apache/maven/scm/provider/hg/command/HgConsumer.java b/maven-scm-providers/maven-scm-provider-hg/src/main/java/org/apache/maven/scm/provider/hg/command/HgConsumer.java index 0523b0a28..b1648808d 100644 --- a/maven-scm-providers/maven-scm-provider-hg/src/main/java/org/apache/maven/scm/provider/hg/command/HgConsumer.java +++ b/maven-scm-providers/maven-scm-provider-hg/src/main/java/org/apache/maven/scm/provider/hg/command/HgConsumer.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.hg.command; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,9 +16,7 @@ * specific language governing permissions and limitations * under the License. */ - -import org.apache.maven.scm.ScmFileStatus; -import org.apache.maven.scm.util.AbstractConsumer; +package org.apache.maven.scm.provider.hg.command; import java.util.ArrayList; import java.util.HashMap; @@ -28,6 +24,9 @@ import java.util.List; import java.util.Map; +import org.apache.maven.scm.ScmFileStatus; +import org.apache.maven.scm.util.AbstractConsumer; + /** * Base consumer to do common parsing for all hg commands. *

@@ -37,9 +36,7 @@ * @author thurner rupert * */ -public class HgConsumer - extends AbstractConsumer -{ +public class HgConsumer extends AbstractConsumer { /** * A list of known keywords from hg @@ -63,66 +60,58 @@ public class HgConsumer */ private final List stderr = new ArrayList<>(); - static - { + static { /* Statuses from hg add */ - IDENTIFIERS.put( "adding", ScmFileStatus.ADDED ); - IDENTIFIERS.put( "unknown", ScmFileStatus.UNKNOWN ); - IDENTIFIERS.put( "modified", ScmFileStatus.MODIFIED ); - IDENTIFIERS.put( "removed", ScmFileStatus.DELETED ); - IDENTIFIERS.put( "renamed", ScmFileStatus.MODIFIED ); + IDENTIFIERS.put("adding", ScmFileStatus.ADDED); + IDENTIFIERS.put("unknown", ScmFileStatus.UNKNOWN); + IDENTIFIERS.put("modified", ScmFileStatus.MODIFIED); + IDENTIFIERS.put("removed", ScmFileStatus.DELETED); + IDENTIFIERS.put("renamed", ScmFileStatus.MODIFIED); /* Statuses from hg status; */ - IDENTIFIERS.put( "A", ScmFileStatus.ADDED ); - IDENTIFIERS.put( "?", ScmFileStatus.UNKNOWN ); - IDENTIFIERS.put( "M", ScmFileStatus.MODIFIED ); - IDENTIFIERS.put( "R", ScmFileStatus.DELETED ); - IDENTIFIERS.put( "C", ScmFileStatus.CHECKED_IN ); - IDENTIFIERS.put( "!", ScmFileStatus.MISSING ); - IDENTIFIERS.put( "I", ScmFileStatus.UNKNOWN ); // not precisely the same, but i think semantics work? - rwd - - MESSAGES.put( "hg: WARNING:", "WARNING" ); - MESSAGES.put( "hg: ERROR:", "ERROR" ); - MESSAGES.put( "'hg' ", "ERROR" ); // hg isn't found in windows path + IDENTIFIERS.put("A", ScmFileStatus.ADDED); + IDENTIFIERS.put("?", ScmFileStatus.UNKNOWN); + IDENTIFIERS.put("M", ScmFileStatus.MODIFIED); + IDENTIFIERS.put("R", ScmFileStatus.DELETED); + IDENTIFIERS.put("C", ScmFileStatus.CHECKED_IN); + IDENTIFIERS.put("!", ScmFileStatus.MISSING); + IDENTIFIERS.put("I", ScmFileStatus.UNKNOWN); // not precisely the same, but i think semantics work? - rwd + + MESSAGES.put("hg: WARNING:", "WARNING"); + MESSAGES.put("hg: ERROR:", "ERROR"); + MESSAGES.put("'hg' ", "ERROR"); // hg isn't found in windows path } - public void doConsume( ScmFileStatus status, String trimmedLine ) - { - //override this + public void doConsume(ScmFileStatus status, String trimmedLine) { + // override this } /** {@inheritDoc} */ - public void consumeLine( String line ) - { - if ( logger.isDebugEnabled() ) - { - logger.debug( line ); + public void consumeLine(String line) { + if (logger.isDebugEnabled()) { + logger.debug(line); } String trimmedLine = line.trim(); - String statusStr = processInputForKnownIdentifiers( trimmedLine ); + String statusStr = processInputForKnownIdentifiers(trimmedLine); - //If its not a status report - then maybe its a message? - if ( statusStr == null ) - { - boolean isMessage = processInputForKnownMessages( trimmedLine ); - //If it is then its already processed and we can ignore futher processing - if ( isMessage ) - { + // If its not a status report - then maybe its a message? + if (statusStr == null) { + boolean isMessage = processInputForKnownMessages(trimmedLine); + // If it is then its already processed and we can ignore futher processing + if (isMessage) { return; } - } - else - { - //Strip away identifier - trimmedLine = trimmedLine.substring( statusStr.length() ); - trimmedLine = trimmedLine.trim(); //one or more spaces + } else { + // Strip away identifier + trimmedLine = trimmedLine.substring(statusStr.length()); + trimmedLine = trimmedLine.trim(); // one or more spaces } - ScmFileStatus status = statusStr != null ? ( IDENTIFIERS.get( statusStr.intern() ) ) : null; - doConsume( status, trimmedLine ); + ScmFileStatus status = statusStr != null ? (IDENTIFIERS.get(statusStr.intern())) : null; + doConsume(status, trimmedLine); } /** @@ -131,54 +120,40 @@ public void consumeLine( String line ) * * @return Return the last lines interpreted as an warning or an error */ - public String getStdErr() - { + public String getStdErr() { StringBuilder str = new StringBuilder(); - for ( Iterator it = stderr.iterator(); it.hasNext(); ) - { - str.append( it.next() ); + for (Iterator it = stderr.iterator(); it.hasNext(); ) { + str.append(it.next()); } return str.toString(); } - private static String processInputForKnownIdentifiers( String line ) - { - for ( Iterator it = IDENTIFIERS.keySet().iterator(); it.hasNext(); ) - { + private static String processInputForKnownIdentifiers(String line) { + for (Iterator it = IDENTIFIERS.keySet().iterator(); it.hasNext(); ) { String id = it.next(); - if ( line.startsWith( id ) ) - { + if (line.startsWith(id)) { return id; } } return null; } - private boolean processInputForKnownMessages( String line ) - { - for ( Iterator it = MESSAGES.keySet().iterator(); it.hasNext(); ) - { + private boolean processInputForKnownMessages(String line) { + for (Iterator it = MESSAGES.keySet().iterator(); it.hasNext(); ) { String prefix = it.next(); - if ( line.startsWith( prefix ) ) - { - stderr.add( line ); //Add line - if ( stderr.size() > MAX_STDERR_SIZE ) - { - stderr.remove( 0 ); //Rotate list + if (line.startsWith(prefix)) { + stderr.add(line); // Add line + if (stderr.size() > MAX_STDERR_SIZE) { + stderr.remove(0); // Rotate list } - String message = line.substring( prefix.length() ); - if ( MESSAGES.get( prefix ).equals( "WARNING" ) ) - { - if ( logger.isWarnEnabled() ) - { - logger.warn( message ); + String message = line.substring(prefix.length()); + if (MESSAGES.get(prefix).equals("WARNING")) { + if (logger.isWarnEnabled()) { + logger.warn(message); } - } - else - { - if ( logger.isErrorEnabled() ) - { - logger.error( message ); + } else { + if (logger.isErrorEnabled()) { + logger.error(message); } } return true; diff --git a/maven-scm-providers/maven-scm-provider-hg/src/main/java/org/apache/maven/scm/provider/hg/command/add/HgAddCommand.java b/maven-scm-providers/maven-scm-provider-hg/src/main/java/org/apache/maven/scm/provider/hg/command/add/HgAddCommand.java index 764692db1..22f722a02 100644 --- a/maven-scm-providers/maven-scm-provider-hg/src/main/java/org/apache/maven/scm/provider/hg/command/add/HgAddCommand.java +++ b/maven-scm-providers/maven-scm-provider-hg/src/main/java/org/apache/maven/scm/provider/hg/command/add/HgAddCommand.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.hg.command.add; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider.hg.command.add; import java.io.File; @@ -39,33 +38,26 @@ * @author thurner rupert * */ -public class HgAddCommand - extends AbstractAddCommand - implements Command -{ +public class HgAddCommand extends AbstractAddCommand implements Command { /** {@inheritDoc} */ - protected ScmResult executeAddCommand( ScmProviderRepository repo, ScmFileSet fileSet, String message, - boolean binary ) - throws ScmException - { - //String[] addCmd = new String[] { ADD_CMD, NO_RECURSE_OPTION }; - String[] addCmd = new String[] { HgCommandConstants.ADD_CMD, HgCommandConstants.VERBOSE_OPTION }; - addCmd = HgUtils.expandCommandLine( addCmd, fileSet ); + protected ScmResult executeAddCommand( + ScmProviderRepository repo, ScmFileSet fileSet, String message, boolean binary) throws ScmException { + // String[] addCmd = new String[] { ADD_CMD, NO_RECURSE_OPTION }; + String[] addCmd = new String[] {HgCommandConstants.ADD_CMD, HgCommandConstants.VERBOSE_OPTION}; + addCmd = HgUtils.expandCommandLine(addCmd, fileSet); File workingDir = fileSet.getBasedir(); - HgAddConsumer consumer = new HgAddConsumer( workingDir ); - ScmResult result = HgUtils.execute( consumer, workingDir, addCmd ); + HgAddConsumer consumer = new HgAddConsumer(workingDir); + ScmResult result = HgUtils.execute(consumer, workingDir, addCmd); - AddScmResult addScmResult = new AddScmResult( consumer.getAddedFiles(), result ); + AddScmResult addScmResult = new AddScmResult(consumer.getAddedFiles(), result); // add in bogus 'added' results for empty directories. only need to do this because the maven scm unit test // framework seems to think that this is the way we should behave. it's pretty hacky. -rwd - for ( File workingFile : fileSet.getFileList() ) - { - File file = new File( workingDir + "/" + workingFile.getPath() ); - if ( file.isDirectory() && file.listFiles().length == 0 ) - { - addScmResult.getAddedFiles().add( new ScmFile( workingFile.getPath(), ScmFileStatus.ADDED ) ); + for (File workingFile : fileSet.getFileList()) { + File file = new File(workingDir + "/" + workingFile.getPath()); + if (file.isDirectory() && file.listFiles().length == 0) { + addScmResult.getAddedFiles().add(new ScmFile(workingFile.getPath(), ScmFileStatus.ADDED)); } } diff --git a/maven-scm-providers/maven-scm-provider-hg/src/main/java/org/apache/maven/scm/provider/hg/command/add/HgAddConsumer.java b/maven-scm-providers/maven-scm-provider-hg/src/main/java/org/apache/maven/scm/provider/hg/command/add/HgAddConsumer.java index dca065491..c2f077485 100644 --- a/maven-scm-providers/maven-scm-provider-hg/src/main/java/org/apache/maven/scm/provider/hg/command/add/HgAddConsumer.java +++ b/maven-scm-providers/maven-scm-provider-hg/src/main/java/org/apache/maven/scm/provider/hg/command/add/HgAddConsumer.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.hg.command.add; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,59 +16,49 @@ * specific language governing permissions and limitations * under the License. */ - -import org.apache.maven.scm.ScmFile; -import org.apache.maven.scm.ScmFileStatus; -import org.apache.maven.scm.provider.hg.command.HgConsumer; +package org.apache.maven.scm.provider.hg.command.add; import java.io.File; import java.util.ArrayList; import java.util.List; +import org.apache.maven.scm.ScmFile; +import org.apache.maven.scm.ScmFileStatus; +import org.apache.maven.scm.provider.hg.command.HgConsumer; + /** * @author thurner rupert * */ -public class HgAddConsumer - extends HgConsumer -{ +public class HgAddConsumer extends HgConsumer { private final File workingDir; private final List addedFiles = new ArrayList(); - public HgAddConsumer( File workingDir ) - { + public HgAddConsumer(File workingDir) { this.workingDir = workingDir; } /** {@inheritDoc} */ - public void doConsume( ScmFileStatus status, String trimmedLine ) - { - if ( status != null && status == ScmFileStatus.ADDED ) - { - //Only include real files (not directories) - File tmpFile = new File( workingDir, trimmedLine ); - if ( !tmpFile.exists() ) - { - if ( logger.isWarnEnabled() ) - { - logger.warn( "Not a file: " + tmpFile + ". Ignored" ); + public void doConsume(ScmFileStatus status, String trimmedLine) { + if (status != null && status == ScmFileStatus.ADDED) { + // Only include real files (not directories) + File tmpFile = new File(workingDir, trimmedLine); + if (!tmpFile.exists()) { + if (logger.isWarnEnabled()) { + logger.warn("Not a file: " + tmpFile + ". Ignored"); } - } - else - { - ScmFile scmFile = new ScmFile( trimmedLine, ScmFileStatus.ADDED ); - if ( logger.isInfoEnabled() ) - { - logger.info( scmFile.toString() ); + } else { + ScmFile scmFile = new ScmFile(trimmedLine, ScmFileStatus.ADDED); + if (logger.isInfoEnabled()) { + logger.info(scmFile.toString()); } - addedFiles.add( scmFile ); + addedFiles.add(scmFile); } } } - public List getAddedFiles() - { + public List getAddedFiles() { return addedFiles; } } diff --git a/maven-scm-providers/maven-scm-provider-hg/src/main/java/org/apache/maven/scm/provider/hg/command/blame/HgBlameCommand.java b/maven-scm-providers/maven-scm-provider-hg/src/main/java/org/apache/maven/scm/provider/hg/command/blame/HgBlameCommand.java index 87b9c0818..4e83c5a19 100644 --- a/maven-scm-providers/maven-scm-provider-hg/src/main/java/org/apache/maven/scm/provider/hg/command/blame/HgBlameCommand.java +++ b/maven-scm-providers/maven-scm-provider-hg/src/main/java/org/apache/maven/scm/provider/hg/command/blame/HgBlameCommand.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.hg.command.blame; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider.hg.command.blame; import org.apache.maven.scm.ScmException; import org.apache.maven.scm.ScmFileSet; @@ -32,24 +31,23 @@ * @author Olivier Lamy * @since 1.4 */ -public class HgBlameCommand - extends AbstractBlameCommand -{ +public class HgBlameCommand extends AbstractBlameCommand { public static final String BLAME_CMD = "blame"; /** * {@inheritDoc} */ - public BlameScmResult executeBlameCommand( ScmProviderRepository repo, ScmFileSet workingDirectory, - String filename ) - throws ScmException - { - String[] cmd = new String[]{ BLAME_CMD, "--user", // list the author - "--date", // list the date + public BlameScmResult executeBlameCommand(ScmProviderRepository repo, ScmFileSet workingDirectory, String filename) + throws ScmException { + String[] cmd = new String[] { + BLAME_CMD, + "--user", // list the author + "--date", // list the date "--changeset", // list the global revision number - filename }; + filename + }; HgBlameConsumer consumer = new HgBlameConsumer(); - ScmResult result = HgUtils.execute( consumer, workingDirectory.getBasedir(), cmd ); - return new BlameScmResult( consumer.getLines(), result ); + ScmResult result = HgUtils.execute(consumer, workingDirectory.getBasedir(), cmd); + return new BlameScmResult(consumer.getLines(), result); } } diff --git a/maven-scm-providers/maven-scm-provider-hg/src/main/java/org/apache/maven/scm/provider/hg/command/blame/HgBlameConsumer.java b/maven-scm-providers/maven-scm-provider-hg/src/main/java/org/apache/maven/scm/provider/hg/command/blame/HgBlameConsumer.java index 26ad8c615..79c29c292 100644 --- a/maven-scm-providers/maven-scm-provider-hg/src/main/java/org/apache/maven/scm/provider/hg/command/blame/HgBlameConsumer.java +++ b/maven-scm-providers/maven-scm-provider-hg/src/main/java/org/apache/maven/scm/provider/hg/command/blame/HgBlameConsumer.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.hg.command.blame; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,56 +16,49 @@ * specific language governing permissions and limitations * under the License. */ - -import org.apache.maven.scm.ScmFileStatus; -import org.apache.maven.scm.command.blame.BlameLine; -import org.apache.maven.scm.provider.hg.command.HgConsumer; +package org.apache.maven.scm.provider.hg.command.blame; import java.util.ArrayList; import java.util.Date; import java.util.List; import java.util.Locale; +import org.apache.maven.scm.ScmFileStatus; +import org.apache.maven.scm.command.blame.BlameLine; +import org.apache.maven.scm.provider.hg.command.HgConsumer; /** * @author Evgeny Mandrikov * @author Olivier Lamy * @since 1.4 */ -public class HgBlameConsumer - extends HgConsumer -{ +public class HgBlameConsumer extends HgConsumer { private final List lines = new ArrayList<>(); private static final String HG_TIMESTAMP_PATTERN = "EEE MMM dd HH:mm:ss yyyy Z"; - public void doConsume( ScmFileStatus status, String trimmedLine ) - { + public void doConsume(ScmFileStatus status, String trimmedLine) { /* godin 0 Sun Jan 31 03:04:54 2010 +0300 */ String annotation; - if ( trimmedLine.indexOf( ": " ) > -1 ) - { - annotation = trimmedLine.substring( 0, trimmedLine.indexOf( ": " ) ).trim(); - } - else - { - annotation = trimmedLine.substring( 0, trimmedLine.lastIndexOf( ":" ) ).trim(); + if (trimmedLine.indexOf(": ") > -1) { + annotation = trimmedLine.substring(0, trimmedLine.indexOf(": ")).trim(); + } else { + annotation = trimmedLine.substring(0, trimmedLine.lastIndexOf(":")).trim(); } - String author = annotation.substring( 0, annotation.indexOf( ' ' ) ); - annotation = annotation.substring( annotation.indexOf( ' ' ) + 1 ).trim(); + String author = annotation.substring(0, annotation.indexOf(' ')); + annotation = annotation.substring(annotation.indexOf(' ') + 1).trim(); - String revision = annotation.substring( 0, annotation.indexOf( ' ' ) ); - annotation = annotation.substring( annotation.indexOf( ' ' ) + 1 ).trim(); + String revision = annotation.substring(0, annotation.indexOf(' ')); + annotation = annotation.substring(annotation.indexOf(' ') + 1).trim(); String dateStr = annotation; - Date dateTime = parseDate( dateStr, null, HG_TIMESTAMP_PATTERN, Locale.ENGLISH ); + Date dateTime = parseDate(dateStr, null, HG_TIMESTAMP_PATTERN, Locale.ENGLISH); - lines.add( new BlameLine( dateTime, revision, author ) ); + lines.add(new BlameLine(dateTime, revision, author)); } - public List getLines() - { + public List getLines() { return lines; } } diff --git a/maven-scm-providers/maven-scm-provider-hg/src/main/java/org/apache/maven/scm/provider/hg/command/branch/HgBranchCommand.java b/maven-scm-providers/maven-scm-provider-hg/src/main/java/org/apache/maven/scm/provider/hg/command/branch/HgBranchCommand.java index fa1ce6814..d3bb9f136 100644 --- a/maven-scm-providers/maven-scm-provider-hg/src/main/java/org/apache/maven/scm/provider/hg/command/branch/HgBranchCommand.java +++ b/maven-scm-providers/maven-scm-provider-hg/src/main/java/org/apache/maven/scm/provider/hg/command/branch/HgBranchCommand.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.hg.command.branch; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider.hg.command.branch; import java.io.File; import java.util.ArrayList; @@ -47,123 +46,105 @@ * @author Henning Schmiedehausen * */ -public class HgBranchCommand - extends AbstractBranchCommand - implements Command -{ - - protected ScmResult executeBranchCommand( ScmProviderRepository scmProviderRepository, ScmFileSet fileSet, - String branch, String message ) - throws ScmException - { - return executeBranchCommand( scmProviderRepository, fileSet, branch, new ScmBranchParameters( message ) ); +public class HgBranchCommand extends AbstractBranchCommand implements Command { + + protected ScmResult executeBranchCommand( + ScmProviderRepository scmProviderRepository, ScmFileSet fileSet, String branch, String message) + throws ScmException { + return executeBranchCommand(scmProviderRepository, fileSet, branch, new ScmBranchParameters(message)); } /** * {@inheritDoc} */ - protected ScmResult executeBranchCommand( ScmProviderRepository scmProviderRepository, ScmFileSet fileSet, - String branch, ScmBranchParameters scmBranchParameters ) - throws ScmException - { - - if ( StringUtils.isBlank( branch ) ) - { - throw new ScmException( "branch must be specified" ); + protected ScmResult executeBranchCommand( + ScmProviderRepository scmProviderRepository, + ScmFileSet fileSet, + String branch, + ScmBranchParameters scmBranchParameters) + throws ScmException { + + if (StringUtils.isBlank(branch)) { + throw new ScmException("branch must be specified"); } - if ( !fileSet.getFileList().isEmpty() ) - { - throw new ScmException( "This provider doesn't support branchging subsets of a directory" ); + if (!fileSet.getFileList().isEmpty()) { + throw new ScmException("This provider doesn't support branchging subsets of a directory"); } File workingDir = fileSet.getBasedir(); // build the command - String[] branchCmd = new String[] { HgCommandConstants.BRANCH_CMD, branch }; + String[] branchCmd = new String[] {HgCommandConstants.BRANCH_CMD, branch}; // keep the command about in string form for reporting - HgConsumer branchConsumer = new HgConsumer() - { - public void doConsume( ScmFileStatus status, String trimmedLine ) - { + HgConsumer branchConsumer = new HgConsumer() { + public void doConsume(ScmFileStatus status, String trimmedLine) { // noop } }; - ScmResult result = HgUtils.execute( branchConsumer, workingDir, branchCmd ); + ScmResult result = HgUtils.execute(branchConsumer, workingDir, branchCmd); HgScmProviderRepository repository = (HgScmProviderRepository) scmProviderRepository; - if ( !result.isSuccess() ) - { - throw new ScmException( "Error while executing command " + joinCmd( branchCmd ) ); + if (!result.isSuccess()) { + throw new ScmException("Error while executing command " + joinCmd(branchCmd)); } // First commit. - String[] commitCmd = - new String[] { HgCommandConstants.COMMIT_CMD, HgCommandConstants.MESSAGE_OPTION, - scmBranchParameters.getMessage() }; + String[] commitCmd = new String[] { + HgCommandConstants.COMMIT_CMD, HgCommandConstants.MESSAGE_OPTION, scmBranchParameters.getMessage() + }; - result = HgUtils.execute( new HgConsumer(), workingDir, commitCmd ); + result = HgUtils.execute(new HgConsumer(), workingDir, commitCmd); - if ( !result.isSuccess() ) - { - throw new ScmException( "Error while executing command " + joinCmd( commitCmd ) ); + if (!result.isSuccess()) { + throw new ScmException("Error while executing command " + joinCmd(commitCmd)); } // now push, if we should. - if ( repository.isPushChanges() ) - { - if ( !repository.getURI().equals( fileSet.getBasedir().getAbsolutePath() ) ) - { + if (repository.isPushChanges()) { + if (!repository.getURI().equals(fileSet.getBasedir().getAbsolutePath())) { String[] pushCmd = new String[] { - HgCommandConstants.PUSH_CMD, - HgCommandConstants.NEW_BRANCH_OPTION, - repository.getURI() + HgCommandConstants.PUSH_CMD, HgCommandConstants.NEW_BRANCH_OPTION, repository.getURI() }; - result = HgUtils.execute( new HgConsumer(), fileSet.getBasedir(), pushCmd ); + result = HgUtils.execute(new HgConsumer(), fileSet.getBasedir(), pushCmd); - if ( !result.isSuccess() ) - { - throw new ScmException( "Error while executing command " + joinCmd( pushCmd ) ); + if (!result.isSuccess()) { + throw new ScmException("Error while executing command " + joinCmd(pushCmd)); } } } // do an inventory to return the files branched (all of them) - String[] listCmd = new String[]{ HgCommandConstants.INVENTORY_CMD }; + String[] listCmd = new String[] {HgCommandConstants.INVENTORY_CMD}; HgListConsumer listconsumer = new HgListConsumer(); - result = HgUtils.execute( listconsumer, fileSet.getBasedir(), listCmd ); + result = HgUtils.execute(listconsumer, fileSet.getBasedir(), listCmd); - if ( !result.isSuccess() ) - { - throw new ScmException( "Error while executing command " + joinCmd( listCmd ) ); + if (!result.isSuccess()) { + throw new ScmException("Error while executing command " + joinCmd(listCmd)); } List files = listconsumer.getFiles(); List fileList = new ArrayList(); - for ( ScmFile f : files ) - { - fileList.add( new ScmFile( f.getPath(), ScmFileStatus.TAGGED ) ); + for (ScmFile f : files) { + fileList.add(new ScmFile(f.getPath(), ScmFileStatus.TAGGED)); } - return new BranchScmResult( fileList, result ); + return new BranchScmResult(fileList, result); } - private String joinCmd( String[] cmd ) - { + private String joinCmd(String[] cmd) { StringBuilder result = new StringBuilder(); - for ( int i = 0; i < cmd.length; i++ ) - { + for (int i = 0; i < cmd.length; i++) { String s = cmd[i]; - result.append( s ); - if ( i < cmd.length - 1 ) - { - result.append( " " ); + result.append(s); + if (i < cmd.length - 1) { + result.append(" "); } } return result.toString(); diff --git a/maven-scm-providers/maven-scm-provider-hg/src/main/java/org/apache/maven/scm/provider/hg/command/changelog/HgChangeLogCommand.java b/maven-scm-providers/maven-scm-provider-hg/src/main/java/org/apache/maven/scm/provider/hg/command/changelog/HgChangeLogCommand.java index c9bde199b..9466368dc 100644 --- a/maven-scm-providers/maven-scm-provider-hg/src/main/java/org/apache/maven/scm/provider/hg/command/changelog/HgChangeLogCommand.java +++ b/maven-scm-providers/maven-scm-provider-hg/src/main/java/org/apache/maven/scm/provider/hg/command/changelog/HgChangeLogCommand.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.hg.command.changelog; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,13 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider.hg.command.changelog; + +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Date; +import java.util.List; import org.apache.maven.scm.ChangeSet; import org.apache.maven.scm.ScmBranch; @@ -34,117 +39,110 @@ import org.apache.maven.scm.provider.hg.HgUtils; import org.apache.maven.scm.provider.hg.command.HgCommandConstants; -import java.text.SimpleDateFormat; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Date; -import java.util.List; - /** * @author thurner rupert * @author Olivier Lamy */ -public class HgChangeLogCommand - extends AbstractChangeLogCommand - implements Command -{ +public class HgChangeLogCommand extends AbstractChangeLogCommand implements Command { /** * {@inheritDoc} */ @Override - protected ChangeLogScmResult executeChangeLogCommand( ChangeLogScmRequest request ) - throws ScmException - { + protected ChangeLogScmResult executeChangeLogCommand(ChangeLogScmRequest request) throws ScmException { final ScmVersion startVersion = request.getStartRevision(); final ScmVersion endVersion = request.getEndRevision(); final ScmFileSet fileSet = request.getScmFileSet(); final String datePattern = request.getDatePattern(); - if ( startVersion != null || endVersion != null ) - { - final ScmProviderRepository scmProviderRepository = request.getScmRepository().getProviderRepository(); - return executeChangeLogCommand( scmProviderRepository, fileSet, startVersion, endVersion, datePattern ); + if (startVersion != null || endVersion != null) { + final ScmProviderRepository scmProviderRepository = + request.getScmRepository().getProviderRepository(); + return executeChangeLogCommand(scmProviderRepository, fileSet, startVersion, endVersion, datePattern); } - return executeChangeLogCommand( fileSet, request.getStartDate(), request.getEndDate(), datePattern, - request.getLimit() ); + return executeChangeLogCommand( + fileSet, request.getStartDate(), request.getEndDate(), datePattern, request.getLimit()); } /** * {@inheritDoc} */ - protected ChangeLogScmResult executeChangeLogCommand( ScmProviderRepository scmProviderRepository, - ScmFileSet fileSet, Date startDate, Date endDate, - ScmBranch branch, String datePattern ) - throws ScmException - { - return executeChangeLogCommand( fileSet, startDate, endDate, datePattern, null ); + protected ChangeLogScmResult executeChangeLogCommand( + ScmProviderRepository scmProviderRepository, + ScmFileSet fileSet, + Date startDate, + Date endDate, + ScmBranch branch, + String datePattern) + throws ScmException { + return executeChangeLogCommand(fileSet, startDate, endDate, datePattern, null); } - private ChangeLogScmResult executeChangeLogCommand( ScmFileSet fileSet, Date startDate, Date endDate, - String datePattern, Integer limit ) - throws ScmException - { - SimpleDateFormat dateFormat = new SimpleDateFormat( "yyyy-MM-dd HH:mm:ss" ); + private ChangeLogScmResult executeChangeLogCommand( + ScmFileSet fileSet, Date startDate, Date endDate, String datePattern, Integer limit) throws ScmException { + SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); StringBuilder dateInterval = new StringBuilder(); // TRICK: Mercurial 1.9.3 don't accept 1970-01-01 dateInterval.append( - dateFormat.format( startDate == null ? new Date( 1000L * 60 * 60 * 24 ) : startDate ) ); // From 2. Jan 1970 - dateInterval.append( " to " ); - dateInterval.append( dateFormat.format( endDate == null ? new Date() : endDate ) ); // Upto now + dateFormat.format(startDate == null ? new Date(1000L * 60 * 60 * 24) : startDate)); // From 2. Jan 1970 + dateInterval.append(" to "); + dateInterval.append(dateFormat.format(endDate == null ? new Date() : endDate)); // Upto now List cmd = new ArrayList(); - cmd.addAll( Arrays.asList( HgCommandConstants.LOG_CMD, HgCommandConstants.TEMPLATE_OPTION, - HgCommandConstants.TEMPLATE_FORMAT, HgCommandConstants.NO_MERGES_OPTION, - HgCommandConstants.DATE_OPTION, dateInterval.toString() ) ); + cmd.addAll(Arrays.asList( + HgCommandConstants.LOG_CMD, HgCommandConstants.TEMPLATE_OPTION, + HgCommandConstants.TEMPLATE_FORMAT, HgCommandConstants.NO_MERGES_OPTION, + HgCommandConstants.DATE_OPTION, dateInterval.toString())); - if ( limit != null && limit > 0 ) - { - cmd.add( HgCommandConstants.LIMIT_OPTION ); - cmd.add( Integer.toString( limit ) ); + if (limit != null && limit > 0) { + cmd.add(HgCommandConstants.LIMIT_OPTION); + cmd.add(Integer.toString(limit)); } - HgChangeLogConsumer consumer = new HgChangeLogConsumer( datePattern ); - ScmResult result = - HgUtils.execute( consumer, fileSet.getBasedir(), cmd.toArray( new String[cmd.size()] ) ); + HgChangeLogConsumer consumer = new HgChangeLogConsumer(datePattern); + ScmResult result = HgUtils.execute(consumer, fileSet.getBasedir(), cmd.toArray(new String[cmd.size()])); List logEntries = consumer.getModifications(); - ChangeLogSet changeLogSet = new ChangeLogSet( logEntries, startDate, endDate ); - return new ChangeLogScmResult( changeLogSet, result ); + ChangeLogSet changeLogSet = new ChangeLogSet(logEntries, startDate, endDate); + return new ChangeLogScmResult(changeLogSet, result); } @Override - protected ChangeLogScmResult executeChangeLogCommand( ScmProviderRepository repository, ScmFileSet fileSet, - ScmVersion startVersion, ScmVersion endVersion, - String datePattern ) - throws ScmException - { + protected ChangeLogScmResult executeChangeLogCommand( + ScmProviderRepository repository, + ScmFileSet fileSet, + ScmVersion startVersion, + ScmVersion endVersion, + String datePattern) + throws ScmException { StringBuilder revisionInterval = new StringBuilder(); - if ( startVersion != null ) - { - revisionInterval.append( startVersion.getName() ); + if (startVersion != null) { + revisionInterval.append(startVersion.getName()); } - revisionInterval.append( ":" ); - if ( endVersion != null ) - { - revisionInterval.append( endVersion.getName() ); + revisionInterval.append(":"); + if (endVersion != null) { + revisionInterval.append(endVersion.getName()); } - String[] cmd = new String[]{ HgCommandConstants.LOG_CMD, HgCommandConstants.TEMPLATE_OPTION, - HgCommandConstants.TEMPLATE_FORMAT, HgCommandConstants.NO_MERGES_OPTION, HgCommandConstants.REVISION_OPTION, - revisionInterval.toString() }; - HgChangeLogConsumer consumer = new HgChangeLogConsumer( datePattern ); - ScmResult result = HgUtils.execute( consumer, fileSet.getBasedir(), cmd ); + String[] cmd = new String[] { + HgCommandConstants.LOG_CMD, + HgCommandConstants.TEMPLATE_OPTION, + HgCommandConstants.TEMPLATE_FORMAT, + HgCommandConstants.NO_MERGES_OPTION, + HgCommandConstants.REVISION_OPTION, + revisionInterval.toString() + }; + HgChangeLogConsumer consumer = new HgChangeLogConsumer(datePattern); + ScmResult result = HgUtils.execute(consumer, fileSet.getBasedir(), cmd); List logEntries = consumer.getModifications(); Date startDate = null; Date endDate = null; - if ( !logEntries.isEmpty() ) - { - startDate = logEntries.get( 0 ).getDate(); - endDate = logEntries.get( logEntries.size() - 1 ).getDate(); + if (!logEntries.isEmpty()) { + startDate = logEntries.get(0).getDate(); + endDate = logEntries.get(logEntries.size() - 1).getDate(); } - ChangeLogSet changeLogSet = new ChangeLogSet( logEntries, startDate, endDate ); - changeLogSet.setStartVersion( startVersion ); - changeLogSet.setEndVersion( endVersion ); - return new ChangeLogScmResult( changeLogSet, result ); + ChangeLogSet changeLogSet = new ChangeLogSet(logEntries, startDate, endDate); + changeLogSet.setStartVersion(startVersion); + changeLogSet.setEndVersion(endVersion); + return new ChangeLogScmResult(changeLogSet, result); } } diff --git a/maven-scm-providers/maven-scm-provider-hg/src/main/java/org/apache/maven/scm/provider/hg/command/changelog/HgChangeLogConsumer.java b/maven-scm-providers/maven-scm-provider-hg/src/main/java/org/apache/maven/scm/provider/hg/command/changelog/HgChangeLogConsumer.java index 828f7aace..16895b2a2 100644 --- a/maven-scm-providers/maven-scm-provider-hg/src/main/java/org/apache/maven/scm/provider/hg/command/changelog/HgChangeLogConsumer.java +++ b/maven-scm-providers/maven-scm-provider-hg/src/main/java/org/apache/maven/scm/provider/hg/command/changelog/HgChangeLogConsumer.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.hg.command.changelog; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider.hg.command.changelog; import java.util.ArrayList; import java.util.Date; @@ -33,9 +32,7 @@ * @author thurner rupert * @author Mads Mohr Christensen */ -public class HgChangeLogConsumer - extends HgConsumer -{ +public class HgChangeLogConsumer extends HgConsumer { private static final String TIME_PATTERN = "yyyy-MM-dd HH:mm:ss Z"; @@ -59,93 +56,73 @@ public class HgChangeLogConsumer private String currentRevision; - @SuppressWarnings( "unused" ) + @SuppressWarnings("unused") private String currentBranch; // don't know what to do with this private String userDatePattern; - public HgChangeLogConsumer( String userDatePattern ) - { + public HgChangeLogConsumer(String userDatePattern) { this.userDatePattern = userDatePattern; } - public List getModifications() - { + public List getModifications() { return logEntries; } /** * {@inheritDoc} */ - public void consumeLine( String line ) - { + public void consumeLine(String line) { // override default behaviour which tries to pick through things for some standard messages. that // does not apply here String trimmedLine = line.trim(); - doConsume( null, trimmedLine ); + doConsume(null, trimmedLine); } /** * {@inheritDoc} */ - public void doConsume( ScmFileStatus status, String line ) - { + public void doConsume(ScmFileStatus status, String line) { String tmpLine; // new changeset - if ( line.startsWith( REVNO_TAG ) ) - { - //Init a new changeset + if (line.startsWith(REVNO_TAG)) { + // Init a new changeset currentChange = new ChangeSet(); - currentChange.setFiles( new ArrayList( 0 ) ); - logEntries.add( currentChange ); + currentChange.setFiles(new ArrayList(0)); + logEntries.add(currentChange); // parse revision - tmpLine = line.substring( REVNO_TAG.length() ).trim(); - currentRevision = tmpLine.substring( tmpLine.indexOf( ':' ) + 1 ); - currentChange.setRevision( currentRevision ); - } - else if ( line.startsWith( BRANCH_TAG ) ) - { - tmpLine = line.substring( BRANCH_TAG.length() ).trim(); + tmpLine = line.substring(REVNO_TAG.length()).trim(); + currentRevision = tmpLine.substring(tmpLine.indexOf(':') + 1); + currentChange.setRevision(currentRevision); + } else if (line.startsWith(BRANCH_TAG)) { + tmpLine = line.substring(BRANCH_TAG.length()).trim(); currentBranch = tmpLine; - } - else if ( line.startsWith( AUTHOR_TAG ) ) - { - tmpLine = line.substring( AUTHOR_TAG.length() ).trim(); - currentChange.setAuthor( tmpLine ); - } - else if ( line.startsWith( TIME_STAMP_TOKEN ) ) - { - tmpLine = line.substring( TIME_STAMP_TOKEN.length() ).trim(); - Date date = parseDate( tmpLine, userDatePattern, TIME_PATTERN, Locale.ENGLISH ); - currentChange.setDate( date ); - } - else if ( line.startsWith( TAG_TAG ) ) - { - tmpLine = line.substring( TAG_TAG.length() ).trim(); - currentChange.addTag( tmpLine ); - } - else if ( line.startsWith( FILES_TOKEN ) ) - { - tmpLine = line.substring( FILES_TOKEN.length() ).trim(); - String[] files = tmpLine.split( " " ); - for ( int i = 0; i < files.length; i++ ) - { + } else if (line.startsWith(AUTHOR_TAG)) { + tmpLine = line.substring(AUTHOR_TAG.length()).trim(); + currentChange.setAuthor(tmpLine); + } else if (line.startsWith(TIME_STAMP_TOKEN)) { + tmpLine = line.substring(TIME_STAMP_TOKEN.length()).trim(); + Date date = parseDate(tmpLine, userDatePattern, TIME_PATTERN, Locale.ENGLISH); + currentChange.setDate(date); + } else if (line.startsWith(TAG_TAG)) { + tmpLine = line.substring(TAG_TAG.length()).trim(); + currentChange.addTag(tmpLine); + } else if (line.startsWith(FILES_TOKEN)) { + tmpLine = line.substring(FILES_TOKEN.length()).trim(); + String[] files = tmpLine.split(" "); + for (int i = 0; i < files.length; i++) { String file = files[i]; - ChangeFile changeFile = new ChangeFile( file, currentRevision ); - currentChange.addFile( changeFile ); + ChangeFile changeFile = new ChangeFile(file, currentRevision); + currentChange.addFile(changeFile); } - } - else if ( line.startsWith( MESSAGE_TOKEN ) ) - { - currentChange.setComment( "" ); - } - else - { - StringBuilder comment = new StringBuilder( currentChange.getComment() ); - comment.append( line ); - currentChange.setComment( comment.toString() ); + } else if (line.startsWith(MESSAGE_TOKEN)) { + currentChange.setComment(""); + } else { + StringBuilder comment = new StringBuilder(currentChange.getComment()); + comment.append(line); + currentChange.setComment(comment.toString()); } } } diff --git a/maven-scm-providers/maven-scm-provider-hg/src/main/java/org/apache/maven/scm/provider/hg/command/checkin/HgCheckInCommand.java b/maven-scm-providers/maven-scm-provider-hg/src/main/java/org/apache/maven/scm/provider/hg/command/checkin/HgCheckInCommand.java index 28efb9936..f93239633 100644 --- a/maven-scm-providers/maven-scm-provider-hg/src/main/java/org/apache/maven/scm/provider/hg/command/checkin/HgCheckInCommand.java +++ b/maven-scm-providers/maven-scm-provider-hg/src/main/java/org/apache/maven/scm/provider/hg/command/checkin/HgCheckInCommand.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.hg.command.checkin; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider.hg.command.checkin; import java.io.File; import java.util.ArrayList; @@ -45,79 +44,65 @@ * @author Olivier Lamy * */ -public class HgCheckInCommand - extends AbstractCheckInCommand -{ +public class HgCheckInCommand extends AbstractCheckInCommand { /** * {@inheritDoc} */ - protected CheckInScmResult executeCheckInCommand( ScmProviderRepository repo, ScmFileSet fileSet, String message, - ScmVersion tag ) - throws ScmException - { - if ( tag != null && !StringUtils.isEmpty( tag.getName() ) ) - { - throw new ScmException( "This provider can't handle tags for this operation" ); + protected CheckInScmResult executeCheckInCommand( + ScmProviderRepository repo, ScmFileSet fileSet, String message, ScmVersion tag) throws ScmException { + if (tag != null && !StringUtils.isEmpty(tag.getName())) { + throw new ScmException("This provider can't handle tags for this operation"); } - File workingDir = fileSet.getBasedir(); - String branchName = HgUtils.getCurrentBranchName( workingDir ); + String branchName = HgUtils.getCurrentBranchName(workingDir); boolean differentOutgoingBranch = - repo.isPushChanges() ? HgUtils.differentOutgoingBranchFound( workingDir, branchName ) : false; + repo.isPushChanges() ? HgUtils.differentOutgoingBranchFound(workingDir, branchName) : false; // Get files that will be committed (if not specified in fileSet) List commitedFiles = new ArrayList(); List files = fileSet.getFileList(); - if ( files.isEmpty() ) - { //Either commit all changes + if (files.isEmpty()) { // Either commit all changes HgStatusCommand statusCmd = new HgStatusCommand(); - StatusScmResult status = statusCmd.executeStatusCommand( repo, fileSet ); + StatusScmResult status = statusCmd.executeStatusCommand(repo, fileSet); List statusFiles = status.getChangedFiles(); - for ( ScmFile file : statusFiles ) - { - if ( file.getStatus() == ScmFileStatus.ADDED || file.getStatus() == ScmFileStatus.DELETED - || file.getStatus() == ScmFileStatus.MODIFIED ) - { - commitedFiles.add( new ScmFile( file.getPath(), ScmFileStatus.CHECKED_IN ) ); + for (ScmFile file : statusFiles) { + if (file.getStatus() == ScmFileStatus.ADDED + || file.getStatus() == ScmFileStatus.DELETED + || file.getStatus() == ScmFileStatus.MODIFIED) { + commitedFiles.add(new ScmFile(file.getPath(), ScmFileStatus.CHECKED_IN)); } } - } - else - { //Or commit spesific files - for ( File file : files ) - { - commitedFiles.add( new ScmFile( file.getPath(), ScmFileStatus.CHECKED_IN ) ); + } else { // Or commit spesific files + for (File file : files) { + commitedFiles.add(new ScmFile(file.getPath(), ScmFileStatus.CHECKED_IN)); } } // Commit to local branch - String[] commitCmd = new String[]{ HgCommandConstants.COMMIT_CMD, HgCommandConstants.MESSAGE_OPTION, message }; - commitCmd = HgUtils.expandCommandLine( commitCmd, fileSet ); - ScmResult result = - HgUtils.execute( new HgConsumer(), fileSet.getBasedir(), commitCmd ); + String[] commitCmd = new String[] {HgCommandConstants.COMMIT_CMD, HgCommandConstants.MESSAGE_OPTION, message}; + commitCmd = HgUtils.expandCommandLine(commitCmd, fileSet); + ScmResult result = HgUtils.execute(new HgConsumer(), fileSet.getBasedir(), commitCmd); // Push to parent branch if any HgScmProviderRepository repository = (HgScmProviderRepository) repo; - if ( repo.isPushChanges() ) - { + if (repo.isPushChanges()) { - if ( !repository.getURI().equals( fileSet.getBasedir().getAbsolutePath() ) ) - { - String[] pushCmd = new String[]{ HgCommandConstants.PUSH_CMD, + if (!repository.getURI().equals(fileSet.getBasedir().getAbsolutePath())) { + String[] pushCmd = new String[] { + HgCommandConstants.PUSH_CMD, differentOutgoingBranch ? HgCommandConstants.REVISION_OPTION + branchName : null, - repository.getURI() }; + repository.getURI() + }; - result = HgUtils.execute( new HgConsumer( ), fileSet.getBasedir(), pushCmd ); + result = HgUtils.execute(new HgConsumer(), fileSet.getBasedir(), pushCmd); } - return new CheckInScmResult( commitedFiles, result ); + return new CheckInScmResult(commitedFiles, result); } - return new CheckInScmResult( commitedFiles, result ); + return new CheckInScmResult(commitedFiles, result); } - - } diff --git a/maven-scm-providers/maven-scm-provider-hg/src/main/java/org/apache/maven/scm/provider/hg/command/checkout/HgCheckOutCommand.java b/maven-scm-providers/maven-scm-provider-hg/src/main/java/org/apache/maven/scm/provider/hg/command/checkout/HgCheckOutCommand.java index 83048b8e0..1b57c3246 100644 --- a/maven-scm-providers/maven-scm-provider-hg/src/main/java/org/apache/maven/scm/provider/hg/command/checkout/HgCheckOutCommand.java +++ b/maven-scm-providers/maven-scm-provider-hg/src/main/java/org/apache/maven/scm/provider/hg/command/checkout/HgCheckOutCommand.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.hg.command.checkout; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,12 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider.hg.command.checkout; + +import java.io.File; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; import org.apache.maven.scm.ScmException; import org.apache.maven.scm.ScmFileSet; @@ -34,74 +38,56 @@ import org.codehaus.plexus.util.FileUtils; import org.codehaus.plexus.util.StringUtils; -import java.io.File; -import java.io.IOException; -import java.util.ArrayList; -import java.util.List; - /** * @author thurner rupert * @author Olivier Lamy * */ -public class HgCheckOutCommand - extends AbstractCheckOutCommand - implements Command -{ +public class HgCheckOutCommand extends AbstractCheckOutCommand implements Command { /** * {@inheritDoc} */ - protected CheckOutScmResult executeCheckOutCommand( ScmProviderRepository repo, ScmFileSet fileSet, - ScmVersion scmVersion, boolean recursive, boolean shallow ) - throws ScmException - { + protected CheckOutScmResult executeCheckOutCommand( + ScmProviderRepository repo, ScmFileSet fileSet, ScmVersion scmVersion, boolean recursive, boolean shallow) + throws ScmException { HgScmProviderRepository repository = (HgScmProviderRepository) repo; String url = repository.getURI(); File checkoutDir = fileSet.getBasedir(); - try - { - if ( logger.isInfoEnabled() ) - { - logger.info( "Removing " + checkoutDir ); + try { + if (logger.isInfoEnabled()) { + logger.info("Removing " + checkoutDir); } - FileUtils.deleteDirectory( checkoutDir ); - } - catch ( IOException e ) - { - throw new ScmException( "Cannot remove " + checkoutDir ); + FileUtils.deleteDirectory(checkoutDir); + } catch (IOException e) { + throw new ScmException("Cannot remove " + checkoutDir); } // Do the actual checkout List cmdList = new ArrayList(); - if ( repo.isPushChanges() ) - { - cmdList.add( HgCommandConstants.CLONE_CMD ); - } - else - { - cmdList.add( HgCommandConstants.UPDATE_CMD ); + if (repo.isPushChanges()) { + cmdList.add(HgCommandConstants.CLONE_CMD); + } else { + cmdList.add(HgCommandConstants.UPDATE_CMD); } - if ( scmVersion != null && !StringUtils.isEmpty( scmVersion.getName() ) ) - { - cmdList.add( HgCommandConstants.REVISION_OPTION ); - cmdList.add( scmVersion.getName() ); + if (scmVersion != null && !StringUtils.isEmpty(scmVersion.getName())) { + cmdList.add(HgCommandConstants.REVISION_OPTION); + cmdList.add(scmVersion.getName()); } - if ( !repo.isPushChanges() ) - { - cmdList.add( HgCommandConstants.CLEAN_OPTION ); + if (!repo.isPushChanges()) { + cmdList.add(HgCommandConstants.CLEAN_OPTION); } - cmdList.add( url ); - cmdList.add( checkoutDir.getAbsolutePath() ); - String[] checkoutCmd = cmdList.toArray( new String[0] ); + cmdList.add(url); + cmdList.add(checkoutDir.getAbsolutePath()); + String[] checkoutCmd = cmdList.toArray(new String[0]); HgConsumer checkoutConsumer = new HgConsumer(); - HgUtils.execute( checkoutConsumer, checkoutDir.getParentFile(), checkoutCmd ); + HgUtils.execute(checkoutConsumer, checkoutDir.getParentFile(), checkoutCmd); // Do inventory to find list of checkedout files - String[] inventoryCmd = new String[]{ HgCommandConstants.INVENTORY_CMD }; - HgCheckOutConsumer consumer = new HgCheckOutConsumer( checkoutDir ); - ScmResult result = HgUtils.execute( consumer, checkoutDir, inventoryCmd ); + String[] inventoryCmd = new String[] {HgCommandConstants.INVENTORY_CMD}; + HgCheckOutConsumer consumer = new HgCheckOutConsumer(checkoutDir); + ScmResult result = HgUtils.execute(consumer, checkoutDir, inventoryCmd); - return new CheckOutScmResult( consumer.getCheckedOutFiles(), result ); + return new CheckOutScmResult(consumer.getCheckedOutFiles(), result); } } diff --git a/maven-scm-providers/maven-scm-provider-hg/src/main/java/org/apache/maven/scm/provider/hg/command/checkout/HgCheckOutConsumer.java b/maven-scm-providers/maven-scm-provider-hg/src/main/java/org/apache/maven/scm/provider/hg/command/checkout/HgCheckOutConsumer.java index fd02eb7fe..0cff626ab 100644 --- a/maven-scm-providers/maven-scm-provider-hg/src/main/java/org/apache/maven/scm/provider/hg/command/checkout/HgCheckOutConsumer.java +++ b/maven-scm-providers/maven-scm-provider-hg/src/main/java/org/apache/maven/scm/provider/hg/command/checkout/HgCheckOutConsumer.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.hg.command.checkout; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,45 +16,40 @@ * specific language governing permissions and limitations * under the License. */ - -import org.apache.maven.scm.ScmFile; -import org.apache.maven.scm.ScmFileStatus; -import org.apache.maven.scm.provider.hg.command.HgConsumer; +package org.apache.maven.scm.provider.hg.command.checkout; import java.io.File; import java.util.ArrayList; import java.util.List; +import org.apache.maven.scm.ScmFile; +import org.apache.maven.scm.ScmFileStatus; +import org.apache.maven.scm.provider.hg.command.HgConsumer; + /** * @author thurner rupert * @author Olivier Lamy * */ -public class HgCheckOutConsumer - extends HgConsumer -{ +public class HgCheckOutConsumer extends HgConsumer { private final File workingDirectory; private List checkedOut = new ArrayList(); - public HgCheckOutConsumer( File workingDirectory ) - { + public HgCheckOutConsumer(File workingDirectory) { this.workingDirectory = workingDirectory; } /** {@inheritDoc} */ - public void doConsume( ScmFileStatus status, String line ) - { - File file = new File( workingDirectory, line ); - if ( file.isFile() ) - { - checkedOut.add( new ScmFile( line, ScmFileStatus.CHECKED_OUT ) ); + public void doConsume(ScmFileStatus status, String line) { + File file = new File(workingDirectory, line); + if (file.isFile()) { + checkedOut.add(new ScmFile(line, ScmFileStatus.CHECKED_OUT)); } } - List getCheckedOutFiles() - { + List getCheckedOutFiles() { return checkedOut; } } diff --git a/maven-scm-providers/maven-scm-provider-hg/src/main/java/org/apache/maven/scm/provider/hg/command/diff/HgDiffCommand.java b/maven-scm-providers/maven-scm-provider-hg/src/main/java/org/apache/maven/scm/provider/hg/command/diff/HgDiffCommand.java index a76dd519e..72952351b 100644 --- a/maven-scm-providers/maven-scm-provider-hg/src/main/java/org/apache/maven/scm/provider/hg/command/diff/HgDiffCommand.java +++ b/maven-scm-providers/maven-scm-provider-hg/src/main/java/org/apache/maven/scm/provider/hg/command/diff/HgDiffCommand.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.hg.command.diff; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider.hg.command.diff; import org.apache.maven.scm.ScmException; import org.apache.maven.scm.ScmFileSet; @@ -35,35 +34,27 @@ * @author thurner rupert * */ -public class HgDiffCommand - extends AbstractDiffCommand - implements Command -{ +public class HgDiffCommand extends AbstractDiffCommand implements Command { /** {@inheritDoc} */ - protected DiffScmResult executeDiffCommand( ScmProviderRepository repo, ScmFileSet fileSet, - ScmVersion startRevision, ScmVersion endRevision ) - throws ScmException - { + protected DiffScmResult executeDiffCommand( + ScmProviderRepository repo, ScmFileSet fileSet, ScmVersion startRevision, ScmVersion endRevision) + throws ScmException { String[] diffCmd; - if ( startRevision != null && !StringUtils.isEmpty( startRevision.getName() ) ) - { + if (startRevision != null && !StringUtils.isEmpty(startRevision.getName())) { String revArg = startRevision.getName(); - if ( endRevision != null && !StringUtils.isEmpty( endRevision.getName() ) ) - { + if (endRevision != null && !StringUtils.isEmpty(endRevision.getName())) { revArg += ".." + endRevision; } - diffCmd = new String[] { HgCommandConstants.DIFF_CMD, HgCommandConstants.REVISION_OPTION, revArg }; - } - else - { - diffCmd = new String[] { HgCommandConstants.DIFF_CMD }; + diffCmd = new String[] {HgCommandConstants.DIFF_CMD, HgCommandConstants.REVISION_OPTION, revArg}; + } else { + diffCmd = new String[] {HgCommandConstants.DIFF_CMD}; } - diffCmd = HgUtils.expandCommandLine( diffCmd, fileSet ); - HgDiffConsumer consumer = new HgDiffConsumer( fileSet.getBasedir() ); + diffCmd = HgUtils.expandCommandLine(diffCmd, fileSet); + HgDiffConsumer consumer = new HgDiffConsumer(fileSet.getBasedir()); - ScmResult result = HgUtils.execute( consumer, fileSet.getBasedir(), diffCmd ); + ScmResult result = HgUtils.execute(consumer, fileSet.getBasedir(), diffCmd); - return new DiffScmResult( consumer.getChangedFiles(), consumer.getDifferences(), consumer.getPatch(), result ); + return new DiffScmResult(consumer.getChangedFiles(), consumer.getDifferences(), consumer.getPatch(), result); } } diff --git a/maven-scm-providers/maven-scm-provider-hg/src/main/java/org/apache/maven/scm/provider/hg/command/diff/HgDiffConsumer.java b/maven-scm-providers/maven-scm-provider-hg/src/main/java/org/apache/maven/scm/provider/hg/command/diff/HgDiffConsumer.java index 810960948..bb65a68a2 100644 --- a/maven-scm-providers/maven-scm-provider-hg/src/main/java/org/apache/maven/scm/provider/hg/command/diff/HgDiffConsumer.java +++ b/maven-scm-providers/maven-scm-provider-hg/src/main/java/org/apache/maven/scm/provider/hg/command/diff/HgDiffConsumer.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.hg.command.diff; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,10 +16,7 @@ * specific language governing permissions and limitations * under the License. */ - -import org.apache.maven.scm.ScmFile; -import org.apache.maven.scm.ScmFileStatus; -import org.apache.maven.scm.provider.hg.command.HgConsumer; +package org.apache.maven.scm.provider.hg.command.diff; import java.io.File; import java.util.ArrayList; @@ -29,14 +24,16 @@ import java.util.List; import java.util.Map; +import org.apache.maven.scm.ScmFile; +import org.apache.maven.scm.ScmFileStatus; +import org.apache.maven.scm.provider.hg.command.HgConsumer; + /** * @author thurner rupert * @author Olivier Lamy * */ -public class HgDiffConsumer - extends HgConsumer -{ +public class HgDiffConsumer extends HgConsumer { // private static final String MODIFIED_FILE_TOKEN = "=== modified file "; @@ -70,12 +67,10 @@ public class HgDiffConsumer private final StringBuilder patch = new StringBuilder(); - @SuppressWarnings( "unused" ) + @SuppressWarnings("unused") private final File workingDirectory; - - public HgDiffConsumer( File workingDirectory ) - { + public HgDiffConsumer(File workingDirectory) { this.workingDirectory = workingDirectory; } @@ -84,84 +79,69 @@ public HgDiffConsumer( File workingDirectory ) // ---------------------------------------------------------------------- /** {@inheritDoc} */ - public void consumeLine( String line ) - { - if ( line.startsWith( INDEX_TOKEN ) ) - { + public void consumeLine(String line) { + if (line.startsWith(INDEX_TOKEN)) { // start a new file - currentFile = line.substring( INDEX_TOKEN.length() + HASH_ID_LEN + 1 ); + currentFile = line.substring(INDEX_TOKEN.length() + HASH_ID_LEN + 1); - changedFiles.add( new ScmFile( currentFile, ScmFileStatus.MODIFIED ) ); + changedFiles.add(new ScmFile(currentFile, ScmFileStatus.MODIFIED)); currentDifference = new StringBuilder(); - differences.put( currentFile, currentDifference ); + differences.put(currentFile, currentDifference); - patch.append( line ).append( "\n" ); + patch.append(line).append("\n"); return; } - if ( currentFile == null ) - { - if ( logger.isWarnEnabled() ) - { - logger.warn( "Unparseable line: '" + line + "'" ); + if (currentFile == null) { + if (logger.isWarnEnabled()) { + logger.warn("Unparseable line: '" + line + "'"); } - patch.append( line ).append( "\n" ); + patch.append(line).append("\n"); return; } - if ( line.startsWith( FILE_SEPARATOR_TOKEN ) ) - { + if (line.startsWith(FILE_SEPARATOR_TOKEN)) { // skip - patch.append( line ).append( "\n" ); - } - else if ( line.startsWith( START_REVISION_TOKEN ) ) - { + patch.append(line).append("\n"); + } else if (line.startsWith(START_REVISION_TOKEN)) { // skip, though could parse to verify filename, start revision - patch.append( line ).append( "\n" ); - } - else if ( line.startsWith( END_REVISION_TOKEN ) ) - { + patch.append(line).append("\n"); + } else if (line.startsWith(END_REVISION_TOKEN)) { // skip, though could parse to verify filename, end revision - patch.append( line ).append( "\n" ); - } - else if ( line.startsWith( ADDED_LINE_TOKEN ) || line.startsWith( REMOVED_LINE_TOKEN ) - || line.startsWith( UNCHANGED_LINE_TOKEN ) || line.startsWith( CHANGE_SEPARATOR_TOKEN ) - || line.equals( NO_NEWLINE_TOKEN ) ) - { + patch.append(line).append("\n"); + } else if (line.startsWith(ADDED_LINE_TOKEN) + || line.startsWith(REMOVED_LINE_TOKEN) + || line.startsWith(UNCHANGED_LINE_TOKEN) + || line.startsWith(CHANGE_SEPARATOR_TOKEN) + || line.equals(NO_NEWLINE_TOKEN)) { // add to buffer - currentDifference.append( line ).append( "\n" ); - patch.append( line ).append( "\n" ); - } - else - { + currentDifference.append(line).append("\n"); + patch.append(line).append("\n"); + } else { // TODO: handle property differences - if ( logger.isWarnEnabled() ) - { - logger.warn( "Unparseable line: '" + line + "'" ); + if (logger.isWarnEnabled()) { + logger.warn("Unparseable line: '" + line + "'"); } - patch.append( line ).append( "\n" ); + patch.append(line).append("\n"); // skip to next file currentFile = null; currentDifference = null; } } - public List getChangedFiles() - { + public List getChangedFiles() { return changedFiles; } - public Map getDifferences() - { + public Map getDifferences() { return differences; } - public String getPatch() - { + public String getPatch() { return patch.toString(); } } diff --git a/maven-scm-providers/maven-scm-provider-hg/src/main/java/org/apache/maven/scm/provider/hg/command/info/HgInfoCommand.java b/maven-scm-providers/maven-scm-provider-hg/src/main/java/org/apache/maven/scm/provider/hg/command/info/HgInfoCommand.java index c7e8841a7..cf8a27192 100644 --- a/maven-scm-providers/maven-scm-provider-hg/src/main/java/org/apache/maven/scm/provider/hg/command/info/HgInfoCommand.java +++ b/maven-scm-providers/maven-scm-provider-hg/src/main/java/org/apache/maven/scm/provider/hg/command/info/HgInfoCommand.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.hg.command.info; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider.hg.command.info; import org.apache.maven.scm.CommandParameters; import org.apache.maven.scm.ScmException; @@ -34,20 +33,14 @@ * @author Olivier Lamy * @since 1.5 */ -public class HgInfoCommand - extends AbstractCommand - implements Command -{ +public class HgInfoCommand extends AbstractCommand implements Command { @Override - protected ScmResult executeCommand( ScmProviderRepository repository, ScmFileSet fileSet, - CommandParameters parameters ) - throws ScmException - { - String[] revCmd = new String[]{ HgCommandConstants.REVNO_CMD, "-i" }; + protected ScmResult executeCommand( + ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters) throws ScmException { + String[] revCmd = new String[] {HgCommandConstants.REVNO_CMD, "-i"}; HgInfoConsumer consumer = new HgInfoConsumer(); - ScmResult scmResult = HgUtils.execute( consumer, fileSet.getBasedir(), revCmd ); - return new InfoScmResult( consumer.getInfoItems(), scmResult ); + ScmResult scmResult = HgUtils.execute(consumer, fileSet.getBasedir(), revCmd); + return new InfoScmResult(consumer.getInfoItems(), scmResult); } - } diff --git a/maven-scm-providers/maven-scm-provider-hg/src/main/java/org/apache/maven/scm/provider/hg/command/info/HgInfoConsumer.java b/maven-scm-providers/maven-scm-provider-hg/src/main/java/org/apache/maven/scm/provider/hg/command/info/HgInfoConsumer.java index 1820d2821..8142ae1b1 100644 --- a/maven-scm-providers/maven-scm-provider-hg/src/main/java/org/apache/maven/scm/provider/hg/command/info/HgInfoConsumer.java +++ b/maven-scm-providers/maven-scm-provider-hg/src/main/java/org/apache/maven/scm/provider/hg/command/info/HgInfoConsumer.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.hg.command.info; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider.hg.command.info; import java.util.ArrayList; import java.util.List; @@ -30,25 +29,21 @@ * @since 1.5 * */ -public class HgInfoConsumer - extends HgConsumer -{ - - private final List infoItems = new ArrayList<>( 1 ); +public class HgInfoConsumer extends HgConsumer { + + private final List infoItems = new ArrayList<>(1); /** * @see org.codehaus.plexus.util.cli.StreamConsumer#consumeLine(java.lang.String) */ - public void consumeLine( String line ) - { + public void consumeLine(String line) { // hg id -i returns only one line so we are safe InfoItem infoItem = new InfoItem(); - infoItem.setRevision( line ); - this.infoItems.add( infoItem ); + infoItem.setRevision(line); + this.infoItems.add(infoItem); } - public List getInfoItems() - { + public List getInfoItems() { return infoItems; } } diff --git a/maven-scm-providers/maven-scm-provider-hg/src/main/java/org/apache/maven/scm/provider/hg/command/inventory/HgChangeSet.java b/maven-scm-providers/maven-scm-provider-hg/src/main/java/org/apache/maven/scm/provider/hg/command/inventory/HgChangeSet.java index 74589a179..7a548985d 100644 --- a/maven-scm-providers/maven-scm-provider-hg/src/main/java/org/apache/maven/scm/provider/hg/command/inventory/HgChangeSet.java +++ b/maven-scm-providers/maven-scm-provider-hg/src/main/java/org/apache/maven/scm/provider/hg/command/inventory/HgChangeSet.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.hg.command.inventory; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider.hg.command.inventory; import org.apache.maven.scm.ChangeSet; @@ -27,26 +26,20 @@ * @author Laurent Perez * */ -public class HgChangeSet - extends ChangeSet -{ +public class HgChangeSet extends ChangeSet { private static final long serialVersionUID = -4556377494055110302L; private String branch; - public HgChangeSet() - { + public HgChangeSet() { super(); } - public HgChangeSet( String branch ) - { + public HgChangeSet(String branch) { this.branch = branch; } - public String getBranch() - { + public String getBranch() { return branch; } - } diff --git a/maven-scm-providers/maven-scm-provider-hg/src/main/java/org/apache/maven/scm/provider/hg/command/inventory/HgListCommand.java b/maven-scm-providers/maven-scm-provider-hg/src/main/java/org/apache/maven/scm/provider/hg/command/inventory/HgListCommand.java index 54d2de708..2c11233d7 100644 --- a/maven-scm-providers/maven-scm-provider-hg/src/main/java/org/apache/maven/scm/provider/hg/command/inventory/HgListCommand.java +++ b/maven-scm-providers/maven-scm-provider-hg/src/main/java/org/apache/maven/scm/provider/hg/command/inventory/HgListCommand.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.hg.command.inventory; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider.hg.command.inventory; import java.io.File; @@ -38,45 +37,36 @@ * @author ryan daum * */ -public class HgListCommand - extends AbstractListCommand - implements Command -{ +public class HgListCommand extends AbstractListCommand implements Command { /** {@inheritDoc} */ - protected ListScmResult executeListCommand( ScmProviderRepository repository, ScmFileSet fileSet, - boolean recursive, ScmVersion scmVersion ) - throws ScmException - { + protected ListScmResult executeListCommand( + ScmProviderRepository repository, ScmFileSet fileSet, boolean recursive, ScmVersion scmVersion) + throws ScmException { // File workingDir = fileSet.getBasedir(); // build the command - String[] listCmd = new String[] { HgCommandConstants.INVENTORY_CMD }; + String[] listCmd = new String[] {HgCommandConstants.INVENTORY_CMD}; // keep the command about in string form for reporting StringBuilder cmd = new StringBuilder(); - for ( int i = 0; i < listCmd.length; i++ ) - { + for (int i = 0; i < listCmd.length; i++) { String s = listCmd[i]; - cmd.append( s ); - if ( i < listCmd.length - 1 ) - { - cmd.append( " " ); + cmd.append(s); + if (i < listCmd.length - 1) { + cmd.append(" "); } } HgListConsumer consumer = new HgListConsumer(); - ScmResult result = HgUtils.execute( consumer, workingDir, listCmd ); + ScmResult result = HgUtils.execute(consumer, workingDir, listCmd); - if ( result.isSuccess() ) - { - return new ListScmResult( consumer.getFiles(), result ); - } - else - { - throw new ScmException( "Error while executing command " + cmd.toString() ); + if (result.isSuccess()) { + return new ListScmResult(consumer.getFiles(), result); + } else { + throw new ScmException("Error while executing command " + cmd.toString()); } } } diff --git a/maven-scm-providers/maven-scm-provider-hg/src/main/java/org/apache/maven/scm/provider/hg/command/inventory/HgListConsumer.java b/maven-scm-providers/maven-scm-provider-hg/src/main/java/org/apache/maven/scm/provider/hg/command/inventory/HgListConsumer.java index 8d9057351..613670bfc 100644 --- a/maven-scm-providers/maven-scm-provider-hg/src/main/java/org/apache/maven/scm/provider/hg/command/inventory/HgListConsumer.java +++ b/maven-scm-providers/maven-scm-provider-hg/src/main/java/org/apache/maven/scm/provider/hg/command/inventory/HgListConsumer.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.hg.command.inventory; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,13 +16,14 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider.hg.command.inventory; -import org.apache.maven.scm.provider.hg.command.HgConsumer; -import org.apache.maven.scm.ScmFileStatus; -import org.apache.maven.scm.ScmFile; - -import java.util.List; import java.util.ArrayList; +import java.util.List; + +import org.apache.maven.scm.ScmFile; +import org.apache.maven.scm.ScmFileStatus; +import org.apache.maven.scm.provider.hg.command.HgConsumer; /** * Get a list of all files in the repository @@ -32,20 +31,16 @@ * @author ryan daum * */ -public class HgListConsumer - extends HgConsumer -{ +public class HgListConsumer extends HgConsumer { private final List files = new ArrayList<>(); /** {@inheritDoc} */ - public void doConsume( ScmFileStatus status, String trimmedLine ) - { - files.add( new ScmFile( trimmedLine, status ) ); + public void doConsume(ScmFileStatus status, String trimmedLine) { + files.add(new ScmFile(trimmedLine, status)); } - public List getFiles() - { + public List getFiles() { return files; } } diff --git a/maven-scm-providers/maven-scm-provider-hg/src/main/java/org/apache/maven/scm/provider/hg/command/inventory/HgOutgoingConsumer.java b/maven-scm-providers/maven-scm-provider-hg/src/main/java/org/apache/maven/scm/provider/hg/command/inventory/HgOutgoingConsumer.java index 78bfc93f8..99215e8be 100644 --- a/maven-scm-providers/maven-scm-provider-hg/src/main/java/org/apache/maven/scm/provider/hg/command/inventory/HgOutgoingConsumer.java +++ b/maven-scm-providers/maven-scm-provider-hg/src/main/java/org/apache/maven/scm/provider/hg/command/inventory/HgOutgoingConsumer.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.hg.command.inventory; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,40 +16,34 @@ * specific language governing permissions and limitations * under the License. */ - -import org.apache.maven.scm.provider.hg.command.HgConsumer; +package org.apache.maven.scm.provider.hg.command.inventory; import java.util.List; import java.util.concurrent.CopyOnWriteArrayList; +import org.apache.maven.scm.provider.hg.command.HgConsumer; + /** * Get a list of outgoing changes * * @author Laurent Perez * */ -public class HgOutgoingConsumer - extends HgConsumer -{ +public class HgOutgoingConsumer extends HgConsumer { private List changes = new CopyOnWriteArrayList(); private static final String BRANCH = "branch"; - public void consumeLine( String line ) - { + public void consumeLine(String line) { String branch = null; - if ( line.startsWith( BRANCH ) ) - { - branch = line.substring( BRANCH.length() + 7 ); + if (line.startsWith(BRANCH)) { + branch = line.substring(BRANCH.length() + 7); } - changes.add( new HgChangeSet( branch ) ); - + changes.add(new HgChangeSet(branch)); } - public List getChanges() - { + public List getChanges() { return changes; } - } diff --git a/maven-scm-providers/maven-scm-provider-hg/src/main/java/org/apache/maven/scm/provider/hg/command/remove/HgRemoveCommand.java b/maven-scm-providers/maven-scm-provider-hg/src/main/java/org/apache/maven/scm/provider/hg/command/remove/HgRemoveCommand.java index e7a4066b0..24a0e86ac 100644 --- a/maven-scm-providers/maven-scm-provider-hg/src/main/java/org/apache/maven/scm/provider/hg/command/remove/HgRemoveCommand.java +++ b/maven-scm-providers/maven-scm-provider-hg/src/main/java/org/apache/maven/scm/provider/hg/command/remove/HgRemoveCommand.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.hg.command.remove; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,9 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider.hg.command.remove; + +import java.io.File; import org.apache.maven.scm.ScmException; import org.apache.maven.scm.ScmFileSet; @@ -29,28 +30,22 @@ import org.apache.maven.scm.provider.hg.HgUtils; import org.apache.maven.scm.provider.hg.command.HgCommandConstants; -import java.io.File; - /** * @author thurner rupert * */ -public class HgRemoveCommand - extends AbstractRemoveCommand - implements Command -{ +public class HgRemoveCommand extends AbstractRemoveCommand implements Command { /** {@inheritDoc} */ - protected ScmResult executeRemoveCommand( ScmProviderRepository repository, ScmFileSet fileSet, String message ) - throws ScmException - { + protected ScmResult executeRemoveCommand(ScmProviderRepository repository, ScmFileSet fileSet, String message) + throws ScmException { - String[] command = new String[] { HgCommandConstants.REMOVE_CMD }; - command = HgUtils.expandCommandLine( command, fileSet ); + String[] command = new String[] {HgCommandConstants.REMOVE_CMD}; + command = HgUtils.expandCommandLine(command, fileSet); File workingDir = fileSet.getBasedir(); - HgRemoveConsumer consumer = new HgRemoveConsumer( workingDir ); + HgRemoveConsumer consumer = new HgRemoveConsumer(workingDir); - ScmResult result = HgUtils.execute( consumer, workingDir, command ); - return new RemoveScmResult( consumer.getRemovedFiles(), result ); + ScmResult result = HgUtils.execute(consumer, workingDir, command); + return new RemoveScmResult(consumer.getRemovedFiles(), result); } } diff --git a/maven-scm-providers/maven-scm-provider-hg/src/main/java/org/apache/maven/scm/provider/hg/command/remove/HgRemoveConsumer.java b/maven-scm-providers/maven-scm-provider-hg/src/main/java/org/apache/maven/scm/provider/hg/command/remove/HgRemoveConsumer.java index c4cc800c8..8abd33c46 100644 --- a/maven-scm-providers/maven-scm-provider-hg/src/main/java/org/apache/maven/scm/provider/hg/command/remove/HgRemoveConsumer.java +++ b/maven-scm-providers/maven-scm-provider-hg/src/main/java/org/apache/maven/scm/provider/hg/command/remove/HgRemoveConsumer.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.hg.command.remove; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,60 +16,50 @@ * specific language governing permissions and limitations * under the License. */ - -import org.apache.maven.scm.ScmFile; -import org.apache.maven.scm.ScmFileStatus; -import org.apache.maven.scm.provider.hg.command.HgConsumer; +package org.apache.maven.scm.provider.hg.command.remove; import java.io.File; import java.util.ArrayList; import java.util.List; +import org.apache.maven.scm.ScmFile; +import org.apache.maven.scm.ScmFileStatus; +import org.apache.maven.scm.provider.hg.command.HgConsumer; + /** * @author thurner rupert * @author Olivier Lamy * */ -public class HgRemoveConsumer - extends HgConsumer -{ +public class HgRemoveConsumer extends HgConsumer { private final File workingDir; private final List removedFiles = new ArrayList(); - public HgRemoveConsumer( File workingDir ) - { + public HgRemoveConsumer(File workingDir) { this.workingDir = workingDir; } /** {@inheritDoc} */ - public void doConsume( ScmFileStatus status, String trimmedLine ) - { - if ( status != null && status == ScmFileStatus.DELETED ) - { - //Only include real files (not directories) - File tmpFile = new File( workingDir, trimmedLine ); - if ( !tmpFile.exists() ) - { - if ( logger.isWarnEnabled() ) - { - logger.warn( "Not a file: " + tmpFile + ". Ignored" ); + public void doConsume(ScmFileStatus status, String trimmedLine) { + if (status != null && status == ScmFileStatus.DELETED) { + // Only include real files (not directories) + File tmpFile = new File(workingDir, trimmedLine); + if (!tmpFile.exists()) { + if (logger.isWarnEnabled()) { + logger.warn("Not a file: " + tmpFile + ". Ignored"); } - } - else - { - ScmFile scmFile = new ScmFile( trimmedLine, ScmFileStatus.DELETED ); - if ( logger.isInfoEnabled() ) - { - logger.info( scmFile.toString() ); + } else { + ScmFile scmFile = new ScmFile(trimmedLine, ScmFileStatus.DELETED); + if (logger.isInfoEnabled()) { + logger.info(scmFile.toString()); } - removedFiles.add( scmFile ); + removedFiles.add(scmFile); } } } - public List getRemovedFiles() - { + public List getRemovedFiles() { return removedFiles; } -} \ No newline at end of file +} diff --git a/maven-scm-providers/maven-scm-provider-hg/src/main/java/org/apache/maven/scm/provider/hg/command/status/HgStatusCommand.java b/maven-scm-providers/maven-scm-provider-hg/src/main/java/org/apache/maven/scm/provider/hg/command/status/HgStatusCommand.java index 398a3f416..0641e295b 100644 --- a/maven-scm-providers/maven-scm-provider-hg/src/main/java/org/apache/maven/scm/provider/hg/command/status/HgStatusCommand.java +++ b/maven-scm-providers/maven-scm-provider-hg/src/main/java/org/apache/maven/scm/provider/hg/command/status/HgStatusCommand.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.hg.command.status; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider.hg.command.status; import java.io.File; @@ -34,26 +33,20 @@ /** * @author thurner rupert */ -public class HgStatusCommand - extends AbstractStatusCommand - implements Command -{ +public class HgStatusCommand extends AbstractStatusCommand implements Command { - public HgStatusCommand() - { + public HgStatusCommand() { super(); } /** {@inheritDoc} */ - public StatusScmResult executeStatusCommand( ScmProviderRepository repo, ScmFileSet fileSet ) - throws ScmException - { + public StatusScmResult executeStatusCommand(ScmProviderRepository repo, ScmFileSet fileSet) throws ScmException { File workingDir = fileSet.getBasedir(); - HgStatusConsumer consumer = new HgStatusConsumer( workingDir ); - String[] statusCmd = new String[] { HgCommandConstants.STATUS_CMD }; - ScmResult result = HgUtils.execute( consumer, workingDir, statusCmd ); + HgStatusConsumer consumer = new HgStatusConsumer(workingDir); + String[] statusCmd = new String[] {HgCommandConstants.STATUS_CMD}; + ScmResult result = HgUtils.execute(consumer, workingDir, statusCmd); - return new StatusScmResult( consumer.getStatus(), result ); + return new StatusScmResult(consumer.getStatus(), result); } } diff --git a/maven-scm-providers/maven-scm-provider-hg/src/main/java/org/apache/maven/scm/provider/hg/command/status/HgStatusConsumer.java b/maven-scm-providers/maven-scm-provider-hg/src/main/java/org/apache/maven/scm/provider/hg/command/status/HgStatusConsumer.java index d7ab07beb..1c9093d55 100644 --- a/maven-scm-providers/maven-scm-provider-hg/src/main/java/org/apache/maven/scm/provider/hg/command/status/HgStatusConsumer.java +++ b/maven-scm-providers/maven-scm-provider-hg/src/main/java/org/apache/maven/scm/provider/hg/command/status/HgStatusConsumer.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.hg.command.status; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,63 +16,51 @@ * specific language governing permissions and limitations * under the License. */ - -import org.apache.maven.scm.ScmFile; -import org.apache.maven.scm.ScmFileStatus; -import org.apache.maven.scm.provider.hg.command.HgConsumer; +package org.apache.maven.scm.provider.hg.command.status; import java.io.File; import java.util.ArrayList; import java.util.List; +import org.apache.maven.scm.ScmFile; +import org.apache.maven.scm.ScmFileStatus; +import org.apache.maven.scm.provider.hg.command.HgConsumer; + /** * @author thurner rupert * */ -class HgStatusConsumer - extends HgConsumer -{ +class HgStatusConsumer extends HgConsumer { private final List repositoryStatus = new ArrayList(); private final File workingDir; - HgStatusConsumer( File workingDir ) - { + HgStatusConsumer(File workingDir) { this.workingDir = workingDir; } /** {@inheritDoc} */ - public void doConsume( ScmFileStatus status, String trimmedLine ) - { - //Only include real files (not directories) - File tmpFile = new File( workingDir, trimmedLine ); - if ( !tmpFile.exists() ) - { - if ( logger.isInfoEnabled() ) - { - logger.info( "Not a file: " + tmpFile + ". Ignoring" ); + public void doConsume(ScmFileStatus status, String trimmedLine) { + // Only include real files (not directories) + File tmpFile = new File(workingDir, trimmedLine); + if (!tmpFile.exists()) { + if (logger.isInfoEnabled()) { + logger.info("Not a file: " + tmpFile + ". Ignoring"); } - } - else if ( tmpFile.isDirectory() ) - { - if ( logger.isInfoEnabled() ) - { - logger.info( "New directory added: " + tmpFile ); + } else if (tmpFile.isDirectory()) { + if (logger.isInfoEnabled()) { + logger.info("New directory added: " + tmpFile); } - } - else - { - ScmFile scmFile = new ScmFile( trimmedLine, status ); - if ( logger.isInfoEnabled() ) - { - logger.info( scmFile.toString() ); + } else { + ScmFile scmFile = new ScmFile(trimmedLine, status); + if (logger.isInfoEnabled()) { + logger.info(scmFile.toString()); } - repositoryStatus.add( scmFile ); + repositoryStatus.add(scmFile); } } - List getStatus() - { + List getStatus() { return repositoryStatus; } } diff --git a/maven-scm-providers/maven-scm-provider-hg/src/main/java/org/apache/maven/scm/provider/hg/command/tag/HgTagCommand.java b/maven-scm-providers/maven-scm-provider-hg/src/main/java/org/apache/maven/scm/provider/hg/command/tag/HgTagCommand.java index b682499e6..4f8067278 100644 --- a/maven-scm-providers/maven-scm-provider-hg/src/main/java/org/apache/maven/scm/provider/hg/command/tag/HgTagCommand.java +++ b/maven-scm-providers/maven-scm-provider-hg/src/main/java/org/apache/maven/scm/provider/hg/command/tag/HgTagCommand.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.hg.command.tag; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider.hg.command.tag; import java.io.File; import java.util.ArrayList; @@ -47,110 +46,93 @@ * @author Olivier Lamy * */ -public class HgTagCommand - extends AbstractTagCommand - implements Command -{ - - protected ScmResult executeTagCommand( ScmProviderRepository scmProviderRepository, ScmFileSet fileSet, String tag, - String message ) - throws ScmException - { - return executeTagCommand( scmProviderRepository, fileSet, tag, new ScmTagParameters( message ) ); +public class HgTagCommand extends AbstractTagCommand implements Command { + + protected ScmResult executeTagCommand( + ScmProviderRepository scmProviderRepository, ScmFileSet fileSet, String tag, String message) + throws ScmException { + return executeTagCommand(scmProviderRepository, fileSet, tag, new ScmTagParameters(message)); } /** * {@inheritDoc} */ - protected ScmResult executeTagCommand( ScmProviderRepository scmProviderRepository, ScmFileSet fileSet, String tag, - ScmTagParameters scmTagParameters ) - throws ScmException - { - - if ( tag == null || StringUtils.isEmpty( tag.trim() ) ) - { - throw new ScmException( "tag must be specified" ); + protected ScmResult executeTagCommand( + ScmProviderRepository scmProviderRepository, + ScmFileSet fileSet, + String tag, + ScmTagParameters scmTagParameters) + throws ScmException { + + if (tag == null || StringUtils.isEmpty(tag.trim())) { + throw new ScmException("tag must be specified"); } - if ( !fileSet.getFileList().isEmpty() ) - { - throw new ScmException( "This provider doesn't support tagging subsets of a directory : " - + fileSet.getFileList() ); + if (!fileSet.getFileList().isEmpty()) { + throw new ScmException( + "This provider doesn't support tagging subsets of a directory : " + fileSet.getFileList()); } File workingDir = fileSet.getBasedir(); // build the command - String[] tagCmd = - new String[]{ HgCommandConstants.TAG_CMD, HgCommandConstants.MESSAGE_OPTION, scmTagParameters.getMessage(), - tag }; + String[] tagCmd = new String[] { + HgCommandConstants.TAG_CMD, HgCommandConstants.MESSAGE_OPTION, scmTagParameters.getMessage(), tag + }; // keep the command about in string form for reporting - StringBuilder cmd = joinCmd( tagCmd ); + StringBuilder cmd = joinCmd(tagCmd); HgTagConsumer consumer = new HgTagConsumer(); - ScmResult result = HgUtils.execute( consumer, workingDir, tagCmd ); + ScmResult result = HgUtils.execute(consumer, workingDir, tagCmd); HgScmProviderRepository repository = (HgScmProviderRepository) scmProviderRepository; - if ( result.isSuccess() ) - { + if (result.isSuccess()) { // now push // Push to parent branch if any - if ( repository.isPushChanges() ) - { - if ( !repository.getURI().equals( fileSet.getBasedir().getAbsolutePath() ) ) - { - String branchName = HgUtils.getCurrentBranchName( workingDir ); - boolean differentOutgoingBranch = - HgUtils.differentOutgoingBranchFound( workingDir, branchName ); + if (repository.isPushChanges()) { + if (!repository.getURI().equals(fileSet.getBasedir().getAbsolutePath())) { + String branchName = HgUtils.getCurrentBranchName(workingDir); + boolean differentOutgoingBranch = HgUtils.differentOutgoingBranchFound(workingDir, branchName); - String[] pushCmd = new String[]{ HgCommandConstants.PUSH_CMD, + String[] pushCmd = new String[] { + HgCommandConstants.PUSH_CMD, differentOutgoingBranch ? HgCommandConstants.REVISION_OPTION + branchName : null, - repository.getURI() }; + repository.getURI() + }; - result = - HgUtils.execute( new HgConsumer(), fileSet.getBasedir(), pushCmd ); + result = HgUtils.execute(new HgConsumer(), fileSet.getBasedir(), pushCmd); } } - } - else - { - throw new ScmException( "Error while executing command " + cmd.toString() ); + } else { + throw new ScmException("Error while executing command " + cmd.toString()); } // do an inventory to return the files tagged (all of them) - String[] listCmd = new String[]{ HgCommandConstants.INVENTORY_CMD }; + String[] listCmd = new String[] {HgCommandConstants.INVENTORY_CMD}; HgListConsumer listconsumer = new HgListConsumer(); - result = HgUtils.execute( listconsumer, fileSet.getBasedir(), listCmd ); - if ( result.isSuccess() ) - { + result = HgUtils.execute(listconsumer, fileSet.getBasedir(), listCmd); + if (result.isSuccess()) { List files = listconsumer.getFiles(); List fileList = new ArrayList(); - for ( ScmFile f : files ) - { - if ( !f.getPath().endsWith( ".hgtags" ) ) - { - fileList.add( new ScmFile( f.getPath(), ScmFileStatus.TAGGED ) ); + for (ScmFile f : files) { + if (!f.getPath().endsWith(".hgtags")) { + fileList.add(new ScmFile(f.getPath(), ScmFileStatus.TAGGED)); } } - return new TagScmResult( fileList, result ); - } - else - { - throw new ScmException( "Error while executing command " + cmd.toString() ); + return new TagScmResult(fileList, result); + } else { + throw new ScmException("Error while executing command " + cmd.toString()); } } - private StringBuilder joinCmd( String[] cmd ) - { + private StringBuilder joinCmd(String[] cmd) { StringBuilder result = new StringBuilder(); - for ( int i = 0; i < cmd.length; i++ ) - { + for (int i = 0; i < cmd.length; i++) { String s = cmd[i]; - result.append( s ); - if ( i < cmd.length - 1 ) - { - result.append( " " ); + result.append(s); + if (i < cmd.length - 1) { + result.append(" "); } } return result; diff --git a/maven-scm-providers/maven-scm-provider-hg/src/main/java/org/apache/maven/scm/provider/hg/command/tag/HgTagConsumer.java b/maven-scm-providers/maven-scm-provider-hg/src/main/java/org/apache/maven/scm/provider/hg/command/tag/HgTagConsumer.java index 4fc8ef236..023b1cdb5 100644 --- a/maven-scm-providers/maven-scm-provider-hg/src/main/java/org/apache/maven/scm/provider/hg/command/tag/HgTagConsumer.java +++ b/maven-scm-providers/maven-scm-provider-hg/src/main/java/org/apache/maven/scm/provider/hg/command/tag/HgTagConsumer.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.hg.command.tag; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider.hg.command.tag; import org.apache.maven.scm.ScmFileStatus; import org.apache.maven.scm.provider.hg.command.HgConsumer; @@ -26,11 +25,7 @@ * @author ryan daum * */ -public class HgTagConsumer - extends HgConsumer -{ +public class HgTagConsumer extends HgConsumer { /** {@inheritDoc} */ - public void doConsume( ScmFileStatus status, String trimmedLine ) - { - } + public void doConsume(ScmFileStatus status, String trimmedLine) {} } diff --git a/maven-scm-providers/maven-scm-provider-hg/src/main/java/org/apache/maven/scm/provider/hg/command/update/HgUpdateCommand.java b/maven-scm-providers/maven-scm-provider-hg/src/main/java/org/apache/maven/scm/provider/hg/command/update/HgUpdateCommand.java index 89ce64aa1..974f85eb7 100644 --- a/maven-scm-providers/maven-scm-provider-hg/src/main/java/org/apache/maven/scm/provider/hg/command/update/HgUpdateCommand.java +++ b/maven-scm-providers/maven-scm-provider-hg/src/main/java/org/apache/maven/scm/provider/hg/command/update/HgUpdateCommand.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.hg.command.update; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider.hg.command.update; import java.io.File; import java.util.ArrayList; @@ -48,78 +47,65 @@ * @author Olivier Lamy * */ -public class HgUpdateCommand - extends AbstractUpdateCommand - implements Command -{ +public class HgUpdateCommand extends AbstractUpdateCommand implements Command { /** {@inheritDoc} */ - protected UpdateScmResult executeUpdateCommand( ScmProviderRepository repo, ScmFileSet fileSet, ScmVersion tag ) - throws ScmException - { + protected UpdateScmResult executeUpdateCommand(ScmProviderRepository repo, ScmFileSet fileSet, ScmVersion tag) + throws ScmException { File workingDir = fileSet.getBasedir(); String[] updateCmd; // Update branch - if ( repo.isPushChanges() ) - { - updateCmd = - new String[] { HgCommandConstants.PULL_CMD, HgCommandConstants.REVISION_OPTION, - tag != null && !StringUtils.isEmpty( tag.getName() ) ? tag.getName() : "tip" }; + if (repo.isPushChanges()) { + updateCmd = new String[] { + HgCommandConstants.PULL_CMD, + HgCommandConstants.REVISION_OPTION, + tag != null && !StringUtils.isEmpty(tag.getName()) ? tag.getName() : "tip" + }; + } else { + updateCmd = new String[] { + HgCommandConstants.UPDATE_CMD, + tag != null && !StringUtils.isEmpty(tag.getName()) ? tag.getName() : "tip", + HgCommandConstants.CLEAN_OPTION + }; } - else - { - updateCmd = - new String[] { HgCommandConstants.UPDATE_CMD, - tag != null && !StringUtils.isEmpty( tag.getName() ) ? tag.getName() : "tip", - HgCommandConstants.CLEAN_OPTION }; - } - ScmResult updateResult = HgUtils.execute( new HgConsumer(), workingDir, updateCmd ); + ScmResult updateResult = HgUtils.execute(new HgConsumer(), workingDir, updateCmd); - if ( !updateResult.isSuccess() ) - { - return new UpdateScmResult( null, null, updateResult ); + if (!updateResult.isSuccess()) { + return new UpdateScmResult(null, null, updateResult); } // Find changes from last revision - int currentRevision = HgUtils.getCurrentRevisionNumber( workingDir ); + int currentRevision = HgUtils.getCurrentRevisionNumber(workingDir); int previousRevision = currentRevision - 1; - String[] diffCmd = new String[] { - HgCommandConstants.DIFF_CMD, - HgCommandConstants.REVISION_OPTION, - "" + previousRevision }; - HgDiffConsumer diffConsumer = new HgDiffConsumer( workingDir ); - ScmResult diffResult = HgUtils.execute( diffConsumer, workingDir, diffCmd ); + String[] diffCmd = + new String[] {HgCommandConstants.DIFF_CMD, HgCommandConstants.REVISION_OPTION, "" + previousRevision}; + HgDiffConsumer diffConsumer = new HgDiffConsumer(workingDir); + ScmResult diffResult = HgUtils.execute(diffConsumer, workingDir, diffCmd); // Now translate between diff and update file status List updatedFiles = new ArrayList<>(); List changes = new ArrayList<>(); List diffFiles = diffConsumer.getChangedFiles(); Map diffChanges = diffConsumer.getDifferences(); - for ( ScmFile file : diffFiles ) - { - changes.add( diffChanges.get( file.getPath() ) ); - if ( file.getStatus() == ScmFileStatus.MODIFIED ) - { - updatedFiles.add( new ScmFile( file.getPath(), ScmFileStatus.PATCHED ) ); - } - else - { - updatedFiles.add( file ); + for (ScmFile file : diffFiles) { + changes.add(diffChanges.get(file.getPath())); + if (file.getStatus() == ScmFileStatus.MODIFIED) { + updatedFiles.add(new ScmFile(file.getPath(), ScmFileStatus.PATCHED)); + } else { + updatedFiles.add(file); } } - - if ( repo.isPushChanges() ) - { - String[] hgUpdateCmd = new String[] { HgCommandConstants.UPDATE_CMD }; - HgUtils.execute( new HgConsumer(), workingDir, hgUpdateCmd ); + + if (repo.isPushChanges()) { + String[] hgUpdateCmd = new String[] {HgCommandConstants.UPDATE_CMD}; + HgUtils.execute(new HgConsumer(), workingDir, hgUpdateCmd); } - return new UpdateScmResultWithRevision( updatedFiles, new ArrayList<>( 0 ), - String.valueOf( currentRevision ), diffResult ); + return new UpdateScmResultWithRevision( + updatedFiles, new ArrayList<>(0), String.valueOf(currentRevision), diffResult); } - protected ChangeLogCommand getChangeLogCommand() - { + protected ChangeLogCommand getChangeLogCommand() { return new HgChangeLogCommand(); } } diff --git a/maven-scm-providers/maven-scm-provider-hg/src/main/java/org/apache/maven/scm/provider/hg/repository/HgScmProviderRepository.java b/maven-scm-providers/maven-scm-provider-hg/src/main/java/org/apache/maven/scm/provider/hg/repository/HgScmProviderRepository.java index 53239d4c9..68ab4d0ee 100644 --- a/maven-scm-providers/maven-scm-provider-hg/src/main/java/org/apache/maven/scm/provider/hg/repository/HgScmProviderRepository.java +++ b/maven-scm-providers/maven-scm-provider-hg/src/main/java/org/apache/maven/scm/provider/hg/repository/HgScmProviderRepository.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.hg.repository; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,21 +16,20 @@ * specific language governing permissions and limitations * under the License. */ - -import org.apache.maven.scm.provider.ScmProviderRepositoryWithHost; -import org.codehaus.plexus.util.StringUtils; +package org.apache.maven.scm.provider.hg.repository; import java.io.File; import java.util.Objects; +import org.apache.maven.scm.provider.ScmProviderRepositoryWithHost; +import org.codehaus.plexus.util.StringUtils; + /** * @author thurner rupert * */ -public class HgScmProviderRepository - extends ScmProviderRepositoryWithHost -{ - //Known and tested protocols +public class HgScmProviderRepository extends ScmProviderRepositoryWithHost { + // Known and tested protocols private static final String FILE = ""; private static final String SFTP = "sftp://"; @@ -51,159 +48,122 @@ public class HgScmProviderRepository private final String orgUrl; - public HgScmProviderRepository( String url ) - { + public HgScmProviderRepository(String url) { orgUrl = url; - protocol = getProtocol( url ); - path = parseUrl( url ); + protocol = getProtocol(url); + path = parseUrl(url); } - public String getURI() - { + public String getURI() { return protocol + addAuthority() + addHost() + addPort() + addPath(); } /** * @return A message if the repository as an invalid URI, null if the URI seems fine. */ - public String validateURI() - { + public String validateURI() { String msg = null; - if ( needsAuthentication() ) - { - if ( getUser() == null ) - { + if (needsAuthentication()) { + if (getUser() == null) { msg = "Username is missing for protocol " + protocol; - } - else if ( getPassword() == null ) - { + } else if (getPassword() == null) { msg = "Password is missing for protocol " + protocol; - } - else if ( getHost() == null ) - { + } else if (getHost() == null) { msg = "Host (eg. www.myhost.com) is missing for protocol " + protocol; } - } - - else if ( getPort() != 0 && getHost() == null ) - { + } else if (getPort() != 0 && getHost() == null) { msg = "Got port information without any host for protocol " + protocol; } - if ( msg != null ) - { - msg = - "Something could be wrong about the repository URL: " + orgUrl + "\nReason: " + msg + if (msg != null) { + msg = "Something could be wrong about the repository URL: " + orgUrl + "\nReason: " + msg + "\nCheck http://maven.apache.org/scm for usage and hints."; } return msg; } - private String getProtocol( String url ) - { + private String getProtocol(String url) { // Assume we have a file unless we find a URL based syntax String prot = FILE; - if ( url.startsWith( SFTP ) ) - { + if (url.startsWith(SFTP)) { prot = SFTP; - } - else if ( url.startsWith( HTTP ) ) - { + } else if (url.startsWith(HTTP)) { prot = HTTP; - } - else if ( url.startsWith( HTTPS ) ) - { + } else if (url.startsWith(HTTPS)) { prot = HTTPS; } return prot; } - private String parseUrl( String url ) - { - if ( Objects.equals( protocol, FILE ) ) - { + private String parseUrl(String url) { + if (Objects.equals(protocol, FILE)) { return url; } - //Strip protocol - url = url.substring( protocol.length() ); + // Strip protocol + url = url.substring(protocol.length()); - url = parseUsernameAndPassword( url ); + url = parseUsernameAndPassword(url); - url = parseHostAndPort( url ); + url = parseHostAndPort(url); - url = parsePath( url ); + url = parsePath(url); - return url; //is now only the path + return url; // is now only the path } - private String parseHostAndPort( String url ) - { - if ( !Objects.equals( protocol, FILE ) ) - { - int indexSlash = url.indexOf( '/' ); + private String parseHostAndPort(String url) { + if (!Objects.equals(protocol, FILE)) { + int indexSlash = url.indexOf('/'); String hostPort = url; - if ( indexSlash > 0 ) - { - hostPort = url.substring( 0, indexSlash ); - url = url.substring( indexSlash ); + if (indexSlash > 0) { + hostPort = url.substring(0, indexSlash); + url = url.substring(indexSlash); } - int indexColon = hostPort.indexOf( ':' ); - if ( indexColon > 0 ) - { - setHost( hostPort.substring( 0, indexColon ) ); - setPort( Integer.parseInt( hostPort.substring( indexColon + 1 ) ) ); - } - else - { - setHost( hostPort ); + int indexColon = hostPort.indexOf(':'); + if (indexColon > 0) { + setHost(hostPort.substring(0, indexColon)); + setPort(Integer.parseInt(hostPort.substring(indexColon + 1))); + } else { + setHost(hostPort); } } return url; } - private String parseUsernameAndPassword( String url ) - { - if ( canAuthenticate() ) - { - String[] split = url.split( "@" ); - if ( split.length == 2 ) - { - url = split[1]; //Strip away 'username:password@' from url - split = split[0].split( ":" ); - if ( split.length == 2 ) - { //both username and password - setUser( split[0] ); - setPassword( split[1] ); - } - else - { //only username - setUser( split[0] ); + private String parseUsernameAndPassword(String url) { + if (canAuthenticate()) { + String[] split = url.split("@"); + if (split.length == 2) { + url = split[1]; // Strip away 'username:password@' from url + split = split[0].split(":"); + if (split.length == 2) { // both username and password + setUser(split[0]); + setPassword(split[1]); + } else { // only username + setUser(split[0]); } } } return url; } - private String parsePath( String url ) - { - if ( Objects.equals( protocol, FILE ) ) - { - //Use OS dependent path separator - url = StringUtils.replace( url, "/", File.separator ); - - //Test first path separator (*nix systems use them to denote root) - File tmpFile = new File( url ); //most likly a *nix system - String url2 = url.substring( File.pathSeparator.length() ); - File tmpFile2 = new File( url2 ); //most likly a windows system - if ( !tmpFile.exists() && !tmpFile2.exists() ) - { + private String parsePath(String url) { + if (Objects.equals(protocol, FILE)) { + // Use OS dependent path separator + url = StringUtils.replace(url, "/", File.separator); + + // Test first path separator (*nix systems use them to denote root) + File tmpFile = new File(url); // most likly a *nix system + String url2 = url.substring(File.pathSeparator.length()); + File tmpFile2 = new File(url2); // most likly a windows system + if (!tmpFile.exists() && !tmpFile2.exists()) { // This is trouble - Trouble is reported in validateURI() } @@ -213,52 +173,44 @@ private String parsePath( String url ) return url; } - private String addUser() - { - return ( getUser() == null ) ? "" : getUser(); + private String addUser() { + return (getUser() == null) ? "" : getUser(); } - private String addPassword() - { - return ( getPassword() == null ) ? "" : ":" + getPassword(); + private String addPassword() { + return (getPassword() == null) ? "" : ":" + getPassword(); } - private String addHost() - { - return ( getHost() == null ) ? "" : getHost(); + private String addHost() { + return (getHost() == null) ? "" : getHost(); } - private String addPort() - { - return ( getPort() == 0 ) ? "" : ":" + getPort(); + private String addPort() { + return (getPort() == 0) ? "" : ":" + getPort(); } - private String addPath() - { + private String addPath() { return path; } - private boolean needsAuthentication() - { - return Objects.equals( protocol, SFTP ) || Objects.equals( protocol, FTP ) || Objects.equals( protocol, HTTPS ) - || Objects.equals( protocol, AFTP ); + private boolean needsAuthentication() { + return Objects.equals(protocol, SFTP) + || Objects.equals(protocol, FTP) + || Objects.equals(protocol, HTTPS) + || Objects.equals(protocol, AFTP); } - private String addAuthority() - { - return ( ( canAuthenticate() && ( getUser() != null ) ) ? addUser() + addPassword() + "@" : "" ); + private String addAuthority() { + return ((canAuthenticate() && (getUser() != null)) ? addUser() + addPassword() + "@" : ""); } - - private boolean canAuthenticate() - { - return needsAuthentication() || Objects.equals( protocol, HTTP ); + private boolean canAuthenticate() { + return needsAuthentication() || Objects.equals(protocol, HTTP); } /** {@inheritDoc} */ - public String toString() - { + public String toString() { return "Hg Repository Interpreted from: " + orgUrl + ":\nProtocol: " + protocol + "\nHost: " + getHost() - + "\nPort: " + getPort() + "\nUsername: " + getUser() + "\nPassword: " + getPassword() + "\nPath: " - + path; + + "\nPort: " + getPort() + "\nUsername: " + getUser() + "\nPassword: " + getPassword() + "\nPath: " + + path; } } diff --git a/maven-scm-providers/maven-scm-provider-hg/src/test/java/org/apache/maven/scm/provider/hg/HgRepoUtils.java b/maven-scm-providers/maven-scm-provider-hg/src/test/java/org/apache/maven/scm/provider/hg/HgRepoUtils.java index 7fe580e45..24d83e455 100644 --- a/maven-scm-providers/maven-scm-provider-hg/src/test/java/org/apache/maven/scm/provider/hg/HgRepoUtils.java +++ b/maven-scm-providers/maven-scm-provider-hg/src/test/java/org/apache/maven/scm/provider/hg/HgRepoUtils.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.hg; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,12 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider.hg; + +import java.io.File; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; import org.apache.maven.scm.ScmFileSet; import org.apache.maven.scm.ScmResult; @@ -25,104 +29,86 @@ import org.apache.maven.scm.provider.hg.command.HgCommandConstants; import org.codehaus.plexus.util.FileUtils; -import java.io.File; -import java.io.IOException; -import java.util.ArrayList; -import java.util.List; - /** * Common code used in all tests. * * @author thurner rupert */ -public class HgRepoUtils - extends ScmTestCase -{ +public class HgRepoUtils extends ScmTestCase { /** 'hg' command line */ public static final String HG_COMMAND_LINE = "hg"; public static final String[] filesInTestBranch = - new String[]{"pom.xml", "readme.txt", "src/main/java/Application.java", "src/test/java/Test.java"}; + new String[] {"pom.xml", "readme.txt", "src/main/java/Application.java", "src/test/java/Test.java"}; public static final String TCK_FILE_CONSTANT = "/"; public static final String BRANCH_NAME = "target" + File.separator + "test-branch"; - public static final File WORKING_DIR = new File( getBasedir(), BRANCH_NAME ); + public static final File WORKING_DIR = new File(getBasedir(), BRANCH_NAME); public static final String COMMIT_MESSAGE = "Add files to test branch"; - public static String getScmUrl() - throws Exception - { + public static String getScmUrl() throws Exception { return "scm:hg:" + WORKING_DIR.getAbsolutePath(); } - public static void initRepo() - throws Exception - { + public static void initRepo() throws Exception { // Prepare tmp directory - if ( WORKING_DIR.exists() ) - { - FileUtils.deleteDirectory( WORKING_DIR ); + if (WORKING_DIR.exists()) { + FileUtils.deleteDirectory(WORKING_DIR); - if ( WORKING_DIR.exists() ) - { - throw new IOException( WORKING_DIR.getAbsolutePath() + " wasn't deleted." ); + if (WORKING_DIR.exists()) { + throw new IOException(WORKING_DIR.getAbsolutePath() + " wasn't deleted."); } } boolean workingDirReady = WORKING_DIR.mkdirs(); - if ( !workingDirReady ) - { - throw new IOException( "Could not initiate test branch at: " + WORKING_DIR ); + if (!workingDirReady) { + throw new IOException("Could not initiate test branch at: " + WORKING_DIR); } // Init repository - String[] init_cmd = new String[]{HgCommandConstants.INIT_CMD}; - HgUtils.execute( WORKING_DIR, init_cmd ); + String[] init_cmd = new String[] {HgCommandConstants.INIT_CMD}; + HgUtils.execute(WORKING_DIR, init_cmd); // Create and add files to repository List files = new ArrayList(); - for ( int i = 0; i < filesInTestBranch.length; i++ ) - { - File file = new File( WORKING_DIR.getAbsolutePath(), filesInTestBranch[i] ); - if ( file.getParentFile() != null && !file.getParentFile().exists() ) - { + for (int i = 0; i < filesInTestBranch.length; i++) { + File file = new File(WORKING_DIR.getAbsolutePath(), filesInTestBranch[i]); + if (file.getParentFile() != null && !file.getParentFile().exists()) { boolean success = file.getParentFile().mkdirs(); - if ( !success ) - { - throw new IOException( "Could not create directories in branch for: " + file ); + if (!success) { + throw new IOException("Could not create directories in branch for: " + file); } } file.createNewFile(); - FileUtils.fileWrite( file.getAbsolutePath(), TCK_FILE_CONSTANT + filesInTestBranch[i] ); + FileUtils.fileWrite(file.getAbsolutePath(), TCK_FILE_CONSTANT + filesInTestBranch[i]); - files.add( file ); + files.add(file); } - //Add to repository - String[] add_cmd = new String[]{HgCommandConstants.ADD_CMD}; - ScmFileSet filesToAdd = new ScmFileSet( new File( "" ), files ); - add_cmd = HgUtils.expandCommandLine( add_cmd, filesToAdd ); - ScmResult result = HgUtils.execute( WORKING_DIR, add_cmd ); - if ( !result.isSuccess() ) - { + // Add to repository + String[] add_cmd = new String[] {HgCommandConstants.ADD_CMD}; + ScmFileSet filesToAdd = new ScmFileSet(new File(""), files); + add_cmd = HgUtils.expandCommandLine(add_cmd, filesToAdd); + ScmResult result = HgUtils.execute(WORKING_DIR, add_cmd); + if (!result.isSuccess()) { String message = - "Provider message: " + result.getProviderMessage() + "\n" + "Output: " + result.getCommandOutput(); - throw new Exception( message ); + "Provider message: " + result.getProviderMessage() + "\n" + "Output: " + result.getCommandOutput(); + throw new Exception(message); } // Commit the initial repository - String[] commit_cmd = new String[]{HgCommandConstants.COMMIT_CMD, HgCommandConstants.MESSAGE_OPTION, COMMIT_MESSAGE}; - result = HgUtils.execute( WORKING_DIR, commit_cmd ); - if ( !result.isSuccess() ) - { + String[] commit_cmd = + new String[] {HgCommandConstants.COMMIT_CMD, HgCommandConstants.MESSAGE_OPTION, COMMIT_MESSAGE}; + result = HgUtils.execute(WORKING_DIR, commit_cmd); + if (!result.isSuccess()) { String message = - "Provider message: " + result.getProviderMessage() + "\n" + "Output: " + result.getCommandOutput(); - throw new Exception( message ); + "Provider message: " + result.getProviderMessage() + "\n" + "Output: " + result.getCommandOutput(); + throw new Exception(message); } } } diff --git a/maven-scm-providers/maven-scm-provider-hg/src/test/java/org/apache/maven/scm/provider/hg/HgUtilsTest.java b/maven-scm-providers/maven-scm-provider-hg/src/test/java/org/apache/maven/scm/provider/hg/HgUtilsTest.java index feddba63c..24433b6ca 100644 --- a/maven-scm-providers/maven-scm-provider-hg/src/test/java/org/apache/maven/scm/provider/hg/HgUtilsTest.java +++ b/maven-scm-providers/maven-scm-provider-hg/src/test/java/org/apache/maven/scm/provider/hg/HgUtilsTest.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.hg; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -18,49 +16,40 @@ * specific language governing permissions and limitations * under the License. */ - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNull; +package org.apache.maven.scm.provider.hg; import org.apache.maven.scm.provider.hg.command.HgCommandConstants; import org.codehaus.plexus.util.StringUtils; import org.codehaus.plexus.util.cli.Commandline; import org.junit.Test; -public class HgUtilsTest -{ +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; + +public class HgUtilsTest { @Test - public void testNullWorkingDirectory() - throws Exception - { - Commandline cmd = HgUtils.buildCmd( null, new String[] {} ); - assertNull( cmd.getWorkingDirectory() ); + public void testNullWorkingDirectory() throws Exception { + Commandline cmd = HgUtils.buildCmd(null, new String[] {}); + assertNull(cmd.getWorkingDirectory()); } @Test - public void testCryptPassword() - throws Exception - { - Commandline cmdHttps = HgUtils.buildCmd( null, new String[] { - HgCommandConstants.PUSH_CMD, - null, - "https://username:password@example.com/foobar" - } ); - Commandline cmd = new Commandline( HgUtils.maskPassword( cmdHttps ) ); - + public void testCryptPassword() throws Exception { + Commandline cmdHttps = HgUtils.buildCmd( + null, new String[] {HgCommandConstants.PUSH_CMD, null, "https://username:password@example.com/foobar"}); + Commandline cmd = new Commandline(HgUtils.maskPassword(cmdHttps)); + String[] shellArgs = cmd.getShell().getShellArgs(); // Watch it: Shell would return null, whereas BourneShell would return an empty array - if ( shellArgs != null && shellArgs.length > 0 ) - { + if (shellArgs != null && shellArgs.length > 0) { // [/C, hg push https://username:*****@example.com/foobar] // [/X, /C, hg push https://username:*****@example.com/foobar] - assertEquals( "https://username:*****@example.com/foobar", - StringUtils.split( cmd.getArguments()[shellArgs.length] )[2] ); - } - else - { - assertEquals( "https://username:*****@example.com/foobar", cmd.getArguments()[3] ); + assertEquals( + "https://username:*****@example.com/foobar", + StringUtils.split(cmd.getArguments()[shellArgs.length])[2]); + } else { + assertEquals("https://username:*****@example.com/foobar", cmd.getArguments()[3]); } } } diff --git a/maven-scm-providers/maven-scm-provider-hg/src/test/java/org/apache/maven/scm/provider/hg/command/blame/HgBlameCommandTckTest.java b/maven-scm-providers/maven-scm-provider-hg/src/test/java/org/apache/maven/scm/provider/hg/command/blame/HgBlameCommandTckTest.java index 0b080b283..76cc78671 100644 --- a/maven-scm-providers/maven-scm-provider-hg/src/test/java/org/apache/maven/scm/provider/hg/command/blame/HgBlameCommandTckTest.java +++ b/maven-scm-providers/maven-scm-provider-hg/src/test/java/org/apache/maven/scm/provider/hg/command/blame/HgBlameCommandTckTest.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.hg.command.blame; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,14 +16,15 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider.hg.command.blame; + +import java.util.List; import org.apache.maven.scm.command.blame.BlameLine; import org.apache.maven.scm.command.blame.BlameScmResult; import org.apache.maven.scm.provider.hg.HgRepoUtils; import org.apache.maven.scm.tck.command.blame.BlameCommandTckTest; -import java.util.List; - import static org.apache.maven.scm.provider.hg.HgRepoUtils.HG_COMMAND_LINE; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotEquals; @@ -33,32 +32,24 @@ /** * @author Evgeny Mandrikov */ -public class HgBlameCommandTckTest - extends BlameCommandTckTest -{ +public class HgBlameCommandTckTest extends BlameCommandTckTest { @Override - public String getScmProviderCommand() - { + public String getScmProviderCommand() { return HG_COMMAND_LINE; } - public String getScmUrl() - throws Exception - { + public String getScmUrl() throws Exception { return HgRepoUtils.getScmUrl(); } - public void initRepo() - throws Exception - { + public void initRepo() throws Exception { HgRepoUtils.initRepo(); } - protected void verifyResult( BlameScmResult result ) - { + protected void verifyResult(BlameScmResult result) { List lines = result.getLines(); - assertEquals( "Expected 1 line in blame", 1, lines.size() ); - BlameLine line = lines.get( 0 ); - assertNotEquals( "0", line.getRevision() ); + assertEquals("Expected 1 line in blame", 1, lines.size()); + BlameLine line = lines.get(0); + assertNotEquals("0", line.getRevision()); } } diff --git a/maven-scm-providers/maven-scm-provider-hg/src/test/java/org/apache/maven/scm/provider/hg/command/changelog/HgChangeLogCommandTckTest.java b/maven-scm-providers/maven-scm-provider-hg/src/test/java/org/apache/maven/scm/provider/hg/command/changelog/HgChangeLogCommandTckTest.java index 8f95b073d..6c5b70f3d 100644 --- a/maven-scm-providers/maven-scm-provider-hg/src/test/java/org/apache/maven/scm/provider/hg/command/changelog/HgChangeLogCommandTckTest.java +++ b/maven-scm-providers/maven-scm-provider-hg/src/test/java/org/apache/maven/scm/provider/hg/command/changelog/HgChangeLogCommandTckTest.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.hg.command.changelog; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,37 +16,29 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider.hg.command.changelog; import org.apache.maven.scm.provider.hg.HgRepoUtils; import org.apache.maven.scm.tck.command.changelog.ChangeLogCommandTckTest; import static org.apache.maven.scm.provider.hg.HgRepoUtils.HG_COMMAND_LINE; -public class HgChangeLogCommandTckTest - extends ChangeLogCommandTckTest -{ +public class HgChangeLogCommandTckTest extends ChangeLogCommandTckTest { @Override - public String getScmProviderCommand() - { + public String getScmProviderCommand() { return HG_COMMAND_LINE; } - public String getScmUrl() - throws Exception - { + public String getScmUrl() throws Exception { return HgRepoUtils.getScmUrl(); } - public void initRepo() - throws Exception - { + public void initRepo() throws Exception { HgRepoUtils.initRepo(); } @Override - public boolean isTagAnExtraCommit() - { + public boolean isTagAnExtraCommit() { return true; } - } diff --git a/maven-scm-providers/maven-scm-provider-hg/src/test/java/org/apache/maven/scm/provider/hg/command/checkin/HgCheckInCommandTckTest.java b/maven-scm-providers/maven-scm-provider-hg/src/test/java/org/apache/maven/scm/provider/hg/command/checkin/HgCheckInCommandTckTest.java index 3d6bf3863..e24b43a92 100644 --- a/maven-scm-providers/maven-scm-provider-hg/src/test/java/org/apache/maven/scm/provider/hg/command/checkin/HgCheckInCommandTckTest.java +++ b/maven-scm-providers/maven-scm-provider-hg/src/test/java/org/apache/maven/scm/provider/hg/command/checkin/HgCheckInCommandTckTest.java @@ -1,20 +1,22 @@ -package org.apache.maven.scm.provider.hg.command.checkin; - /* - * Copyright 2001-2006 The Apache Software Foundation. + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. */ +package org.apache.maven.scm.provider.hg.command.checkin; import org.apache.maven.scm.provider.hg.HgRepoUtils; import org.apache.maven.scm.tck.command.checkin.CheckInCommandTckTest; @@ -24,24 +26,17 @@ /** * @author thurner rupert */ -public class HgCheckInCommandTckTest - extends CheckInCommandTckTest -{ +public class HgCheckInCommandTckTest extends CheckInCommandTckTest { @Override - public String getScmProviderCommand() - { + public String getScmProviderCommand() { return HG_COMMAND_LINE; } - public String getScmUrl() - throws Exception - { + public String getScmUrl() throws Exception { return HgRepoUtils.getScmUrl(); } - public void initRepo() - throws Exception - { + public void initRepo() throws Exception { HgRepoUtils.initRepo(); } } diff --git a/maven-scm-providers/maven-scm-provider-hg/src/test/java/org/apache/maven/scm/provider/hg/command/checkout/HgCheckOutCommandTckTest.java b/maven-scm-providers/maven-scm-provider-hg/src/test/java/org/apache/maven/scm/provider/hg/command/checkout/HgCheckOutCommandTckTest.java index a4c686eb3..141922269 100644 --- a/maven-scm-providers/maven-scm-provider-hg/src/test/java/org/apache/maven/scm/provider/hg/command/checkout/HgCheckOutCommandTckTest.java +++ b/maven-scm-providers/maven-scm-provider-hg/src/test/java/org/apache/maven/scm/provider/hg/command/checkout/HgCheckOutCommandTckTest.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.hg.command.checkout; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider.hg.command.checkout; import org.apache.maven.scm.provider.hg.HgRepoUtils; import org.apache.maven.scm.tck.command.checkout.CheckOutCommandTckTest; @@ -27,24 +26,17 @@ /** * @author thurner rupert */ -public class HgCheckOutCommandTckTest - extends CheckOutCommandTckTest -{ +public class HgCheckOutCommandTckTest extends CheckOutCommandTckTest { @Override - public String getScmProviderCommand() - { + public String getScmProviderCommand() { return HG_COMMAND_LINE; } - public String getScmUrl() - throws Exception - { + public String getScmUrl() throws Exception { return HgRepoUtils.getScmUrl(); } - public void initRepo() - throws Exception - { + public void initRepo() throws Exception { HgRepoUtils.initRepo(); } } diff --git a/maven-scm-providers/maven-scm-provider-hg/src/test/java/org/apache/maven/scm/provider/hg/command/diff/HgDiffCommandTckTest.java b/maven-scm-providers/maven-scm-provider-hg/src/test/java/org/apache/maven/scm/provider/hg/command/diff/HgDiffCommandTckTest.java index d118ce8c7..74b78dd67 100644 --- a/maven-scm-providers/maven-scm-provider-hg/src/test/java/org/apache/maven/scm/provider/hg/command/diff/HgDiffCommandTckTest.java +++ b/maven-scm-providers/maven-scm-provider-hg/src/test/java/org/apache/maven/scm/provider/hg/command/diff/HgDiffCommandTckTest.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.hg.command.diff; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider.hg.command.diff; import java.io.File; import java.util.Iterator; @@ -36,35 +35,25 @@ import org.apache.maven.scm.tck.command.diff.DiffCommandTckTest; import org.junit.Test; -import static org.junit.Assert.assertTrue; - import static org.apache.maven.scm.provider.hg.HgRepoUtils.HG_COMMAND_LINE; +import static org.junit.Assert.assertTrue; -public class HgDiffCommandTckTest - extends DiffCommandTckTest -{ +public class HgDiffCommandTckTest extends DiffCommandTckTest { @Override - public String getScmProviderCommand() - { + public String getScmProviderCommand() { return HG_COMMAND_LINE; } - public String getScmUrl() - throws Exception - { + public String getScmUrl() throws Exception { return HgRepoUtils.getScmUrl(); } - public void initRepo() - throws Exception - { + public void initRepo() throws Exception { HgRepoUtils.initRepo(); } @Test - public void testDiffCommand() - throws Exception - { + public void testDiffCommand() throws Exception { ScmRepository repository = getScmRepository(); // ---------------------------------------------------------------------- @@ -86,91 +75,90 @@ public void testDiffCommand() // // /readme.txt - ScmTestCase.makeFile( getWorkingCopy(), "/readme.txt", "changed readme.txt" ); + ScmTestCase.makeFile(getWorkingCopy(), "/readme.txt", "changed readme.txt"); // /project.xml - ScmTestCase.makeFile( getWorkingCopy(), "/project.xml", "changed project.xml" ); + ScmTestCase.makeFile(getWorkingCopy(), "/project.xml", "changed project.xml"); - addToWorkingTree( getWorkingCopy(), new File( "project.xml" ), repository ); + addToWorkingTree(getWorkingCopy(), new File("project.xml"), repository); // /src/test/java/org -// ScmTestCase.makeDirectory(getWorkingCopy(), "/src/test/java/org"); -// -// addToWorkingTree(getWorkingCopy(), new File("src/test/java/org"), -// repository); + // ScmTestCase.makeDirectory(getWorkingCopy(), "/src/test/java/org"); + // + // addToWorkingTree(getWorkingCopy(), new File("src/test/java/org"), + // repository); // /src/main/java/org/Foo.java - ScmTestCase.makeFile( getWorkingCopy(), "/src/main/java/org/Foo.java" ); + ScmTestCase.makeFile(getWorkingCopy(), "/src/main/java/org/Foo.java"); -// addToWorkingTree(getWorkingCopy(), new File("src/main/java/org"), -// repository); + // addToWorkingTree(getWorkingCopy(), new File("src/main/java/org"), + // repository); // src/main/java/org/Foo.java - addToWorkingTree( getWorkingCopy(), new File( "src/main/java/org/Foo.java" ), repository ); + addToWorkingTree(getWorkingCopy(), new File("src/main/java/org/Foo.java"), repository); // ---------------------------------------------------------------------- // Diff the project // ---------------------------------------------------------------------- - ScmProvider provider = getScmManager().getProviderByUrl( getScmUrl() ); - ScmFileSet fileSet = new ScmFileSet( getWorkingCopy() ); - DiffScmResult result = provider.diff( repository, fileSet, (ScmVersion) null, null ); + ScmProvider provider = getScmManager().getProviderByUrl(getScmUrl()); + ScmFileSet fileSet = new ScmFileSet(getWorkingCopy()); + DiffScmResult result = provider.diff(repository, fileSet, (ScmVersion) null, null); -// todo: check asserts -// assertNotNull("The command returned a null result.", result); + // todo: check asserts + // assertNotNull("The command returned a null result.", result); -// assertResultIsSuccess(result); + // assertResultIsSuccess(result); List changedFiles = result.getChangedFiles(); Map differences = result.getDifferences(); -// assertEquals("Expected 3 files in the changed files list " -// + changedFiles, 3, changedFiles.size()); + // assertEquals("Expected 3 files in the changed files list " + // + changedFiles, 3, changedFiles.size()); -// assertEquals("Expected 3 files in the differences list " + differences, -// 3, differences.size()); + // assertEquals("Expected 3 files in the differences list " + differences, + // 3, differences.size()); -// ---------------------------------------------------------------------- -// Assert the files in the changed files list -// ---------------------------------------------------------------------- + // ---------------------------------------------------------------------- + // Assert the files in the changed files list + // ---------------------------------------------------------------------- - Iterator files = new TreeSet( changedFiles ).iterator(); + Iterator files = new TreeSet(changedFiles).iterator(); -// Check Foo.java + // Check Foo.java ScmFile file = (ScmFile) files.next(); -// assertPath("/src/main/java/org/Foo.java", file.getPath()); + // assertPath("/src/main/java/org/Foo.java", file.getPath()); -// assertTrue(file.getStatus().isDiff()); + // assertTrue(file.getStatus().isDiff()); String postRangeStr = "+/src/main/java/org/Foo.java\n\\ No newline at end of file\n"; - String actualStr = differences.get( file.getPath() ).toString(); -// assertTrue(actualStr.endsWith(postRangeStr)); + String actualStr = differences.get(file.getPath()).toString(); + // assertTrue(actualStr.endsWith(postRangeStr)); -// Check readme.txt + // Check readme.txt file = (ScmFile) files.next(); -// assertPath("/readme.txt", file.getPath()); + // assertPath("/readme.txt", file.getPath()); -// assertTrue(file.getStatus().isDiff()); + // assertTrue(file.getStatus().isDiff()); postRangeStr = - "-/readme.txt\n\\ No newline at end of file\n+changed readme.txt\n\\ No newline at end of file\n"; - actualStr = differences.get( file.getPath() ).toString(); -// assertTrue(actualStr.endsWith(postRangeStr)); + "-/readme.txt\n\\ No newline at end of file\n+changed readme.txt\n\\ No newline at end of file\n"; + actualStr = differences.get(file.getPath()).toString(); + // assertTrue(actualStr.endsWith(postRangeStr)); -// Check project.xml + // Check project.xml file = (ScmFile) files.next(); -// assertPath("/project.xml", file.getPath()); + // assertPath("/project.xml", file.getPath()); postRangeStr = "+changed project.xml\n\\ No newline at end of file\n"; - actualStr = differences.get( file.getPath() ).toString(); -// assertTrue(actualStr.endsWith(postRangeStr)); + actualStr = differences.get(file.getPath()).toString(); + // assertTrue(actualStr.endsWith(postRangeStr)); -// assertTrue(file.getStatus().isDiff()); - assertTrue( true ); + // assertTrue(file.getStatus().isDiff()); + assertTrue(true); } - } diff --git a/maven-scm-providers/maven-scm-provider-hg/src/test/java/org/apache/maven/scm/provider/hg/command/status/HgStatusCommandTckTest.java b/maven-scm-providers/maven-scm-provider-hg/src/test/java/org/apache/maven/scm/provider/hg/command/status/HgStatusCommandTckTest.java index 4ff7fff06..54c2111ad 100644 --- a/maven-scm-providers/maven-scm-provider-hg/src/test/java/org/apache/maven/scm/provider/hg/command/status/HgStatusCommandTckTest.java +++ b/maven-scm-providers/maven-scm-provider-hg/src/test/java/org/apache/maven/scm/provider/hg/command/status/HgStatusCommandTckTest.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.hg.command.status; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider.hg.command.status; import org.apache.maven.scm.provider.hg.HgRepoUtils; import org.apache.maven.scm.tck.command.status.StatusCommandTckTest; @@ -27,24 +26,17 @@ /** * @author thurner rupert */ -public class HgStatusCommandTckTest - extends StatusCommandTckTest -{ +public class HgStatusCommandTckTest extends StatusCommandTckTest { @Override - public String getScmProviderCommand() - { + public String getScmProviderCommand() { return HG_COMMAND_LINE; } - public String getScmUrl() - throws Exception - { + public String getScmUrl() throws Exception { return HgRepoUtils.getScmUrl(); } - public void initRepo() - throws Exception - { + public void initRepo() throws Exception { HgRepoUtils.initRepo(); } } diff --git a/maven-scm-providers/maven-scm-provider-hg/src/test/java/org/apache/maven/scm/provider/hg/command/tag/HgTagCommandTckTest.java b/maven-scm-providers/maven-scm-provider-hg/src/test/java/org/apache/maven/scm/provider/hg/command/tag/HgTagCommandTckTest.java index a022a07f3..048c9947c 100644 --- a/maven-scm-providers/maven-scm-provider-hg/src/test/java/org/apache/maven/scm/provider/hg/command/tag/HgTagCommandTckTest.java +++ b/maven-scm-providers/maven-scm-provider-hg/src/test/java/org/apache/maven/scm/provider/hg/command/tag/HgTagCommandTckTest.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.hg.command.tag; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider.hg.command.tag; import org.apache.maven.scm.provider.hg.HgRepoUtils; import org.apache.maven.scm.tck.command.tag.TagCommandTckTest; @@ -30,24 +29,17 @@ * @author Ryan Daum * */ -public class HgTagCommandTckTest - extends TagCommandTckTest -{ +public class HgTagCommandTckTest extends TagCommandTckTest { @Override - public String getScmProviderCommand() - { + public String getScmProviderCommand() { return HG_COMMAND_LINE; } - public String getScmUrl() - throws Exception - { + public String getScmUrl() throws Exception { return HgRepoUtils.getScmUrl(); } - public void initRepo() - throws Exception - { + public void initRepo() throws Exception { HgRepoUtils.initRepo(); } } diff --git a/maven-scm-providers/maven-scm-provider-hg/src/test/java/org/apache/maven/scm/provider/hg/command/update/HgUpdateCommandTckTest.java b/maven-scm-providers/maven-scm-provider-hg/src/test/java/org/apache/maven/scm/provider/hg/command/update/HgUpdateCommandTckTest.java index cb3733f1a..fbf5c0ce1 100644 --- a/maven-scm-providers/maven-scm-provider-hg/src/test/java/org/apache/maven/scm/provider/hg/command/update/HgUpdateCommandTckTest.java +++ b/maven-scm-providers/maven-scm-provider-hg/src/test/java/org/apache/maven/scm/provider/hg/command/update/HgUpdateCommandTckTest.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.hg.command.update; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider.hg.command.update; import org.apache.maven.scm.provider.hg.HgRepoUtils; import org.apache.maven.scm.tck.command.update.UpdateCommandTckTest; @@ -27,24 +26,17 @@ /** * @author thurner rupert */ -public class HgUpdateCommandTckTest - extends UpdateCommandTckTest -{ +public class HgUpdateCommandTckTest extends UpdateCommandTckTest { @Override - public String getScmProviderCommand() - { + public String getScmProviderCommand() { return HG_COMMAND_LINE; } - public String getScmUrl() - throws Exception - { + public String getScmUrl() throws Exception { return HgRepoUtils.getScmUrl(); } - public void initRepo() - throws Exception - { + public void initRepo() throws Exception { HgRepoUtils.initRepo(); } } diff --git a/maven-scm-providers/maven-scm-provider-hg/src/test/java/org/apache/maven/scm/provider/hg/repository/HgScmProviderRepositoryTest.java b/maven-scm-providers/maven-scm-provider-hg/src/test/java/org/apache/maven/scm/provider/hg/repository/HgScmProviderRepositoryTest.java index de05fa391..5c7051979 100644 --- a/maven-scm-providers/maven-scm-provider-hg/src/test/java/org/apache/maven/scm/provider/hg/repository/HgScmProviderRepositoryTest.java +++ b/maven-scm-providers/maven-scm-provider-hg/src/test/java/org/apache/maven/scm/provider/hg/repository/HgScmProviderRepositoryTest.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.hg.repository; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider.hg.repository; import org.junit.Test; @@ -25,99 +24,94 @@ import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; -public class HgScmProviderRepositoryTest -{ +public class HgScmProviderRepositoryTest { -// public void testInvalidRepo() -// { -// //No protocol - makes it invalid -// String url = "username:password@myhost.com/~/dev/maven"; -// HgScmProviderRepository repo = new HgScmProviderRepository( url ); -// assertNotNull( repo.validateURI() ); -// } + // public void testInvalidRepo() + // { + // //No protocol - makes it invalid + // String url = "username:password@myhost.com/~/dev/maven"; + // HgScmProviderRepository repo = new HgScmProviderRepository( url ); + // assertNotNull( repo.validateURI() ); + // } @Test - public void testFileRepo() - { - //1. Test *nix like paths + public void testFileRepo() { + // 1. Test *nix like paths String url = "/home/username/dev/maven"; - HgScmProviderRepository repo = new HgScmProviderRepository( url ); - assertNull( repo.validateURI() ); + HgScmProviderRepository repo = new HgScmProviderRepository(url); + assertNull(repo.validateURI()); - //2. Test windows like paths (with slash) + // 2. Test windows like paths (with slash) url = "C:/Documents and Settings/username/dev/maven"; - repo = new HgScmProviderRepository( url ); - assertNull( repo.validateURI() ); + repo = new HgScmProviderRepository(url); + assertNull(repo.validateURI()); - //3. Test windows like paths (with backslash) + // 3. Test windows like paths (with backslash) url = "C:\\Documents and Settings\\username\\dev\\maven"; - repo = new HgScmProviderRepository( url ); - assertNull( repo.validateURI() ); + repo = new HgScmProviderRepository(url); + assertNull(repo.validateURI()); -// //4. Test invalid file url -// url = "file:/C:\\Documents and Settings\\username\\dev\\maven"; -// repo = new HgScmProviderRepository( url ); -// assertNotNull( repo.validateURI() ); + // //4. Test invalid file url + // url = "file:/C:\\Documents and Settings\\username\\dev\\maven"; + // repo = new HgScmProviderRepository( url ); + // assertNotNull( repo.validateURI() ); } @Test - public void testSSHRepo() - { - //todo: check assert - //1. Test with relativ path + public void testSSHRepo() { + // todo: check assert + // 1. Test with relativ path String url = "ssh://username:password@myhost.com/~/dev/maven"; - HgScmProviderRepository repo = new HgScmProviderRepository( url ); - assertEquals( url, repo.getURI() ); - assertNull( repo.validateURI() ); + HgScmProviderRepository repo = new HgScmProviderRepository(url); + assertEquals(url, repo.getURI()); + assertNull(repo.validateURI()); - //2. Test with absolute path + // 2. Test with absolute path url = "ssh://username:password@myhost.com/home/username/dev/maven"; - repo = new HgScmProviderRepository( url ); - assertEquals( url, repo.getURI() ); - assertNull( repo.validateURI() ); + repo = new HgScmProviderRepository(url); + assertEquals(url, repo.getURI()); + assertNull(repo.validateURI()); - //3. Test with passwordless (Public-key auth) + // 3. Test with passwordless (Public-key auth) String incompleteUrl = "ssh://username@myhost.com/home/username/dev/maven"; - repo = new HgScmProviderRepository( incompleteUrl ); - assertEquals( incompleteUrl, repo.getURI() ); - assertNull( repo.validateURI() ); + repo = new HgScmProviderRepository(incompleteUrl); + assertEquals(incompleteUrl, repo.getURI()); + assertNull(repo.validateURI()); } @Test - public void testHTTPRepo() - { - //todo: check assert - //1. Test with relativ path + public void testHTTPRepo() { + // todo: check assert + // 1. Test with relativ path String url = "http://www.myhost.com/~username/dev/maven"; - HgScmProviderRepository repo = new HgScmProviderRepository( url ); - assertEquals( url, repo.getURI() ); - assertNull( repo.validateURI() ); + HgScmProviderRepository repo = new HgScmProviderRepository(url); + assertEquals(url, repo.getURI()); + assertNull(repo.validateURI()); - //2. Test with absolute path + // 2. Test with absolute path url = "http://www.myhost.com/dev/maven"; - repo = new HgScmProviderRepository( url ); - assertEquals( url, repo.getURI() ); - assertNull( repo.validateURI() ); - - //3. Test with authentication information - repo.setPassword( "Password" ); - repo.setUser( "User" ); - repo.setPassphrase( "Passphrase" ); - assertEquals( "http://User:Password@www.myhost.com/dev/maven", repo.getURI() ); - assertNull( repo.validateURI() ); - repo.setPort( 81 ); - assertEquals( "http://User:Password@www.myhost.com:81/dev/maven", repo.getURI() ); - assertNull( repo.validateURI() ); - assertTrue( true ); + repo = new HgScmProviderRepository(url); + assertEquals(url, repo.getURI()); + assertNull(repo.validateURI()); + + // 3. Test with authentication information + repo.setPassword("Password"); + repo.setUser("User"); + repo.setPassphrase("Passphrase"); + assertEquals("http://User:Password@www.myhost.com/dev/maven", repo.getURI()); + assertNull(repo.validateURI()); + repo.setPort(81); + assertEquals("http://User:Password@www.myhost.com:81/dev/maven", repo.getURI()); + assertNull(repo.validateURI()); + assertTrue(true); } @Test - public void testHTTPRepoWithHgInUrl() - { + public void testHTTPRepoWithHgInUrl() { String url = "http://hg/hg/maven"; - HgScmProviderRepository repo = new HgScmProviderRepository( url ); - assertEquals( url, repo.getURI() ); - assertNull( repo.validateURI() ); + HgScmProviderRepository repo = new HgScmProviderRepository(url); + assertEquals(url, repo.getURI()); + assertNull(repo.validateURI()); } /** @@ -126,20 +120,18 @@ public void testHTTPRepoWithHgInUrl() * @throws Exception */ @Test - public void testParseHostAndPort() - throws Exception - { + public void testParseHostAndPort() throws Exception { String url = "http://localhost:8000/"; - HgScmProviderRepository repo = new HgScmProviderRepository( url ); - assertEquals( repo.getURI(), url ); + HgScmProviderRepository repo = new HgScmProviderRepository(url); + assertEquals(repo.getURI(), url); url = "http://localhost/"; - repo = new HgScmProviderRepository( url ); - assertEquals( repo.getURI(), url ); + repo = new HgScmProviderRepository(url); + assertEquals(repo.getURI(), url); url = "http://www.myhost.com:81/dev/maven"; - repo = new HgScmProviderRepository( url ); - assertEquals( repo.getURI(), url ); + repo = new HgScmProviderRepository(url); + assertEquals(repo.getURI(), url); } /** @@ -148,19 +140,17 @@ public void testParseHostAndPort() * @throws Exception */ @Test - public void testParseBasicAuth() - throws Exception - { + public void testParseBasicAuth() throws Exception { String url = "http://a:b@localhost:8000/"; - HgScmProviderRepository repo = new HgScmProviderRepository( url ); - assertEquals( url, repo.getURI() ); + HgScmProviderRepository repo = new HgScmProviderRepository(url); + assertEquals(url, repo.getURI()); url = "http://aa@localhost/"; - repo = new HgScmProviderRepository( url ); - assertEquals( url, repo.getURI() ); + repo = new HgScmProviderRepository(url); + assertEquals(url, repo.getURI()); url = "http://SCM:431@www.myhost.com:81/dev/maven"; - repo = new HgScmProviderRepository( url ); - assertEquals( url, repo.getURI() ); + repo = new HgScmProviderRepository(url); + assertEquals(url, repo.getURI()); } } diff --git a/maven-scm-providers/maven-scm-provider-local/pom.xml b/maven-scm-providers/maven-scm-provider-local/pom.xml index 0fab87b5e..ebed2d8c5 100644 --- a/maven-scm-providers/maven-scm-provider-local/pom.xml +++ b/maven-scm-providers/maven-scm-provider-local/pom.xml @@ -1,5 +1,4 @@ - - 4.0.0 @@ -59,6 +57,12 @@ org.codehaus.modello modello-maven-plugin + + 1.0.0 + + src/main/mdo/maven-scm-local-metadata.mdo + + @@ -69,12 +73,6 @@ - - 1.0.0 - - src/main/mdo/maven-scm-local-metadata.mdo - - diff --git a/maven-scm-providers/maven-scm-provider-local/src/main/java/org/apache/maven/scm/provider/local/LocalScmProvider.java b/maven-scm-providers/maven-scm-provider-local/src/main/java/org/apache/maven/scm/provider/local/LocalScmProvider.java index b7d4588d7..2fbe89b83 100644 --- a/maven-scm-providers/maven-scm-provider-local/src/main/java/org/apache/maven/scm/provider/local/LocalScmProvider.java +++ b/maven-scm-providers/maven-scm-provider-local/src/main/java/org/apache/maven/scm/provider/local/LocalScmProvider.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.local; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,10 +16,13 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider.local; import javax.inject.Named; import javax.inject.Singleton; +import java.io.File; + import org.apache.maven.scm.CommandParameters; import org.apache.maven.scm.ScmException; import org.apache.maven.scm.ScmFileSet; @@ -31,9 +32,9 @@ import org.apache.maven.scm.command.checkout.CheckOutScmResult; import org.apache.maven.scm.command.list.ListScmResult; import org.apache.maven.scm.command.mkdir.MkdirScmResult; -import org.apache.maven.scm.command.update.UpdateScmResult; import org.apache.maven.scm.command.status.StatusScmResult; import org.apache.maven.scm.command.tag.TagScmResult; +import org.apache.maven.scm.command.update.UpdateScmResult; import org.apache.maven.scm.provider.AbstractScmProvider; import org.apache.maven.scm.provider.ScmProviderRepository; import org.apache.maven.scm.provider.local.command.add.LocalAddCommand; @@ -42,42 +43,35 @@ import org.apache.maven.scm.provider.local.command.checkout.LocalCheckOutCommand; import org.apache.maven.scm.provider.local.command.list.LocalListCommand; import org.apache.maven.scm.provider.local.command.mkdir.LocalMkdirCommand; -import org.apache.maven.scm.provider.local.command.update.LocalUpdateCommand; import org.apache.maven.scm.provider.local.command.status.LocalStatusCommand; import org.apache.maven.scm.provider.local.command.tag.LocalTagCommand; +import org.apache.maven.scm.provider.local.command.update.LocalUpdateCommand; import org.apache.maven.scm.provider.local.repository.LocalScmProviderRepository; import org.apache.maven.scm.repository.ScmRepositoryException; import org.codehaus.plexus.util.StringUtils; -import java.io.File; - /** * @author Trygve Laugstøl * @author Emmanuel Venisse */ @Singleton -@Named( "local" ) -public class LocalScmProvider - extends AbstractScmProvider -{ +@Named("local") +public class LocalScmProvider extends AbstractScmProvider { /** {@inheritDoc} */ @Override - public String getScmType() - { + public String getScmType() { return "local"; } /** {@inheritDoc} */ @Override - public ScmProviderRepository makeProviderScmRepository( String scmSpecificUrl, char delimiter ) - throws ScmRepositoryException - { - String[] tokens = StringUtils.split( scmSpecificUrl, Character.toString( delimiter ) ); - - if ( tokens.length != 2 ) - { - throw new ScmRepositoryException( "The connection string didn't contain the expected number of tokens. " - + "Expected 2 tokens but got " + tokens.length + " tokens." ); + public ScmProviderRepository makeProviderScmRepository(String scmSpecificUrl, char delimiter) + throws ScmRepositoryException { + String[] tokens = StringUtils.split(scmSpecificUrl, Character.toString(delimiter)); + + if (tokens.length != 2) { + throw new ScmRepositoryException("The connection string didn't contain the expected number of tokens. " + + "Expected 2 tokens but got " + tokens.length + " tokens."); } // ---------------------------------------------------------------------- @@ -86,23 +80,20 @@ public ScmProviderRepository makeProviderScmRepository( String scmSpecificUrl, c String root = tokens[0]; - File rootFile = new File( root ); + File rootFile = new File(root); - if ( !rootFile.isAbsolute() ) - { - String basedir = System.getProperty( "basedir", new File( "" ).getAbsolutePath() ); + if (!rootFile.isAbsolute()) { + String basedir = System.getProperty("basedir", new File("").getAbsolutePath()); - rootFile = new File( basedir, root ); + rootFile = new File(basedir, root); } - if ( !rootFile.exists() ) - { - throw new ScmRepositoryException( "The root doesn't exists (" + rootFile.getAbsolutePath() + ")." ); + if (!rootFile.exists()) { + throw new ScmRepositoryException("The root doesn't exists (" + rootFile.getAbsolutePath() + ")."); } - if ( !rootFile.isDirectory() ) - { - throw new ScmRepositoryException( "The root isn't a directory (" + rootFile.getAbsolutePath() + ")." ); + if (!rootFile.isDirectory()) { + throw new ScmRepositoryException("The root isn't a directory (" + rootFile.getAbsolutePath() + ")."); } // ---------------------------------------------------------------------- @@ -111,36 +102,31 @@ public ScmProviderRepository makeProviderScmRepository( String scmSpecificUrl, c String module = tokens[1]; - File moduleFile = new File( rootFile, module ); + File moduleFile = new File(rootFile, module); - if ( !moduleFile.exists() ) - { + if (!moduleFile.exists()) { throw new ScmRepositoryException( - "The module doesn't exist (root: " + rootFile.getAbsolutePath() + ", module: " + module + ")." ); + "The module doesn't exist (root: " + rootFile.getAbsolutePath() + ", module: " + module + ")."); } - if ( !moduleFile.isDirectory() ) - { - throw new ScmRepositoryException( "The module isn't a directory." ); + if (!moduleFile.isDirectory()) { + throw new ScmRepositoryException("The module isn't a directory."); } - return new LocalScmProviderRepository( rootFile.getAbsolutePath(), module ); + return new LocalScmProviderRepository(rootFile.getAbsolutePath(), module); } // ---------------------------------------------------------------------- // Utility methods // ---------------------------------------------------------------------- - public static String fixModuleName( String module ) - { - if ( module.endsWith( "/" ) ) - { - module = module.substring( 0, module.length() - 1 ); + public static String fixModuleName(String module) { + if (module.endsWith("/")) { + module = module.substring(0, module.length() - 1); } - if ( module.startsWith( "/" ) ) - { - module = module.substring( 1 ); + if (module.startsWith("/")) { + module = module.substring(1); } return module; @@ -148,94 +134,82 @@ public static String fixModuleName( String module ) /** {@inheritDoc} */ @Override - public StatusScmResult status( ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters ) - throws ScmException - { + public StatusScmResult status(ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters) + throws ScmException { LocalStatusCommand command = new LocalStatusCommand(); - return (StatusScmResult) command.execute( repository, fileSet, parameters ); + return (StatusScmResult) command.execute(repository, fileSet, parameters); } /** {@inheritDoc} */ @Override - public TagScmResult tag( ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters ) - throws ScmException - { + public TagScmResult tag(ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters) + throws ScmException { LocalTagCommand command = new LocalTagCommand(); - return (TagScmResult) command.execute( repository, fileSet, parameters ); + return (TagScmResult) command.execute(repository, fileSet, parameters); } /** {@inheritDoc} */ @Override - public AddScmResult add( ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters ) - throws ScmException - { + public AddScmResult add(ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters) + throws ScmException { LocalAddCommand command = new LocalAddCommand(); - return (AddScmResult) command.execute( repository, fileSet, parameters ); + return (AddScmResult) command.execute(repository, fileSet, parameters); } /** {@inheritDoc} */ @Override - protected ChangeLogScmResult changelog( ScmProviderRepository repository, ScmFileSet fileSet, - CommandParameters parameters ) - throws ScmException - { + protected ChangeLogScmResult changelog( + ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters) throws ScmException { LocalChangeLogCommand command = new LocalChangeLogCommand(); - return (ChangeLogScmResult) command.execute( repository, fileSet, parameters ); + return (ChangeLogScmResult) command.execute(repository, fileSet, parameters); } /** {@inheritDoc} */ @Override - public CheckInScmResult checkin( ScmProviderRepository repository, ScmFileSet fileSet, - CommandParameters parameters ) - throws ScmException - { + public CheckInScmResult checkin(ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters) + throws ScmException { LocalCheckInCommand command = new LocalCheckInCommand(); - return (CheckInScmResult) command.execute( repository, fileSet, parameters ); + return (CheckInScmResult) command.execute(repository, fileSet, parameters); } /** {@inheritDoc} */ @Override - public CheckOutScmResult checkout( ScmProviderRepository repository, ScmFileSet fileSet, - CommandParameters parameters ) - throws ScmException - { + public CheckOutScmResult checkout( + ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters) throws ScmException { LocalCheckOutCommand command = new LocalCheckOutCommand(); - return (CheckOutScmResult) command.execute( repository, fileSet, parameters ); + return (CheckOutScmResult) command.execute(repository, fileSet, parameters); } /** {@inheritDoc} */ @Override - protected ListScmResult list( ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters ) - throws ScmException - { + protected ListScmResult list(ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters) + throws ScmException { LocalListCommand command = new LocalListCommand(); - return (ListScmResult) command.execute( repository, fileSet, parameters ); + return (ListScmResult) command.execute(repository, fileSet, parameters); } - + /** {@inheritDoc} */ @Override - protected MkdirScmResult mkdir( ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters ) - throws ScmException - { + protected MkdirScmResult mkdir(ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters) + throws ScmException { LocalMkdirCommand command = new LocalMkdirCommand(); - return (MkdirScmResult) command.execute( repository, fileSet, parameters ); + return (MkdirScmResult) command.execute(repository, fileSet, parameters); } /** {@inheritDoc} */ @Override - public UpdateScmResult update( ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters ) - throws ScmException - { + public UpdateScmResult update(ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters) + throws ScmException { LocalUpdateCommand command = new LocalUpdateCommand(); - return (UpdateScmResult) command.execute( repository, fileSet, parameters ); + return (UpdateScmResult) command.execute(repository, fileSet, parameters); } } diff --git a/maven-scm-providers/maven-scm-provider-local/src/main/java/org/apache/maven/scm/provider/local/command/LocalCommand.java b/maven-scm-providers/maven-scm-provider-local/src/main/java/org/apache/maven/scm/provider/local/command/LocalCommand.java index 13a8140df..e3b39ef13 100644 --- a/maven-scm-providers/maven-scm-provider-local/src/main/java/org/apache/maven/scm/provider/local/command/LocalCommand.java +++ b/maven-scm-providers/maven-scm-provider-local/src/main/java/org/apache/maven/scm/provider/local/command/LocalCommand.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.local.command; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider.local.command; import org.apache.maven.scm.command.Command; @@ -25,7 +24,4 @@ * @author Trygve Laugstøl * */ -public interface LocalCommand - extends Command -{ -} +public interface LocalCommand extends Command {} diff --git a/maven-scm-providers/maven-scm-provider-local/src/main/java/org/apache/maven/scm/provider/local/command/add/LocalAddCommand.java b/maven-scm-providers/maven-scm-provider-local/src/main/java/org/apache/maven/scm/provider/local/command/add/LocalAddCommand.java index ffe81293b..c6320d1e1 100644 --- a/maven-scm-providers/maven-scm-provider-local/src/main/java/org/apache/maven/scm/provider/local/command/add/LocalAddCommand.java +++ b/maven-scm-providers/maven-scm-provider-local/src/main/java/org/apache/maven/scm/provider/local/command/add/LocalAddCommand.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.local.command.add; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,11 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider.local.command.add; + +import java.io.File; +import java.util.ArrayList; +import java.util.List; import org.apache.maven.scm.ScmException; import org.apache.maven.scm.ScmFile; @@ -30,34 +33,24 @@ import org.apache.maven.scm.provider.local.command.LocalCommand; import org.apache.maven.scm.provider.local.repository.LocalScmProviderRepository; -import java.io.File; -import java.util.ArrayList; -import java.util.List; - /** * @author Brett Porter * */ -public class LocalAddCommand - extends AbstractAddCommand - implements LocalCommand -{ +public class LocalAddCommand extends AbstractAddCommand implements LocalCommand { /** {@inheritDoc} */ - protected ScmResult executeAddCommand( ScmProviderRepository repository, ScmFileSet fileSet, String message, - boolean binary ) - throws ScmException - { + protected ScmResult executeAddCommand( + ScmProviderRepository repository, ScmFileSet fileSet, String message, boolean binary) throws ScmException { LocalScmProviderRepository localRepo = (LocalScmProviderRepository) repository; List fileList = new ArrayList(); - for ( File file : fileSet.getFileList() ) - { - String path = file.getPath().replace( '\\', '/' ); - localRepo.addFile( path ); - fileList.add( new ScmFile( path, ScmFileStatus.ADDED ) ); + for (File file : fileSet.getFileList()) { + String path = file.getPath().replace('\\', '/'); + localRepo.addFile(path); + fileList.add(new ScmFile(path, ScmFileStatus.ADDED)); } // TODO: Also, ensure it is tested from the update test - return new AddScmResult( null, fileList ); + return new AddScmResult(null, fileList); } } diff --git a/maven-scm-providers/maven-scm-provider-local/src/main/java/org/apache/maven/scm/provider/local/command/changelog/LocalChangeLogCommand.java b/maven-scm-providers/maven-scm-provider-local/src/main/java/org/apache/maven/scm/provider/local/command/changelog/LocalChangeLogCommand.java index 3021b6a11..eca02275e 100644 --- a/maven-scm-providers/maven-scm-provider-local/src/main/java/org/apache/maven/scm/provider/local/command/changelog/LocalChangeLogCommand.java +++ b/maven-scm-providers/maven-scm-provider-local/src/main/java/org/apache/maven/scm/provider/local/command/changelog/LocalChangeLogCommand.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.local.command.changelog; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider.local.command.changelog; import java.io.File; import java.io.IOException; @@ -42,120 +41,100 @@ * @author Olivier Lamy * */ -public class LocalChangeLogCommand - extends AbstractChangeLogCommand -{ +public class LocalChangeLogCommand extends AbstractChangeLogCommand { /** {@inheritDoc} */ - protected ChangeLogScmResult executeChangeLogCommand( ScmProviderRepository repository, ScmFileSet fileSet, - Date startDate, Date endDate, ScmBranch branch, - String datePattern ) - throws ScmException - { + protected ChangeLogScmResult executeChangeLogCommand( + ScmProviderRepository repository, + ScmFileSet fileSet, + Date startDate, + Date endDate, + ScmBranch branch, + String datePattern) + throws ScmException { LocalScmProviderRepository repo = (LocalScmProviderRepository) repository; - if ( branch != null ) - { - throw new ScmException( "The local scm doesn't support tags." ); + if (branch != null) { + throw new ScmException("The local scm doesn't support tags."); } - File root = new File( repo.getRoot() ); + File root = new File(repo.getRoot()); String module = repo.getModule(); - File source = new File( root, module ); + File source = new File(root, module); File baseDestination = fileSet.getBasedir(); - if ( !baseDestination.exists() ) - { - throw new ScmException( - "The working directory doesn't exist (" + baseDestination.getAbsolutePath() + ")." ); + if (!baseDestination.exists()) { + throw new ScmException("The working directory doesn't exist (" + baseDestination.getAbsolutePath() + ")."); } - if ( !root.exists() ) - { - throw new ScmException( "The base directory doesn't exist (" + root.getAbsolutePath() + ")." ); + if (!root.exists()) { + throw new ScmException("The base directory doesn't exist (" + root.getAbsolutePath() + ")."); } - if ( !source.exists() ) - { - throw new ScmException( "The module directory doesn't exist (" + source.getAbsolutePath() + ")." ); + if (!source.exists()) { + throw new ScmException("The module directory doesn't exist (" + source.getAbsolutePath() + ")."); } List changeLogList = new ArrayList<>(); - try - { - File repoRoot = new File( repo.getRoot(), repo.getModule() ); + try { + File repoRoot = new File(repo.getRoot(), repo.getModule()); List files = fileSet.getFileList(); - if ( files.isEmpty() ) - { - files = FileUtils.getFiles( baseDestination, "**", null, false ); + if (files.isEmpty()) { + files = FileUtils.getFiles(baseDestination, "**", null, false); } - for ( File file : files ) - { + for (File file : files) { - String path = file.getPath().replace( '\\', '/' ); + String path = file.getPath().replace('\\', '/'); - File repoFile = new File( repoRoot, path ); + File repoFile = new File(repoRoot, path); - file = new File( baseDestination, path ); + file = new File(baseDestination, path); ChangeSet changeSet = new ChangeSet(); int chop = repoRoot.getAbsolutePath().length(); - String fileName = "/" + repoFile.getAbsolutePath().substring( chop + 1 ); + String fileName = "/" + repoFile.getAbsolutePath().substring(chop + 1); - changeSet.addFile( new ChangeFile( fileName, null ) ); + changeSet.addFile(new ChangeFile(fileName, null)); - if ( repoFile.exists() ) - { + if (repoFile.exists()) { long lastModified = repoFile.lastModified(); - Date modifiedDate = new Date( lastModified ); + Date modifiedDate = new Date(lastModified); - if ( startDate != null ) - { - if ( startDate.before( modifiedDate ) || startDate.equals( modifiedDate ) ) - { - if ( endDate != null ) - { - if ( endDate.after( modifiedDate ) || endDate.equals( modifiedDate ) ) - { + if (startDate != null) { + if (startDate.before(modifiedDate) || startDate.equals(modifiedDate)) { + if (endDate != null) { + if (endDate.after(modifiedDate) || endDate.equals(modifiedDate)) { // nop - } - else - { + } else { continue; } } - } - else - { + } else { continue; } } - changeSet.setDate( modifiedDate ); + changeSet.setDate(modifiedDate); - changeLogList.add( changeSet ); - } - else - { + changeLogList.add(changeSet); + } else { // This file is deleted - changeLogList.add( changeSet ); + changeLogList.add(changeSet); } } - } - catch ( IOException ex ) - { - throw new ScmException( "Error while getting change logs.", ex ); + } catch (IOException ex) { + throw new ScmException("Error while getting change logs.", ex); } - return new ChangeLogScmResult( null, new ChangeLogSet( changeLogList, startDate, endDate ) ); + return new ChangeLogScmResult(null, new ChangeLogSet(changeLogList, startDate, endDate)); } } diff --git a/maven-scm-providers/maven-scm-provider-local/src/main/java/org/apache/maven/scm/provider/local/command/checkin/LocalCheckInCommand.java b/maven-scm-providers/maven-scm-provider-local/src/main/java/org/apache/maven/scm/provider/local/command/checkin/LocalCheckInCommand.java index d88f15d87..914c6ed2a 100644 --- a/maven-scm-providers/maven-scm-provider-local/src/main/java/org/apache/maven/scm/provider/local/command/checkin/LocalCheckInCommand.java +++ b/maven-scm-providers/maven-scm-provider-local/src/main/java/org/apache/maven/scm/provider/local/command/checkin/LocalCheckInCommand.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.local.command.checkin; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider.local.command.checkin; import java.io.File; import java.io.IOException; @@ -42,111 +41,88 @@ * @author Trygve Laugstøl * */ -public class LocalCheckInCommand - extends AbstractCheckInCommand - implements LocalCommand -{ +public class LocalCheckInCommand extends AbstractCheckInCommand implements LocalCommand { /** {@inheritDoc} */ - protected CheckInScmResult executeCheckInCommand( ScmProviderRepository repo, ScmFileSet fileSet, String message, - ScmVersion version ) - throws ScmException - { + protected CheckInScmResult executeCheckInCommand( + ScmProviderRepository repo, ScmFileSet fileSet, String message, ScmVersion version) throws ScmException { LocalScmProviderRepository repository = (LocalScmProviderRepository) repo; - if ( version != null && StringUtils.isNotEmpty( version.getName() ) ) - { - throw new ScmException( "The local scm doesn't support tags." ); + if (version != null && StringUtils.isNotEmpty(version.getName())) { + throw new ScmException("The local scm doesn't support tags."); } - File root = new File( repository.getRoot() ); + File root = new File(repository.getRoot()); String module = repository.getModule(); - File source = new File( root, module ); + File source = new File(root, module); File basedir = fileSet.getBasedir(); - if ( !basedir.exists() ) - { - throw new ScmException( - "The working directory doesn't exist (" + basedir.getAbsolutePath() + ")." ); + if (!basedir.exists()) { + throw new ScmException("The working directory doesn't exist (" + basedir.getAbsolutePath() + ")."); } - if ( !root.exists() ) - { - throw new ScmException( "The base directory doesn't exist (" + root.getAbsolutePath() + ")." ); + if (!root.exists()) { + throw new ScmException("The base directory doesn't exist (" + root.getAbsolutePath() + ")."); } - if ( !source.exists() ) - { - throw new ScmException( "The module directory doesn't exist (" + source.getAbsolutePath() + ")." ); + if (!source.exists()) { + throw new ScmException("The module directory doesn't exist (" + source.getAbsolutePath() + ")."); } List checkedInFiles = new ArrayList<>(); - try - { + try { // Only copy files newer than in the repo - File repoRoot = new File( repository.getRoot(), repository.getModule() ); + File repoRoot = new File(repository.getRoot(), repository.getModule()); List files = fileSet.getFileList(); - if ( files.isEmpty() ) - { - files = FileUtils.getFiles( basedir, "**", null, false ); + if (files.isEmpty()) { + files = FileUtils.getFiles(basedir, "**", null, false); } - for ( File file : files ) - { - String path = FilenameUtils.normalizeFilename( file.getPath() ); - File repoFile = new File( repoRoot, path ); - file = new File( basedir, path ); + for (File file : files) { + String path = FilenameUtils.normalizeFilename(file.getPath()); + File repoFile = new File(repoRoot, path); + file = new File(basedir, path); ScmFileStatus status; - if ( repoFile.exists() ) - { - String repoFileContents = FileUtils.fileRead( repoFile ); + if (repoFile.exists()) { + String repoFileContents = FileUtils.fileRead(repoFile); - String fileContents = FileUtils.fileRead( file ); + String fileContents = FileUtils.fileRead(file); - if ( logger.isDebugEnabled() ) - { - logger.debug( "fileContents:" + fileContents ); - logger.debug( "repoFileContents:" + repoFileContents ); + if (logger.isDebugEnabled()) { + logger.debug("fileContents:" + fileContents); + logger.debug("repoFileContents:" + repoFileContents); } - if ( fileContents.equals( repoFileContents ) ) - { + if (fileContents.equals(repoFileContents)) { continue; } status = ScmFileStatus.CHECKED_IN; - } - else if ( repository.isFileAdded( path ) ) - { + } else if (repository.isFileAdded(path)) { status = ScmFileStatus.CHECKED_IN; - } - else - { - if ( logger.isWarnEnabled() ) - { - logger.warn( "skipped unknown file in checkin:" + path ); + } else { + if (logger.isWarnEnabled()) { + logger.warn("skipped unknown file in checkin:" + path); } // unknown file, skip continue; } - FileUtils.copyFile( file, repoFile ); - ScmFile scmFile = new ScmFile( path, status ); - logger.info( scmFile.toString() ); - checkedInFiles.add( scmFile ); + FileUtils.copyFile(file, repoFile); + ScmFile scmFile = new ScmFile(path, status); + logger.info(scmFile.toString()); + checkedInFiles.add(scmFile); } - } - catch ( IOException ex ) - { - throw new ScmException( "Error while checking in the files.", ex ); + } catch (IOException ex) { + throw new ScmException("Error while checking in the files.", ex); } - return new CheckInScmResult( null, checkedInFiles ); + return new CheckInScmResult(null, checkedInFiles); } } diff --git a/maven-scm-providers/maven-scm-provider-local/src/main/java/org/apache/maven/scm/provider/local/command/checkout/LocalCheckOutCommand.java b/maven-scm-providers/maven-scm-provider-local/src/main/java/org/apache/maven/scm/provider/local/command/checkout/LocalCheckOutCommand.java index 107c24123..f6653f58b 100644 --- a/maven-scm-providers/maven-scm-provider-local/src/main/java/org/apache/maven/scm/provider/local/command/checkout/LocalCheckOutCommand.java +++ b/maven-scm-providers/maven-scm-provider-local/src/main/java/org/apache/maven/scm/provider/local/command/checkout/LocalCheckOutCommand.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.local.command.checkout; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider.local.command.checkout; import java.io.File; import java.io.IOException; @@ -41,121 +40,99 @@ * @author Trygve Laugstøl * */ -public class LocalCheckOutCommand - extends AbstractCheckOutCommand - implements LocalCommand -{ +public class LocalCheckOutCommand extends AbstractCheckOutCommand implements LocalCommand { /** {@inheritDoc} */ - protected CheckOutScmResult executeCheckOutCommand( ScmProviderRepository repo, ScmFileSet fileSet, - ScmVersion version, boolean recursive, boolean shallow ) - throws ScmException - { + protected CheckOutScmResult executeCheckOutCommand( + ScmProviderRepository repo, ScmFileSet fileSet, ScmVersion version, boolean recursive, boolean shallow) + throws ScmException { LocalScmProviderRepository repository = (LocalScmProviderRepository) repo; - if ( version != null ) - { - throw new ScmException( "The local scm doesn't support tags." ); + if (version != null) { + throw new ScmException("The local scm doesn't support tags."); } - File root = new File( repository.getRoot() ); + File root = new File(repository.getRoot()); String module = repository.getModule(); - File source = new File( root, module ); + File source = new File(root, module); File baseDestination = fileSet.getBasedir(); - if ( !root.exists() ) - { - throw new ScmException( "The base directory doesn't exist (" + root.getAbsolutePath() + ")." ); + if (!root.exists()) { + throw new ScmException("The base directory doesn't exist (" + root.getAbsolutePath() + ")."); } - if ( !source.exists() ) - { - throw new ScmException( "The module directory doesn't exist (" + source.getAbsolutePath() + ")." ); + if (!source.exists()) { + throw new ScmException("The module directory doesn't exist (" + source.getAbsolutePath() + ")."); } List checkedOutFiles; - try - { - if ( baseDestination.exists() ) - { - FileUtils.deleteDirectory( baseDestination ); + try { + if (baseDestination.exists()) { + FileUtils.deleteDirectory(baseDestination); } - if ( !baseDestination.mkdirs() ) - { + if (!baseDestination.mkdirs()) { throw new ScmException( - "Could not create destination directory '" + baseDestination.getAbsolutePath() + "'." ); + "Could not create destination directory '" + baseDestination.getAbsolutePath() + "'."); } - if ( logger.isInfoEnabled() ) - { - logger.info( - "Checking out '" + source.getAbsolutePath() + "' to '" - + baseDestination.getAbsolutePath() + "'." ); + if (logger.isInfoEnabled()) { + logger.info("Checking out '" + source.getAbsolutePath() + "' to '" + baseDestination.getAbsolutePath() + + "'."); } List fileList; - if ( fileSet.getFileList().isEmpty() ) - { - fileList = FileUtils.getFiles( source.getAbsoluteFile(), "**", null ); - } - else - { + if (fileSet.getFileList().isEmpty()) { + fileList = FileUtils.getFiles(source.getAbsoluteFile(), "**", null); + } else { fileList = fileSet.getFileList(); } - checkedOutFiles = checkOut( source, baseDestination, fileList, repository.getModule() ); + checkedOutFiles = checkOut(source, baseDestination, fileList, repository.getModule()); // write metadata file LocalScmMetadataUtils metadataUtils = new LocalScmMetadataUtils(); - metadataUtils.writeMetadata( baseDestination, metadataUtils.buildMetadata( source ) ); - } - catch ( IOException ex ) - { - throw new ScmException( "Error while checking out the files.", ex ); + metadataUtils.writeMetadata(baseDestination, metadataUtils.buildMetadata(source)); + } catch (IOException ex) { + throw new ScmException("Error while checking out the files.", ex); } - return new LocalCheckOutScmResult( null, checkedOutFiles ); + return new LocalCheckOutScmResult(null, checkedOutFiles); } - private List checkOut( File source, File baseDestination, List files, String module ) - throws ScmException, IOException - { + private List checkOut(File source, File baseDestination, List files, String module) + throws ScmException, IOException { String sourcePath = source.getAbsolutePath(); List checkedOutFiles = new ArrayList<>(); - for ( File file : files ) - { + for (File file : files) { String dest = file.getAbsolutePath(); - dest = dest.substring( sourcePath.length() + 1 ); + dest = dest.substring(sourcePath.length() + 1); - File destination = new File( baseDestination, dest ); + File destination = new File(baseDestination, dest); destination = destination.getParentFile(); - if ( !destination.exists() && !destination.mkdirs() ) - { + if (!destination.exists() && !destination.mkdirs()) { throw new ScmException( - "Could not create destination directory '" + destination.getAbsolutePath() + "'." ); + "Could not create destination directory '" + destination.getAbsolutePath() + "'."); } - FileUtils.copyFileToDirectory( file, destination ); + FileUtils.copyFileToDirectory(file, destination); File parent = file.getParentFile(); String fileName = "/" + module + "/" + dest; - checkedOutFiles.add( new ScmFile( fileName, ScmFileStatus.CHECKED_OUT ) ); + checkedOutFiles.add(new ScmFile(fileName, ScmFileStatus.CHECKED_OUT)); } return checkedOutFiles; } - - } diff --git a/maven-scm-providers/maven-scm-provider-local/src/main/java/org/apache/maven/scm/provider/local/command/checkout/LocalCheckOutScmResult.java b/maven-scm-providers/maven-scm-provider-local/src/main/java/org/apache/maven/scm/provider/local/command/checkout/LocalCheckOutScmResult.java index 75952c739..347828909 100644 --- a/maven-scm-providers/maven-scm-provider-local/src/main/java/org/apache/maven/scm/provider/local/command/checkout/LocalCheckOutScmResult.java +++ b/maven-scm-providers/maven-scm-provider-local/src/main/java/org/apache/maven/scm/provider/local/command/checkout/LocalCheckOutScmResult.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.local.command.checkout; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider.local.command.checkout; import java.util.List; @@ -28,13 +27,10 @@ * @author Trygve Laugstøl * */ -public class LocalCheckOutScmResult - extends CheckOutScmResult -{ +public class LocalCheckOutScmResult extends CheckOutScmResult { private static final long serialVersionUID = -2646018573623668026L; - public LocalCheckOutScmResult( String commandLine, List files ) - { - super( commandLine, files ); + public LocalCheckOutScmResult(String commandLine, List files) { + super(commandLine, files); } } diff --git a/maven-scm-providers/maven-scm-provider-local/src/main/java/org/apache/maven/scm/provider/local/command/list/LocalListCommand.java b/maven-scm-providers/maven-scm-provider-local/src/main/java/org/apache/maven/scm/provider/local/command/list/LocalListCommand.java index b5fc01bef..d6028396f 100644 --- a/maven-scm-providers/maven-scm-provider-local/src/main/java/org/apache/maven/scm/provider/local/command/list/LocalListCommand.java +++ b/maven-scm-providers/maven-scm-provider-local/src/main/java/org/apache/maven/scm/provider/local/command/list/LocalListCommand.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.local.command.list; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,11 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider.local.command.list; + +import java.io.File; +import java.util.ArrayList; +import java.util.List; import org.apache.maven.scm.ScmException; import org.apache.maven.scm.ScmFile; @@ -30,101 +33,77 @@ import org.apache.maven.scm.provider.local.repository.LocalScmProviderRepository; import org.codehaus.plexus.util.StringUtils; -import java.io.File; -import java.util.ArrayList; -import java.util.List; - /** * @author Emmanuel Venisse * */ -public class LocalListCommand - extends AbstractListCommand -{ +public class LocalListCommand extends AbstractListCommand { /** {@inheritDoc} */ - protected ListScmResult executeListCommand( ScmProviderRepository repo, ScmFileSet fileSet, boolean recursive, - ScmVersion version ) - throws ScmException - { - if ( version != null ) - { - throw new ScmException( "The local scm doesn't support tags." ); + protected ListScmResult executeListCommand( + ScmProviderRepository repo, ScmFileSet fileSet, boolean recursive, ScmVersion version) throws ScmException { + if (version != null) { + throw new ScmException("The local scm doesn't support tags."); } LocalScmProviderRepository repository = (LocalScmProviderRepository) repo; - File root = new File( repository.getRoot() ); + File root = new File(repository.getRoot()); String module = repository.getModule(); - File source = new File( root, module ); + File source = new File(root, module); - if ( !root.exists() ) - { - throw new ScmException( "The base directory doesn't exist (" + root.getAbsolutePath() + ")." ); + if (!root.exists()) { + throw new ScmException("The base directory doesn't exist (" + root.getAbsolutePath() + ")."); } - if ( !source.exists() ) - { - throw new ScmException( "The module directory doesn't exist (" + source.getAbsolutePath() + ")." ); + if (!source.exists()) { + throw new ScmException("The module directory doesn't exist (" + source.getAbsolutePath() + ")."); } - if ( logger.isInfoEnabled() ) - { - logger.info( "Listing files of '" + source.getAbsolutePath() + "'." ); + if (logger.isInfoEnabled()) { + logger.info("Listing files of '" + source.getAbsolutePath() + "'."); } - try - { - if ( fileSet.getFileList() == null || fileSet.getFileList().isEmpty() ) - { - return new LocalListScmResult( null, getFiles( source, source, recursive ) ); - } - else - { + try { + if (fileSet.getFileList() == null || fileSet.getFileList().isEmpty()) { + return new LocalListScmResult(null, getFiles(source, source, recursive)); + } else { List files = new ArrayList<>(); - for ( File file : fileSet.getFileList() ) - { - files.addAll( getFiles( source, new File( source, file.getPath() ), recursive ) ); + for (File file : fileSet.getFileList()) { + files.addAll(getFiles(source, new File(source, file.getPath()), recursive)); } - return new LocalListScmResult( null, files ); + return new LocalListScmResult(null, files); } - } - catch ( Exception e ) - { - return new ListScmResult( null, "The svn command failed.", e.getMessage(), false ); + } catch (Exception e) { + return new ListScmResult(null, "The svn command failed.", e.getMessage(), false); } } - private List getFiles( File source, File directory, boolean recursive ) - throws Exception - { - if ( !directory.exists() ) - { - throw new Exception( "Directory '" + directory.getAbsolutePath() + "' doesn't exist." ); + private List getFiles(File source, File directory, boolean recursive) throws Exception { + if (!directory.exists()) { + throw new Exception("Directory '" + directory.getAbsolutePath() + "' doesn't exist."); } List files = new ArrayList<>(); File[] filesArray = directory.listFiles(); - if ( filesArray != null ) - { - for ( int i = 0; i < filesArray.length; i++ ) - { + if (filesArray != null) { + for (int i = 0; i < filesArray.length; i++) { File f = filesArray[i]; - String path = f.getAbsolutePath().substring( source.getAbsolutePath().length() ); - path = StringUtils.replace( path, "\\", "/" ); - path = StringUtils.replace( path, "/./", "/" ); + String path = + f.getAbsolutePath().substring(source.getAbsolutePath().length()); + path = StringUtils.replace(path, "\\", "/"); + path = StringUtils.replace(path, "/./", "/"); - files.add( new ScmFile( path, ScmFileStatus.CHECKED_IN ) ); + files.add(new ScmFile(path, ScmFileStatus.CHECKED_IN)); - if ( f.isDirectory() && recursive ) - { - files.addAll( getFiles( source, f, recursive ) ); + if (f.isDirectory() && recursive) { + files.addAll(getFiles(source, f, recursive)); } } } diff --git a/maven-scm-providers/maven-scm-provider-local/src/main/java/org/apache/maven/scm/provider/local/command/list/LocalListScmResult.java b/maven-scm-providers/maven-scm-provider-local/src/main/java/org/apache/maven/scm/provider/local/command/list/LocalListScmResult.java index 02fc9060d..74fee24e0 100644 --- a/maven-scm-providers/maven-scm-provider-local/src/main/java/org/apache/maven/scm/provider/local/command/list/LocalListScmResult.java +++ b/maven-scm-providers/maven-scm-provider-local/src/main/java/org/apache/maven/scm/provider/local/command/list/LocalListScmResult.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.local.command.list; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider.local.command.list; import java.util.List; @@ -28,14 +27,11 @@ * @author Emmanuel Venisse * */ -public class LocalListScmResult - extends ListScmResult -{ +public class LocalListScmResult extends ListScmResult { private static final long serialVersionUID = 259954569217343901L; - public LocalListScmResult( String commandLine, List files ) - { - super( commandLine, files ); + public LocalListScmResult(String commandLine, List files) { + super(commandLine, files); } } diff --git a/maven-scm-providers/maven-scm-provider-local/src/main/java/org/apache/maven/scm/provider/local/command/mkdir/LocalMkdirCommand.java b/maven-scm-providers/maven-scm-provider-local/src/main/java/org/apache/maven/scm/provider/local/command/mkdir/LocalMkdirCommand.java index ffff58ad6..457c995a0 100644 --- a/maven-scm-providers/maven-scm-provider-local/src/main/java/org/apache/maven/scm/provider/local/command/mkdir/LocalMkdirCommand.java +++ b/maven-scm-providers/maven-scm-provider-local/src/main/java/org/apache/maven/scm/provider/local/command/mkdir/LocalMkdirCommand.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.local.command.mkdir; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider.local.command.mkdir; import java.io.File; import java.util.ArrayList; @@ -41,57 +40,46 @@ * @author Maria Odea Ching * */ -public class LocalMkdirCommand - extends AbstractMkdirCommand -{ - protected MkdirScmResult executeMkdirCommand( ScmProviderRepository repository, ScmFileSet fileSet, String message, - boolean createInLocal ) - throws ScmException - { +public class LocalMkdirCommand extends AbstractMkdirCommand { + protected MkdirScmResult executeMkdirCommand( + ScmProviderRepository repository, ScmFileSet fileSet, String message, boolean createInLocal) + throws ScmException { LocalScmProviderRepository repo = (LocalScmProviderRepository) repository; List createdDirs = new ArrayList<>(); // create/commit the directory directly in the repository - if ( !createInLocal ) - { - File file = fileSet.getFileList().get( 0 ); - File modulePath = new File( repo.getRoot(), repo.getModule() ); - File dir = new File( modulePath, file.getName() ); + if (!createInLocal) { + File file = fileSet.getFileList().get(0); + File modulePath = new File(repo.getRoot(), repo.getModule()); + File dir = new File(modulePath, file.getName()); - if ( dir.exists() ) - { - return new MkdirScmResult( null, "Directory already exists!", "Directory already exists.", false ); - } - else - { - if ( logger.isInfoEnabled() ) - { - logger.info( "Creating directory in '" + modulePath.getAbsolutePath() + "'" ); + if (dir.exists()) { + return new MkdirScmResult(null, "Directory already exists!", "Directory already exists.", false); + } else { + if (logger.isInfoEnabled()) { + logger.info("Creating directory in '" + modulePath.getAbsolutePath() + "'"); } - FileUtils.mkdir( dir.getAbsolutePath() ); - createdDirs.add( new ScmFile( dir.getPath(), ScmFileStatus.ADDED ) ); + FileUtils.mkdir(dir.getAbsolutePath()); + createdDirs.add(new ScmFile(dir.getPath(), ScmFileStatus.ADDED)); } - } - else - { + } else { // add the directory, but not commit LocalAddCommand addCmd = new LocalAddCommand(); CommandParameters parameters = new CommandParameters(); - parameters.setString( CommandParameter.MESSAGE, message ); - parameters.setString( CommandParameter.BINARY, "false" ); + parameters.setString(CommandParameter.MESSAGE, message); + parameters.setString(CommandParameter.BINARY, "false"); - String path = ( fileSet.getFileList().get( 0 ) ).getPath(); - if ( repo.isFileAdded( path ) ) - { - return new MkdirScmResult( null, "Directory already exists!", "Directory already exists.", false ); + String path = (fileSet.getFileList().get(0)).getPath(); + if (repo.isFileAdded(path)) { + return new MkdirScmResult(null, "Directory already exists!", "Directory already exists.", false); } - AddScmResult result = (AddScmResult) addCmd.execute( repository, fileSet, parameters ); - createdDirs.addAll( result.getAddedFiles() ); + AddScmResult result = (AddScmResult) addCmd.execute(repository, fileSet, parameters); + createdDirs.addAll(result.getAddedFiles()); } - return new MkdirScmResult( null, createdDirs ); + return new MkdirScmResult(null, createdDirs); } } diff --git a/maven-scm-providers/maven-scm-provider-local/src/main/java/org/apache/maven/scm/provider/local/command/status/LocalStatusCommand.java b/maven-scm-providers/maven-scm-provider-local/src/main/java/org/apache/maven/scm/provider/local/command/status/LocalStatusCommand.java index 4a030f549..8738f247f 100644 --- a/maven-scm-providers/maven-scm-provider-local/src/main/java/org/apache/maven/scm/provider/local/command/status/LocalStatusCommand.java +++ b/maven-scm-providers/maven-scm-provider-local/src/main/java/org/apache/maven/scm/provider/local/command/status/LocalStatusCommand.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.local.command.status; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider.local.command.status; import java.util.Collections; @@ -32,14 +31,10 @@ * @author Matthew McCullough * */ -public class LocalStatusCommand - extends AbstractStatusCommand - implements LocalCommand -{ +public class LocalStatusCommand extends AbstractStatusCommand implements LocalCommand { /** {@inheritDoc} */ - protected StatusScmResult executeStatusCommand( ScmProviderRepository repository, ScmFileSet fileSet ) - throws ScmException - { - return new StatusScmResult( null, Collections.emptyList() ); + protected StatusScmResult executeStatusCommand(ScmProviderRepository repository, ScmFileSet fileSet) + throws ScmException { + return new StatusScmResult(null, Collections.emptyList()); } } diff --git a/maven-scm-providers/maven-scm-provider-local/src/main/java/org/apache/maven/scm/provider/local/command/tag/LocalTagCommand.java b/maven-scm-providers/maven-scm-provider-local/src/main/java/org/apache/maven/scm/provider/local/command/tag/LocalTagCommand.java index 87a2371ea..7b498af25 100644 --- a/maven-scm-providers/maven-scm-provider-local/src/main/java/org/apache/maven/scm/provider/local/command/tag/LocalTagCommand.java +++ b/maven-scm-providers/maven-scm-provider-local/src/main/java/org/apache/maven/scm/provider/local/command/tag/LocalTagCommand.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.local.command.tag; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider.local.command.tag; import java.util.Collections; @@ -35,24 +34,18 @@ * @author Olivier Lamy * */ -public class LocalTagCommand - extends AbstractTagCommand - implements LocalCommand -{ +public class LocalTagCommand extends AbstractTagCommand implements LocalCommand { /** {@inheritDoc} */ - protected ScmResult executeTagCommand( ScmProviderRepository repository, ScmFileSet fileSet, String message, - ScmTagParameters scmTagParameters ) - throws ScmException - { - return new TagScmResult( null, Collections.emptyList() ); + protected ScmResult executeTagCommand( + ScmProviderRepository repository, ScmFileSet fileSet, String message, ScmTagParameters scmTagParameters) + throws ScmException { + return new TagScmResult(null, Collections.emptyList()); } - //Satisfies deprecated interface + // Satisfies deprecated interface /** {@inheritDoc} */ - protected ScmResult executeTagCommand( ScmProviderRepository repository, ScmFileSet fileSet, String tagName, - String message ) - throws ScmException - { - return new TagScmResult( null, Collections.emptyList() ); + protected ScmResult executeTagCommand( + ScmProviderRepository repository, ScmFileSet fileSet, String tagName, String message) throws ScmException { + return new TagScmResult(null, Collections.emptyList()); } } diff --git a/maven-scm-providers/maven-scm-provider-local/src/main/java/org/apache/maven/scm/provider/local/command/update/LocalUpdateCommand.java b/maven-scm-providers/maven-scm-provider-local/src/main/java/org/apache/maven/scm/provider/local/command/update/LocalUpdateCommand.java index caf1df84b..bff005eff 100644 --- a/maven-scm-providers/maven-scm-provider-local/src/main/java/org/apache/maven/scm/provider/local/command/update/LocalUpdateCommand.java +++ b/maven-scm-providers/maven-scm-provider-local/src/main/java/org/apache/maven/scm/provider/local/command/update/LocalUpdateCommand.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.local.command.update; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,13 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider.local.command.update; + +import java.io.File; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; import org.apache.maven.scm.ScmException; import org.apache.maven.scm.ScmFile; @@ -35,172 +40,139 @@ import org.apache.maven.scm.provider.local.repository.LocalScmProviderRepository; import org.codehaus.plexus.util.FileUtils; -import java.io.File; -import java.io.IOException; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - /** * @author Trygve Laugstøl * @author Olivier Lamy * */ -public class LocalUpdateCommand - extends AbstractUpdateCommand - implements LocalCommand -{ +public class LocalUpdateCommand extends AbstractUpdateCommand implements LocalCommand { /** {@inheritDoc} */ - protected UpdateScmResult executeUpdateCommand( ScmProviderRepository repo, ScmFileSet fileSet, ScmVersion version ) - throws ScmException - { + protected UpdateScmResult executeUpdateCommand(ScmProviderRepository repo, ScmFileSet fileSet, ScmVersion version) + throws ScmException { LocalScmProviderRepository repository = (LocalScmProviderRepository) repo; - if ( version != null ) - { - throw new ScmException( "The local scm doesn't support tags." ); + if (version != null) { + throw new ScmException("The local scm doesn't support tags."); } - File root = new File( repository.getRoot() ); + File root = new File(repository.getRoot()); String module = repository.getModule(); - File source = new File( root, module ); + File source = new File(root, module); File baseDestination = fileSet.getBasedir(); - if ( !baseDestination.exists() ) - { - throw new ScmException( - "The working directory doesn't exist (" + baseDestination.getAbsolutePath() + ")." ); + if (!baseDestination.exists()) { + throw new ScmException("The working directory doesn't exist (" + baseDestination.getAbsolutePath() + ")."); } - if ( !root.exists() ) - { - throw new ScmException( "The base directory doesn't exist (" + root.getAbsolutePath() + ")." ); + if (!root.exists()) { + throw new ScmException("The base directory doesn't exist (" + root.getAbsolutePath() + ")."); } - if ( !source.exists() ) - { - throw new ScmException( "The module directory doesn't exist (" + source.getAbsolutePath() + ")." ); + if (!source.exists()) { + throw new ScmException("The module directory doesn't exist (" + source.getAbsolutePath() + ")."); } - if ( !baseDestination.exists() && !baseDestination.isDirectory() ) - { - throw new ScmException( "The destination directory isn't a directory or doesn't exist (" - + baseDestination.getAbsolutePath() + ")." ); + if (!baseDestination.exists() && !baseDestination.isDirectory()) { + throw new ScmException("The destination directory isn't a directory or doesn't exist (" + + baseDestination.getAbsolutePath() + ")."); } List updatedFiles; - try - { - if ( logger.isInfoEnabled() ) - { - logger.info( - "Updating '" + baseDestination.getAbsolutePath() + "' from '" - + source.getAbsolutePath() + "'." ); + try { + if (logger.isInfoEnabled()) { + logger.info("Updating '" + baseDestination.getAbsolutePath() + "' from '" + source.getAbsolutePath() + + "'."); } - List fileList = FileUtils.getFiles( source.getAbsoluteFile(), "**", null ); - updatedFiles = update( source, baseDestination, fileList ); + List fileList = FileUtils.getFiles(source.getAbsoluteFile(), "**", null); + updatedFiles = update(source, baseDestination, fileList); // process deletions in repository LocalScmMetadataUtils metadataUtils = new LocalScmMetadataUtils(); - LocalScmMetadata originalMetadata = metadataUtils.readMetadata( baseDestination ); - if ( originalMetadata != null ) - { - LocalScmMetadata newMetadata = metadataUtils.buildMetadata( source ); - for ( Iterator it = originalMetadata.getRepositoryFileNames().iterator(); it.hasNext(); ) - { + LocalScmMetadata originalMetadata = metadataUtils.readMetadata(baseDestination); + if (originalMetadata != null) { + LocalScmMetadata newMetadata = metadataUtils.buildMetadata(source); + for (Iterator it = + originalMetadata.getRepositoryFileNames().iterator(); + it.hasNext(); ) { String filename = it.next(); - if ( !newMetadata.getRepositoryFileNames().contains( filename ) ) - { - File localFile = new File( baseDestination, filename ); - if ( localFile.exists() ) - { + if (!newMetadata.getRepositoryFileNames().contains(filename)) { + File localFile = new File(baseDestination, filename); + if (localFile.exists()) { localFile.delete(); - updatedFiles.add( new ScmFile( "/" + filename, ScmFileStatus.UPDATED ) ); + updatedFiles.add(new ScmFile("/" + filename, ScmFileStatus.UPDATED)); } } } } // rewrite metadata file - metadataUtils.writeMetadata( baseDestination, metadataUtils.buildMetadata( source ) ); + metadataUtils.writeMetadata(baseDestination, metadataUtils.buildMetadata(source)); - } - catch ( IOException ex ) - { - throw new ScmException( "Error while checking out the files.", ex ); + } catch (IOException ex) { + throw new ScmException("Error while checking out the files.", ex); } - return new LocalUpdateScmResult( null, updatedFiles ); + return new LocalUpdateScmResult(null, updatedFiles); } - private List update( File source, File baseDestination, List files ) - throws ScmException, IOException - { + private List update(File source, File baseDestination, List files) throws ScmException, IOException { String sourcePath = source.getAbsolutePath(); List updatedFiles = new ArrayList<>(); - for ( Iterator i = files.iterator(); i.hasNext(); ) - { + for (Iterator i = files.iterator(); i.hasNext(); ) { File repositoryFile = i.next(); File repositoryDirectory = repositoryFile.getParentFile(); - String dest = repositoryFile.getAbsolutePath().substring( sourcePath.length() + 1 ); + String dest = repositoryFile.getAbsolutePath().substring(sourcePath.length() + 1); - File destinationFile = new File( baseDestination, dest ); + File destinationFile = new File(baseDestination, dest); - String repositoryFileContents = FileUtils.fileRead( repositoryFile ); + String repositoryFileContents = FileUtils.fileRead(repositoryFile); - if ( destinationFile.exists() ) - { - String destionationFileContents = FileUtils.fileRead( destinationFile ); + if (destinationFile.exists()) { + String destionationFileContents = FileUtils.fileRead(destinationFile); - if ( repositoryFileContents.equals( destionationFileContents ) ) - { + if (repositoryFileContents.equals(destionationFileContents)) { continue; } } File destinationDirectory = destinationFile.getParentFile(); - if ( !destinationDirectory.exists() && !destinationDirectory.mkdirs() ) - { + if (!destinationDirectory.exists() && !destinationDirectory.mkdirs()) { throw new ScmException( - "Could not create destination directory '" + destinationDirectory.getAbsolutePath() + "'." ); + "Could not create destination directory '" + destinationDirectory.getAbsolutePath() + "'."); } ScmFileStatus status; - if ( destinationFile.exists() ) - { + if (destinationFile.exists()) { status = ScmFileStatus.UPDATED; - } - else - { + } else { status = ScmFileStatus.ADDED; } - FileUtils.copyFileToDirectory( repositoryFile, destinationDirectory ); + FileUtils.copyFileToDirectory(repositoryFile, destinationDirectory); int chop = baseDestination.getAbsolutePath().length(); - String fileName = destinationFile.getAbsolutePath().substring( chop + 1 ); + String fileName = destinationFile.getAbsolutePath().substring(chop + 1); - updatedFiles.add( new ScmFile( fileName, status ) ); + updatedFiles.add(new ScmFile(fileName, status)); } return updatedFiles; } /** {@inheritDoc} */ - protected ChangeLogCommand getChangeLogCommand() - { + protected ChangeLogCommand getChangeLogCommand() { return new LocalChangeLogCommand(); } } diff --git a/maven-scm-providers/maven-scm-provider-local/src/main/java/org/apache/maven/scm/provider/local/command/update/LocalUpdateScmResult.java b/maven-scm-providers/maven-scm-provider-local/src/main/java/org/apache/maven/scm/provider/local/command/update/LocalUpdateScmResult.java index e32300f66..2dbee4afd 100644 --- a/maven-scm-providers/maven-scm-provider-local/src/main/java/org/apache/maven/scm/provider/local/command/update/LocalUpdateScmResult.java +++ b/maven-scm-providers/maven-scm-provider-local/src/main/java/org/apache/maven/scm/provider/local/command/update/LocalUpdateScmResult.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.local.command.update; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider.local.command.update; import java.util.List; @@ -28,13 +27,10 @@ * @author Trygve Laugstøl * */ -public class LocalUpdateScmResult - extends UpdateScmResult -{ +public class LocalUpdateScmResult extends UpdateScmResult { private static final long serialVersionUID = -932254303678432167L; - public LocalUpdateScmResult( String commandLine, List files ) - { - super( commandLine, files ); + public LocalUpdateScmResult(String commandLine, List files) { + super(commandLine, files); } } diff --git a/maven-scm-providers/maven-scm-provider-local/src/main/java/org/apache/maven/scm/provider/local/metadata/LocalScmMetadataUtils.java b/maven-scm-providers/maven-scm-provider-local/src/main/java/org/apache/maven/scm/provider/local/metadata/LocalScmMetadataUtils.java index 541acf6a4..742d2c4ac 100644 --- a/maven-scm-providers/maven-scm-provider-local/src/main/java/org/apache/maven/scm/provider/local/metadata/LocalScmMetadataUtils.java +++ b/maven-scm-providers/maven-scm-provider-local/src/main/java/org/apache/maven/scm/provider/local/metadata/LocalScmMetadataUtils.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.local.metadata; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,13 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider.local.metadata; + +import java.io.File; +import java.io.IOException; +import java.io.Reader; +import java.io.Writer; +import java.util.List; import org.apache.maven.scm.provider.local.metadata.io.xpp3.LocalScmMetadataXpp3Reader; import org.apache.maven.scm.provider.local.metadata.io.xpp3.LocalScmMetadataXpp3Writer; @@ -29,26 +34,19 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import java.io.File; -import java.io.IOException; -import java.io.Reader; -import java.io.Writer; -import java.util.List; - /** * Utils for dealing with LocalScmMetadata * * @author Arne Degenring * */ -public class LocalScmMetadataUtils -{ +public class LocalScmMetadataUtils { /** * The name of the metadata file */ public static final String FILENAME = ".maven-scm-local"; - private static final Logger LOGGER = LoggerFactory.getLogger( LocalScmMetadataUtils.class ); + private static final Logger LOGGER = LoggerFactory.getLogger(LocalScmMetadataUtils.class); /** * Builds LocalScmMetadata based on contents of repository @@ -57,13 +55,11 @@ public class LocalScmMetadataUtils * @return TODO * @throws IOException if any */ - public LocalScmMetadata buildMetadata( File repository ) - throws IOException - { - @SuppressWarnings( "unchecked" ) - List repoFilenames = FileUtils.getFileNames( repository.getAbsoluteFile(), "**", null, false ); + public LocalScmMetadata buildMetadata(File repository) throws IOException { + @SuppressWarnings("unchecked") + List repoFilenames = FileUtils.getFileNames(repository.getAbsoluteFile(), "**", null, false); LocalScmMetadata metadata = new LocalScmMetadata(); - metadata.setRepositoryFileNames( repoFilenames ); + metadata.setRepositoryFileNames(repoFilenames); return metadata; } @@ -74,19 +70,14 @@ public LocalScmMetadata buildMetadata( File repository ) * @param metadata * @throws IOException if any */ - public void writeMetadata( File destinationDir, LocalScmMetadata metadata ) - throws IOException - { - File metadataFile = new File( destinationDir, FILENAME ); + public void writeMetadata(File destinationDir, LocalScmMetadata metadata) throws IOException { + File metadataFile = new File(destinationDir, FILENAME); metadataFile.createNewFile(); - Writer writer = WriterFactory.newXmlWriter( metadataFile ); - try - { - new LocalScmMetadataXpp3Writer().write( writer, metadata ); - } - finally - { - IOUtil.close( writer ); + Writer writer = WriterFactory.newXmlWriter(metadataFile); + try { + new LocalScmMetadataXpp3Writer().write(writer, metadata); + } finally { + IOUtil.close(writer); } } @@ -96,40 +87,28 @@ public void writeMetadata( File destinationDir, LocalScmMetadata metadata ) * @param dir The directory that should contain the metadata file * @return LocalScmMetadata or null in case of problems */ - public LocalScmMetadata readMetadata( File dir ) - { - File metadataFile = new File( dir, FILENAME ); - if ( !metadataFile.exists() ) - { + public LocalScmMetadata readMetadata(File dir) { + File metadataFile = new File(dir, FILENAME); + if (!metadataFile.exists()) { return null; } LocalScmMetadata result = null; Reader reader = null; - try - { - reader = ReaderFactory.newXmlReader( metadataFile ); - result = new LocalScmMetadataXpp3Reader().read( reader ); - } - catch ( XmlPullParserException e ) - { - if ( LOGGER.isWarnEnabled() ) - { - LOGGER.warn( "Could not interpret .maven-scm-local - ignoring", e ); + try { + reader = ReaderFactory.newXmlReader(metadataFile); + result = new LocalScmMetadataXpp3Reader().read(reader); + } catch (XmlPullParserException e) { + if (LOGGER.isWarnEnabled()) { + LOGGER.warn("Could not interpret .maven-scm-local - ignoring", e); } return null; - } - catch ( IOException e ) - { - if ( LOGGER.isWarnEnabled() ) - { - LOGGER.warn( "Could not Read .maven-scm-local - ignoring", e ); + } catch (IOException e) { + if (LOGGER.isWarnEnabled()) { + LOGGER.warn("Could not Read .maven-scm-local - ignoring", e); } - } - finally - { - IOUtil.close( reader ); + } finally { + IOUtil.close(reader); } return result; } - } diff --git a/maven-scm-providers/maven-scm-provider-local/src/main/java/org/apache/maven/scm/provider/local/repository/LocalScmProviderRepository.java b/maven-scm-providers/maven-scm-provider-local/src/main/java/org/apache/maven/scm/provider/local/repository/LocalScmProviderRepository.java index 42d6e3d10..40b8a1628 100644 --- a/maven-scm-providers/maven-scm-provider-local/src/main/java/org/apache/maven/scm/provider/local/repository/LocalScmProviderRepository.java +++ b/maven-scm-providers/maven-scm-provider-local/src/main/java/org/apache/maven/scm/provider/local/repository/LocalScmProviderRepository.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.local.repository; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,19 +16,18 @@ * specific language governing permissions and limitations * under the License. */ - -import org.apache.maven.scm.provider.ScmProviderRepository; +package org.apache.maven.scm.provider.local.repository; import java.util.HashSet; import java.util.Set; +import org.apache.maven.scm.provider.ScmProviderRepository; + /** * @author Trygve Laugstøl * */ -public class LocalScmProviderRepository - extends ScmProviderRepository -{ +public class LocalScmProviderRepository extends ScmProviderRepository { private String root; private String module; @@ -41,8 +38,7 @@ public class LocalScmProviderRepository * @param root * @param module */ - public LocalScmProviderRepository( String root, String module ) - { + public LocalScmProviderRepository(String root, String module) { this.root = root; this.module = module; @@ -51,26 +47,22 @@ public LocalScmProviderRepository( String root, String module ) /** * @return Returns the root. */ - public String getRoot() - { + public String getRoot() { return root; } /** * @return Returns the module. */ - public String getModule() - { + public String getModule() { return module; } - public void addFile( String path ) - { - addedFiles.add( path ); + public void addFile(String path) { + addedFiles.add(path); } - public boolean isFileAdded( String path ) - { - return addedFiles.contains( path ); + public boolean isFileAdded(String path) { + return addedFiles.contains(path); } } diff --git a/maven-scm-providers/maven-scm-provider-local/src/test/java/org/apache/maven/scm/provider/local/LocalScmProviderTest.java b/maven-scm-providers/maven-scm-provider-local/src/test/java/org/apache/maven/scm/provider/local/LocalScmProviderTest.java index 2ddc4f481..430640827 100644 --- a/maven-scm-providers/maven-scm-provider-local/src/test/java/org/apache/maven/scm/provider/local/LocalScmProviderTest.java +++ b/maven-scm-providers/maven-scm-provider-local/src/test/java/org/apache/maven/scm/provider/local/LocalScmProviderTest.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.local; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider.local; import org.apache.maven.scm.ScmTestCase; import org.junit.Test; @@ -28,18 +27,15 @@ * @author Trygve Laugstøl * */ -public class LocalScmProviderTest - extends ScmTestCase -{ +public class LocalScmProviderTest extends ScmTestCase { @Test - public void testFixModuleName() - { - assertEquals( "my-module", LocalScmProvider.fixModuleName( "my-module" ) ); + public void testFixModuleName() { + assertEquals("my-module", LocalScmProvider.fixModuleName("my-module")); - assertEquals( "my-module", LocalScmProvider.fixModuleName( "/my-module" ) ); + assertEquals("my-module", LocalScmProvider.fixModuleName("/my-module")); - assertEquals( "my-module", LocalScmProvider.fixModuleName( "my-module/" ) ); + assertEquals("my-module", LocalScmProvider.fixModuleName("my-module/")); - assertEquals( "my-module", LocalScmProvider.fixModuleName( "/my-module/" ) ); + assertEquals("my-module", LocalScmProvider.fixModuleName("/my-module/")); } } diff --git a/maven-scm-providers/maven-scm-provider-local/src/test/java/org/apache/maven/scm/provider/local/command/checkin/LocalCheckInCommandTckTest.java b/maven-scm-providers/maven-scm-provider-local/src/test/java/org/apache/maven/scm/provider/local/command/checkin/LocalCheckInCommandTckTest.java index 9993328d9..a73c708db 100644 --- a/maven-scm-providers/maven-scm-provider-local/src/test/java/org/apache/maven/scm/provider/local/command/checkin/LocalCheckInCommandTckTest.java +++ b/maven-scm-providers/maven-scm-provider-local/src/test/java/org/apache/maven/scm/provider/local/command/checkin/LocalCheckInCommandTckTest.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.local.command.checkin; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,43 +16,36 @@ * specific language governing permissions and limitations * under the License. */ - -import org.apache.maven.scm.tck.command.checkin.CheckInCommandTckTest; +package org.apache.maven.scm.provider.local.command.checkin; import java.io.File; +import org.apache.maven.scm.tck.command.checkin.CheckInCommandTckTest; + /** * @author Brett Porter * */ -public class LocalCheckInCommandTckTest - extends CheckInCommandTckTest -{ +public class LocalCheckInCommandTckTest extends CheckInCommandTckTest { private static final String moduleName = "checkin-tck"; - public String getScmUrl() - throws Exception - { + public String getScmUrl() throws Exception { return "scm:local|" + getRepositoryRoot() + "|" + moduleName; } - public void initRepo() - throws Exception - { - makeRepo( getRepositoryRoot() ); + public void initRepo() throws Exception { + makeRepo(getRepositoryRoot()); } - private void makeRepo( File workingDirectory ) - throws Exception - { - makeFile( workingDirectory, moduleName + "/pom.xml", "/pom.xml" ); + private void makeRepo(File workingDirectory) throws Exception { + makeFile(workingDirectory, moduleName + "/pom.xml", "/pom.xml"); - makeFile( workingDirectory, moduleName + "/readme.txt", "/readme.txt" ); + makeFile(workingDirectory, moduleName + "/readme.txt", "/readme.txt"); - makeFile( workingDirectory, moduleName + "/src/main/java/Application.java", "/src/main/java/Application.java" ); + makeFile(workingDirectory, moduleName + "/src/main/java/Application.java", "/src/main/java/Application.java"); - makeFile( workingDirectory, moduleName + "/src/test/java/Test.java", "/src/test/java/Test.java" ); + makeFile(workingDirectory, moduleName + "/src/test/java/Test.java", "/src/test/java/Test.java"); - makeDirectory( workingDirectory, moduleName + "/src/test/resources" ); + makeDirectory(workingDirectory, moduleName + "/src/test/resources"); } } diff --git a/maven-scm-providers/maven-scm-provider-local/src/test/java/org/apache/maven/scm/provider/local/command/checkout/LocalCheckOutCommandTckTest.java b/maven-scm-providers/maven-scm-provider-local/src/test/java/org/apache/maven/scm/provider/local/command/checkout/LocalCheckOutCommandTckTest.java index abaaf38ef..64a0e1a8b 100644 --- a/maven-scm-providers/maven-scm-provider-local/src/test/java/org/apache/maven/scm/provider/local/command/checkout/LocalCheckOutCommandTckTest.java +++ b/maven-scm-providers/maven-scm-provider-local/src/test/java/org/apache/maven/scm/provider/local/command/checkout/LocalCheckOutCommandTckTest.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.local.command.checkout; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider.local.command.checkout; import java.io.File; import java.io.FileReader; @@ -40,68 +39,57 @@ * @author Emmanuel Venisse * */ -public class LocalCheckOutCommandTckTest - extends CheckOutCommandTckTest -{ +public class LocalCheckOutCommandTckTest extends CheckOutCommandTckTest { private String module = "check-out"; - public String getScmUrl() - throws Exception - { + public String getScmUrl() throws Exception { return "scm:local|" + getRepositoryRoot().getAbsolutePath() + "|" + module; } - public void initRepo() - throws Exception - { - File root = new File( getRepositoryRoot() + "/" + module ); + public void initRepo() throws Exception { + File root = new File(getRepositoryRoot() + "/" + module); - makeFile( root, "/pom.xml" ); + makeFile(root, "/pom.xml"); - makeFile( root, "/readme.txt" ); + makeFile(root, "/readme.txt"); - makeFile( root, "/src/main/java/Application.java" ); + makeFile(root, "/src/main/java/Application.java"); - makeFile( root, "/src/test/java/Test.java" ); + makeFile(root, "/src/test/java/Test.java"); - makeDirectory( root, "/src/test/resources" ); + makeDirectory(root, "/src/test/resources"); } /** * Tests that the metadata file .maven-scm-local is written correctly */ @Test - public void testMetadata() - throws Exception - { - FileUtils.deleteDirectory( getWorkingCopy() ); + public void testMetadata() throws Exception { + FileUtils.deleteDirectory(getWorkingCopy()); - CheckOutScmResult result = checkOut( getWorkingCopy(), getScmRepository() ); + CheckOutScmResult result = checkOut(getWorkingCopy(), getScmRepository()); - assertResultIsSuccess( result ); + assertResultIsSuccess(result); List checkedOutFiles = result.getCheckedOutFiles(); - assertEquals( 4, checkedOutFiles.size() ); + assertEquals(4, checkedOutFiles.size()); // ---------------------------------------------------------------------- // Assert metadata file // ---------------------------------------------------------------------- - File metadataFile = new File( getWorkingCopy(), ".maven-scm-local" ); - assertTrue( "Expected metadata file .maven-scm-local does not exist", metadataFile.exists() ); - Reader reader = new FileReader( metadataFile ); + File metadataFile = new File(getWorkingCopy(), ".maven-scm-local"); + assertTrue("Expected metadata file .maven-scm-local does not exist", metadataFile.exists()); + Reader reader = new FileReader(metadataFile); LocalScmMetadata metadata; - try - { - metadata = new LocalScmMetadataXpp3Reader().read( reader ); - } - finally - { - IOUtil.close( reader ); + try { + metadata = new LocalScmMetadataXpp3Reader().read(reader); + } finally { + IOUtil.close(reader); } - File root = new File( getRepositoryRoot() + "/" + module ); - @SuppressWarnings( "unchecked" ) - List fileNames = FileUtils.getFileNames( root, "**", null, false ); - assertEquals( fileNames, metadata.getRepositoryFileNames() ); + File root = new File(getRepositoryRoot() + "/" + module); + @SuppressWarnings("unchecked") + List fileNames = FileUtils.getFileNames(root, "**", null, false); + assertEquals(fileNames, metadata.getRepositoryFileNames()); } } diff --git a/maven-scm-providers/maven-scm-provider-local/src/test/java/org/apache/maven/scm/provider/local/command/list/LocalListCommandTckTest.java b/maven-scm-providers/maven-scm-provider-local/src/test/java/org/apache/maven/scm/provider/local/command/list/LocalListCommandTckTest.java index 28ff7d596..6747633bf 100644 --- a/maven-scm-providers/maven-scm-provider-local/src/test/java/org/apache/maven/scm/provider/local/command/list/LocalListCommandTckTest.java +++ b/maven-scm-providers/maven-scm-provider-local/src/test/java/org/apache/maven/scm/provider/local/command/list/LocalListCommandTckTest.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.local.command.list; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,39 +16,34 @@ * specific language governing permissions and limitations * under the License. */ - -import org.apache.maven.scm.tck.command.list.ListCommandTckTest; +package org.apache.maven.scm.provider.local.command.list; import java.io.File; +import org.apache.maven.scm.tck.command.list.ListCommandTckTest; + /** * @author Emmanuel Venisse * */ -public class LocalListCommandTckTest - extends ListCommandTckTest -{ +public class LocalListCommandTckTest extends ListCommandTckTest { private String module = "check-out"; - public String getScmUrl() - throws Exception - { + public String getScmUrl() throws Exception { return "scm:local|" + getRepositoryRoot().getAbsolutePath() + "|" + module; } - public void initRepo() - throws Exception - { - File root = new File( getRepositoryRoot() + "/" + module ); + public void initRepo() throws Exception { + File root = new File(getRepositoryRoot() + "/" + module); - makeFile( root, "/pom.xml" ); + makeFile(root, "/pom.xml"); - makeFile( root, "/readme.txt" ); + makeFile(root, "/readme.txt"); - makeFile( root, "/src/main/java/Application.java" ); + makeFile(root, "/src/main/java/Application.java"); - makeFile( root, "/src/test/java/Test.java" ); + makeFile(root, "/src/test/java/Test.java"); - makeDirectory( root, "/src/test/resources" ); + makeDirectory(root, "/src/test/resources"); } } diff --git a/maven-scm-providers/maven-scm-provider-local/src/test/java/org/apache/maven/scm/provider/local/command/mkdir/LocalMkdirCommandTckTest.java b/maven-scm-providers/maven-scm-provider-local/src/test/java/org/apache/maven/scm/provider/local/command/mkdir/LocalMkdirCommandTckTest.java index 085b27283..1f71cfd60 100644 --- a/maven-scm-providers/maven-scm-provider-local/src/test/java/org/apache/maven/scm/provider/local/command/mkdir/LocalMkdirCommandTckTest.java +++ b/maven-scm-providers/maven-scm-provider-local/src/test/java/org/apache/maven/scm/provider/local/command/mkdir/LocalMkdirCommandTckTest.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.local.command.mkdir; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider.local.command.mkdir; import java.io.File; @@ -34,71 +33,59 @@ * @author Maria Odea Ching * */ -public class LocalMkdirCommandTckTest - extends MkdirCommandTckTest -{ +public class LocalMkdirCommandTckTest extends MkdirCommandTckTest { private static final String moduleName = "checkin-tck"; - public String getScmUrl() - throws Exception - { + public String getScmUrl() throws Exception { return "scm:local|" + getRepositoryRoot() + "|" + moduleName; } - public void initRepo() - throws Exception - { - makeRepo( getRepositoryRoot() ); + public void initRepo() throws Exception { + makeRepo(getRepositoryRoot()); } - private void makeRepo( File workingDirectory ) - throws Exception - { - makeFile( workingDirectory, moduleName + "/pom.xml", "/pom.xml" ); + private void makeRepo(File workingDirectory) throws Exception { + makeFile(workingDirectory, moduleName + "/pom.xml", "/pom.xml"); - makeFile( workingDirectory, moduleName + "/readme.txt", "/readme.txt" ); + makeFile(workingDirectory, moduleName + "/readme.txt", "/readme.txt"); - makeFile( workingDirectory, moduleName + "/src/main/java/Application.java", "/src/main/java/Application.java" ); + makeFile(workingDirectory, moduleName + "/src/main/java/Application.java", "/src/main/java/Application.java"); - makeFile( workingDirectory, moduleName + "/src/test/java/Test.java", "/src/test/java/Test.java" ); + makeFile(workingDirectory, moduleName + "/src/test/java/Test.java", "/src/test/java/Test.java"); - makeDirectory( workingDirectory, moduleName + "/src/test/resources" ); + makeDirectory(workingDirectory, moduleName + "/src/test/resources"); } @Test - public void testMkdirCommandMkdirUrl() - throws Exception - { - ScmFileSet fileSet = new ScmFileSet( getWorkingCopy(), new File( getMissingDirectory() ) ); + public void testMkdirCommandMkdirUrl() throws Exception { + ScmFileSet fileSet = new ScmFileSet(getWorkingCopy(), new File(getMissingDirectory())); - MkdirScmResult result = getScmManager().mkdir( getScmRepository(), fileSet, "Mkdir message", false ); + MkdirScmResult result = getScmManager().mkdir(getScmRepository(), fileSet, "Mkdir message", false); - assertResultIsSuccess( result ); + assertResultIsSuccess(result); - ListScmResult listResult = getScmManager().list( getScmRepository(), fileSet, true, null ); + ListScmResult listResult = getScmManager().list(getScmRepository(), fileSet, true, null); - assertTrue( "Directory should have been found.", listResult.isSuccess() ); + assertTrue("Directory should have been found.", listResult.isSuccess()); } @Test - public void testMkdirCommandDirAlreadyAdded() - throws Exception - { - ScmFileSet fileSet = new ScmFileSet( getWorkingCopy(), new File( getMissingDirectory() ) ); + public void testMkdirCommandDirAlreadyAdded() throws Exception { + ScmFileSet fileSet = new ScmFileSet(getWorkingCopy(), new File(getMissingDirectory())); - MkdirScmResult result = getScmManager().mkdir( getScmRepository(), fileSet, "Mkdir message", false ); + MkdirScmResult result = getScmManager().mkdir(getScmRepository(), fileSet, "Mkdir message", false); - assertResultIsSuccess( result ); + assertResultIsSuccess(result); - ListScmResult listResult = getScmManager().list( getScmRepository(), fileSet, true, null ); + ListScmResult listResult = getScmManager().list(getScmRepository(), fileSet, true, null); - assertTrue( "Directory should have been found.", listResult.isSuccess() ); + assertTrue("Directory should have been found.", listResult.isSuccess()); // add the directory again - result = getScmManager().mkdir( getScmRepository(), fileSet, "Mkdir message", false ); + result = getScmManager().mkdir(getScmRepository(), fileSet, "Mkdir message", false); - assertFalse( result.isSuccess() ); + assertFalse(result.isSuccess()); - printOutputError( result ); + printOutputError(result); } } diff --git a/maven-scm-providers/maven-scm-provider-local/src/test/java/org/apache/maven/scm/provider/local/command/update/LocalUpdateCommandTckTest.java b/maven-scm-providers/maven-scm-provider-local/src/test/java/org/apache/maven/scm/provider/local/command/update/LocalUpdateCommandTckTest.java index b6b15aa0d..e896f6d36 100644 --- a/maven-scm-providers/maven-scm-provider-local/src/test/java/org/apache/maven/scm/provider/local/command/update/LocalUpdateCommandTckTest.java +++ b/maven-scm-providers/maven-scm-provider-local/src/test/java/org/apache/maven/scm/provider/local/command/update/LocalUpdateCommandTckTest.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.local.command.update; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider.local.command.update; import java.io.File; import java.io.FileReader; @@ -49,21 +48,15 @@ * @author Trygve Laugstøl * */ -public class LocalUpdateCommandTckTest - extends UpdateCommandTckTest -{ +public class LocalUpdateCommandTckTest extends UpdateCommandTckTest { private static final String moduleName = "update-tck"; - public String getScmUrl() - throws Exception - { + public String getScmUrl() throws Exception { return "scm:local|" + getRepositoryRoot() + "|" + moduleName; } - public void initRepo() - throws Exception - { - makeRepo( getRepositoryRoot() ); + public void initRepo() throws Exception { + makeRepo(getRepositoryRoot()); } /** @@ -71,103 +64,94 @@ public void initRepo() * additions must not be deleted. */ @Test - public void testDeletion() - throws Exception - { - FileUtils.deleteDirectory( getUpdatingCopy() ); + public void testDeletion() throws Exception { + FileUtils.deleteDirectory(getUpdatingCopy()); - ScmRepository repository = makeScmRepository( getScmUrl() ); + ScmRepository repository = makeScmRepository(getScmUrl()); - checkOut( getUpdatingCopy(), repository ); + checkOut(getUpdatingCopy(), repository); // Check preconditions - File readmeFileLocal = new File( getUpdatingCopy(), "readme.txt" ); - assertTrue( readmeFileLocal.exists() ); - File newFileLocal = new File( getUpdatingCopy(), "newfile.xml" ); - assertFalse( newFileLocal.exists() ); + File readmeFileLocal = new File(getUpdatingCopy(), "readme.txt"); + assertTrue(readmeFileLocal.exists()); + File newFileLocal = new File(getUpdatingCopy(), "newfile.xml"); + assertFalse(newFileLocal.exists()); // Delete readme.txt from repository - File readmeFileRepo = new File( getRepositoryRoot(), moduleName + "/readme.txt" ); - assertTrue( readmeFileRepo.exists() ); - assertTrue( "Could not delete", readmeFileRepo.delete() ); - assertFalse( readmeFileRepo.exists() ); + File readmeFileRepo = new File(getRepositoryRoot(), moduleName + "/readme.txt"); + assertTrue(readmeFileRepo.exists()); + assertTrue("Could not delete", readmeFileRepo.delete()); + assertFalse(readmeFileRepo.exists()); // Make local addition to updating copy - this one must not be touched - ScmTestCase.makeFile( getUpdatingCopy(), "newfile.xml", "added newfile.xml locally" ); - assertTrue( newFileLocal.exists() ); + ScmTestCase.makeFile(getUpdatingCopy(), "newfile.xml", "added newfile.xml locally"); + assertTrue(newFileLocal.exists()); // ---------------------------------------------------------------------- // Update the project // ---------------------------------------------------------------------- ScmManager scmManager = getScmManager(); - Date lastUpdate = new Date( System.currentTimeMillis() ); - Thread.sleep( 1000 ); - UpdateScmResult result = - scmManager.update( repository, new ScmFileSet( getUpdatingCopy() ), lastUpdate ); + Date lastUpdate = new Date(System.currentTimeMillis()); + Thread.sleep(1000); + UpdateScmResult result = scmManager.update(repository, new ScmFileSet(getUpdatingCopy()), lastUpdate); - assertNotNull( "The command returned a null result.", result ); + assertNotNull("The command returned a null result.", result); - assertResultIsSuccess( result ); + assertResultIsSuccess(result); List updatedFiles = result.getUpdatedFiles(); - assertEquals( "Expected 1 files in the updated files list " + updatedFiles, 1, updatedFiles.size() ); + assertEquals("Expected 1 files in the updated files list " + updatedFiles, 1, updatedFiles.size()); // ---------------------------------------------------------------------- // Assert the files in the updated files list // ---------------------------------------------------------------------- - Iterator files = new TreeSet( updatedFiles ).iterator(); + Iterator files = new TreeSet(updatedFiles).iterator(); // readme.txt ScmFile file = (ScmFile) files.next(); - assertPath( "/readme.txt", file.getPath() ); - assertTrue( file.getStatus().isUpdate() ); + assertPath("/readme.txt", file.getPath()); + assertTrue(file.getStatus().isUpdate()); // ---------------------------------------------------------------------- // Assert working directory contents // ---------------------------------------------------------------------- // readme.txt - assertFalse( "Expected local copy of readme.txt to be deleted", readmeFileLocal.exists() ); + assertFalse("Expected local copy of readme.txt to be deleted", readmeFileLocal.exists()); // newfile.xml - assertTrue( "Expected local copy of newfile.xml NOT to be deleted", newFileLocal.exists() ); + assertTrue("Expected local copy of newfile.xml NOT to be deleted", newFileLocal.exists()); // ---------------------------------------------------------------------- // Assert metadata file // ---------------------------------------------------------------------- - File metadataFile = new File( getUpdatingCopy(), ".maven-scm-local" ); - assertTrue( "Expected metadata file .maven-scm-local does not exist", metadataFile.exists() ); - Reader reader = new FileReader( metadataFile ); + File metadataFile = new File(getUpdatingCopy(), ".maven-scm-local"); + assertTrue("Expected metadata file .maven-scm-local does not exist", metadataFile.exists()); + Reader reader = new FileReader(metadataFile); LocalScmMetadata metadata; - try - { - metadata = new LocalScmMetadataXpp3Reader().read( reader ); + try { + metadata = new LocalScmMetadataXpp3Reader().read(reader); + } finally { + IOUtil.close(reader); } - finally - { - IOUtil.close( reader ); - } - File root = new File( getRepositoryRoot() + "/" + moduleName ); - @SuppressWarnings( "unchecked" ) - List fileNames = FileUtils.getFileNames( root, "**", null, false ); - assertEquals( fileNames, metadata.getRepositoryFileNames() ); - + File root = new File(getRepositoryRoot() + "/" + moduleName); + @SuppressWarnings("unchecked") + List fileNames = FileUtils.getFileNames(root, "**", null, false); + assertEquals(fileNames, metadata.getRepositoryFileNames()); } - private void makeRepo( File workingDirectory ) - throws Exception - { - makeFile( workingDirectory, moduleName + "/pom.xml", "/pom.xml" ); + private void makeRepo(File workingDirectory) throws Exception { + makeFile(workingDirectory, moduleName + "/pom.xml", "/pom.xml"); - makeFile( workingDirectory, moduleName + "/readme.txt", "/readme.txt" ); + makeFile(workingDirectory, moduleName + "/readme.txt", "/readme.txt"); - makeFile( workingDirectory, moduleName + "/src/main/java/Application.java", "/src/main/java/Application.java" ); + makeFile(workingDirectory, moduleName + "/src/main/java/Application.java", "/src/main/java/Application.java"); - makeFile( workingDirectory, moduleName + "/src/test/java/Test.java", "/src/test/java/Test.java" ); + makeFile(workingDirectory, moduleName + "/src/test/java/Test.java", "/src/test/java/Test.java"); - makeDirectory( workingDirectory, moduleName + "/src/test/resources" ); + makeDirectory(workingDirectory, moduleName + "/src/test/resources"); } } diff --git a/maven-scm-providers/maven-scm-provider-local/src/test/java/org/apache/maven/scm/provider/local/repository/LocalRepositoryTest.java b/maven-scm-providers/maven-scm-provider-local/src/test/java/org/apache/maven/scm/provider/local/repository/LocalRepositoryTest.java index fe62288d4..7adb6b95e 100644 --- a/maven-scm-providers/maven-scm-provider-local/src/test/java/org/apache/maven/scm/provider/local/repository/LocalRepositoryTest.java +++ b/maven-scm-providers/maven-scm-provider-local/src/test/java/org/apache/maven/scm/provider/local/repository/LocalRepositoryTest.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.local.repository; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider.local.repository; import org.apache.maven.scm.ScmTestCase; import org.apache.maven.scm.provider.ScmProviderRepository; @@ -36,113 +35,84 @@ * @author Trygve Laugstøl * */ -public class LocalRepositoryTest - extends ScmTestCase -{ +public class LocalRepositoryTest extends ScmTestCase { @Before @Override - public void setUp() - throws Exception - { + public void setUp() throws Exception { super.setUp(); - FileUtils.mkdir( getWorkingDirectory().getAbsolutePath() ); + FileUtils.mkdir(getWorkingDirectory().getAbsolutePath()); } @Test - public void testExistingRepository() - throws Exception - { - ScmRepository repository = getScmManager().makeScmRepository( "scm:local:src/test/repository:test-repo" ); + public void testExistingRepository() throws Exception { + ScmRepository repository = getScmManager().makeScmRepository("scm:local:src/test/repository:test-repo"); - assertNotNull( repository ); + assertNotNull(repository); - assertEquals( "local", repository.getProvider() ); + assertEquals("local", repository.getProvider()); ScmProviderRepository providerRepository = repository.getProviderRepository(); - assertNotNull( providerRepository ); + assertNotNull(providerRepository); - assertTrue( providerRepository instanceof LocalScmProviderRepository ); + assertTrue(providerRepository instanceof LocalScmProviderRepository); LocalScmProviderRepository local = (LocalScmProviderRepository) providerRepository; - assertEquals( getTestFile( "src/test/repository" ).getAbsolutePath(), local.getRoot() ); + assertEquals(getTestFile("src/test/repository").getAbsolutePath(), local.getRoot()); - assertEquals( "test-repo", local.getModule() ); + assertEquals("test-repo", local.getModule()); } @Test - public void testMissingRepositoryRoot() - throws Exception - { - try - { - getScmManager().makeScmRepository( "scm:local:" ); - - fail( "Expected ScmRepositoryException." ); - } - catch ( ScmRepositoryException ex ) - { + public void testMissingRepositoryRoot() throws Exception { + try { + getScmManager().makeScmRepository("scm:local:"); + + fail("Expected ScmRepositoryException."); + } catch (ScmRepositoryException ex) { // expected } } @Test - public void testNonExistingMissingRepositoryRoot() - throws Exception - { - try - { - getScmManager().makeScmRepository( "scm:local:non-existing-directory:module" ); - - fail( "Expected ScmRepositoryException." ); - } - catch ( ScmRepositoryException ex ) - { + public void testNonExistingMissingRepositoryRoot() throws Exception { + try { + getScmManager().makeScmRepository("scm:local:non-existing-directory:module"); + + fail("Expected ScmRepositoryException."); + } catch (ScmRepositoryException ex) { // expected } } @Test - public void testMissingModule() - throws Exception - { - try - { - getScmManager().makeScmRepository( "scm:local:src/test/repository" ); - - fail( "Expected ScmRepositoryException." ); - } - catch ( ScmRepositoryException ex ) - { + public void testMissingModule() throws Exception { + try { + getScmManager().makeScmRepository("scm:local:src/test/repository"); + + fail("Expected ScmRepositoryException."); + } catch (ScmRepositoryException ex) { // expected } - try - { - getScmManager().makeScmRepository( "scm:local:src/test/repository:" ); + try { + getScmManager().makeScmRepository("scm:local:src/test/repository:"); - fail( "Expected ScmRepositoryException." ); - } - catch ( ScmRepositoryException ex ) - { + fail("Expected ScmRepositoryException."); + } catch (ScmRepositoryException ex) { // expected } } @Test - public void testNonExistingModule() - throws Exception - { - try - { - getScmManager().makeScmRepository( "scm:local:src/test/repository:non-existing-module" ); - - fail( "Expected ScmRepositoryException." ); - } - catch ( ScmRepositoryException ex ) - { + public void testNonExistingModule() throws Exception { + try { + getScmManager().makeScmRepository("scm:local:src/test/repository:non-existing-module"); + + fail("Expected ScmRepositoryException."); + } catch (ScmRepositoryException ex) { // expected } } diff --git a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-git-commons/pom.xml b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-git-commons/pom.xml index 3728a3d44..90075b696 100644 --- a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-git-commons/pom.xml +++ b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-git-commons/pom.xml @@ -1,5 +1,4 @@ - - 4.0.0 @@ -33,28 +31,56 @@ Maven SCM Git Provider - Common library Common library for SCM Git Provider. + + + org.codehaus.plexus + plexus-utils + + + org.slf4j + slf4j-api + + + + javax.inject + javax.inject + test + + + junit + junit + test + + + org.codehaus.modello modello-maven-plugin + + 1.1.0 + + src/main/mdo/git-settings.mdo + + generate-xsd-site - pre-site xsd + pre-site ${project.reporting.outputDirectory}/xsd site-docs - pre-site xdoc + pre-site standard @@ -65,35 +91,7 @@ - - 1.1.0 - - src/main/mdo/git-settings.mdo - - - - - - org.codehaus.plexus - plexus-utils - - - org.slf4j - slf4j-api - - - - javax.inject - javax.inject - test - - - junit - junit - test - - diff --git a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-git-commons/src/main/java/org/apache/maven/scm/provider/git/AbstractGitScmProvider.java b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-git-commons/src/main/java/org/apache/maven/scm/provider/git/AbstractGitScmProvider.java index 02fd80e19..38aecb42f 100644 --- a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-git-commons/src/main/java/org/apache/maven/scm/provider/git/AbstractGitScmProvider.java +++ b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-git-commons/src/main/java/org/apache/maven/scm/provider/git/AbstractGitScmProvider.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.git; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider.git; import java.io.File; import java.util.ArrayList; @@ -57,9 +56,7 @@ * @author Emmanuel Venisse * */ -public abstract class AbstractGitScmProvider - extends AbstractScmProvider -{ +public abstract class AbstractGitScmProvider extends AbstractScmProvider { // ---------------------------------------------------------------------- // @@ -68,8 +65,7 @@ public abstract class AbstractGitScmProvider /** * Internal class */ - private static class ScmUrlParserResult - { + private static class ScmUrlParserResult { private final List messages = new ArrayList<>(); private ScmProviderRepository repository; @@ -80,84 +76,65 @@ private static class ScmUrlParserResult // ---------------------------------------------------------------------- /** {@inheritDoc} */ - public String getScmSpecificFilename() - { + public String getScmSpecificFilename() { return ".git"; } /** {@inheritDoc} */ - public ScmProviderRepository makeProviderScmRepository( String scmSpecificUrl, char delimiter ) - throws ScmRepositoryException - { - try - { - ScmUrlParserResult result = parseScmUrl( scmSpecificUrl, delimiter ); - - if ( result.messages.size() > 0 ) - { - throw new ScmRepositoryException( "The scm url " + scmSpecificUrl + " is invalid.", result.messages ); + public ScmProviderRepository makeProviderScmRepository(String scmSpecificUrl, char delimiter) + throws ScmRepositoryException { + try { + ScmUrlParserResult result = parseScmUrl(scmSpecificUrl, delimiter); + + if (result.messages.size() > 0) { + throw new ScmRepositoryException("The scm url " + scmSpecificUrl + " is invalid.", result.messages); } return result.repository; - } - catch ( ScmException e ) - { + } catch (ScmException e) { // XXX We should allow throwing of SCMException. - throw new ScmRepositoryException( "Error creating the scm repository", e ); + throw new ScmRepositoryException("Error creating the scm repository", e); } } /** {@inheritDoc} */ - public ScmProviderRepository makeProviderScmRepository( File path ) - throws ScmRepositoryException, UnknownRepositoryStructure - { - if ( path == null ) - { - throw new NullPointerException( "Path argument is null" ); + public ScmProviderRepository makeProviderScmRepository(File path) + throws ScmRepositoryException, UnknownRepositoryStructure { + if (path == null) { + throw new NullPointerException("Path argument is null"); } - if ( !path.isDirectory() ) - { - throw new ScmRepositoryException( path.getAbsolutePath() + " isn't a valid directory." ); + if (!path.isDirectory()) { + throw new ScmRepositoryException(path.getAbsolutePath() + " isn't a valid directory."); } - if ( !new File( path, ".git" ).exists() ) - { - throw new ScmRepositoryException( path.getAbsolutePath() + " isn't a git checkout directory." ); + if (!new File(path, ".git").exists()) { + throw new ScmRepositoryException(path.getAbsolutePath() + " isn't a git checkout directory."); } - try - { - return makeProviderScmRepository( getRepositoryURL( path ), ':' ); - } - catch ( ScmException e ) - { + try { + return makeProviderScmRepository(getRepositoryURL(path), ':'); + } catch (ScmException e) { // XXX We should allow throwing of SCMException. - throw new ScmRepositoryException( "Error creating the scm repository", e ); + throw new ScmRepositoryException("Error creating the scm repository", e); } } - protected abstract String getRepositoryURL( File path ) - throws ScmException; + protected abstract String getRepositoryURL(File path) throws ScmException; /** {@inheritDoc} */ - public List validateScmUrl( String scmSpecificUrl, char delimiter ) - { + public List validateScmUrl(String scmSpecificUrl, char delimiter) { List messages = new ArrayList<>(); - try - { - makeProviderScmRepository( scmSpecificUrl, delimiter ); - } - catch ( ScmRepositoryException e ) - { + try { + makeProviderScmRepository(scmSpecificUrl, delimiter); + } catch (ScmRepositoryException e) { messages = e.getValidationMessages(); } return messages; } /** {@inheritDoc} */ - public String getScmType() - { + public String getScmType() { return "git"; } @@ -169,12 +146,10 @@ public String getScmType() * The git-submodule(1) command is available since Git 1.5.3, so modules will * be activated in a later stage */ - private ScmUrlParserResult parseScmUrl( String scmSpecificUrl, char delimiter ) - throws ScmException - { + private ScmUrlParserResult parseScmUrl(String scmSpecificUrl, char delimiter) throws ScmException { ScmUrlParserResult result = new ScmUrlParserResult(); - result.repository = new GitScmProviderRepository( scmSpecificUrl ); + result.repository = new GitScmProviderRepository(scmSpecificUrl); return result; } @@ -182,155 +157,132 @@ private ScmUrlParserResult parseScmUrl( String scmSpecificUrl, char delimiter ) protected abstract GitCommand getAddCommand(); /** {@inheritDoc} */ - public AddScmResult add( ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters ) - throws ScmException - { - return (AddScmResult) executeCommand( getAddCommand(), repository, fileSet, parameters ); + public AddScmResult add(ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters) + throws ScmException { + return (AddScmResult) executeCommand(getAddCommand(), repository, fileSet, parameters); } protected abstract GitCommand getBranchCommand(); /** {@inheritDoc} */ - protected BranchScmResult branch( ScmProviderRepository repository, ScmFileSet fileSet, - CommandParameters parameters ) - throws ScmException - { - return (BranchScmResult) executeCommand( getBranchCommand(), repository, fileSet, parameters ); + protected BranchScmResult branch(ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters) + throws ScmException { + return (BranchScmResult) executeCommand(getBranchCommand(), repository, fileSet, parameters); } protected abstract GitCommand getChangeLogCommand(); /** {@inheritDoc} */ - public ChangeLogScmResult changelog( ScmProviderRepository repository, ScmFileSet fileSet, - CommandParameters parameters ) - throws ScmException - { - return (ChangeLogScmResult) executeCommand( getChangeLogCommand(), repository, fileSet, parameters ); + public ChangeLogScmResult changelog( + ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters) throws ScmException { + return (ChangeLogScmResult) executeCommand(getChangeLogCommand(), repository, fileSet, parameters); } protected abstract GitCommand getCheckInCommand(); /** {@inheritDoc} */ - public CheckInScmResult checkin( ScmProviderRepository repository, ScmFileSet fileSet, - CommandParameters parameters ) - throws ScmException - { - return (CheckInScmResult) executeCommand( getCheckInCommand(), repository, fileSet, parameters ); + public CheckInScmResult checkin(ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters) + throws ScmException { + return (CheckInScmResult) executeCommand(getCheckInCommand(), repository, fileSet, parameters); } protected abstract GitCommand getCheckOutCommand(); /** {@inheritDoc} */ - public CheckOutScmResult checkout( ScmProviderRepository repository, ScmFileSet fileSet, - CommandParameters parameters ) - throws ScmException - { - return (CheckOutScmResult) executeCommand( getCheckOutCommand(), repository, fileSet, parameters ); + public CheckOutScmResult checkout( + ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters) throws ScmException { + return (CheckOutScmResult) executeCommand(getCheckOutCommand(), repository, fileSet, parameters); } protected abstract GitCommand getDiffCommand(); /** {@inheritDoc} */ - public DiffScmResult diff( ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters ) - throws ScmException - { - return (DiffScmResult) executeCommand( getDiffCommand(), repository, fileSet, parameters ); + public DiffScmResult diff(ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters) + throws ScmException { + return (DiffScmResult) executeCommand(getDiffCommand(), repository, fileSet, parameters); } protected abstract GitCommand getExportCommand(); /** {@inheritDoc} */ - protected ExportScmResult export( ScmProviderRepository repository, ScmFileSet fileSet, - CommandParameters parameters ) - throws ScmException - { - return (ExportScmResult) executeCommand( getExportCommand(), repository, fileSet, parameters ); + protected ExportScmResult export(ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters) + throws ScmException { + return (ExportScmResult) executeCommand(getExportCommand(), repository, fileSet, parameters); } protected abstract GitCommand getRemoveCommand(); /** {@inheritDoc} */ - public RemoveScmResult remove( ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters ) - throws ScmException - { - return (RemoveScmResult) executeCommand( getRemoveCommand(), repository, fileSet, parameters ); + public RemoveScmResult remove(ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters) + throws ScmException { + return (RemoveScmResult) executeCommand(getRemoveCommand(), repository, fileSet, parameters); } protected abstract GitCommand getStatusCommand(); /** {@inheritDoc} */ - public StatusScmResult status( ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters ) - throws ScmException - { - return (StatusScmResult) executeCommand( getStatusCommand(), repository, fileSet, parameters ); + public StatusScmResult status(ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters) + throws ScmException { + return (StatusScmResult) executeCommand(getStatusCommand(), repository, fileSet, parameters); } protected abstract GitCommand getTagCommand(); /** {@inheritDoc} */ - public TagScmResult tag( ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters ) - throws ScmException - { - return (TagScmResult) executeCommand( getTagCommand(), repository, fileSet, parameters ); + public TagScmResult tag(ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters) + throws ScmException { + return (TagScmResult) executeCommand(getTagCommand(), repository, fileSet, parameters); } protected abstract GitCommand getUntagCommand(); /** {@inheritDoc} */ - public UntagScmResult untag( ScmRepository repository, ScmFileSet fileSet, CommandParameters parameters ) - throws ScmException - { - return (UntagScmResult) executeCommand( getUntagCommand(), - repository.getProviderRepository(), fileSet, parameters ); + public UntagScmResult untag(ScmRepository repository, ScmFileSet fileSet, CommandParameters parameters) + throws ScmException { + return (UntagScmResult) + executeCommand(getUntagCommand(), repository.getProviderRepository(), fileSet, parameters); } protected abstract GitCommand getUpdateCommand(); /** {@inheritDoc} */ - public UpdateScmResult update( ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters ) - throws ScmException - { - return (UpdateScmResult) executeCommand( getUpdateCommand(), repository, fileSet, parameters ); + public UpdateScmResult update(ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters) + throws ScmException { + return (UpdateScmResult) executeCommand(getUpdateCommand(), repository, fileSet, parameters); } - protected ScmResult executeCommand( GitCommand command, ScmProviderRepository repository, ScmFileSet fileSet, - CommandParameters parameters ) - throws ScmException - { - return command.execute( repository, fileSet, parameters ); + protected ScmResult executeCommand( + GitCommand command, ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters) + throws ScmException { + return command.execute(repository, fileSet, parameters); } protected abstract GitCommand getInfoCommand(); - public InfoScmResult info( ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters ) - throws ScmException - { + public InfoScmResult info(ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters) + throws ScmException { GitCommand cmd = getInfoCommand(); - return (InfoScmResult) executeCommand( cmd, repository, fileSet, parameters ); + return (InfoScmResult) executeCommand(cmd, repository, fileSet, parameters); } /** {@inheritDoc} */ - protected BlameScmResult blame( ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters ) - throws ScmException - { + protected BlameScmResult blame(ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters) + throws ScmException { GitCommand cmd = getBlameCommand(); - return (BlameScmResult) executeCommand( cmd, repository, fileSet, parameters ); + return (BlameScmResult) executeCommand(cmd, repository, fileSet, parameters); } protected abstract GitCommand getBlameCommand(); /** {@inheritDoc} */ - public RemoteInfoScmResult remoteInfo( ScmProviderRepository repository, ScmFileSet fileSet, - CommandParameters parameters ) - throws ScmException - { + public RemoteInfoScmResult remoteInfo( + ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters) throws ScmException { GitCommand cmd = getRemoteInfoCommand(); - return (RemoteInfoScmResult) executeCommand( cmd, repository, fileSet, parameters ); + return (RemoteInfoScmResult) executeCommand(cmd, repository, fileSet, parameters); } protected abstract GitCommand getRemoteInfoCommand(); - } diff --git a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-git-commons/src/main/java/org/apache/maven/scm/provider/git/GitCommandUtils.java b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-git-commons/src/main/java/org/apache/maven/scm/provider/git/GitCommandUtils.java index 8c0db8987..df08f0fea 100644 --- a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-git-commons/src/main/java/org/apache/maven/scm/provider/git/GitCommandUtils.java +++ b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-git-commons/src/main/java/org/apache/maven/scm/provider/git/GitCommandUtils.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.git; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider.git; import org.apache.maven.scm.ScmFileSet; import org.apache.maven.scm.provider.git.repository.GitScmProviderRepository; @@ -31,42 +30,35 @@ * @author Jerome Lacoste * */ -public class GitCommandUtils -{ +public class GitCommandUtils { - private GitCommandUtils() - { - } + private GitCommandUtils() {} - public static Commandline getBaseCommand( String commandName, GitScmProviderRepository repo, ScmFileSet fileSet ) - { - return getBaseCommand( commandName, repo, fileSet, null ); + public static Commandline getBaseCommand(String commandName, GitScmProviderRepository repo, ScmFileSet fileSet) { + return getBaseCommand(commandName, repo, fileSet, null); } - public static Commandline getBaseCommand( String commandName, GitScmProviderRepository repo, ScmFileSet fileSet, - String options ) - { + public static Commandline getBaseCommand( + String commandName, GitScmProviderRepository repo, ScmFileSet fileSet, String options) { Settings settings = GitUtil.getSettings(); Commandline cl = new Commandline(); - cl.setExecutable( settings.getGitCommand() ); + cl.setExecutable(settings.getGitCommand()); - cl.setWorkingDirectory( fileSet.getBasedir().getAbsolutePath() ); + cl.setWorkingDirectory(fileSet.getBasedir().getAbsolutePath()); - if ( settings.getTraceGitCommand() != null ) - { - cl.addEnvironment( "GIT_TRACE", settings.getTraceGitCommand() ); + if (settings.getTraceGitCommand() != null) { + cl.addEnvironment("GIT_TRACE", settings.getTraceGitCommand()); } - cl.createArg().setLine( options ); - cl.createArg().setValue( commandName ); + cl.createArg().setLine(options); + cl.createArg().setValue(commandName); return cl; } - - public static String getRevParseDateFormat() - { + + public static String getRevParseDateFormat() { return GitUtil.getSettings().getRevParseDateFormat(); - } + } } diff --git a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-git-commons/src/main/java/org/apache/maven/scm/provider/git/GitConfigFileReader.java b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-git-commons/src/main/java/org/apache/maven/scm/provider/git/GitConfigFileReader.java index 466c120de..b046e616d 100644 --- a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-git-commons/src/main/java/org/apache/maven/scm/provider/git/GitConfigFileReader.java +++ b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-git-commons/src/main/java/org/apache/maven/scm/provider/git/GitConfigFileReader.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.git; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,8 +16,7 @@ * specific language governing permissions and limitations * under the License. */ - -import org.codehaus.plexus.util.StringUtils; +package org.apache.maven.scm.provider.git; import java.io.BufferedReader; import java.io.File; @@ -29,86 +26,69 @@ import java.util.Iterator; import java.util.List; +import org.codehaus.plexus.util.StringUtils; + /** * @author Emmanuel Venisse * */ -public class GitConfigFileReader -{ +public class GitConfigFileReader { private File configDirectory; - public File getConfigDirectory() - { - if ( configDirectory == null ) - { - - File confDir = new File( ".git" ); - - if ( confDir.exists() ) - { + public File getConfigDirectory() { + if (configDirectory == null) { + + File confDir = new File(".git"); + + if (confDir.exists()) { configDirectory = confDir; - } - else - { - confDir = new File( "." ); - - if ( confDir.exists() ) - { + } else { + confDir = new File("."); + + if (confDir.exists()) { configDirectory = confDir; } } - } return configDirectory; } - public void setConfigDirectory( File configDirectory ) - { + public void setConfigDirectory(File configDirectory) { this.configDirectory = configDirectory; } - public String getProperty( String group, String propertyName ) - { + public String getProperty(String group, String propertyName) { List lines = getConfLines(); boolean inGroup = false; - for ( Iterator i = lines.iterator(); i.hasNext(); ) - { + for (Iterator i = lines.iterator(); i.hasNext(); ) { String line = i.next().trim(); - if ( !inGroup ) - { - if ( ( "[" + group + "]" ).equals( line ) ) - { + if (!inGroup) { + if (("[" + group + "]").equals(line)) { inGroup = true; } - } - else - { - if ( line.startsWith( "[" ) && line.endsWith( "]" ) ) - { - //a new group start + } else { + if (line.startsWith("[") && line.endsWith("]")) { + // a new group start return null; } - if ( line.startsWith( "#" ) ) - { + if (line.startsWith("#")) { continue; } - if ( line.indexOf( '=' ) < 0 ) - { + if (line.indexOf('=') < 0) { continue; } - String property = line.substring( 0, line.indexOf( '=' ) ).trim(); + String property = line.substring(0, line.indexOf('=')).trim(); - if ( !property.equals( propertyName ) ) - { + if (!property.equals(propertyName)) { continue; } - String value = line.substring( line.indexOf( '=' ) + 1 ); + String value = line.substring(line.indexOf('=') + 1); return value.trim(); } } @@ -121,30 +101,22 @@ public String getProperty( String group, String propertyName ) * * @return the list of all lines */ - private List getConfLines() - { + private List getConfLines() { List lines = new ArrayList<>(); - try - { - if ( getConfigDirectory().exists() ) - { - try ( BufferedReader reader = new BufferedReader( new FileReader( - new File( getConfigDirectory(), "config" ) ) ) ) - { + try { + if (getConfigDirectory().exists()) { + try (BufferedReader reader = + new BufferedReader(new FileReader(new File(getConfigDirectory(), "config")))) { String line; - while ( ( line = reader.readLine() ) != null ) - { - if ( !line.startsWith( "#" ) && StringUtils.isNotEmpty( line ) ) - { - lines.add( line ); + while ((line = reader.readLine()) != null) { + if (!line.startsWith("#") && StringUtils.isNotEmpty(line)) { + lines.add(line); } } } } - } - catch ( IOException e ) - { + } catch (IOException e) { lines.clear(); } diff --git a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-git-commons/src/main/java/org/apache/maven/scm/provider/git/command/GitCommand.java b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-git-commons/src/main/java/org/apache/maven/scm/provider/git/command/GitCommand.java index d1f3d8afc..50dd61158 100644 --- a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-git-commons/src/main/java/org/apache/maven/scm/provider/git/command/GitCommand.java +++ b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-git-commons/src/main/java/org/apache/maven/scm/provider/git/command/GitCommand.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.git.command; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider.git.command; import org.apache.maven.scm.command.Command; @@ -25,7 +24,4 @@ * @author Trygve Laugstøl * */ -public interface GitCommand - extends Command -{ -} +public interface GitCommand extends Command {} diff --git a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-git-commons/src/main/java/org/apache/maven/scm/provider/git/command/diff/GitDiffConsumer.java b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-git-commons/src/main/java/org/apache/maven/scm/provider/git/command/diff/GitDiffConsumer.java index b39410cb0..adb920fa8 100644 --- a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-git-commons/src/main/java/org/apache/maven/scm/provider/git/command/diff/GitDiffConsumer.java +++ b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-git-commons/src/main/java/org/apache/maven/scm/provider/git/command/diff/GitDiffConsumer.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.git.command.diff; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,10 +16,7 @@ * specific language governing permissions and limitations * under the License. */ - -import org.apache.maven.scm.ScmFile; -import org.apache.maven.scm.ScmFileStatus; -import org.apache.maven.scm.util.AbstractConsumer; +package org.apache.maven.scm.provider.git.command.diff; import java.io.File; import java.util.ArrayList; @@ -31,15 +26,17 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; +import org.apache.maven.scm.ScmFile; +import org.apache.maven.scm.ScmFileStatus; +import org.apache.maven.scm.util.AbstractConsumer; + /** * @author Brett Porter * @author Mark Struberg * @author Olivier Lamy * */ -public class GitDiffConsumer - extends AbstractConsumer -{ +public class GitDiffConsumer extends AbstractConsumer { // diff --git a/readme.txt b/readme.txt // index fea1611..9e131cf 100644 // --- a/readme.txt @@ -49,13 +46,12 @@ public class GitDiffConsumer // \ No newline at end of file // +new version of /readme.txt - /** * patern matches the index line of the diff comparison * paren.1 matches the first file * paren.2 matches the 2nd file */ - private static final Pattern DIFF_FILES_PATTERN = Pattern.compile( "^diff --git\\sa/(.*)\\sb/(.*)" ); + private static final Pattern DIFF_FILES_PATTERN = Pattern.compile("^diff --git\\sa/(.*)\\sb/(.*)"); private static final String START_REVISION_TOKEN = "---"; @@ -97,8 +93,7 @@ public class GitDiffConsumer // // ---------------------------------------------------------------------- - public GitDiffConsumer( File workingDirectory ) - { + public GitDiffConsumer(File workingDirectory) { // empty } @@ -107,100 +102,77 @@ public GitDiffConsumer( File workingDirectory ) // ---------------------------------------------------------------------- /** {@inheritDoc} */ - public void consumeLine( String line ) - { - Matcher matcher = DIFF_FILES_PATTERN.matcher( line ); - if ( matcher.matches() ) - { + public void consumeLine(String line) { + Matcher matcher = DIFF_FILES_PATTERN.matcher(line); + if (matcher.matches()) { // start a new file - currentFile = matcher.group( 1 ); + currentFile = matcher.group(1); - changedFiles.add( new ScmFile( currentFile, ScmFileStatus.MODIFIED ) ); + changedFiles.add(new ScmFile(currentFile, ScmFileStatus.MODIFIED)); currentDifference = new StringBuilder(); - differences.put( currentFile, currentDifference ); + differences.put(currentFile, currentDifference); - patch.append( line ).append( "\n" ); + patch.append(line).append("\n"); return; } - if ( currentFile == null ) - { - if ( logger.isWarnEnabled() ) - { - logger.warn( "Unparseable line: '" + line + "'" ); + if (currentFile == null) { + if (logger.isWarnEnabled()) { + logger.warn("Unparseable line: '" + line + "'"); } - patch.append( line ).append( "\n" ); + patch.append(line).append("\n"); return; - } - else if ( line.startsWith( INDEX_LINE_TOKEN ) ) - { + } else if (line.startsWith(INDEX_LINE_TOKEN)) { // skip, though could parse to verify start revision and end revision - patch.append( line ).append( "\n" ); - } - else if ( line.startsWith( NEW_FILE_MODE_TOKEN ) || line.startsWith( DELETED_FILE_MODE_TOKEN ) ) - { + patch.append(line).append("\n"); + } else if (line.startsWith(NEW_FILE_MODE_TOKEN) || line.startsWith(DELETED_FILE_MODE_TOKEN)) { // skip, though could parse to verify file mode - patch.append( line ).append( "\n" ); - } - else if ( line.startsWith( START_REVISION_TOKEN ) ) - { + patch.append(line).append("\n"); + } else if (line.startsWith(START_REVISION_TOKEN)) { // skip, though could parse to verify filename, start revision - patch.append( line ).append( "\n" ); - } - else if ( line.startsWith( END_REVISION_TOKEN ) ) - { + patch.append(line).append("\n"); + } else if (line.startsWith(END_REVISION_TOKEN)) { // skip, though could parse to verify filename, end revision - patch.append( line ).append( "\n" ); - } - else if ( line.startsWith( SIMILARITY_INDEX_LINE_TOKEN ) ) - { + patch.append(line).append("\n"); + } else if (line.startsWith(SIMILARITY_INDEX_LINE_TOKEN)) { // skip - patch.append( line ).append( "\n" ); - } - else if ( line.startsWith( RENAME_FROM_LINE_TOKEN ) || line.startsWith( RENAME_TO_LINE_TOKEN ) ) - { + patch.append(line).append("\n"); + } else if (line.startsWith(RENAME_FROM_LINE_TOKEN) || line.startsWith(RENAME_TO_LINE_TOKEN)) { // skip, though could parse to verify filename - patch.append( line ).append( "\n" ); - } - else if ( line.startsWith( ADDED_LINE_TOKEN ) || line.startsWith( REMOVED_LINE_TOKEN ) - || line.startsWith( UNCHANGED_LINE_TOKEN ) || line.startsWith( CHANGE_SEPARATOR_TOKEN ) - || line.equals( NO_NEWLINE_TOKEN ) ) - { + patch.append(line).append("\n"); + } else if (line.startsWith(ADDED_LINE_TOKEN) + || line.startsWith(REMOVED_LINE_TOKEN) + || line.startsWith(UNCHANGED_LINE_TOKEN) + || line.startsWith(CHANGE_SEPARATOR_TOKEN) + || line.equals(NO_NEWLINE_TOKEN)) { // add to buffer - currentDifference.append( line ).append( "\n" ); - patch.append( line ).append( "\n" ); - } - else - { + currentDifference.append(line).append("\n"); + patch.append(line).append("\n"); + } else { // TODO: handle property differences - if ( logger.isWarnEnabled() ) - { - logger.warn( "Unparseable line: '" + line + "'" ); + if (logger.isWarnEnabled()) { + logger.warn("Unparseable line: '" + line + "'"); } - patch.append( line ).append( "\n" ); + patch.append(line).append("\n"); // skip to next file currentFile = null; currentDifference = null; } } - public List getChangedFiles() - { + public List getChangedFiles() { return changedFiles; } - public Map getDifferences() - { + public Map getDifferences() { return differences; } - public String getPatch() - { + public String getPatch() { return patch.toString(); } - } diff --git a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-git-commons/src/main/java/org/apache/maven/scm/provider/git/command/info/GitInfoItem.java b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-git-commons/src/main/java/org/apache/maven/scm/provider/git/command/info/GitInfoItem.java index 438436b6f..69d4323ff 100644 --- a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-git-commons/src/main/java/org/apache/maven/scm/provider/git/command/info/GitInfoItem.java +++ b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-git-commons/src/main/java/org/apache/maven/scm/provider/git/command/info/GitInfoItem.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.git.command.info; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider.git.command.info; import org.apache.maven.scm.command.info.InfoItem; @@ -25,8 +24,6 @@ * @author Kenney Westerhof * */ -public class GitInfoItem - extends InfoItem -{ +public class GitInfoItem extends InfoItem { // no op } diff --git a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-git-commons/src/main/java/org/apache/maven/scm/provider/git/command/info/GitInfoScmResult.java b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-git-commons/src/main/java/org/apache/maven/scm/provider/git/command/info/GitInfoScmResult.java index 2c7ea9f8b..f159344ac 100644 --- a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-git-commons/src/main/java/org/apache/maven/scm/provider/git/command/info/GitInfoScmResult.java +++ b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-git-commons/src/main/java/org/apache/maven/scm/provider/git/command/info/GitInfoScmResult.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.git.command.info; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider.git.command.info; import java.util.List; @@ -28,36 +27,27 @@ * @author Kenney Westerhof * */ -public class GitInfoScmResult - extends InfoScmResult -{ +public class GitInfoScmResult extends InfoScmResult { private static final long serialVersionUID = -1314905338508176675L; - - public GitInfoScmResult( String commandLine, String providerMessage, String commandOutput, boolean success ) - { - super( commandLine, providerMessage, commandOutput, success ); + public GitInfoScmResult(String commandLine, String providerMessage, String commandOutput, boolean success) { + super(commandLine, providerMessage, commandOutput, success); } - public GitInfoScmResult( String commandLine, List files ) - { - super( commandLine, null, null, true ); + public GitInfoScmResult(String commandLine, List files) { + super(commandLine, null, null, true); - if ( files != null ) - { - getInfoItems().addAll( files ); + if (files != null) { + getInfoItems().addAll(files); } } - public GitInfoScmResult( List files, ScmResult result ) - { - super( result ); + public GitInfoScmResult(List files, ScmResult result) { + super(result); - if ( files != null ) - { - getInfoItems().addAll( files ); + if (files != null) { + getInfoItems().addAll(files); } } - } diff --git a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-git-commons/src/main/java/org/apache/maven/scm/provider/git/command/update/GitUpdateScmResult.java b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-git-commons/src/main/java/org/apache/maven/scm/provider/git/command/update/GitUpdateScmResult.java index 7a30ed3a0..933362f3b 100644 --- a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-git-commons/src/main/java/org/apache/maven/scm/provider/git/command/update/GitUpdateScmResult.java +++ b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-git-commons/src/main/java/org/apache/maven/scm/provider/git/command/update/GitUpdateScmResult.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.git.command.update; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider.git.command.update; import java.util.List; @@ -29,13 +28,10 @@ * * @deprecated */ -public class GitUpdateScmResult - extends UpdateScmResultWithRevision -{ +public class GitUpdateScmResult extends UpdateScmResultWithRevision { private static final long serialVersionUID = 7360578324181996847L; - public GitUpdateScmResult( String commandLine, List updatedFiles, int revision ) - { - super( commandLine, updatedFiles, String.valueOf( revision ) ); + public GitUpdateScmResult(String commandLine, List updatedFiles, int revision) { + super(commandLine, updatedFiles, String.valueOf(revision)); } } diff --git a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-git-commons/src/main/java/org/apache/maven/scm/provider/git/repository/GitScmProviderRepository.java b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-git-commons/src/main/java/org/apache/maven/scm/provider/git/repository/GitScmProviderRepository.java index 1a242043b..24dacb3e5 100644 --- a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-git-commons/src/main/java/org/apache/maven/scm/provider/git/repository/GitScmProviderRepository.java +++ b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-git-commons/src/main/java/org/apache/maven/scm/provider/git/repository/GitScmProviderRepository.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.git.repository; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,24 +16,23 @@ * specific language governing permissions and limitations * under the License. */ - -import org.apache.maven.scm.ScmException; -import org.apache.maven.scm.provider.ScmProviderRepository; -import org.apache.maven.scm.provider.ScmProviderRepositoryWithHost; +package org.apache.maven.scm.provider.git.repository; import java.net.URI; import java.net.URISyntaxException; import java.util.regex.Matcher; import java.util.regex.Pattern; +import org.apache.maven.scm.ScmException; +import org.apache.maven.scm.provider.ScmProviderRepository; +import org.apache.maven.scm.provider.ScmProviderRepositoryWithHost; + /** * @author Emmanuel Venisse * @author Mark Struberg * */ -public class GitScmProviderRepository - extends ScmProviderRepositoryWithHost -{ +public class GitScmProviderRepository extends ScmProviderRepositoryWithHost { /** * sequence used to delimit the fetch URL @@ -84,7 +81,7 @@ public class GitScmProviderRepository public static final String PROTOCOL_RSYNC = "rsync"; private static final Pattern HOST_AND_PORT_EXTRACTOR = - Pattern.compile( "([^:/\\\\~]*)(?::(\\d*))?(?:([:/\\\\~])(.*))?" ); + Pattern.compile("([^:/\\\\~]*)(?::(\\d*))?(?:([:/\\\\~])(.*))?"); /** * No special protocol specified. Git will either use git:// @@ -107,116 +104,94 @@ public class GitScmProviderRepository */ private RepositoryUrl pushInfo; - public GitScmProviderRepository( String url ) - throws ScmException - { - if ( url == null ) - { - throw new ScmException( "url must not be null" ); + public GitScmProviderRepository(String url) throws ScmException { + if (url == null) { + throw new ScmException("url must not be null"); } - if ( url.startsWith( URL_DELIMITER_FETCH ) ) - { - String fetch = url.substring( URL_DELIMITER_FETCH.length() ); + if (url.startsWith(URL_DELIMITER_FETCH)) { + String fetch = url.substring(URL_DELIMITER_FETCH.length()); - int indexPushDelimiter = fetch.indexOf( URL_DELIMITER_PUSH ); - if ( indexPushDelimiter >= 0 ) - { - String push = fetch.substring( indexPushDelimiter + URL_DELIMITER_PUSH.length() ); - pushInfo = parseUrl( push ); + int indexPushDelimiter = fetch.indexOf(URL_DELIMITER_PUSH); + if (indexPushDelimiter >= 0) { + String push = fetch.substring(indexPushDelimiter + URL_DELIMITER_PUSH.length()); + pushInfo = parseUrl(push); - fetch = fetch.substring( 0, indexPushDelimiter ); + fetch = fetch.substring(0, indexPushDelimiter); } - fetchInfo = parseUrl( fetch ); + fetchInfo = parseUrl(fetch); - if ( pushInfo == null ) - { + if (pushInfo == null) { pushInfo = fetchInfo; } - } - else if ( url.startsWith( URL_DELIMITER_PUSH ) ) - { - String push = url.substring( URL_DELIMITER_PUSH.length() ); + } else if (url.startsWith(URL_DELIMITER_PUSH)) { + String push = url.substring(URL_DELIMITER_PUSH.length()); - int indexFetchDelimiter = push.indexOf( URL_DELIMITER_FETCH ); - if ( indexFetchDelimiter >= 0 ) - { - String fetch = push.substring( indexFetchDelimiter + URL_DELIMITER_FETCH.length() ); - fetchInfo = parseUrl( fetch ); + int indexFetchDelimiter = push.indexOf(URL_DELIMITER_FETCH); + if (indexFetchDelimiter >= 0) { + String fetch = push.substring(indexFetchDelimiter + URL_DELIMITER_FETCH.length()); + fetchInfo = parseUrl(fetch); - push = push.substring( 0, indexFetchDelimiter ); + push = push.substring(0, indexFetchDelimiter); } - pushInfo = parseUrl( push ); + pushInfo = parseUrl(push); - if ( fetchInfo == null ) - { + if (fetchInfo == null) { fetchInfo = pushInfo; } - } - else - { - fetchInfo = pushInfo = parseUrl( url ); + } else { + fetchInfo = pushInfo = parseUrl(url); } // set the default values for backward compatibility from the push url // because it's more likely that the push URL contains 'better' credentials - setUser( pushInfo.getUserName() ); - setPassword( pushInfo.getPassword() ); - setHost( pushInfo.getHost() ); - if ( pushInfo.getPort() != null && pushInfo.getPort().length() > 0 ) - { - setPort( Integer.parseInt( pushInfo.getPort() ) ); + setUser(pushInfo.getUserName()); + setPassword(pushInfo.getPassword()); + setHost(pushInfo.getHost()); + if (pushInfo.getPort() != null && pushInfo.getPort().length() > 0) { + setPort(Integer.parseInt(pushInfo.getPort())); } } - public GitScmProviderRepository( String url, String user, String password ) - throws ScmException - { - this( url ); + public GitScmProviderRepository(String url, String user, String password) throws ScmException { + this(url); - setUser( user ); + setUser(user); - setPassword( password ); + setPassword(password); } /** * @return either 'git' or 'jgit' depending on the underlying implementation being used */ - public String getProvider() - { + public String getProvider() { return provider; } - public RepositoryUrl getFetchInfo() - { + public RepositoryUrl getFetchInfo() { return fetchInfo; } - public RepositoryUrl getPushInfo() - { + public RepositoryUrl getPushInfo() { return pushInfo; } - /** * @return the URL used to fetch from the upstream repository */ - public String getFetchUrl() - { - return getUrl( fetchInfo ); + public String getFetchUrl() { + return getUrl(fetchInfo); } /** * @return the URL used to push to the upstream repository */ - public String getPushUrl() - { - return getUrl( pushInfo ); + public String getPushUrl() { + return getUrl(pushInfo); } - /** * Parse the given url string and store all the extracted * information in a {@code RepositoryUrl} @@ -225,90 +200,78 @@ public String getPushUrl() * @return filled with the information from the given URL * @throws ScmException */ - private RepositoryUrl parseUrl( String url ) - throws ScmException - { + private RepositoryUrl parseUrl(String url) throws ScmException { RepositoryUrl repoUrl = new RepositoryUrl(); - url = parseProtocol( repoUrl, url ); - url = parseUserInfo( repoUrl, url ); - url = parseHostAndPort( repoUrl, url ); + url = parseProtocol(repoUrl, url); + url = parseUserInfo(repoUrl, url); + url = parseHostAndPort(repoUrl, url); // the rest of the url must be the path to the repository on the server - repoUrl.setPath( url ); + repoUrl.setPath(url); return repoUrl; } - /** * @param repoUrl * @return TODO */ - private String getUrl( RepositoryUrl repoUrl ) - { - StringBuilder urlSb = new StringBuilder( repoUrl.getProtocol() ); + private String getUrl(RepositoryUrl repoUrl) { + StringBuilder urlSb = new StringBuilder(repoUrl.getProtocol()); boolean urlSupportsUserInformation = false; - if ( PROTOCOL_SSH.equals( repoUrl.getProtocol() ) || PROTOCOL_RSYNC.equals( repoUrl.getProtocol() ) - || PROTOCOL_GIT.equals( repoUrl.getProtocol() ) || PROTOCOL_HTTP.equals( repoUrl.getProtocol() ) - || PROTOCOL_HTTPS.equals( repoUrl.getProtocol() ) || PROTOCOL_NONE.equals( repoUrl.getProtocol() ) ) - { + if (PROTOCOL_SSH.equals(repoUrl.getProtocol()) + || PROTOCOL_RSYNC.equals(repoUrl.getProtocol()) + || PROTOCOL_GIT.equals(repoUrl.getProtocol()) + || PROTOCOL_HTTP.equals(repoUrl.getProtocol()) + || PROTOCOL_HTTPS.equals(repoUrl.getProtocol()) + || PROTOCOL_NONE.equals(repoUrl.getProtocol())) { urlSupportsUserInformation = true; } - if ( repoUrl.getProtocol() != null && repoUrl.getProtocol().length() > 0 ) - { - urlSb.append( "://" ); + if (repoUrl.getProtocol() != null && repoUrl.getProtocol().length() > 0) { + urlSb.append("://"); } // add user information if given and allowed for the protocol - if ( urlSupportsUserInformation ) - { + if (urlSupportsUserInformation) { String userName = repoUrl.getUserName(); // if specified on the commandline or other configuration, we take this. - if ( getUser() != null && getUser().length() > 0 ) - { + if (getUser() != null && getUser().length() > 0) { userName = getUser(); } String password = repoUrl.getPassword(); - if ( getPassword() != null && getPassword().length() > 0 ) - { + if (getPassword() != null && getPassword().length() > 0) { password = getPassword(); } - if ( userName != null && userName.length() > 0 ) - { + if (userName != null && userName.length() > 0) { String userInfo = userName; - if ( password != null && password.length() > 0 ) - { - userInfo += ":" + password; + if (password != null && password.length() > 0) { + userInfo += ":" + password; } - try - { - URI uri = new URI( null, userInfo, "localhost", -1, null, null, null ); - urlSb.append( uri.getRawUserInfo() ); - } - catch ( URISyntaxException e ) - { + try { + URI uri = new URI(null, userInfo, "localhost", -1, null, null, null); + urlSb.append(uri.getRawUserInfo()); + } catch (URISyntaxException e) { // Quite impossible... // Otherwise throw a RTE since this method is also used by toString() e.printStackTrace(); } - urlSb.append( '@' ); + urlSb.append('@'); } } // add host and port information - urlSb.append( repoUrl.getHost() ); - if ( repoUrl.getPort() != null && repoUrl.getPort().length() > 0 ) - { - urlSb.append( ':' ).append( repoUrl.getPort() ); + urlSb.append(repoUrl.getHost()); + if (repoUrl.getPort() != null && repoUrl.getPort().length() > 0) { + urlSb.append(':').append(repoUrl.getPort()); } // finaly we add the path to the repo on the host - urlSb.append( repoUrl.getPath() ); + urlSb.append(repoUrl.getPath()); return urlSb.toString(); } @@ -320,43 +283,28 @@ private String getUrl( RepositoryUrl repoUrl ) * @param url * @return the given url with the protocol parts removed */ - private String parseProtocol( RepositoryUrl repoUrl, String url ) - throws ScmException - { + private String parseProtocol(RepositoryUrl repoUrl, String url) throws ScmException { // extract the protocol - if ( url.startsWith( PROTOCOL_FILE + PROTOCOL_SEPARATOR ) ) - { - repoUrl.setProtocol( PROTOCOL_FILE ); - } - else if ( url.startsWith( PROTOCOL_HTTPS + PROTOCOL_SEPARATOR ) ) - { - repoUrl.setProtocol( PROTOCOL_HTTPS ); - } - else if ( url.startsWith( PROTOCOL_HTTP + PROTOCOL_SEPARATOR ) ) - { - repoUrl.setProtocol( PROTOCOL_HTTP ); - } - else if ( url.startsWith( PROTOCOL_SSH + PROTOCOL_SEPARATOR ) ) - { - repoUrl.setProtocol( PROTOCOL_SSH ); - } - else if ( url.startsWith( PROTOCOL_GIT + PROTOCOL_SEPARATOR ) ) - { - repoUrl.setProtocol( PROTOCOL_GIT ); - } - else if ( url.startsWith( PROTOCOL_RSYNC + PROTOCOL_SEPARATOR ) ) - { - repoUrl.setProtocol( PROTOCOL_RSYNC ); - } - else - { + if (url.startsWith(PROTOCOL_FILE + PROTOCOL_SEPARATOR)) { + repoUrl.setProtocol(PROTOCOL_FILE); + } else if (url.startsWith(PROTOCOL_HTTPS + PROTOCOL_SEPARATOR)) { + repoUrl.setProtocol(PROTOCOL_HTTPS); + } else if (url.startsWith(PROTOCOL_HTTP + PROTOCOL_SEPARATOR)) { + repoUrl.setProtocol(PROTOCOL_HTTP); + } else if (url.startsWith(PROTOCOL_SSH + PROTOCOL_SEPARATOR)) { + repoUrl.setProtocol(PROTOCOL_SSH); + } else if (url.startsWith(PROTOCOL_GIT + PROTOCOL_SEPARATOR)) { + repoUrl.setProtocol(PROTOCOL_GIT); + } else if (url.startsWith(PROTOCOL_RSYNC + PROTOCOL_SEPARATOR)) { + repoUrl.setProtocol(PROTOCOL_RSYNC); + } else { // when no protocol is specified git will pick either ssh:// or git:// // depending on whether we work locally or over the network - repoUrl.setProtocol( PROTOCOL_NONE ); + repoUrl.setProtocol(PROTOCOL_NONE); return url; } - url = url.substring( repoUrl.getProtocol().length() + 3 ); + url = url.substring(repoUrl.getProtocol().length() + 3); return url; } @@ -369,31 +317,24 @@ else if ( url.startsWith( PROTOCOL_RSYNC + PROTOCOL_SEPARATOR ) ) * @param url * @return the given url with the user parts removed */ - private String parseUserInfo( RepositoryUrl repoUrl, String url ) - throws ScmException - { - if ( PROTOCOL_FILE.equals( repoUrl.getProtocol() ) ) - { - // a file:// URL may contain userinfo according to RFC 8089, but our implementation is broken - return url; - } + private String parseUserInfo(RepositoryUrl repoUrl, String url) throws ScmException { + if (PROTOCOL_FILE.equals(repoUrl.getProtocol())) { + // a file:// URL may contain userinfo according to RFC 8089, but our implementation is broken + return url; + } // extract user information, broken see SCM-907 - int indexAt = url.lastIndexOf( '@' ); - if ( indexAt >= 0 ) - { - String userInfo = url.substring( 0, indexAt ); - int indexPwdSep = userInfo.indexOf( ':' ); - if ( indexPwdSep < 0 ) - { - repoUrl.setUserName( userInfo ); - } - else - { - repoUrl.setUserName( userInfo.substring( 0, indexPwdSep ) ); - repoUrl.setPassword( userInfo.substring( indexPwdSep + 1 ) ); + int indexAt = url.lastIndexOf('@'); + if (indexAt >= 0) { + String userInfo = url.substring(0, indexAt); + int indexPwdSep = userInfo.indexOf(':'); + if (indexPwdSep < 0) { + repoUrl.setUserName(userInfo); + } else { + repoUrl.setUserName(userInfo.substring(0, indexPwdSep)); + repoUrl.setPassword(userInfo.substring(indexPwdSep + 1)); } - url = url.substring( indexAt + 1 ); + url = url.substring(indexAt + 1); } return url; } @@ -407,68 +348,52 @@ private String parseUserInfo( RepositoryUrl repoUrl, String url ) * @return the given url with the server parts removed * @throws ScmException */ - private String parseHostAndPort( RepositoryUrl repoUrl, String url ) - throws ScmException - { + private String parseHostAndPort(RepositoryUrl repoUrl, String url) throws ScmException { - repoUrl.setPort( "" ); - repoUrl.setHost( "" ); + repoUrl.setPort(""); + repoUrl.setHost(""); - if ( PROTOCOL_FILE.equals( repoUrl.getProtocol() ) ) - { + if (PROTOCOL_FILE.equals(repoUrl.getProtocol())) { // a file:// URL doesn't need any further parsing as it cannot contain a port, etc return url; - } - else - { - - Matcher hostAndPortMatcher = HOST_AND_PORT_EXTRACTOR.matcher( url ); - if ( hostAndPortMatcher.matches() ) - { - if ( hostAndPortMatcher.groupCount() > 1 && hostAndPortMatcher.group( 1 ) != null ) - { - repoUrl.setHost( hostAndPortMatcher.group( 1 ) ); + } else { + + Matcher hostAndPortMatcher = HOST_AND_PORT_EXTRACTOR.matcher(url); + if (hostAndPortMatcher.matches()) { + if (hostAndPortMatcher.groupCount() > 1 && hostAndPortMatcher.group(1) != null) { + repoUrl.setHost(hostAndPortMatcher.group(1)); } - if ( hostAndPortMatcher.groupCount() > 2 && hostAndPortMatcher.group( 2 ) != null ) - { - repoUrl.setPort( hostAndPortMatcher.group( 2 ) ); + if (hostAndPortMatcher.groupCount() > 2 && hostAndPortMatcher.group(2) != null) { + repoUrl.setPort(hostAndPortMatcher.group(2)); } StringBuilder computedUrl = new StringBuilder(); - if ( hostAndPortMatcher.group( hostAndPortMatcher.groupCount() - 1 ) != null ) - { - computedUrl.append( hostAndPortMatcher.group( hostAndPortMatcher.groupCount() - 1 ) ); + if (hostAndPortMatcher.group(hostAndPortMatcher.groupCount() - 1) != null) { + computedUrl.append(hostAndPortMatcher.group(hostAndPortMatcher.groupCount() - 1)); } - if ( hostAndPortMatcher.group( hostAndPortMatcher.groupCount() ) != null ) - { - computedUrl.append( hostAndPortMatcher.group( hostAndPortMatcher.groupCount() ) ); + if (hostAndPortMatcher.group(hostAndPortMatcher.groupCount()) != null) { + computedUrl.append(hostAndPortMatcher.group(hostAndPortMatcher.groupCount())); } return computedUrl.toString(); - } - else - { + } else { // Pattern doesn't match, let's return the original url return url; } } } - /** * {@inheritDoc} */ - public String getRelativePath( ScmProviderRepository ancestor ) - { - if ( ancestor instanceof GitScmProviderRepository ) - { + public String getRelativePath(ScmProviderRepository ancestor) { + if (ancestor instanceof GitScmProviderRepository) { GitScmProviderRepository gitAncestor = (GitScmProviderRepository) ancestor; - //X TODO review! + // X TODO review! String url = getFetchUrl(); - String path = url.replaceFirst( gitAncestor.getFetchUrl() + "/", "" ); + String path = url.replaceFirst(gitAncestor.getFetchUrl() + "/", ""); - if ( !path.equals( url ) ) - { + if (!path.equals(url)) { return path; } } @@ -478,14 +403,11 @@ public String getRelativePath( ScmProviderRepository ancestor ) /** * {@inheritDoc} */ - public String toString() - { + public String toString() { // yes we really like to check if those are the exact same instance! - if ( fetchInfo == pushInfo ) - { - return getUrl( fetchInfo ); + if (fetchInfo == pushInfo) { + return getUrl(fetchInfo); } - return URL_DELIMITER_FETCH + getUrl( fetchInfo ) + URL_DELIMITER_PUSH + getUrl( pushInfo ); + return URL_DELIMITER_FETCH + getUrl(fetchInfo) + URL_DELIMITER_PUSH + getUrl(pushInfo); } - } diff --git a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-git-commons/src/main/java/org/apache/maven/scm/provider/git/repository/RepositoryUrl.java b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-git-commons/src/main/java/org/apache/maven/scm/provider/git/repository/RepositoryUrl.java index 56779c26f..b56d94139 100644 --- a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-git-commons/src/main/java/org/apache/maven/scm/provider/git/repository/RepositoryUrl.java +++ b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-git-commons/src/main/java/org/apache/maven/scm/provider/git/repository/RepositoryUrl.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.git.repository; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,95 +16,80 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider.git.repository; /** - * This class is a container which holds information about - * repository URL. + * This class is a container which holds information about + * repository URL. * @author Mark Struberg * * @since 1.3 */ -public class RepositoryUrl -{ +public class RepositoryUrl { /** the protocol used to access the upstream repository */ private String protocol; - + /** the server to access the upstream repository */ private String host; - + /** the port to access the upstream repository */ private String port; - + /** the path on the server to access the upstream repository */ private String path; - + /** the user name from the repository URL */ private String userName; - + /** the password from the repository URL */ private String password; - - public String getProtocol() - { + + public String getProtocol() { return protocol; } - public void setProtocol( String protocol ) - { + public void setProtocol(String protocol) { this.protocol = protocol; } - public String getHost() - { + public String getHost() { return host; } - public void setHost( String host ) - { + public void setHost(String host) { this.host = host; } - public String getPort() - { + public String getPort() { return port; } - public void setPort( String port ) - { + public void setPort(String port) { this.port = port; } - public String getPath() - { + public String getPath() { return path; } - public void setPath( String path ) - { + public void setPath(String path) { this.path = path; } - public String getUserName() - { + public String getUserName() { return userName; } - public void setUserName( String userName ) - { + public void setUserName(String userName) { this.userName = userName; } - public String getPassword() - { + public String getPassword() { return password; } - public void setPassword( String password ) - { + public void setPassword(String password) { this.password = password; } - - - } diff --git a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-git-commons/src/main/java/org/apache/maven/scm/provider/git/util/GitUtil.java b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-git-commons/src/main/java/org/apache/maven/scm/provider/git/util/GitUtil.java index 0845ad052..53cbfb48c 100644 --- a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-git-commons/src/main/java/org/apache/maven/scm/provider/git/util/GitUtil.java +++ b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-git-commons/src/main/java/org/apache/maven/scm/provider/git/util/GitUtil.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.git.util; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,77 +16,65 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider.git.util; + +import java.io.File; +import java.io.IOException; import org.apache.maven.scm.providers.gitlib.settings.Settings; import org.apache.maven.scm.providers.gitlib.settings.io.xpp3.GitXpp3Reader; import org.codehaus.plexus.util.ReaderFactory; import org.codehaus.plexus.util.xml.pull.XmlPullParserException; -import java.io.File; -import java.io.IOException; - /** * @author Emmanuel Venisse * */ -public class GitUtil -{ +public class GitUtil { protected static final String GIT_SETTINGS_FILENAME = "git-settings.xml"; - public static final File DEFAULT_SETTINGS_DIRECTORY = new File( System.getProperty( "user.home" ), ".scm" ); + public static final File DEFAULT_SETTINGS_DIRECTORY = new File(System.getProperty("user.home"), ".scm"); private static File settingsDirectory = DEFAULT_SETTINGS_DIRECTORY; private static Settings settings; - private GitUtil() - { + private GitUtil() { // no op } - public static Settings getSettings() - { - if ( settings == null ) - { + public static Settings getSettings() { + if (settings == null) { settings = readSettings(); } return settings; } - public static Settings readSettings() - { + public static Settings readSettings() { File settingsFile = getSettingsFile(); - if ( settingsFile.exists() ) - { + if (settingsFile.exists()) { GitXpp3Reader reader = new GitXpp3Reader(); - try - { - return reader.read( ReaderFactory.newXmlReader( settingsFile ) ); - } - catch ( IOException e ) - { - //Nothing to do - } - catch ( XmlPullParserException e ) - { + try { + return reader.read(ReaderFactory.newXmlReader(settingsFile)); + } catch (IOException e) { + // Nothing to do + } catch (XmlPullParserException e) { String message = settingsFile.getAbsolutePath() + " isn't well formed. SKIPPED." + e.getMessage(); - System.err.println( message ); + System.err.println(message); } } return new Settings(); } - public static void setSettingsDirectory( File directory ) - { + public static void setSettingsDirectory(File directory) { settingsDirectory = directory; settings = readSettings(); } - public static File getSettingsFile() - { - return new File( settingsDirectory, GIT_SETTINGS_FILENAME ); - } + public static File getSettingsFile() { + return new File(settingsDirectory, GIT_SETTINGS_FILENAME); + } } diff --git a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-git-commons/src/test/java/org/apache/maven/scm/provider/git/TestGitScmProvider.java b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-git-commons/src/test/java/org/apache/maven/scm/provider/git/TestGitScmProvider.java index 335b65f67..b64d0730c 100644 --- a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-git-commons/src/test/java/org/apache/maven/scm/provider/git/TestGitScmProvider.java +++ b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-git-commons/src/test/java/org/apache/maven/scm/provider/git/TestGitScmProvider.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.git; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,95 +16,79 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider.git; import javax.inject.Named; import javax.inject.Singleton; -import org.apache.maven.scm.provider.git.command.GitCommand; - import java.io.File; +import org.apache.maven.scm.provider.git.command.GitCommand; + @Singleton -@Named( "git" ) -public class TestGitScmProvider - extends AbstractGitScmProvider -{ - protected GitCommand getAddCommand() - { +@Named("git") +public class TestGitScmProvider extends AbstractGitScmProvider { + protected GitCommand getAddCommand() { return null; } - protected GitCommand getBranchCommand() - { + protected GitCommand getBranchCommand() { return null; } - protected GitCommand getChangeLogCommand() - { + protected GitCommand getChangeLogCommand() { return null; } - protected GitCommand getCheckInCommand() - { + protected GitCommand getCheckInCommand() { return null; } - protected GitCommand getCheckOutCommand() - { + protected GitCommand getCheckOutCommand() { return null; } - protected GitCommand getDiffCommand() - { + protected GitCommand getDiffCommand() { return null; } - protected GitCommand getExportCommand() - { + protected GitCommand getExportCommand() { return null; } - protected GitCommand getRemoveCommand() - { + protected GitCommand getRemoveCommand() { return null; } - protected GitCommand getStatusCommand() - { + protected GitCommand getStatusCommand() { return null; } - protected GitCommand getTagCommand() - { + protected GitCommand getTagCommand() { return null; } - protected GitCommand getUntagCommand() - { + protected GitCommand getUntagCommand() { return null; } - protected GitCommand getUpdateCommand() - { + protected GitCommand getUpdateCommand() { return null; } - protected GitCommand getInfoCommand() - { + protected GitCommand getInfoCommand() { return null; } - protected GitCommand getBlameCommand() - { + protected GitCommand getBlameCommand() { return null; } - + public GitCommand getRemoteInfoCommand() { - return null; + return null; } - protected String getRepositoryURL( File path ) - { + protected String getRepositoryURL(File path) { return null; } } diff --git a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-git-commons/src/test/java/org/apache/maven/scm/provider/git/command/diff/GitDiffConsumerTest.java b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-git-commons/src/test/java/org/apache/maven/scm/provider/git/command/diff/GitDiffConsumerTest.java index 7b4e9e3f9..224ff0822 100644 --- a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-git-commons/src/test/java/org/apache/maven/scm/provider/git/command/diff/GitDiffConsumerTest.java +++ b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-git-commons/src/test/java/org/apache/maven/scm/provider/git/command/diff/GitDiffConsumerTest.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.git.command.diff; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,11 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider.git.command.diff; + +import java.io.File; +import java.util.List; +import java.util.Map; import org.apache.maven.scm.ScmFile; import org.apache.maven.scm.ScmFileStatus; @@ -25,10 +28,6 @@ import org.apache.maven.scm.util.ConsumerUtils; import org.junit.Test; -import java.io.File; -import java.util.List; -import java.util.Map; - import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; @@ -36,130 +35,116 @@ /** * @author Mark Struberg */ -public class GitDiffConsumerTest - extends ScmTestCase -{ +public class GitDiffConsumerTest extends ScmTestCase { @Test - public void testEmptyLogConsumer() - throws Exception - { - GitDiffConsumer consumer = new GitDiffConsumer( null ); + public void testEmptyLogConsumer() throws Exception { + GitDiffConsumer consumer = new GitDiffConsumer(null); - File f = getTestFile( "/src/test/resources/git/diff/git-diff-empty.log" ); + File f = getTestFile("/src/test/resources/git/diff/git-diff-empty.log"); - ConsumerUtils.consumeFile( f, consumer ); + ConsumerUtils.consumeFile(f, consumer); List changedFiles = consumer.getChangedFiles(); - assertEquals( 0, changedFiles.size() ); + assertEquals(0, changedFiles.size()); } @Test - public void testLog1Consumer() - throws Exception - { - GitDiffConsumer consumer = new GitDiffConsumer( null ); + public void testLog1Consumer() throws Exception { + GitDiffConsumer consumer = new GitDiffConsumer(null); - File f = getTestFile( "src/test/resources/git/diff/git-diff1.log" ); + File f = getTestFile("src/test/resources/git/diff/git-diff1.log"); - ConsumerUtils.consumeFile( f, consumer ); + ConsumerUtils.consumeFile(f, consumer); List changedFiles = consumer.getChangedFiles(); - assertEquals( 1, changedFiles.size() ); + assertEquals(1, changedFiles.size()); - testScmFile( changedFiles.get( 0 ), "olamy.test", ScmFileStatus.MODIFIED ); + testScmFile(changedFiles.get(0), "olamy.test", ScmFileStatus.MODIFIED); - Map differences = consumer.getDifferences(); - assertNotNull( differences ); + Map differences = consumer.getDifferences(); + assertNotNull(differences); - StringBuilder readmeDiffs = new StringBuilder( differences.get( "olamy.test" ) ); - assertNotNull( readmeDiffs ); - assertTrue( readmeDiffs.indexOf( "+new line" ) >= 0 ); + StringBuilder readmeDiffs = new StringBuilder(differences.get("olamy.test")); + assertNotNull(readmeDiffs); + assertTrue(readmeDiffs.indexOf("+new line") >= 0); } @Test - public void testLog2Consumer() - throws Exception - { - GitDiffConsumer consumer = new GitDiffConsumer( null ); + public void testLog2Consumer() throws Exception { + GitDiffConsumer consumer = new GitDiffConsumer(null); - File f = getTestFile( "src/test/resources/git/diff/git-diff2.log" ); + File f = getTestFile("src/test/resources/git/diff/git-diff2.log"); - ConsumerUtils.consumeFile( f, consumer ); + ConsumerUtils.consumeFile(f, consumer); List changedFiles = consumer.getChangedFiles(); - assertEquals( 2, changedFiles.size() ); + assertEquals(2, changedFiles.size()); - testScmFile( changedFiles.get( 0 ), "pom.xml", ScmFileStatus.MODIFIED ); + testScmFile(changedFiles.get(0), "pom.xml", ScmFileStatus.MODIFIED); - testScmFile( changedFiles.get( 1 ), "test.txt", ScmFileStatus.MODIFIED ); + testScmFile(changedFiles.get(1), "test.txt", ScmFileStatus.MODIFIED); - Map differences = consumer.getDifferences(); - assertNotNull( differences ); + Map differences = consumer.getDifferences(); + assertNotNull(differences); - StringBuilder addDiffs = new StringBuilder( differences.get( "pom.xml" ) ); - assertNotNull( addDiffs ); - assertTrue( addDiffs.indexOf( "+ " ) >= 0 ); + StringBuilder addDiffs = new StringBuilder(differences.get("pom.xml")); + assertNotNull(addDiffs); + assertTrue(addDiffs.indexOf("+ ") >= 0); - addDiffs = new StringBuilder( differences.get( "test.txt" ) ); - assertNotNull( addDiffs ); - assertTrue( addDiffs.indexOf( "+maven-scm git provider works fine :-)" ) >= 0 ); + addDiffs = new StringBuilder(differences.get("test.txt")); + assertNotNull(addDiffs); + assertTrue(addDiffs.indexOf("+maven-scm git provider works fine :-)") >= 0); } @Test - public void testLog3Consumer() - throws Exception - { - GitDiffConsumer consumer = new GitDiffConsumer( null ); + public void testLog3Consumer() throws Exception { + GitDiffConsumer consumer = new GitDiffConsumer(null); - File f = getTestFile( "src/test/resources/git/diff/git-diff3.log" ); + File f = getTestFile("src/test/resources/git/diff/git-diff3.log"); - ConsumerUtils.consumeFile( f, consumer ); + ConsumerUtils.consumeFile(f, consumer); List changedFiles = consumer.getChangedFiles(); - assertEquals( 1, changedFiles.size() ); + assertEquals(1, changedFiles.size()); - testScmFile( changedFiles.get( 0 ), "pom.xml", ScmFileStatus.MODIFIED ); + testScmFile(changedFiles.get(0), "pom.xml", ScmFileStatus.MODIFIED); - Map differences = consumer.getDifferences(); - assertNotNull( differences ); + Map differences = consumer.getDifferences(); + assertNotNull(differences); - CharSequence addDiffs = differences.get( "pom.xml" ); - assertNotNull( addDiffs ); - assertEquals( "", addDiffs.toString() ); + CharSequence addDiffs = differences.get("pom.xml"); + assertNotNull(addDiffs); + assertEquals("", addDiffs.toString()); } @Test - public void testLog4Consumer() - throws Exception - { - GitDiffConsumer consumer = new GitDiffConsumer( null ); + public void testLog4Consumer() throws Exception { + GitDiffConsumer consumer = new GitDiffConsumer(null); - File f = getTestFile( "src/test/resources/git/diff/git-diff4.log" ); + File f = getTestFile("src/test/resources/git/diff/git-diff4.log"); - ConsumerUtils.consumeFile( f, consumer ); + ConsumerUtils.consumeFile(f, consumer); List changedFiles = consumer.getChangedFiles(); - assertEquals( 1, changedFiles.size() ); + assertEquals(1, changedFiles.size()); - testScmFile( changedFiles.get( 0 ), "pom.xml", ScmFileStatus.MODIFIED ); + testScmFile(changedFiles.get(0), "pom.xml", ScmFileStatus.MODIFIED); - Map differences = consumer.getDifferences(); - assertNotNull( differences ); + Map differences = consumer.getDifferences(); + assertNotNull(differences); - StringBuilder addDiffs = new StringBuilder( differences.get( "pom.xml" ) ); - assertNotNull( addDiffs ); - assertTrue( addDiffs.indexOf( "+ " ) >= 0 ); + StringBuilder addDiffs = new StringBuilder(differences.get("pom.xml")); + assertNotNull(addDiffs); + assertTrue(addDiffs.indexOf("+ ") >= 0); } - private void testScmFile( ScmFile fileToTest, String expectedFilePath, ScmFileStatus expectedStatus ) - { - assertEquals( expectedFilePath, fileToTest.getPath() ); - assertEquals( expectedStatus, fileToTest.getStatus() ); + private void testScmFile(ScmFile fileToTest, String expectedFilePath, ScmFileStatus expectedStatus) { + assertEquals(expectedFilePath, fileToTest.getPath()); + assertEquals(expectedStatus, fileToTest.getStatus()); } - } diff --git a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-git-commons/src/test/java/org/apache/maven/scm/provider/git/repository/GitScmProviderRepositoryTest.java b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-git-commons/src/test/java/org/apache/maven/scm/provider/git/repository/GitScmProviderRepositoryTest.java index e94701619..aa1a0faf9 100644 --- a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-git-commons/src/test/java/org/apache/maven/scm/provider/git/repository/GitScmProviderRepositoryTest.java +++ b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-git-commons/src/test/java/org/apache/maven/scm/provider/git/repository/GitScmProviderRepositoryTest.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.git.repository; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider.git.repository; import org.apache.maven.scm.ScmTestCase; import org.apache.maven.scm.manager.NoSuchScmProviderException; @@ -37,16 +36,12 @@ * @author Emmanuel Venisse * */ -public class GitScmProviderRepositoryTest - extends ScmTestCase -{ +public class GitScmProviderRepositoryTest extends ScmTestCase { private ScmManager scmManager; @Before @Override - public void setUp() - throws Exception - { + public void setUp() throws Exception { super.setUp(); scmManager = getScmManager(); @@ -57,206 +52,338 @@ public void setUp() // ---------------------------------------------------------------------- @Test - public void testLegalFileURL() - throws Exception - { - testUrl( "scm:git:file:///tmp/repo", null, "file:///tmp/repo", null, null, null, null, 0, null); + public void testLegalFileURL() throws Exception { + testUrl("scm:git:file:///tmp/repo", null, "file:///tmp/repo", null, null, null, null, 0, null); } @Test - public void testLegalFileHomeURL() - throws Exception - { - testUrl( "scm:git:file://~/repo", null, "file://~/repo", null, null, null, null, 0, null); + public void testLegalFileHomeURL() throws Exception { + testUrl("scm:git:file://~/repo", null, "file://~/repo", null, null, null, null, 0, null); } @Test - public void testLegalSshHomeURL() - throws Exception - { - testUrl( "scm:git:ssh://~/repo", null, "ssh://~/repo", null, null, null, null, 0, null); + public void testLegalSshHomeURL() throws Exception { + testUrl("scm:git:ssh://~/repo", null, "ssh://~/repo", null, null, null, null, 0, null); } @Test - public void testLegalLocalhostFileURL() - throws Exception - { - testUrl( "scm:git:file://somedirectory/tmp/repo", null, "file://somedirectory/tmp/repo", null, null, - null, null, 0, "somedirectory/tmp/repo"); + public void testLegalLocalhostFileURL() throws Exception { + testUrl( + "scm:git:file://somedirectory/tmp/repo", + null, + "file://somedirectory/tmp/repo", + null, + null, + null, + null, + 0, + "somedirectory/tmp/repo"); } @Test - public void testLegalHistnameFileURL() - throws Exception - { - testUrl( "scm:git:file://my_server/tmp/repo", null, "file://my_server/tmp/repo", null, null, - null, null, 0, "my_server/tmp/repo"); + public void testLegalHistnameFileURL() throws Exception { + testUrl( + "scm:git:file://my_server/tmp/repo", + null, + "file://my_server/tmp/repo", + null, + null, + null, + null, + 0, + "my_server/tmp/repo"); } @Test - public void testLegalHttpURL() - throws Exception - { - testUrl( "scm:git:http://gitrepos.apache.org", null, "http://gitrepos.apache.org", null, null, - null, "gitrepos.apache.org", 0, null); + public void testLegalHttpURL() throws Exception { + testUrl( + "scm:git:http://gitrepos.apache.org", + null, + "http://gitrepos.apache.org", + null, + null, + null, + "gitrepos.apache.org", + 0, + null); } @Test - public void testLegalHttpURLWithUser() - throws Exception - { - testUrl( "scm:git:http://user@gitrepos.apache.org", null, "http://user@gitrepos.apache.org", null, "user", - null, "gitrepos.apache.org", 0, null); + public void testLegalHttpURLWithUser() throws Exception { + testUrl( + "scm:git:http://user@gitrepos.apache.org", + null, + "http://user@gitrepos.apache.org", + null, + "user", + null, + "gitrepos.apache.org", + 0, + null); } @Test - public void testLegalHttpURLWithUserPassword() - throws Exception - { - testUrl( "scm:git:http://user:password@gitrepos.apache.org", null, "http://user:password@gitrepos.apache.org", - null, "user", "password", "gitrepos.apache.org", 0, null); + public void testLegalHttpURLWithUserPassword() throws Exception { + testUrl( + "scm:git:http://user:password@gitrepos.apache.org", + null, + "http://user:password@gitrepos.apache.org", + null, + "user", + "password", + "gitrepos.apache.org", + 0, + null); } @Test - public void testLegalHttpsURL() - throws Exception - { - testUrl( "scm:git:https://gitrepos.apache.org/repos/projectA", null, "https://gitrepos.apache.org/repos/projectA", null, null, - null, "gitrepos.apache.org", 0, "repos/projectA"); + public void testLegalHttpsURL() throws Exception { + testUrl( + "scm:git:https://gitrepos.apache.org/repos/projectA", + null, + "https://gitrepos.apache.org/repos/projectA", + null, + null, + null, + "gitrepos.apache.org", + 0, + "repos/projectA"); } @Test - public void testLegalFileWindowsURL() - throws Exception - { + public void testLegalFileWindowsURL() throws Exception { // FIXME This URL is invalid, hell knows why Git accepts it. It should be by us right away - testUrl( "scm:git:file://c:\\tmp\\repo", null, "file://c:\\tmp\\repo", null, null, null, null, 0, null); + testUrl("scm:git:file://c:\\tmp\\repo", null, "file://c:\\tmp\\repo", null, null, null, null, 0, null); } @Test - public void testLegalHttpsURLWithUser() - throws Exception - { - testUrl( "scm:git:https://user@gitrepos.apache.org", null, "https://user@gitrepos.apache.org", null, "user", - null, "gitrepos.apache.org", 0, null); + public void testLegalHttpsURLWithUser() throws Exception { + testUrl( + "scm:git:https://user@gitrepos.apache.org", + null, + "https://user@gitrepos.apache.org", + null, + "user", + null, + "gitrepos.apache.org", + 0, + null); } @Test - public void testLegalHttpsURLWithUserPassword() - throws Exception - { - testUrl( "scm:git:https://user:password@gitrepos.apache.org", null, "https://user:password@gitrepos.apache.org", - null, "user", "password", "gitrepos.apache.org", 0, null); + public void testLegalHttpsURLWithUserPassword() throws Exception { + testUrl( + "scm:git:https://user:password@gitrepos.apache.org", + null, + "https://user:password@gitrepos.apache.org", + null, + "user", + "password", + "gitrepos.apache.org", + 0, + null); } @Test - public void testLegalSshURLWithUser() - throws Exception - { - testUrl( "scm:git:ssh://user@gitrepos.apache.org", null, "ssh://user@gitrepos.apache.org", null, "user", - null, "gitrepos.apache.org", 0, null); + public void testLegalSshURLWithUser() throws Exception { + testUrl( + "scm:git:ssh://user@gitrepos.apache.org", + null, + "ssh://user@gitrepos.apache.org", + null, + "user", + null, + "gitrepos.apache.org", + 0, + null); } @Test - public void testLegalSshURLWithUserPassword() - throws Exception - { - testUrl( "scm:git:ssh://user:password@gitrepos.apache.org", null, "ssh://user:password@gitrepos.apache.org", - null, "user", "password", "gitrepos.apache.org", 0, null); + public void testLegalSshURLWithUserPassword() throws Exception { + testUrl( + "scm:git:ssh://user:password@gitrepos.apache.org", + null, + "ssh://user:password@gitrepos.apache.org", + null, + "user", + "password", + "gitrepos.apache.org", + 0, + null); } @Test - public void testLegalGitURL() - throws Exception - { - testUrl( "scm:git:git://gitrepos.apache.org", null, "git://gitrepos.apache.org", null, null, - null, "gitrepos.apache.org", 0, null); + public void testLegalGitURL() throws Exception { + testUrl( + "scm:git:git://gitrepos.apache.org", + null, + "git://gitrepos.apache.org", + null, + null, + null, + "gitrepos.apache.org", + 0, + null); } @Test - public void testGitDevURL() - throws Exception, ScmRepositoryException - { - testUrl( "scm:git:git@github.com:olamy/scm-git-test-one-module.git", - null, "git@github.com:olamy/scm-git-test-one-module.git", null, "git" , null, "github.com", 0, null); + public void testGitDevURL() throws Exception, ScmRepositoryException { + testUrl( + "scm:git:git@github.com:olamy/scm-git-test-one-module.git", + null, + "git@github.com:olamy/scm-git-test-one-module.git", + null, + "git", + null, + "github.com", + 0, + null); } @Test - public void testGitDevURLWIthPort() - throws Exception, ScmRepositoryException - { - testUrl( "scm:git:git@github.com:222:olamy/scm-git-test-one-module.git", - null, "git@github.com:222:olamy/scm-git-test-one-module.git", null, "git", null, "github.com", 222, null); + public void testGitDevURLWIthPort() throws Exception, ScmRepositoryException { + testUrl( + "scm:git:git@github.com:222:olamy/scm-git-test-one-module.git", + null, + "git@github.com:222:olamy/scm-git-test-one-module.git", + null, + "git", + null, + "github.com", + 222, + null); } // For SCM-639 @Test - public void testGitDevUrlWithNumberedRepoAndNoPort() - throws Exception, ScmRepositoryException - { - testUrl( "scm:git:git@github.com:4sh/blah.git", - null, "git@github.com:4sh/blah.git", null, "git", null, "github.com", 0, null); + public void testGitDevUrlWithNumberedRepoAndNoPort() throws Exception, ScmRepositoryException { + testUrl( + "scm:git:git@github.com:4sh/blah.git", + null, + "git@github.com:4sh/blah.git", + null, + "git", + null, + "github.com", + 0, + null); } - // For SCM-629 @Test - public void testGitDevUrlWithNumberedRepoAndMinus() - throws Exception, ScmRepositoryException - { - testUrl( "scm:git:ssh://git@github.com/360-Innovations/FJPAQuery.git", - null, "ssh://git@github.com/360-Innovations/FJPAQuery.git", null, "git", null, "github.com", 0, null); + public void testGitDevUrlWithNumberedRepoAndMinus() throws Exception, ScmRepositoryException { + testUrl( + "scm:git:ssh://git@github.com/360-Innovations/FJPAQuery.git", + null, + "ssh://git@github.com/360-Innovations/FJPAQuery.git", + null, + "git", + null, + "github.com", + 0, + null); } // For SCM-707 @Test - public void testSpecialCharacters() - throws Exception - { - testUrl( "scm:git:http://gitrepos.apache.org", "@_&_:_?_#_%20", "pass word", null, "http://gitrepos.apache.org", null, - "http://%40_&_:_%3F_%23_%2520:pass%20word@gitrepos.apache.org", null, - "gitrepos.apache.org", 0, null ); - - testUrl( "scm:git:http://gitrepos.apache.org", "user name", "@_&_:_?_#_%20", null, "http://gitrepos.apache.org", null, - "http://user%20name:%40_&_:_%3F_%23_%2520@gitrepos.apache.org", null, - "gitrepos.apache.org", 0, null ); - + public void testSpecialCharacters() throws Exception { + testUrl( + "scm:git:http://gitrepos.apache.org", + "@_&_:_?_#_%20", + "pass word", + null, + "http://gitrepos.apache.org", + null, + "http://%40_&_:_%3F_%23_%2520:pass%20word@gitrepos.apache.org", + null, + "gitrepos.apache.org", + 0, + null); + + testUrl( + "scm:git:http://gitrepos.apache.org", + "user name", + "@_&_:_?_#_%20", + null, + "http://gitrepos.apache.org", + null, + "http://user%20name:%40_&_:_%3F_%23_%2520@gitrepos.apache.org", + null, + "gitrepos.apache.org", + 0, + null); } @Test - public void testLegalGitPortUrl() - throws Exception - { - testUrl( "scm:git:http://username@gitrepos.apache.org:8800/pmgt/trunk", - null, "http://username@gitrepos.apache.org:8800/pmgt/trunk", - null, "username", null, "gitrepos.apache.org", 8800, null); - - - - testUrl( "scm:git:https://username@gitrepos.apache.org:20443/pmgt/trunk", - null, "https://username@gitrepos.apache.org:20443/pmgt/trunk", - null, "username", null, "gitrepos.apache.org", 20443, null); - - testUrl( "scm:git:git://username@gitrepos.apache.org:8800/pmgt/trunk", - null, "git://username@gitrepos.apache.org:8800/pmgt/trunk", - null, "username", null, "gitrepos.apache.org", 8800, null); - - testUrl( "scm:git:ssh://username@gitrepos.apache.org:8080/pmgt/trunk", - null, "ssh://username@gitrepos.apache.org:8080/pmgt/trunk", - null, "username", null, "gitrepos.apache.org", 8080, null); - - testUrl( "scm:git:ssh://username:password@gitrepos.apache.org/pmgt/trunk", - null, "ssh://username:password@gitrepos.apache.org/pmgt/trunk", - null, "username", "password", "gitrepos.apache.org", 0, null); - + public void testLegalGitPortUrl() throws Exception { + testUrl( + "scm:git:http://username@gitrepos.apache.org:8800/pmgt/trunk", + null, + "http://username@gitrepos.apache.org:8800/pmgt/trunk", + null, + "username", + null, + "gitrepos.apache.org", + 8800, + null); + + testUrl( + "scm:git:https://username@gitrepos.apache.org:20443/pmgt/trunk", + null, + "https://username@gitrepos.apache.org:20443/pmgt/trunk", + null, + "username", + null, + "gitrepos.apache.org", + 20443, + null); + + testUrl( + "scm:git:git://username@gitrepos.apache.org:8800/pmgt/trunk", + null, + "git://username@gitrepos.apache.org:8800/pmgt/trunk", + null, + "username", + null, + "gitrepos.apache.org", + 8800, + null); + + testUrl( + "scm:git:ssh://username@gitrepos.apache.org:8080/pmgt/trunk", + null, + "ssh://username@gitrepos.apache.org:8080/pmgt/trunk", + null, + "username", + null, + "gitrepos.apache.org", + 8080, + null); + + testUrl( + "scm:git:ssh://username:password@gitrepos.apache.org/pmgt/trunk", + null, + "ssh://username:password@gitrepos.apache.org/pmgt/trunk", + null, + "username", + "password", + "gitrepos.apache.org", + 0, + null); } @Test - public void testUsernameWithAtAndPasswordInUrl() throws ScmRepositoryException, Exception{ - testUrl( "scm:git:http://username@site.com:password@gitrepos.apache.org:8800/pmgt/trunk", - null, "http://username%40site.com:password@gitrepos.apache.org:8800/pmgt/trunk", - null, "username@site.com", "password", "gitrepos.apache.org", 8800, null); - + public void testUsernameWithAtAndPasswordInUrl() throws ScmRepositoryException, Exception { + testUrl( + "scm:git:http://username@site.com:password@gitrepos.apache.org:8800/pmgt/trunk", + null, + "http://username%40site.com:password@gitrepos.apache.org:8800/pmgt/trunk", + null, + "username@site.com", + "password", + "gitrepos.apache.org", + 8800, + null); } // ---------------------------------------------------------------------- @@ -264,143 +391,168 @@ public void testUsernameWithAtAndPasswordInUrl() throws ScmRepositoryException, // ---------------------------------------------------------------------- @Test - public void testHttpFetchSshPushUrl() - throws Exception - { - testUrl( "scm:git:[fetch=]http://git.apache.org/myprj.git[push=]ssh://myuser:mypassword@git.apache.org/~/myrepo/myprj.git", - "[fetch=]http://myuser:mypassword@git.apache.org/myprj.git[push=]ssh://myuser:mypassword@git.apache.org/~/myrepo/myprj.git", - "http://myuser:mypassword@git.apache.org/myprj.git", - "ssh://myuser:mypassword@git.apache.org/~/myrepo/myprj.git", "myuser", "mypassword", "git.apache.org", 0, null); - - testUrl( "scm:git:[push=]ssh://myuser:mypassword@git.apache.org/~/myrepo/myprj.git[fetch=]http://git.apache.org/myprj.git", - "[fetch=]http://myuser:mypassword@git.apache.org/myprj.git[push=]ssh://myuser:mypassword@git.apache.org/~/myrepo/myprj.git", - "http://myuser:mypassword@git.apache.org/myprj.git", - "ssh://myuser:mypassword@git.apache.org/~/myrepo/myprj.git", "myuser", "mypassword", "git.apache.org", 0, null); + public void testHttpFetchSshPushUrl() throws Exception { + testUrl( + "scm:git:[fetch=]http://git.apache.org/myprj.git[push=]ssh://myuser:mypassword@git.apache.org/~/myrepo/myprj.git", + "[fetch=]http://myuser:mypassword@git.apache.org/myprj.git[push=]ssh://myuser:mypassword@git.apache.org/~/myrepo/myprj.git", + "http://myuser:mypassword@git.apache.org/myprj.git", + "ssh://myuser:mypassword@git.apache.org/~/myrepo/myprj.git", + "myuser", + "mypassword", + "git.apache.org", + 0, + null); + + testUrl( + "scm:git:[push=]ssh://myuser:mypassword@git.apache.org/~/myrepo/myprj.git[fetch=]http://git.apache.org/myprj.git", + "[fetch=]http://myuser:mypassword@git.apache.org/myprj.git[push=]ssh://myuser:mypassword@git.apache.org/~/myrepo/myprj.git", + "http://myuser:mypassword@git.apache.org/myprj.git", + "ssh://myuser:mypassword@git.apache.org/~/myrepo/myprj.git", + "myuser", + "mypassword", + "git.apache.org", + 0, + null); } // ---------------------------------------------------------------------- // Testing illegal URLs // ---------------------------------------------------------------------- - //X in fact this url is perfectly valid from a technical perspective - //X it will be interpreted by git as git://file/tmp/git + // X in fact this url is perfectly valid from a technical perspective + // X it will be interpreted by git as git://file/tmp/git @Test @Ignore - public void nottestIllegalFileUrl() - throws Exception - { - testIllegalUrl( "file:/tmp/git" ); + public void nottestIllegalFileUrl() throws Exception { + testIllegalUrl("file:/tmp/git"); } // ---------------------------------------------------------------------- // // ---------------------------------------------------------------------- - private GitScmProviderRepository testUrl(String scmUrl, String expectedToString, - String expectedFetchUrl, String expectedPushUrl, - String expectedUser, String expectedPassword, - String expectedHost, int expectedPort, String expectedPath) - throws Exception, ScmRepositoryException - { + private GitScmProviderRepository testUrl( + String scmUrl, + String expectedToString, + String expectedFetchUrl, + String expectedPushUrl, + String expectedUser, + String expectedPassword, + String expectedHost, + int expectedPort, + String expectedPath) + throws Exception, ScmRepositoryException { - ScmRepository repository = testScmRepository( scmUrl, expectedToString, expectedFetchUrl ); + ScmRepository repository = testScmRepository(scmUrl, expectedToString, expectedFetchUrl); GitScmProviderRepository providerRepository = (GitScmProviderRepository) repository.getProviderRepository(); - return testScmProviderRepository( expectedToString, expectedFetchUrl, expectedPushUrl, expectedUser, - expectedPassword, expectedHost, expectedPort, providerRepository ); - + return testScmProviderRepository( + expectedToString, + expectedFetchUrl, + expectedPushUrl, + expectedUser, + expectedPassword, + expectedHost, + expectedPort, + providerRepository); } - private GitScmProviderRepository testUrl(String scmUrl, String username, String password, - String expectedScmRepositoryToString, String expectedScmRepositoryFetchUrl, - String expectedScmProviderRepositoryToString, String expectedScmProviderRepositoryFetchUrl, String expectedPushUrl, - String expectedHost, int expectedPort, String expectedPath) - throws Exception, ScmRepositoryException - { - - ScmRepository repository = testScmRepository( scmUrl, expectedScmRepositoryToString, expectedScmRepositoryFetchUrl ); + private GitScmProviderRepository testUrl( + String scmUrl, + String username, + String password, + String expectedScmRepositoryToString, + String expectedScmRepositoryFetchUrl, + String expectedScmProviderRepositoryToString, + String expectedScmProviderRepositoryFetchUrl, + String expectedPushUrl, + String expectedHost, + int expectedPort, + String expectedPath) + throws Exception, ScmRepositoryException { + + ScmRepository repository = + testScmRepository(scmUrl, expectedScmRepositoryToString, expectedScmRepositoryFetchUrl); GitScmProviderRepository providerRepository = (GitScmProviderRepository) repository.getProviderRepository(); - providerRepository.setUser( username ); + providerRepository.setUser(username); - providerRepository.setPassword( password ); + providerRepository.setPassword(password); - return testScmProviderRepository( expectedScmProviderRepositoryToString, expectedScmProviderRepositoryFetchUrl, expectedPushUrl, username, - password, expectedHost, expectedPort, providerRepository ); + return testScmProviderRepository( + expectedScmProviderRepositoryToString, + expectedScmProviderRepositoryFetchUrl, + expectedPushUrl, + username, + password, + expectedHost, + expectedPort, + providerRepository); } - private GitScmProviderRepository testScmProviderRepository( String expectedToString, String expectedFetchUrl, - String expectedPushUrl, String expectedUser, - String expectedPassword, String expectedHost, - int expectedPort, - GitScmProviderRepository providerRepository ) - { - assertEquals( "fetch url is incorrect", expectedFetchUrl, providerRepository.getFetchUrl() ); - - if ( expectedPushUrl != null ) - { - assertEquals( "push url is incorrect", expectedPushUrl, providerRepository.getPushUrl() ); + private GitScmProviderRepository testScmProviderRepository( + String expectedToString, + String expectedFetchUrl, + String expectedPushUrl, + String expectedUser, + String expectedPassword, + String expectedHost, + int expectedPort, + GitScmProviderRepository providerRepository) { + assertEquals("fetch url is incorrect", expectedFetchUrl, providerRepository.getFetchUrl()); + + if (expectedPushUrl != null) { + assertEquals("push url is incorrect", expectedPushUrl, providerRepository.getPushUrl()); } - assertEquals( "User is incorrect", expectedUser, providerRepository.getUser() ); + assertEquals("User is incorrect", expectedUser, providerRepository.getUser()); - assertEquals( "Password is incorrect", expectedPassword, providerRepository.getPassword() ); + assertEquals("Password is incorrect", expectedPassword, providerRepository.getPassword()); - assertEquals( "Host is incorrect", expectedHost == null ? "" : expectedHost, providerRepository.getHost() ); + assertEquals("Host is incorrect", expectedHost == null ? "" : expectedHost, providerRepository.getHost()); - if ( expectedPort > 0 ) - { - assertEquals( "Port is incorrect", expectedPort, providerRepository.getPort() ); + if (expectedPort > 0) { + assertEquals("Port is incorrect", expectedPort, providerRepository.getPort()); } return providerRepository; } - private ScmRepository testScmRepository( String scmUrl, String expectedToString, String expectedFetchUrl ) - throws ScmRepositoryException, NoSuchScmProviderException - { - ScmRepository repository = scmManager.makeScmRepository( scmUrl ); + private ScmRepository testScmRepository(String scmUrl, String expectedToString, String expectedFetchUrl) + throws ScmRepositoryException, NoSuchScmProviderException { + ScmRepository repository = scmManager.makeScmRepository(scmUrl); - assertNotNull( "ScmManager.makeScmRepository() returned null", repository ); + assertNotNull("ScmManager.makeScmRepository() returned null", repository); - assertNotNull( "The provider repository was null.", repository.getProviderRepository() ); + assertNotNull("The provider repository was null.", repository.getProviderRepository()); - assertTrue( "The SCM Repository isn't a " + GitScmProviderRepository.class.getName() + ".", repository - .getProviderRepository() instanceof GitScmProviderRepository ); + assertTrue( + "The SCM Repository isn't a " + GitScmProviderRepository.class.getName() + ".", + repository.getProviderRepository() instanceof GitScmProviderRepository); - if ( expectedToString != null ) - { - assertEquals( "toString is incorrect", "git:" + expectedToString, repository.toString() ); - } - else - { - assertEquals( "toString is incorrect", "git:" + expectedFetchUrl, repository.toString() ); + if (expectedToString != null) { + assertEquals("toString is incorrect", "git:" + expectedToString, repository.toString()); + } else { + assertEquals("toString is incorrect", "git:" + expectedFetchUrl, repository.toString()); } return repository; } - private void testIllegalUrl( String url ) - throws Exception - { - try - { - scmManager.makeScmRepository( "scm:git:" + url ); + private void testIllegalUrl(String url) throws Exception { + try { + scmManager.makeScmRepository("scm:git:" + url); - fail( "Expected a ScmRepositoryException while testing the url '" + url + "'." ); - } - catch ( ScmRepositoryException e ) - { + fail("Expected a ScmRepositoryException while testing the url '" + url + "'."); + } catch (ScmRepositoryException e) { // expected } } @Test - public void testGetParent() throws Exception - { - new GitScmProviderRepository( "http://gitrepos.apache.org" ); + public void testGetParent() throws Exception { + new GitScmProviderRepository("http://gitrepos.apache.org"); } - } diff --git a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/pom.xml b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/pom.xml index b420ba042..bd6ba172b 100644 --- a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/pom.xml +++ b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/pom.xml @@ -1,5 +1,4 @@ - - 4.0.0 diff --git a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/main/java/org/apache/maven/scm/provider/git/gitexe/GitExeScmProvider.java b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/main/java/org/apache/maven/scm/provider/git/gitexe/GitExeScmProvider.java index 1b3948441..dad934842 100644 --- a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/main/java/org/apache/maven/scm/provider/git/gitexe/GitExeScmProvider.java +++ b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/main/java/org/apache/maven/scm/provider/git/gitexe/GitExeScmProvider.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.git.gitexe; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider.git.gitexe; import javax.inject.Named; import javax.inject.Singleton; @@ -52,128 +51,106 @@ * @author Emmanuel Venisse */ @Singleton -@Named( "git" ) -public class GitExeScmProvider - extends AbstractGitScmProvider -{ +@Named("git") +public class GitExeScmProvider extends AbstractGitScmProvider { private final Map environmentVariables; - public GitExeScmProvider() - { + public GitExeScmProvider() { environmentVariables = new HashMap<>(); } /** {@inheritDoc} */ - protected GitCommand getAddCommand() - { + protected GitCommand getAddCommand() { return new GitAddCommand(); } /** {@inheritDoc} */ - protected GitCommand getBranchCommand() - { + protected GitCommand getBranchCommand() { return new GitBranchCommand(); } /** {@inheritDoc} */ - protected GitCommand getChangeLogCommand() - { + protected GitCommand getChangeLogCommand() { return new GitChangeLogCommand(); } /** {@inheritDoc} */ - protected GitCommand getCheckInCommand() - { - return new GitCheckInCommand( environmentVariables ); + protected GitCommand getCheckInCommand() { + return new GitCheckInCommand(environmentVariables); } /** {@inheritDoc} */ - protected GitCommand getCheckOutCommand() - { - return new GitCheckOutCommand( environmentVariables ); + protected GitCommand getCheckOutCommand() { + return new GitCheckOutCommand(environmentVariables); } /** {@inheritDoc} */ - protected GitCommand getDiffCommand() - { + protected GitCommand getDiffCommand() { return new GitDiffCommand(); } /** {@inheritDoc} */ - protected GitCommand getExportCommand() - { - return null; //X TODO + protected GitCommand getExportCommand() { + return null; // X TODO } /** {@inheritDoc} */ - protected GitCommand getRemoveCommand() - { + protected GitCommand getRemoveCommand() { return new GitRemoveCommand(); } /** {@inheritDoc} */ - protected GitCommand getStatusCommand() - { + protected GitCommand getStatusCommand() { return new GitStatusCommand(); } /** {@inheritDoc} */ - protected GitCommand getTagCommand() - { + protected GitCommand getTagCommand() { return new GitTagCommand(); } /** {@inheritDoc} */ - protected GitCommand getUntagCommand() - { + protected GitCommand getUntagCommand() { return new GitUntagCommand(); } /** {@inheritDoc} */ - protected GitCommand getUpdateCommand() - { + protected GitCommand getUpdateCommand() { return new GitUpdateCommand(); } /** {@inheritDoc} */ - public GitCommand getInfoCommand() - { + public GitCommand getInfoCommand() { return new GitInfoCommand(); } /** {@inheritDoc} */ - protected GitCommand getBlameCommand() - { + protected GitCommand getBlameCommand() { return new GitBlameCommand(); } /** {@inheritDoc} */ - protected GitCommand getRemoteInfoCommand() - { - return new GitRemoteInfoCommand( environmentVariables ); + protected GitCommand getRemoteInfoCommand() { + return new GitRemoteInfoCommand(environmentVariables); } /** {@inheritDoc} */ - protected String getRepositoryURL( File path ) - throws ScmException - { + protected String getRepositoryURL(File path) throws ScmException { // Note: I need to supply just 1 absolute path, but ScmFileSet won't let me without // a basedir (which isn't used here anyway), so use a dummy file. // and a dummy ScmProviderRepository - InfoScmResult result = info( new GitScmProviderRepository( path.toPath().toUri().toASCIIString() ), - new ScmFileSet( path ), null ); + InfoScmResult result = + info(new GitScmProviderRepository(path.toPath().toUri().toASCIIString()), new ScmFileSet(path), null); - if ( result.getInfoItems().size() != 1 ) - { - throw new ScmRepositoryException( "Cannot find URL: " - + ( result.getInfoItems().size() == 0 ? "no" : "multiple" ) + " items returned by the info command" ); + if (result.getInfoItems().size() != 1) { + throw new ScmRepositoryException("Cannot find URL: " + + (result.getInfoItems().size() == 0 ? "no" : "multiple") + " items returned by the info command"); } - return result.getInfoItems().get( 0 ).getURL(); + return result.getInfoItems().get(0).getURL(); } - public void setEnvironmentVariable( String key, String value ) - { - environmentVariables.put( key, value ); + public void setEnvironmentVariable(String key, String value) { + environmentVariables.put(key, value); } } diff --git a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/main/java/org/apache/maven/scm/provider/git/gitexe/command/AbstractFileCheckingConsumer.java b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/main/java/org/apache/maven/scm/provider/git/gitexe/command/AbstractFileCheckingConsumer.java index 13cd4ad7d..e31609342 100644 --- a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/main/java/org/apache/maven/scm/provider/git/gitexe/command/AbstractFileCheckingConsumer.java +++ b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/main/java/org/apache/maven/scm/provider/git/gitexe/command/AbstractFileCheckingConsumer.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.git.gitexe.command; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,23 +16,22 @@ * specific language governing permissions and limitations * under the License. */ - -import org.apache.maven.scm.ScmFile; -import org.apache.maven.scm.util.AbstractConsumer; +package org.apache.maven.scm.provider.git.gitexe.command; import java.io.File; import java.util.ArrayList; import java.util.Iterator; import java.util.List; +import org.apache.maven.scm.ScmFile; +import org.apache.maven.scm.util.AbstractConsumer; + /** * @author Kenney Westerhof * @author Olivier Lamy * */ -public abstract class AbstractFileCheckingConsumer - extends AbstractConsumer -{ +public abstract class AbstractFileCheckingConsumer extends AbstractConsumer { protected File workingDirectory; private final List files = new ArrayList<>(); @@ -43,37 +40,29 @@ public abstract class AbstractFileCheckingConsumer private boolean filtered; - public AbstractFileCheckingConsumer( File workingDirectory ) - { + public AbstractFileCheckingConsumer(File workingDirectory) { this.workingDirectory = workingDirectory; } /** {@inheritDoc} */ - public final void consumeLine( String line ) - { - if ( line.length() <= 3 ) - { + public final void consumeLine(String line) { + if (line.length() <= 3) { return; } - if ( logger.isDebugEnabled() ) - { - logger.debug( line ); + if (logger.isDebugEnabled()) { + logger.debug(line); } - parseLine( line ); + parseLine(line); } - protected abstract void parseLine( String line ); + protected abstract void parseLine(String line); - protected List getFiles() - { - if ( !filtered ) - { - for ( Iterator it = files.iterator(); it.hasNext(); ) - { - if ( !new File( workingDirectory, it.next().getPath() ).isFile() ) - { + protected List getFiles() { + if (!filtered) { + for (Iterator it = files.iterator(); it.hasNext(); ) { + if (!new File(workingDirectory, it.next().getPath()).isFile()) { it.remove(); } } @@ -84,26 +73,19 @@ protected List getFiles() return files; } - protected final int parseInt( String revisionString ) - { - try - { - return Integer.parseInt( revisionString ); - } - catch ( NumberFormatException ex ) - { + protected final int parseInt(String revisionString) { + try { + return Integer.parseInt(revisionString); + } catch (NumberFormatException ex) { return 0; } } - protected void addFile( ScmFile file ) - { - files.add( file ); + protected void addFile(ScmFile file) { + files.add(file); } - public final int getRevision() - { + public final int getRevision() { return revision; } - } diff --git a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/main/java/org/apache/maven/scm/provider/git/gitexe/command/AnonymousCommandLine.java b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/main/java/org/apache/maven/scm/provider/git/gitexe/command/AnonymousCommandLine.java index b87b1a3c0..3a787fc7a 100644 --- a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/main/java/org/apache/maven/scm/provider/git/gitexe/command/AnonymousCommandLine.java +++ b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/main/java/org/apache/maven/scm/provider/git/gitexe/command/AnonymousCommandLine.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.git.gitexe.command; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,23 +16,22 @@ * specific language governing permissions and limitations * under the License. */ - -import org.codehaus.plexus.util.cli.Commandline; +package org.apache.maven.scm.provider.git.gitexe.command; import java.util.regex.Matcher; import java.util.regex.Pattern; +import org.codehaus.plexus.util.cli.Commandline; + /** * CommandLine extension to mask password * @since 1.9.3 */ -public class AnonymousCommandLine - extends Commandline -{ +public class AnonymousCommandLine extends Commandline { public static final String PASSWORD_PLACE_HOLDER = "********"; - private Pattern passwordPattern = Pattern.compile( "^.*:(.*)@.*$" ); + private Pattern passwordPattern = Pattern.compile("^.*:(.*)@.*$"); /** * Provides an anonymous output to mask password. Considering URL of type : @@ -42,17 +39,15 @@ public class AnonymousCommandLine * <<host_definition>> */ @Override - public String toString() - { + public String toString() { String output = super.toString(); - final Matcher passwordMatcher = passwordPattern.matcher( output ); - if ( passwordMatcher.find() ) - { + final Matcher passwordMatcher = passwordPattern.matcher(output); + if (passwordMatcher.find()) { // clear password - final String clearPassword = passwordMatcher.group( 1 ); + final String clearPassword = passwordMatcher.group(1); // to be replaced in output by stars - output = output.replace( clearPassword, PASSWORD_PLACE_HOLDER ); + output = output.replace(clearPassword, PASSWORD_PLACE_HOLDER); } return output; } -} \ No newline at end of file +} diff --git a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/main/java/org/apache/maven/scm/provider/git/gitexe/command/GitCommandLineUtils.java b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/main/java/org/apache/maven/scm/provider/git/gitexe/command/GitCommandLineUtils.java index 0f0484cc6..997ba0823 100644 --- a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/main/java/org/apache/maven/scm/provider/git/gitexe/command/GitCommandLineUtils.java +++ b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/main/java/org/apache/maven/scm/provider/git/gitexe/command/GitCommandLineUtils.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.git.gitexe.command; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,9 +16,15 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider.git.gitexe.command; -import org.apache.commons.io.FilenameUtils; +import java.io.File; +import java.io.IOException; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import org.apache.commons.io.FilenameUtils; import org.apache.maven.scm.ScmException; import org.apache.maven.scm.provider.git.repository.GitScmProviderRepository; import org.apache.maven.scm.provider.git.util.GitUtil; @@ -33,12 +37,6 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import java.io.File; -import java.io.IOException; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - /** * Command line construction utility. * @@ -46,64 +44,53 @@ * @author Mark Struberg * */ -public final class GitCommandLineUtils -{ - private static final Logger LOGGER = LoggerFactory.getLogger( GitCommandLineUtils.class ); +public final class GitCommandLineUtils { + private static final Logger LOGGER = LoggerFactory.getLogger(GitCommandLineUtils.class); // https://git-scm.com/docs/git#Documentation/git.txt-codeGITSSHCOMMANDcode, requires git 2.3.0 or newer public static final String VARIABLE_GIT_SSH_COMMAND = "GIT_SSH_COMMAND"; - private GitCommandLineUtils() - { - } + private GitCommandLineUtils() {} - public static void addTarget( Commandline cl, List files ) - { - if ( files == null || files.isEmpty() ) - { + public static void addTarget(Commandline cl, List files) { + if (files == null || files.isEmpty()) { return; } final File workingDirectory = cl.getWorkingDirectory(); - try - { + try { final String canonicalWorkingDirectory = workingDirectory.getCanonicalPath(); - for ( File file : files ) - { + for (File file : files) { String relativeFile = file.getPath(); final String canonicalFile = file.getCanonicalPath(); - if ( canonicalFile.startsWith( canonicalWorkingDirectory ) ) - { + if (canonicalFile.startsWith(canonicalWorkingDirectory)) { // so we can omit the starting characters - relativeFile = canonicalFile.substring( canonicalWorkingDirectory.length() ); + relativeFile = canonicalFile.substring(canonicalWorkingDirectory.length()); - if ( relativeFile.startsWith( File.separator ) ) - { - relativeFile = relativeFile.substring( File.separator.length() ); + if (relativeFile.startsWith(File.separator)) { + relativeFile = relativeFile.substring(File.separator.length()); } } // no setFile() since this screws up the working directory! - cl.createArg().setValue( FilenameUtils.separatorsToUnix( relativeFile ) ); + cl.createArg().setValue(FilenameUtils.separatorsToUnix(relativeFile)); } - } - catch ( IOException ex ) - { - throw new IllegalArgumentException( "Could not get canonical paths for workingDirectory = " - + workingDirectory + " or files=" + files, ex ); + } catch (IOException ex) { + throw new IllegalArgumentException( + "Could not get canonical paths for workingDirectory = " + workingDirectory + " or files=" + files, + ex); } } - /** - * Use this only for commands not requiring environment variables (i.e. local commands). - * @param workingDirectory - * @param command - * @return TODO - */ - public static Commandline getBaseGitCommandLine( File workingDirectory, String command ) - { - return getBaseGitCommandLine( workingDirectory, command, null, null ); - } + /** + * Use this only for commands not requiring environment variables (i.e. local commands). + * @param workingDirectory + * @param command + * @return TODO + */ + public static Commandline getBaseGitCommandLine(File workingDirectory, String command) { + return getBaseGitCommandLine(workingDirectory, command, null, null); + } /** * Use this for commands requiring environment variables (i.e. remote commands). @@ -112,18 +99,16 @@ public static Commandline getBaseGitCommandLine( File workingDirectory, String c * @param environment * @return TODO */ - public static Commandline getBaseGitCommandLine( File workingDirectory, String command, - GitScmProviderRepository repository, - Map environment ) - { - Commandline cl = getAnonymousBaseGitCommandLine( workingDirectory, command ); - if ( repository != null ) - { - prepareEnvVariablesForRepository( repository, environment ).forEach( cl::addEnvironment ); - } - else if ( environment != null ) - { - environment.forEach( cl::addEnvironment ); + public static Commandline getBaseGitCommandLine( + File workingDirectory, + String command, + GitScmProviderRepository repository, + Map environment) { + Commandline cl = getAnonymousBaseGitCommandLine(workingDirectory, command); + if (repository != null) { + prepareEnvVariablesForRepository(repository, environment).forEach(cl::addEnvironment); + } else if (environment != null) { + environment.forEach(cl::addEnvironment); } return cl; } @@ -136,99 +121,84 @@ else if ( environment != null ) * @param command * @return CommandLine with anonymous output. */ - private static Commandline getAnonymousBaseGitCommandLine( File workingDirectory, String command ) - { - if ( command == null || command.length() == 0 ) - { + private static Commandline getAnonymousBaseGitCommandLine(File workingDirectory, String command) { + if (command == null || command.length() == 0) { return null; } Commandline cl = new AnonymousCommandLine(); - composeCommand( workingDirectory, command, cl ); + composeCommand(workingDirectory, command, cl); return cl; } - private static void composeCommand( File workingDirectory, String command, Commandline cl ) - { + private static void composeCommand(File workingDirectory, String command, Commandline cl) { Settings settings = GitUtil.getSettings(); - cl.setExecutable( settings.getGitCommand() ); + cl.setExecutable(settings.getGitCommand()); - cl.createArg().setValue( command ); + cl.createArg().setValue(command); - if ( workingDirectory != null ) - { - cl.setWorkingDirectory( workingDirectory.getAbsolutePath() ); + if (workingDirectory != null) { + cl.setWorkingDirectory(workingDirectory.getAbsolutePath()); } } - public static int execute( Commandline cl, StreamConsumer consumer, CommandLineUtils.StringStreamConsumer stderr ) - throws ScmException - { - if ( LOGGER.isInfoEnabled() ) - { - LOGGER.info( "Executing: " + cl ); - LOGGER.info( "Working directory: " + cl.getWorkingDirectory().getAbsolutePath() ); + public static int execute(Commandline cl, StreamConsumer consumer, CommandLineUtils.StringStreamConsumer stderr) + throws ScmException { + if (LOGGER.isInfoEnabled()) { + LOGGER.info("Executing: " + cl); + LOGGER.info("Working directory: " + cl.getWorkingDirectory().getAbsolutePath()); } int exitCode; - try - { - exitCode = CommandLineUtils.executeCommandLine( cl, consumer, stderr ); - } - catch ( CommandLineException ex ) - { - throw new ScmException( "Error while executing command.", ex ); + try { + exitCode = CommandLineUtils.executeCommandLine(cl, consumer, stderr); + } catch (CommandLineException ex) { + throw new ScmException("Error while executing command.", ex); } return exitCode; } - public static int execute( Commandline cl, CommandLineUtils.StringStreamConsumer stdout, - CommandLineUtils.StringStreamConsumer stderr ) - throws ScmException - { - if ( LOGGER.isInfoEnabled() ) - { - LOGGER.info( "Executing: " + cl ); - LOGGER.info( "Working directory: " + cl.getWorkingDirectory().getAbsolutePath() ); + public static int execute( + Commandline cl, CommandLineUtils.StringStreamConsumer stdout, CommandLineUtils.StringStreamConsumer stderr) + throws ScmException { + if (LOGGER.isInfoEnabled()) { + LOGGER.info("Executing: " + cl); + LOGGER.info("Working directory: " + cl.getWorkingDirectory().getAbsolutePath()); } int exitCode; - try - { - exitCode = CommandLineUtils.executeCommandLine( cl, stdout, stderr ); - } - catch ( CommandLineException ex ) - { - throw new ScmException( "Error while executing command.", ex ); + try { + exitCode = CommandLineUtils.executeCommandLine(cl, stdout, stderr); + } catch (CommandLineException ex) { + throw new ScmException("Error while executing command.", ex); } return exitCode; } - static Map prepareEnvVariablesForRepository( GitScmProviderRepository repository, - Map environmentVariables ) - { + static Map prepareEnvVariablesForRepository( + GitScmProviderRepository repository, Map environmentVariables) { Map effectiveEnvironmentVariables = new HashMap<>(); - if ( environmentVariables != null ) - { - effectiveEnvironmentVariables.putAll( environmentVariables ); - } - if ( StringUtils.isNotBlank( repository.getPrivateKey() ) ) - { - if ( effectiveEnvironmentVariables.putIfAbsent( VARIABLE_GIT_SSH_COMMAND, "ssh -o IdentitiesOnly=yes -i " - + FilenameUtils.separatorsToUnix( repository.getPrivateKey() ) ) != null ) - { - LOGGER.warn( "Ignore GitScmProviderRepository.privateKey as environment variable {} is already set", - VARIABLE_GIT_SSH_COMMAND ); + if (environmentVariables != null) { + effectiveEnvironmentVariables.putAll(environmentVariables); + } + if (StringUtils.isNotBlank(repository.getPrivateKey())) { + if (effectiveEnvironmentVariables.putIfAbsent( + VARIABLE_GIT_SSH_COMMAND, + "ssh -o IdentitiesOnly=yes -i " + + FilenameUtils.separatorsToUnix(repository.getPrivateKey())) + != null) { + LOGGER.warn( + "Ignore GitScmProviderRepository.privateKey as environment variable {} is already set", + VARIABLE_GIT_SSH_COMMAND); } } - if ( StringUtils.isNotBlank( repository.getPassphrase() ) ) - { - LOGGER.warn( "GitScmProviderRepository.passphrase currently not supported by provider 'git'" ); + if (StringUtils.isNotBlank(repository.getPassphrase())) { + LOGGER.warn("GitScmProviderRepository.passphrase currently not supported by provider 'git'"); } return effectiveEnvironmentVariables; } diff --git a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/main/java/org/apache/maven/scm/provider/git/gitexe/command/add/GitAddCommand.java b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/main/java/org/apache/maven/scm/provider/git/gitexe/command/add/GitAddCommand.java index f8324b4a5..922045df0 100644 --- a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/main/java/org/apache/maven/scm/provider/git/gitexe/command/add/GitAddCommand.java +++ b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/main/java/org/apache/maven/scm/provider/git/gitexe/command/add/GitAddCommand.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.git.gitexe.command.add; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,13 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider.git.gitexe.command.add; + +import java.io.File; +import java.net.URI; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; import org.apache.commons.io.FilenameUtils; import org.apache.maven.scm.ScmException; @@ -36,42 +41,29 @@ import org.codehaus.plexus.util.cli.CommandLineUtils; import org.codehaus.plexus.util.cli.Commandline; -import java.io.File; -import java.net.URI; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - /** * @author Mark Struberg */ -public class GitAddCommand - extends AbstractAddCommand - implements GitCommand -{ +public class GitAddCommand extends AbstractAddCommand implements GitCommand { /** * {@inheritDoc} */ - protected ScmResult executeAddCommand( ScmProviderRepository repo, ScmFileSet fileSet, String message, - boolean binary ) - throws ScmException - { + protected ScmResult executeAddCommand( + ScmProviderRepository repo, ScmFileSet fileSet, String message, boolean binary) throws ScmException { GitScmProviderRepository repository = (GitScmProviderRepository) repo; - if ( fileSet.getFileList().isEmpty() ) - { - throw new ScmException( "You must provide at least one file/directory to add" ); + if (fileSet.getFileList().isEmpty()) { + throw new ScmException("You must provide at least one file/directory to add"); } - AddScmResult result = executeAddFileSet( fileSet ); + AddScmResult result = executeAddFileSet(fileSet); - if ( result != null ) - { + if (result != null) { return result; } // SCM-709: statusCommand uses repositoryRoot instead of workingDirectory, adjust it with relativeRepositoryPath - URI relativeRepositoryPath = GitStatusCommand.getRelativeCWD( logger, fileSet ); + URI relativeRepositoryPath = GitStatusCommand.getRelativeCWD(logger, fileSet); int exitCode; CommandLineUtils.StringStreamConsumer stderr; @@ -79,78 +71,62 @@ protected ScmResult executeAddCommand( ScmProviderRepository repo, ScmFileSet fi // git-add doesn't show single files, but only summary :/ // so we must run git-status and consume the output // borrow a few things from the git-status command - Commandline clStatus = GitStatusCommand.createCommandLine( repository, fileSet ); + Commandline clStatus = GitStatusCommand.createCommandLine(repository, fileSet); - GitStatusConsumer statusConsumer = - new GitStatusConsumer( fileSet.getBasedir(), relativeRepositoryPath ); + GitStatusConsumer statusConsumer = new GitStatusConsumer(fileSet.getBasedir(), relativeRepositoryPath); stderr = new CommandLineUtils.StringStreamConsumer(); - exitCode = GitCommandLineUtils.execute( clStatus, statusConsumer, stderr ); - if ( exitCode != 0 ) - { + exitCode = GitCommandLineUtils.execute(clStatus, statusConsumer, stderr); + if (exitCode != 0) { // git-status returns non-zero if nothing to do - if ( logger.isInfoEnabled() ) - { - logger.info( "nothing added to commit but untracked files present (use \"git add\" to track)" ); + if (logger.isInfoEnabled()) { + logger.info("nothing added to commit but untracked files present (use \"git add\" to track)"); } } List changedFiles = new ArrayList<>(); // rewrite all detected files to now have status 'checked_in' - for ( ScmFile scmfile : statusConsumer.getChangedFiles() ) - { + for (ScmFile scmfile : statusConsumer.getChangedFiles()) { // if a specific fileSet is given, we have to check if the file is really tracked - for ( File f : fileSet.getFileList() ) - { - if ( FilenameUtils.separatorsToUnix( f.getPath() ).equals( scmfile.getPath() ) ) - { - changedFiles.add( scmfile ); + for (File f : fileSet.getFileList()) { + if (FilenameUtils.separatorsToUnix(f.getPath()).equals(scmfile.getPath())) { + changedFiles.add(scmfile); } } } - Commandline cl = createCommandLine( fileSet.getBasedir(), fileSet.getFileList() ); - return new AddScmResult( cl.toString(), changedFiles ); + Commandline cl = createCommandLine(fileSet.getBasedir(), fileSet.getFileList()); + return new AddScmResult(cl.toString(), changedFiles); } - public static Commandline createCommandLine( File workingDirectory, List files ) - throws ScmException - { - Commandline cl = GitCommandLineUtils.getBaseGitCommandLine( workingDirectory, "add" ); + public static Commandline createCommandLine(File workingDirectory, List files) throws ScmException { + Commandline cl = GitCommandLineUtils.getBaseGitCommandLine(workingDirectory, "add"); // use this separator to make clear that the following parameters are files and not revision info. - cl.createArg().setValue( "--" ); + cl.createArg().setValue("--"); - GitCommandLineUtils.addTarget( cl, files ); + GitCommandLineUtils.addTarget(cl, files); return cl; } - private AddScmResult executeAddFileSet( ScmFileSet fileSet ) - throws ScmException - { + private AddScmResult executeAddFileSet(ScmFileSet fileSet) throws ScmException { File workingDirectory = fileSet.getBasedir(); List files = fileSet.getFileList(); // command line can be too long for windows so add files individually (see SCM-697) - if ( Os.isFamily( Os.FAMILY_WINDOWS ) ) - { - for ( File file : files ) - { - AddScmResult result = executeAddFiles( workingDirectory, Collections.singletonList( file ) ); - - if ( result != null ) - { + if (Os.isFamily(Os.FAMILY_WINDOWS)) { + for (File file : files) { + AddScmResult result = executeAddFiles(workingDirectory, Collections.singletonList(file)); + + if (result != null) { return result; } } - } - else - { - AddScmResult result = executeAddFiles( workingDirectory, files ); + } else { + AddScmResult result = executeAddFiles(workingDirectory, files); - if ( result != null ) - { + if (result != null) { return result; } } @@ -158,19 +134,16 @@ private AddScmResult executeAddFileSet( ScmFileSet fileSet ) return null; } - private AddScmResult executeAddFiles( File workingDirectory, List files ) - throws ScmException - { - Commandline cl = createCommandLine( workingDirectory, files ); + private AddScmResult executeAddFiles(File workingDirectory, List files) throws ScmException { + Commandline cl = createCommandLine(workingDirectory, files); CommandLineUtils.StringStreamConsumer stderr = new CommandLineUtils.StringStreamConsumer(); CommandLineUtils.StringStreamConsumer stdout = new CommandLineUtils.StringStreamConsumer(); - int exitCode = GitCommandLineUtils.execute( cl, stdout, stderr ); + int exitCode = GitCommandLineUtils.execute(cl, stdout, stderr); - if ( exitCode != 0 ) - { - return new AddScmResult( cl.toString(), "The git-add command failed.", stderr.getOutput(), false ); + if (exitCode != 0) { + return new AddScmResult(cl.toString(), "The git-add command failed.", stderr.getOutput(), false); } return null; diff --git a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/main/java/org/apache/maven/scm/provider/git/gitexe/command/blame/GitBlameCommand.java b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/main/java/org/apache/maven/scm/provider/git/gitexe/command/blame/GitBlameCommand.java index 284439a59..b6b8350be 100644 --- a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/main/java/org/apache/maven/scm/provider/git/gitexe/command/blame/GitBlameCommand.java +++ b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/main/java/org/apache/maven/scm/provider/git/gitexe/command/blame/GitBlameCommand.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.git.gitexe.command.blame; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,9 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider.git.gitexe.command.blame; + +import java.io.File; import org.apache.maven.scm.CommandParameter; import org.apache.maven.scm.CommandParameters; @@ -32,58 +33,49 @@ import org.codehaus.plexus.util.cli.CommandLineUtils; import org.codehaus.plexus.util.cli.Commandline; -import java.io.File; - /** * @author Evgeny Mandrikov * @author Olivier Lamy * @since 1.4 */ -public class GitBlameCommand - extends AbstractBlameCommand - implements GitCommand -{ +public class GitBlameCommand extends AbstractBlameCommand implements GitCommand { @Override - protected ScmResult executeCommand( ScmProviderRepository repository, ScmFileSet workingDirectory, - CommandParameters parameters ) - throws ScmException - { - String filename = parameters.getString( CommandParameter.FILE ); - Commandline cl = createCommandLine( workingDirectory.getBasedir(), filename, - parameters.getBoolean( CommandParameter.IGNORE_WHITESPACE, false ) ); + protected ScmResult executeCommand( + ScmProviderRepository repository, ScmFileSet workingDirectory, CommandParameters parameters) + throws ScmException { + String filename = parameters.getString(CommandParameter.FILE); + Commandline cl = createCommandLine( + workingDirectory.getBasedir(), + filename, + parameters.getBoolean(CommandParameter.IGNORE_WHITESPACE, false)); GitBlameConsumer consumer = new GitBlameConsumer(); CommandLineUtils.StringStreamConsumer stderr = new CommandLineUtils.StringStreamConsumer(); - int exitCode = GitCommandLineUtils.execute( cl, consumer, stderr ); - if ( exitCode != 0 ) - { - return new BlameScmResult( cl.toString(), "The git blame command failed.", stderr.getOutput(), false ); + int exitCode = GitCommandLineUtils.execute(cl, consumer, stderr); + if (exitCode != 0) { + return new BlameScmResult(cl.toString(), "The git blame command failed.", stderr.getOutput(), false); } - return new BlameScmResult( cl.toString(), consumer.getLines() ); + return new BlameScmResult(cl.toString(), consumer.getLines()); } /** * {@inheritDoc} */ - public BlameScmResult executeBlameCommand( ScmProviderRepository repo, ScmFileSet workingDirectory, - String filename ) - throws ScmException - { + public BlameScmResult executeBlameCommand(ScmProviderRepository repo, ScmFileSet workingDirectory, String filename) + throws ScmException { CommandParameters commandParameters = new CommandParameters(); - commandParameters.setString( CommandParameter.FILE, filename ); - commandParameters.setString( CommandParameter.IGNORE_WHITESPACE, Boolean.FALSE.toString() ); - return (BlameScmResult) execute( repo, workingDirectory, commandParameters ); + commandParameters.setString(CommandParameter.FILE, filename); + commandParameters.setString(CommandParameter.IGNORE_WHITESPACE, Boolean.FALSE.toString()); + return (BlameScmResult) execute(repo, workingDirectory, commandParameters); } - protected static Commandline createCommandLine( File workingDirectory, String filename, boolean ignoreWhitespace ) - { - Commandline cl = GitCommandLineUtils.getBaseGitCommandLine( workingDirectory, "blame" ); - cl.createArg().setValue( "--porcelain" ); - cl.createArg().setValue( filename ); - if ( ignoreWhitespace ) - { - cl.createArg().setValue( "-w" ); + protected static Commandline createCommandLine(File workingDirectory, String filename, boolean ignoreWhitespace) { + Commandline cl = GitCommandLineUtils.getBaseGitCommandLine(workingDirectory, "blame"); + cl.createArg().setValue("--porcelain"); + cl.createArg().setValue(filename); + if (ignoreWhitespace) { + cl.createArg().setValue("-w"); } return cl; } diff --git a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/main/java/org/apache/maven/scm/provider/git/gitexe/command/blame/GitBlameConsumer.java b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/main/java/org/apache/maven/scm/provider/git/gitexe/command/blame/GitBlameConsumer.java index ad32a36de..7e269a200 100644 --- a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/main/java/org/apache/maven/scm/provider/git/gitexe/command/blame/GitBlameConsumer.java +++ b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/main/java/org/apache/maven/scm/provider/git/gitexe/command/blame/GitBlameConsumer.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.git.gitexe.command.blame; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,9 +16,7 @@ * specific language governing permissions and limitations * under the License. */ - -import org.apache.maven.scm.command.blame.BlameLine; -import org.apache.maven.scm.util.AbstractConsumer; +package org.apache.maven.scm.provider.git.gitexe.command.blame; import java.text.DateFormat; import java.text.SimpleDateFormat; @@ -30,6 +26,9 @@ import java.util.List; import java.util.Map; +import org.apache.maven.scm.command.blame.BlameLine; +import org.apache.maven.scm.util.AbstractConsumer; + /** * Parses the --porcelain format of git-blame * @@ -42,14 +41,11 @@ * @author Mark Struberg * @since 1.4 */ -public class GitBlameConsumer - extends AbstractConsumer -{ +public class GitBlameConsumer extends AbstractConsumer { private static final String GIT_COMMITTER_PREFIX = "committer"; - private static final String GIT_COMMITTER = GIT_COMMITTER_PREFIX + " "; + private static final String GIT_COMMITTER = GIT_COMMITTER_PREFIX + " "; private static final String GIT_COMMITTER_TIME = GIT_COMMITTER_PREFIX + "-time "; - private static final String GIT_AUTHOR = "author "; - + private static final String GIT_AUTHOR = "author "; private final List lines = new ArrayList<>(); @@ -65,86 +61,71 @@ public class GitBlameConsumer private boolean expectRevisionLine = true; - private String revision = null; - private String author = null; + private String revision = null; + private String author = null; private String committer = null; - private Date time = null; + private Date time = null; - public void consumeLine( String line ) - { - if ( line == null ) - { + public void consumeLine(String line) { + if (line == null) { return; } - if ( expectRevisionLine ) - { + if (expectRevisionLine) { // this is the revision line - String parts[] = line.split( "\\s", 4 ); + String parts[] = line.split("\\s", 4); - if ( parts.length >= 1 ) - { + if (parts.length >= 1) { revision = parts[0]; - BlameLine oldLine = commitInfo.get( revision ); + BlameLine oldLine = commitInfo.get(revision); - if ( oldLine != null ) - { + if (oldLine != null) { // restore the commit info - author = oldLine.getAuthor(); + author = oldLine.getAuthor(); committer = oldLine.getCommitter(); - time = oldLine.getDate(); + time = oldLine.getDate(); } expectRevisionLine = false; } - } - else - { - if ( line.startsWith( GIT_AUTHOR ) ) - { - author = line.substring( GIT_AUTHOR.length() ); + } else { + if (line.startsWith(GIT_AUTHOR)) { + author = line.substring(GIT_AUTHOR.length()); return; } - if ( line.startsWith( GIT_COMMITTER ) ) - { - committer = line.substring( GIT_COMMITTER.length() ); + if (line.startsWith(GIT_COMMITTER)) { + committer = line.substring(GIT_COMMITTER.length()); return; } - if ( line.startsWith( GIT_COMMITTER_TIME ) ) - { - String timeStr = line.substring( GIT_COMMITTER_TIME.length() ); - time = new Date( Long.parseLong( timeStr ) * 1000L ); + if (line.startsWith(GIT_COMMITTER_TIME)) { + String timeStr = line.substring(GIT_COMMITTER_TIME.length()); + time = new Date(Long.parseLong(timeStr) * 1000L); return; } - - if ( line.startsWith( "\t" ) ) - { + if (line.startsWith("\t")) { // this is the content line. // we actually don't need the content, but this is the right time to add the blame line - BlameLine blameLine = new BlameLine( time, revision, author, committer ); - getLines().add( blameLine ); + BlameLine blameLine = new BlameLine(time, revision, author, committer); + getLines().add(blameLine); // keep commitinfo for this sha-1 - commitInfo.put( revision, blameLine ); + commitInfo.put(revision, blameLine); - if ( logger.isDebugEnabled() ) - { + if (logger.isDebugEnabled()) { DateFormat df = SimpleDateFormat.getDateTimeInstance(); - logger.debug( author + " " + df.format( time ) ); + logger.debug(author + " " + df.format(time)); } expectRevisionLine = true; } - } } - public List getLines() - { + public List getLines() { return lines; } } diff --git a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/main/java/org/apache/maven/scm/provider/git/gitexe/command/branch/GitBranchCommand.java b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/main/java/org/apache/maven/scm/provider/git/gitexe/command/branch/GitBranchCommand.java index 7575df06d..628466b8a 100644 --- a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/main/java/org/apache/maven/scm/provider/git/gitexe/command/branch/GitBranchCommand.java +++ b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/main/java/org/apache/maven/scm/provider/git/gitexe/command/branch/GitBranchCommand.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.git.gitexe.command.branch; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,9 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider.git.gitexe.command.branch; + +import java.io.File; import org.apache.maven.scm.ScmException; import org.apache.maven.scm.ScmFileSet; @@ -27,127 +28,108 @@ import org.apache.maven.scm.command.branch.BranchScmResult; import org.apache.maven.scm.provider.ScmProviderRepository; import org.apache.maven.scm.provider.git.command.GitCommand; -import org.apache.maven.scm.provider.git.repository.GitScmProviderRepository; import org.apache.maven.scm.provider.git.gitexe.command.GitCommandLineUtils; import org.apache.maven.scm.provider.git.gitexe.command.list.GitListCommand; import org.apache.maven.scm.provider.git.gitexe.command.list.GitListConsumer; +import org.apache.maven.scm.provider.git.repository.GitScmProviderRepository; import org.codehaus.plexus.util.StringUtils; import org.codehaus.plexus.util.cli.CommandLineUtils; import org.codehaus.plexus.util.cli.Commandline; -import java.io.File; - /** * @author Mark Struberg * */ -public class GitBranchCommand - extends AbstractBranchCommand - implements GitCommand -{ +public class GitBranchCommand extends AbstractBranchCommand implements GitCommand { /** {@inheritDoc} */ - public ScmResult executeBranchCommand( ScmProviderRepository repo, ScmFileSet fileSet, String branch, - String message ) - throws ScmException - { - if ( branch == null || StringUtils.isEmpty( branch.trim() ) ) - { - throw new ScmException( "branch name must be specified" ); + public ScmResult executeBranchCommand(ScmProviderRepository repo, ScmFileSet fileSet, String branch, String message) + throws ScmException { + if (branch == null || StringUtils.isEmpty(branch.trim())) { + throw new ScmException("branch name must be specified"); } - if ( !fileSet.getFileList().isEmpty() ) - { - throw new ScmException( "This provider doesn't support branching subsets of a directory" ); + if (!fileSet.getFileList().isEmpty()) { + throw new ScmException("This provider doesn't support branching subsets of a directory"); } GitScmProviderRepository repository = (GitScmProviderRepository) repo; - Commandline cl = createCommandLine( repository, fileSet.getBasedir(), branch ); + Commandline cl = createCommandLine(repository, fileSet.getBasedir(), branch); CommandLineUtils.StringStreamConsumer stdout = new CommandLineUtils.StringStreamConsumer(); CommandLineUtils.StringStreamConsumer stderr = new CommandLineUtils.StringStreamConsumer(); int exitCode; - exitCode = GitCommandLineUtils.execute( cl, stdout, stderr ); - if ( exitCode != 0 ) - { - return new BranchScmResult( cl.toString(), "The git-branch command failed.", stderr.getOutput(), false ); + exitCode = GitCommandLineUtils.execute(cl, stdout, stderr); + if (exitCode != 0) { + return new BranchScmResult(cl.toString(), "The git-branch command failed.", stderr.getOutput(), false); } - if ( repo.isPushChanges() ) - { + if (repo.isPushChanges()) { // and now push the branch to the upstream repository - Commandline clPush = createPushCommandLine( repository, fileSet, branch ); + Commandline clPush = createPushCommandLine(repository, fileSet, branch); - exitCode = GitCommandLineUtils.execute( clPush, stdout, stderr ); - if ( exitCode != 0 ) - { - return new BranchScmResult( clPush.toString(), "The git-push command failed.", stderr.getOutput(), - false ); + exitCode = GitCommandLineUtils.execute(clPush, stdout, stderr); + if (exitCode != 0) { + return new BranchScmResult( + clPush.toString(), "The git-push command failed.", stderr.getOutput(), false); } } // as last action we search for the branched files - GitListConsumer listConsumer = new GitListConsumer( fileSet.getBasedir(), ScmFileStatus.TAGGED ); + GitListConsumer listConsumer = new GitListConsumer(fileSet.getBasedir(), ScmFileStatus.TAGGED); - Commandline clList = GitListCommand.createCommandLine( repository, fileSet.getBasedir() ); + Commandline clList = GitListCommand.createCommandLine(repository, fileSet.getBasedir()); - exitCode = GitCommandLineUtils.execute( clList, listConsumer, stderr ); - if ( exitCode != 0 ) - { - return new BranchScmResult( clList.toString(), "The git-ls-files command failed.", stderr.getOutput(), - false ); + exitCode = GitCommandLineUtils.execute(clList, listConsumer, stderr); + if (exitCode != 0) { + return new BranchScmResult( + clList.toString(), "The git-ls-files command failed.", stderr.getOutput(), false); } - return new BranchScmResult( cl.toString(), listConsumer.getListedFiles() ); + return new BranchScmResult(cl.toString(), listConsumer.getListedFiles()); } // ---------------------------------------------------------------------- // // ---------------------------------------------------------------------- - public static Commandline createCommandLine( GitScmProviderRepository repository, File workingDirectory, - String branch ) - { - Commandline cl = GitCommandLineUtils.getBaseGitCommandLine( workingDirectory, "branch" ); + public static Commandline createCommandLine( + GitScmProviderRepository repository, File workingDirectory, String branch) { + Commandline cl = GitCommandLineUtils.getBaseGitCommandLine(workingDirectory, "branch"); - cl.createArg().setValue( branch ); + cl.createArg().setValue(branch); return cl; } - public static Commandline createPushCommandLine( GitScmProviderRepository repository, ScmFileSet fileSet, - String branch ) - throws ScmException - { - Commandline cl = GitCommandLineUtils.getBaseGitCommandLine( fileSet.getBasedir(), "push" ); + public static Commandline createPushCommandLine( + GitScmProviderRepository repository, ScmFileSet fileSet, String branch) throws ScmException { + Commandline cl = GitCommandLineUtils.getBaseGitCommandLine(fileSet.getBasedir(), "push"); - cl.createArg().setValue( repository.getPushUrl() ); - cl.createArg().setValue( "refs/heads/" + branch ); + cl.createArg().setValue(repository.getPushUrl()); + cl.createArg().setValue("refs/heads/" + branch); return cl; } /** - * Helper function to detect the current branch + * Helper function to detect the current branch */ - public static String getCurrentBranch( GitScmProviderRepository repository, ScmFileSet fileSet ) - throws ScmException - { - Commandline cl = GitCommandLineUtils.getBaseGitCommandLine( fileSet.getBasedir(), "symbolic-ref" ); - cl.createArg().setValue( "HEAD" ); + public static String getCurrentBranch(GitScmProviderRepository repository, ScmFileSet fileSet) throws ScmException { + Commandline cl = GitCommandLineUtils.getBaseGitCommandLine(fileSet.getBasedir(), "symbolic-ref"); + cl.createArg().setValue("HEAD"); CommandLineUtils.StringStreamConsumer stderr = new CommandLineUtils.StringStreamConsumer(); GitCurrentBranchConsumer cbConsumer = new GitCurrentBranchConsumer(); int exitCode; - exitCode = GitCommandLineUtils.execute( cl, cbConsumer, stderr ); + exitCode = GitCommandLineUtils.execute(cl, cbConsumer, stderr); - if ( exitCode != 0 ) - { - throw new ScmException( "Detecting the current branch failed: " + stderr.getOutput() ); + if (exitCode != 0) { + throw new ScmException("Detecting the current branch failed: " + stderr.getOutput()); } - + return cbConsumer.getBranchName(); } } diff --git a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/main/java/org/apache/maven/scm/provider/git/gitexe/command/branch/GitCurrentBranchConsumer.java b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/main/java/org/apache/maven/scm/provider/git/gitexe/command/branch/GitCurrentBranchConsumer.java index 6008edc10..d56a16bea 100644 --- a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/main/java/org/apache/maven/scm/provider/git/gitexe/command/branch/GitCurrentBranchConsumer.java +++ b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/main/java/org/apache/maven/scm/provider/git/gitexe/command/branch/GitCurrentBranchConsumer.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.git.gitexe.command.branch; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider.git.gitexe.command.branch; import org.apache.maven.scm.util.AbstractConsumer; @@ -27,16 +26,13 @@ * @author Mark Struberg * */ -public class GitCurrentBranchConsumer - extends AbstractConsumer -{ - +public class GitCurrentBranchConsumer extends AbstractConsumer { + private static final String BRANCH_INDICATOR = "refs/heads/"; - + private String branch; - public String getBranchName() - { + public String getBranchName() { return branch; } @@ -45,14 +41,11 @@ public String getBranchName() // ---------------------------------------------------------------------- /** {@inheritDoc} */ - public void consumeLine( String line ) - { + public void consumeLine(String line) { line = line.trim(); - - if ( line.startsWith( BRANCH_INDICATOR ) ) - { - branch = line.substring( BRANCH_INDICATOR.length() ); + + if (line.startsWith(BRANCH_INDICATOR)) { + branch = line.substring(BRANCH_INDICATOR.length()); } } - } diff --git a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/main/java/org/apache/maven/scm/provider/git/gitexe/command/changelog/GitChangeLogCommand.java b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/main/java/org/apache/maven/scm/provider/git/gitexe/command/changelog/GitChangeLogCommand.java index e8670b8ae..259b24d8e 100644 --- a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/main/java/org/apache/maven/scm/provider/git/gitexe/command/changelog/GitChangeLogCommand.java +++ b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/main/java/org/apache/maven/scm/provider/git/gitexe/command/changelog/GitChangeLogCommand.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.git.gitexe.command.changelog; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,10 +16,19 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider.git.gitexe.command.changelog; +import java.io.File; +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.TimeZone; + +import org.apache.maven.scm.CommandParameter; +import org.apache.maven.scm.CommandParameters; import org.apache.maven.scm.ScmBranch; import org.apache.maven.scm.ScmException; import org.apache.maven.scm.ScmFileSet; +import org.apache.maven.scm.ScmResult; import org.apache.maven.scm.ScmVersion; import org.apache.maven.scm.command.changelog.AbstractChangeLogCommand; import org.apache.maven.scm.command.changelog.ChangeLogScmRequest; @@ -29,139 +36,162 @@ import org.apache.maven.scm.command.changelog.ChangeLogSet; import org.apache.maven.scm.provider.ScmProviderRepository; import org.apache.maven.scm.provider.git.command.GitCommand; -import org.apache.maven.scm.provider.git.repository.GitScmProviderRepository; import org.apache.maven.scm.provider.git.gitexe.command.GitCommandLineUtils; +import org.apache.maven.scm.provider.git.repository.GitScmProviderRepository; import org.codehaus.plexus.util.StringUtils; import org.codehaus.plexus.util.cli.CommandLineUtils; import org.codehaus.plexus.util.cli.Commandline; -import java.io.File; -import java.text.SimpleDateFormat; -import java.util.Date; -import java.util.TimeZone; -import org.apache.maven.scm.CommandParameter; -import org.apache.maven.scm.CommandParameters; -import org.apache.maven.scm.ScmResult; - /** * @author Emmanuel Venisse * @author Olivier Lamy * */ -public class GitChangeLogCommand - extends AbstractChangeLogCommand - implements GitCommand -{ +public class GitChangeLogCommand extends AbstractChangeLogCommand implements GitCommand { private static final String DATE_FORMAT = "yyyy-MM-dd HH:mm:ss Z"; @Override - public ScmResult executeCommand( ScmProviderRepository repository, ScmFileSet fileSet, - CommandParameters parameters ) - throws ScmException - { - return executeChangeLogCommand( repository, fileSet, - parameters.getDate( CommandParameter.START_DATE, null ), - parameters.getDate( CommandParameter.END_DATE, null ), - (ScmBranch) parameters.getScmVersion( CommandParameter.BRANCH, null ), - parameters.getString( CommandParameter.CHANGELOG_DATE_PATTERN, null ), - parameters.getScmVersion( CommandParameter.START_SCM_VERSION, null ), - parameters.getScmVersion( CommandParameter.END_SCM_VERSION, null ), - parameters.getInt( CommandParameter.LIMIT, -1 ), - parameters.getScmVersion( CommandParameter.SCM_VERSION, null ) ); + public ScmResult executeCommand(ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters) + throws ScmException { + return executeChangeLogCommand( + repository, + fileSet, + parameters.getDate(CommandParameter.START_DATE, null), + parameters.getDate(CommandParameter.END_DATE, null), + (ScmBranch) parameters.getScmVersion(CommandParameter.BRANCH, null), + parameters.getString(CommandParameter.CHANGELOG_DATE_PATTERN, null), + parameters.getScmVersion(CommandParameter.START_SCM_VERSION, null), + parameters.getScmVersion(CommandParameter.END_SCM_VERSION, null), + parameters.getInt(CommandParameter.LIMIT, -1), + parameters.getScmVersion(CommandParameter.SCM_VERSION, null)); } /** {@inheritDoc} */ @Override - protected ChangeLogScmResult executeChangeLogCommand( ScmProviderRepository repo, ScmFileSet fileSet, - ScmVersion startVersion, ScmVersion endVersion, - String datePattern ) - throws ScmException - { - return executeChangeLogCommand( repo, fileSet, null, null, null, datePattern, startVersion, endVersion ); + protected ChangeLogScmResult executeChangeLogCommand( + ScmProviderRepository repo, + ScmFileSet fileSet, + ScmVersion startVersion, + ScmVersion endVersion, + String datePattern) + throws ScmException { + return executeChangeLogCommand(repo, fileSet, null, null, null, datePattern, startVersion, endVersion); } /** {@inheritDoc} */ @Override - protected ChangeLogScmResult executeChangeLogCommand( ScmProviderRepository repo, ScmFileSet fileSet, - Date startDate, Date endDate, ScmBranch branch, - String datePattern ) - throws ScmException - { - return executeChangeLogCommand( repo, fileSet, startDate, endDate, branch, datePattern, null, null ); + protected ChangeLogScmResult executeChangeLogCommand( + ScmProviderRepository repo, + ScmFileSet fileSet, + Date startDate, + Date endDate, + ScmBranch branch, + String datePattern) + throws ScmException { + return executeChangeLogCommand(repo, fileSet, startDate, endDate, branch, datePattern, null, null); } @Override - protected ChangeLogScmResult executeChangeLogCommand( ScmProviderRepository repository, ScmFileSet fileSet, - ScmVersion version, String datePattern ) - throws ScmException - { - return executeChangeLogCommand( repository, fileSet, null, null, null, datePattern, null, null, null, version ); + protected ChangeLogScmResult executeChangeLogCommand( + ScmProviderRepository repository, ScmFileSet fileSet, ScmVersion version, String datePattern) + throws ScmException { + return executeChangeLogCommand(repository, fileSet, null, null, null, datePattern, null, null, null, version); } - protected ChangeLogScmResult executeChangeLogCommand( ScmProviderRepository repo, ScmFileSet fileSet, - Date startDate, Date endDate, ScmBranch branch, - String datePattern, ScmVersion startVersion, - ScmVersion endVersion ) - throws ScmException - { - return executeChangeLogCommand( repo, fileSet, startDate, endDate, branch, datePattern, startVersion, - endVersion, null, null ); + protected ChangeLogScmResult executeChangeLogCommand( + ScmProviderRepository repo, + ScmFileSet fileSet, + Date startDate, + Date endDate, + ScmBranch branch, + String datePattern, + ScmVersion startVersion, + ScmVersion endVersion) + throws ScmException { + return executeChangeLogCommand( + repo, fileSet, startDate, endDate, branch, datePattern, startVersion, endVersion, null, null); } @Override - protected ChangeLogScmResult executeChangeLogCommand( ChangeLogScmRequest request ) - throws ScmException - { + protected ChangeLogScmResult executeChangeLogCommand(ChangeLogScmRequest request) throws ScmException { final ScmVersion startVersion = request.getStartRevision(); final ScmVersion endVersion = request.getEndRevision(); final ScmVersion revision = request.getRevision(); final ScmFileSet fileSet = request.getScmFileSet(); final String datePattern = request.getDatePattern(); - final ScmProviderRepository providerRepository = request.getScmRepository().getProviderRepository(); + final ScmProviderRepository providerRepository = + request.getScmRepository().getProviderRepository(); final Date startDate = request.getStartDate(); final Date endDate = request.getEndDate(); final ScmBranch branch = request.getScmBranch(); final Integer limit = request.getLimit(); - return executeChangeLogCommand( providerRepository, fileSet, startDate, endDate, branch, datePattern, - startVersion, endVersion, limit, revision ); + return executeChangeLogCommand( + providerRepository, + fileSet, + startDate, + endDate, + branch, + datePattern, + startVersion, + endVersion, + limit, + revision); } - protected ChangeLogScmResult executeChangeLogCommand( ScmProviderRepository repo, ScmFileSet fileSet, - Date startDate, Date endDate, ScmBranch branch, - String datePattern, ScmVersion startVersion, - ScmVersion endVersion, Integer limit ) - throws ScmException - { - return executeChangeLogCommand( repo, fileSet, startDate, endDate, branch, datePattern, - startVersion, endVersion, limit, null ); + protected ChangeLogScmResult executeChangeLogCommand( + ScmProviderRepository repo, + ScmFileSet fileSet, + Date startDate, + Date endDate, + ScmBranch branch, + String datePattern, + ScmVersion startVersion, + ScmVersion endVersion, + Integer limit) + throws ScmException { + return executeChangeLogCommand( + repo, fileSet, startDate, endDate, branch, datePattern, startVersion, endVersion, limit, null); } - protected ChangeLogScmResult executeChangeLogCommand( ScmProviderRepository repo, ScmFileSet fileSet, - Date startDate, Date endDate, ScmBranch branch, - String datePattern, ScmVersion startVersion, - ScmVersion endVersion, Integer limit, ScmVersion version ) - throws ScmException - { - Commandline cl = createCommandLine( (GitScmProviderRepository) repo, fileSet.getBasedir(), branch, startDate, - endDate, startVersion, endVersion, limit, version ); - - GitChangeLogConsumer consumer = new GitChangeLogConsumer( datePattern ); + protected ChangeLogScmResult executeChangeLogCommand( + ScmProviderRepository repo, + ScmFileSet fileSet, + Date startDate, + Date endDate, + ScmBranch branch, + String datePattern, + ScmVersion startVersion, + ScmVersion endVersion, + Integer limit, + ScmVersion version) + throws ScmException { + Commandline cl = createCommandLine( + (GitScmProviderRepository) repo, + fileSet.getBasedir(), + branch, + startDate, + endDate, + startVersion, + endVersion, + limit, + version); + + GitChangeLogConsumer consumer = new GitChangeLogConsumer(datePattern); CommandLineUtils.StringStreamConsumer stderr = new CommandLineUtils.StringStreamConsumer(); int exitCode; - exitCode = GitCommandLineUtils.execute( cl, consumer, stderr ); - if ( exitCode != 0 ) - { - return new ChangeLogScmResult( cl.toString(), "The git-log command failed.", stderr.getOutput(), false ); + exitCode = GitCommandLineUtils.execute(cl, consumer, stderr); + if (exitCode != 0) { + return new ChangeLogScmResult(cl.toString(), "The git-log command failed.", stderr.getOutput(), false); } - ChangeLogSet changeLogSet = new ChangeLogSet( consumer.getModifications(), startDate, endDate ); - changeLogSet.setStartVersion( startVersion ); - changeLogSet.setEndVersion( endVersion ); + ChangeLogSet changeLogSet = new ChangeLogSet(consumer.getModifications(), startDate, endDate); + changeLogSet.setStartVersion(startVersion); + changeLogSet.setEndVersion(endVersion); - return new ChangeLogScmResult( cl.toString(), changeLogSet ); + return new ChangeLogScmResult(cl.toString(), changeLogSet); } // ---------------------------------------------------------------------- @@ -172,7 +202,7 @@ protected ChangeLogScmResult executeChangeLogCommand( ScmProviderRepository repo * This method creates the commandline for the git-whatchanged command. *

* Since it uses --since and --until for the start and end date, the branch - * and version parameters can be used simultanously. + * and version parameters can be used simultanously. * * @param repository Provider repositry to use. * @param workingDirectory Working copy directory. @@ -183,96 +213,99 @@ protected ChangeLogScmResult executeChangeLogCommand( ScmProviderRepository repo * @param endVersion End version of log entries. * @return Command line. */ - public static Commandline createCommandLine( GitScmProviderRepository repository, File workingDirectory, - ScmBranch branch, Date startDate, Date endDate, - ScmVersion startVersion, ScmVersion endVersion ) - { - return createCommandLine( repository, workingDirectory, branch, startDate, endDate, startVersion, endVersion, - null ); + public static Commandline createCommandLine( + GitScmProviderRepository repository, + File workingDirectory, + ScmBranch branch, + Date startDate, + Date endDate, + ScmVersion startVersion, + ScmVersion endVersion) { + return createCommandLine( + repository, workingDirectory, branch, startDate, endDate, startVersion, endVersion, null); } - static Commandline createCommandLine( GitScmProviderRepository repository, File workingDirectory, - ScmBranch branch, Date startDate, Date endDate, - ScmVersion startVersion, ScmVersion endVersion, Integer limit ) - { - return createCommandLine( repository, workingDirectory, branch, startDate, endDate, startVersion, endVersion, - limit, null ); + static Commandline createCommandLine( + GitScmProviderRepository repository, + File workingDirectory, + ScmBranch branch, + Date startDate, + Date endDate, + ScmVersion startVersion, + ScmVersion endVersion, + Integer limit) { + return createCommandLine( + repository, workingDirectory, branch, startDate, endDate, startVersion, endVersion, limit, null); } - static Commandline createCommandLine( GitScmProviderRepository repository, File workingDirectory, - ScmBranch branch, Date startDate, Date endDate, - ScmVersion startVersion, ScmVersion endVersion, Integer limit, - ScmVersion version ) - { - SimpleDateFormat dateFormat = new SimpleDateFormat( DATE_FORMAT ); - dateFormat.setTimeZone( TimeZone.getTimeZone( "GMT" ) ); - - Commandline cl = GitCommandLineUtils.getBaseGitCommandLine( workingDirectory, "whatchanged" ); - cl.createArg().setValue( "--format=medium" ); - cl.createArg().setValue( "--decorate=short" ); - cl.createArg().setValue( "--raw" ); - cl.createArg().setValue( "--no-merges" ); - - if ( startDate != null || endDate != null ) - { - if ( startDate != null ) - { - cl.createArg().setValue( "--since=" + StringUtils.escape( dateFormat.format( startDate ) ) ); + static Commandline createCommandLine( + GitScmProviderRepository repository, + File workingDirectory, + ScmBranch branch, + Date startDate, + Date endDate, + ScmVersion startVersion, + ScmVersion endVersion, + Integer limit, + ScmVersion version) { + SimpleDateFormat dateFormat = new SimpleDateFormat(DATE_FORMAT); + dateFormat.setTimeZone(TimeZone.getTimeZone("GMT")); + + Commandline cl = GitCommandLineUtils.getBaseGitCommandLine(workingDirectory, "whatchanged"); + cl.createArg().setValue("--format=medium"); + cl.createArg().setValue("--decorate=short"); + cl.createArg().setValue("--raw"); + cl.createArg().setValue("--no-merges"); + + if (startDate != null || endDate != null) { + if (startDate != null) { + cl.createArg().setValue("--since=" + StringUtils.escape(dateFormat.format(startDate))); } - if ( endDate != null ) - { - cl.createArg().setValue( "--until=" + StringUtils.escape( dateFormat.format( endDate ) ) ); + if (endDate != null) { + cl.createArg().setValue("--until=" + StringUtils.escape(dateFormat.format(endDate))); } - } // since this parameter is also used for the output formatting, we need it also if no start nor end date is // given - cl.createArg().setValue( "--date=iso" ); + cl.createArg().setValue("--date=iso"); - if ( startVersion != null || endVersion != null ) - { + if (startVersion != null || endVersion != null) { StringBuilder versionRange = new StringBuilder(); - if ( startVersion != null ) - { - versionRange.append( StringUtils.escape( startVersion.getName() ) ); + if (startVersion != null) { + versionRange.append(StringUtils.escape(startVersion.getName())); } - versionRange.append( ".." ); + versionRange.append(".."); - if ( endVersion != null ) - { - versionRange.append( StringUtils.escape( endVersion.getName() ) ); + if (endVersion != null) { + versionRange.append(StringUtils.escape(endVersion.getName())); } - cl.createArg().setValue( versionRange.toString() ); + cl.createArg().setValue(versionRange.toString()); - } - else if ( version != null ) - { - cl.createArg().setValue( StringUtils.escape( version.getName() ) ); + } else if (version != null) { + cl.createArg().setValue(StringUtils.escape(version.getName())); } - if ( limit != null && limit > 0 ) - { - cl.createArg().setValue( "--max-count=" + limit ); + if (limit != null && limit > 0) { + cl.createArg().setValue("--max-count=" + limit); } - if ( branch != null && branch.getName() != null && branch.getName().length() > 0 ) - { - cl.createArg().setValue( branch.getName() ); + if (branch != null && branch.getName() != null && branch.getName().length() > 0) { + cl.createArg().setValue(branch.getName()); } // Insert a separator to make sure that files aren't interpreted as part of the version spec - cl.createArg().setValue( "--" ); - + cl.createArg().setValue("--"); + // We have to report only the changes of the current project. - // This is needed for child projects, otherwise we would get the changelog of the + // This is needed for child projects, otherwise we would get the changelog of the // whole parent-project including all childs. - cl.createArg().setValue( "." ); - + cl.createArg().setValue("."); + return cl; } } diff --git a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/main/java/org/apache/maven/scm/provider/git/gitexe/command/changelog/GitChangeLogConsumer.java b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/main/java/org/apache/maven/scm/provider/git/gitexe/command/changelog/GitChangeLogConsumer.java index 7d0d6e757..cf9acde9e 100644 --- a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/main/java/org/apache/maven/scm/provider/git/gitexe/command/changelog/GitChangeLogConsumer.java +++ b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/main/java/org/apache/maven/scm/provider/git/gitexe/command/changelog/GitChangeLogConsumer.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.git.gitexe.command.changelog; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,11 +16,7 @@ * specific language governing permissions and limitations * under the License. */ - -import org.apache.maven.scm.ChangeFile; -import org.apache.maven.scm.ChangeSet; -import org.apache.maven.scm.ScmFileStatus; -import org.apache.maven.scm.util.AbstractConsumer; +package org.apache.maven.scm.provider.git.gitexe.command.changelog; import java.util.ArrayList; import java.util.Calendar; @@ -33,14 +27,17 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; +import org.apache.maven.scm.ChangeFile; +import org.apache.maven.scm.ChangeSet; +import org.apache.maven.scm.ScmFileStatus; +import org.apache.maven.scm.util.AbstractConsumer; + /** * @author Mark Struberg * @author Olivier Lamy * */ -public class GitChangeLogConsumer - extends AbstractConsumer -{ +public class GitChangeLogConsumer extends AbstractConsumer { /** * Date formatter for git timestamp * we use iso format cli git log --date=iso sample : 2008-08-06 01:37:18 +0200 @@ -95,43 +92,43 @@ public class GitChangeLogConsumer /** * The pattern used to match git header lines */ - private static final Pattern HEADER_PATTERN = Pattern.compile( "^commit ([A-Fa-f0-9]+)(?: \\((.*)\\))?$" ); + private static final Pattern HEADER_PATTERN = Pattern.compile("^commit ([A-Fa-f0-9]+)(?: \\((.*)\\))?$"); /** * The pattern used to match git author lines */ - private static final Pattern AUTHOR_PATTERN = Pattern.compile( "^Author: (.*)" ); + private static final Pattern AUTHOR_PATTERN = Pattern.compile("^Author: (.*)"); /** * The pattern used to match git tree hash lines (raw mode) */ - private static final Pattern RAW_TREE_PATTERN = Pattern.compile( "^tree ([A-Fa-f0-9]+)" ); + private static final Pattern RAW_TREE_PATTERN = Pattern.compile("^tree ([A-Fa-f0-9]+)"); /** * The pattern used to match git parent hash lines (raw mode) */ - private static final Pattern RAW_PARENT_PATTERN = Pattern.compile( "^parent ([A-Fa-f0-9]+)" ); + private static final Pattern RAW_PARENT_PATTERN = Pattern.compile("^parent ([A-Fa-f0-9]+)"); /** * The pattern used to match git author lines (raw mode) */ - private static final Pattern RAW_AUTHOR_PATTERN = Pattern.compile( "^author (.+ <.+>) ([0-9]+) (.*)" ); + private static final Pattern RAW_AUTHOR_PATTERN = Pattern.compile("^author (.+ <.+>) ([0-9]+) (.*)"); /** * The pattern used to match git author lines (raw mode) */ - private static final Pattern RAW_COMMITTER_PATTERN = Pattern.compile( "^committer (.+ <.+>) ([0-9]+) (.*)" ); + private static final Pattern RAW_COMMITTER_PATTERN = Pattern.compile("^committer (.+ <.+>) ([0-9]+) (.*)"); /** * The pattern used to match git date lines */ - private static final Pattern DATE_PATTERN = Pattern.compile( "^Date:\\s*(.*)" ); + private static final Pattern DATE_PATTERN = Pattern.compile("^Date:\\s*(.*)"); /** * The pattern used to match git file lines */ private static final Pattern FILE_PATTERN = - Pattern.compile( "^:\\d* \\d* [A-Fa-f0-9]*\\.* [A-Fa-f0-9]*\\.* ([A-Z])[0-9]*\\t([^\\t]*)(\\t(.*))?" ); + Pattern.compile("^:\\d* \\d* [A-Fa-f0-9]*\\.* [A-Fa-f0-9]*\\.* ([A-Z])[0-9]*\\t([^\\t]*)(\\t(.*))?"); /** * Current status of the parser @@ -163,15 +160,13 @@ public class GitChangeLogConsumer /** * Default constructor. */ - public GitChangeLogConsumer( String userDateFormat ) - { + public GitChangeLogConsumer(String userDateFormat) { this.userDateFormat = userDateFormat; } - public List getModifications() - { + public List getModifications() { // this is needed since the processFile does not always get a the end-sequence correctly. - processGetFile( "" ); + processGetFile(""); return entries; } @@ -183,39 +178,37 @@ public List getModifications() /** * {@inheritDoc} */ - public void consumeLine( String line ) - { - switch ( status ) - { + public void consumeLine(String line) { + switch (status) { case STATUS_GET_HEADER: - processGetHeader( line ); + processGetHeader(line); break; case STATUS_GET_AUTHOR: - processGetAuthor( line ); + processGetAuthor(line); break; case STATUS_GET_DATE: - processGetDate( line, null ); + processGetDate(line, null); break; case STATUS_GET_COMMENT: - processGetComment( line ); + processGetComment(line); break; case STATUS_GET_FILE: - processGetFile( line ); + processGetFile(line); break; case STATUS_RAW_TREE: - processGetRawTree( line ); + processGetRawTree(line); break; case STATUS_RAW_PARENT: - processGetRawParent( line ); + processGetRawParent(line); break; case STATUS_RAW_AUTHOR: - processGetRawAuthor( line ); + processGetRawAuthor(line); break; case STATUS_RAW_COMMITTER: - processGetRawCommitter( line ); + processGetRawCommitter(line); break; default: - throw new IllegalStateException( "Unknown state: " + status ); + throw new IllegalStateException("Unknown state: " + status); } } @@ -232,31 +225,26 @@ public void consumeLine( String line ) * * @param line A line of text from the git log output */ - private void processGetHeader( String line ) - { - Matcher matcher = HEADER_PATTERN.matcher( line ); - if ( !matcher.matches() ) - { + private void processGetHeader(String line) { + Matcher matcher = HEADER_PATTERN.matcher(line); + if (!matcher.matches()) { return; } - currentRevision = matcher.group( 1 ); + currentRevision = matcher.group(1); currentChange = new ChangeSet(); - currentChange.setRevision( currentRevision ); + currentChange.setRevision(currentRevision); // Extract the tags (if present) - String tagList = matcher.group( 2 ); - if ( tagList != null ) - { - String[] rawTags = tagList.split( "," ); - for ( String rawTag : rawTags ) - { - String[] tagParts = rawTag.trim().split( ":" ); - if ( tagParts.length == 2 && "tag".equals( tagParts[0] ) ) - { - currentChange.addTag( tagParts[1].trim() ); + String tagList = matcher.group(2); + if (tagList != null) { + String[] rawTags = tagList.split(","); + for (String rawTag : rawTags) { + String[] tagParts = rawTag.trim().split(":"); + if (tagParts.length == 2 && "tag".equals(tagParts[0])) { + currentChange.addTag(tagParts[1].trim()); } } } @@ -270,24 +258,21 @@ private void processGetHeader( String line ) * * @param line a line of text from the git log output */ - private void processGetAuthor( String line ) - { + private void processGetAuthor(String line) { // this autodetects 'raw' format - if ( RAW_TREE_PATTERN.matcher( line ).matches() ) - { + if (RAW_TREE_PATTERN.matcher(line).matches()) { status = STATUS_RAW_TREE; - processGetRawTree( line ); + processGetRawTree(line); return; } - Matcher matcher = AUTHOR_PATTERN.matcher( line ); - if ( !matcher.matches() ) - { + Matcher matcher = AUTHOR_PATTERN.matcher(line); + if (!matcher.matches()) { return; } - String author = matcher.group( 1 ); + String author = matcher.group(1); - currentChange.setAuthor( author ); + currentChange.setAuthor(author); status = STATUS_GET_DATE; } @@ -298,13 +283,11 @@ private void processGetAuthor( String line ) * * @param line a line of text from the git log output */ - private void processGetRawTree( String line ) - { - if ( !RAW_TREE_PATTERN.matcher( line ).matches() ) - { + private void processGetRawTree(String line) { + if (!RAW_TREE_PATTERN.matcher(line).matches()) { return; } - //here we could set treeHash if it appears in the model: currentChange.setTreeHash( matcher.group( 1 ) ); + // here we could set treeHash if it appears in the model: currentChange.setTreeHash( matcher.group( 1 ) ); status = STATUS_RAW_PARENT; } @@ -314,18 +297,16 @@ private void processGetRawTree( String line ) * * @param line a line of text from the git log output */ - private void processGetRawParent( String line ) - { - Matcher matcher = RAW_PARENT_PATTERN.matcher( line ); - if ( !matcher.matches() ) - { + private void processGetRawParent(String line) { + Matcher matcher = RAW_PARENT_PATTERN.matcher(line); + if (!matcher.matches()) { status = STATUS_RAW_AUTHOR; - processGetRawAuthor( line ); + processGetRawAuthor(line); return; } - String parentHash = matcher.group( 1 ); + String parentHash = matcher.group(1); - addParentRevision( parentHash ); + addParentRevision(parentHash); } /** @@ -334,15 +315,11 @@ private void processGetRawParent( String line ) * * @param hash - */ - private void addParentRevision( String hash ) - { - if ( currentChange.getParentRevision() == null ) - { - currentChange.setParentRevision( hash ); - } - else - { - currentChange.addMergedRevision( hash ); + private void addParentRevision(String hash) { + if (currentChange.getParentRevision() == null) { + currentChange.setParentRevision(hash); + } else { + currentChange.addMergedRevision(hash); } } @@ -352,24 +329,22 @@ private void addParentRevision( String hash ) * * @param line a line of text from the git log output */ - private void processGetRawAuthor( String line ) - { - Matcher matcher = RAW_AUTHOR_PATTERN.matcher( line ); - if ( !matcher.matches() ) - { + private void processGetRawAuthor(String line) { + Matcher matcher = RAW_AUTHOR_PATTERN.matcher(line); + if (!matcher.matches()) { return; } - String author = matcher.group( 1 ); - currentChange.setAuthor( author ); + String author = matcher.group(1); + currentChange.setAuthor(author); - String datestring = matcher.group( 2 ); - String tz = matcher.group( 3 ); + String datestring = matcher.group(2); + String tz = matcher.group(3); // with --format=raw option (which gets us to this methods), date is always in seconds since beginning of time // even explicit --date=iso is ignored, so we ignore both userDateFormat and GIT_TIMESTAMP_PATTERN here - Calendar c = Calendar.getInstance( TimeZone.getTimeZone( tz ) ); - c.setTimeInMillis( Long.parseLong( datestring ) * 1000 ); - currentChange.setDate( c.getTime() ); + Calendar c = Calendar.getInstance(TimeZone.getTimeZone(tz)); + c.setTimeInMillis(Long.parseLong(datestring) * 1000); + currentChange.setDate(c.getTime()); status = STATUS_RAW_COMMITTER; } @@ -380,10 +355,8 @@ private void processGetRawAuthor( String line ) * * @param line a line of text from the git log output */ - private void processGetRawCommitter( String line ) - { - if ( !RAW_COMMITTER_PATTERN.matcher( line ).matches() ) - { + private void processGetRawCommitter(String line) { + if (!RAW_COMMITTER_PATTERN.matcher(line).matches()) { return; } // here we could set committer and committerDate, the same way as in processGetRawAuthor @@ -396,19 +369,17 @@ private void processGetRawCommitter( String line ) * * @param line a line of text from the git log output */ - private void processGetDate( String line, Locale locale ) - { - Matcher matcher = DATE_PATTERN.matcher( line ); - if ( !matcher.matches() ) - { + private void processGetDate(String line, Locale locale) { + Matcher matcher = DATE_PATTERN.matcher(line); + if (!matcher.matches()) { return; } - String datestring = matcher.group( 1 ); + String datestring = matcher.group(1); - Date date = parseDate( datestring.trim(), userDateFormat, GIT_TIMESTAMP_PATTERN, locale ); + Date date = parseDate(datestring.trim(), userDateFormat, GIT_TIMESTAMP_PATTERN, locale); - currentChange.setDate( date ); + currentChange.setDate(date); status = STATUS_GET_COMMENT; } @@ -419,28 +390,20 @@ private void processGetDate( String line, Locale locale ) * * @param line a line of text from the git log output */ - private void processGetComment( String line ) - { - if ( line.length() < 4 ) - { - if ( currentComment == null ) - { + private void processGetComment(String line) { + if (line.length() < 4) { + if (currentComment == null) { currentComment = new StringBuilder(); - } - else - { - currentChange.setComment( currentComment.toString() ); + } else { + currentChange.setComment(currentComment.toString()); status = STATUS_GET_FILE; } - } - else - { - if ( currentComment.length() > 0 ) - { - currentComment.append( '\n' ); + } else { + if (currentComment.length() > 0) { + currentComment.append('\n'); } - currentComment.append( line.substring( 4 ) ); + currentComment.append(line.substring(4)); } } @@ -452,73 +415,55 @@ private void processGetComment( String line ) * * @param line A line of text from the git log output */ - private void processGetFile( String line ) - { - if ( line.length() == 0 ) - { - if ( currentChange != null ) - { - entries.add( currentChange ); + private void processGetFile(String line) { + if (line.length() == 0) { + if (currentChange != null) { + entries.add(currentChange); } resetChangeLog(); status = STATUS_GET_HEADER; - } - else - { - Matcher matcher = FILE_PATTERN.matcher( line ); - if ( !matcher.matches() ) - { + } else { + Matcher matcher = FILE_PATTERN.matcher(line); + if (!matcher.matches()) { return; } - final String actionChar = matcher.group( 1 ); + final String actionChar = matcher.group(1); // action is currently not used final ScmFileStatus action; - String name = matcher.group( 2 ); + String name = matcher.group(2); String originalName = null; String originalRevision = null; - if ( "A".equals( actionChar ) ) - { + if ("A".equals(actionChar)) { action = ScmFileStatus.ADDED; - } - else if ( "M".equals( actionChar ) ) - { + } else if ("M".equals(actionChar)) { action = ScmFileStatus.MODIFIED; - } - else if ( "D".equals( actionChar ) ) - { + } else if ("D".equals(actionChar)) { action = ScmFileStatus.DELETED; - } - else if ( "R".equals( actionChar ) ) - { + } else if ("R".equals(actionChar)) { action = ScmFileStatus.RENAMED; originalName = name; - name = matcher.group( 4 ); + name = matcher.group(4); originalRevision = currentChange.getParentRevision(); - } - else if ( "C".equals( actionChar ) ) - { + } else if ("C".equals(actionChar)) { action = ScmFileStatus.COPIED; originalName = name; - name = matcher.group( 4 ); + name = matcher.group(4); originalRevision = currentChange.getParentRevision(); - } - else - { + } else { action = ScmFileStatus.UNKNOWN; } - final ChangeFile changeFile = new ChangeFile( name, currentRevision ); - changeFile.setAction( action ); - changeFile.setOriginalName( originalName ); - changeFile.setOriginalRevision( originalRevision ); - currentChange.addFile( changeFile ); + final ChangeFile changeFile = new ChangeFile(name, currentRevision); + changeFile.setAction(action); + changeFile.setOriginalName(originalName); + changeFile.setOriginalRevision(originalRevision); + currentChange.addFile(changeFile); } } - private void resetChangeLog() - { + private void resetChangeLog() { currentComment = null; currentChange = null; } diff --git a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/main/java/org/apache/maven/scm/provider/git/gitexe/command/checkin/GitCheckInCommand.java b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/main/java/org/apache/maven/scm/provider/git/gitexe/command/checkin/GitCheckInCommand.java index ee4809cbd..94c166f75 100644 --- a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/main/java/org/apache/maven/scm/provider/git/gitexe/command/checkin/GitCheckInCommand.java +++ b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/main/java/org/apache/maven/scm/provider/git/gitexe/command/checkin/GitCheckInCommand.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.git.gitexe.command.checkin; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider.git.gitexe.command.checkin; import java.io.File; import java.io.IOException; @@ -54,23 +53,17 @@ * @author Olivier Lamy * */ -public class GitCheckInCommand - extends AbstractCheckInCommand - implements GitCommand -{ +public class GitCheckInCommand extends AbstractCheckInCommand implements GitCommand { private final Map environmentVariables; - public GitCheckInCommand( Map environmentVariables ) - { + public GitCheckInCommand(Map environmentVariables) { super(); this.environmentVariables = environmentVariables; } /** {@inheritDoc} */ - protected CheckInScmResult executeCheckInCommand( ScmProviderRepository repo, ScmFileSet fileSet, String message, - ScmVersion version ) - throws ScmException - { + protected CheckInScmResult executeCheckInCommand( + ScmProviderRepository repo, ScmFileSet fileSet, String message, ScmVersion version) throws ScmException { GitScmProviderRepository repository = (GitScmProviderRepository) repo; CommandLineUtils.StringStreamConsumer stderr = new CommandLineUtils.StringStreamConsumer(); @@ -78,200 +71,165 @@ protected CheckInScmResult executeCheckInCommand( ScmProviderRepository repo, Sc int exitCode = -1; - File messageFile = FileUtils.createTempFile( "maven-scm-", ".commit", null ); - try - { - FileUtils.fileWrite( messageFile.getAbsolutePath(), "UTF-8", message ); - } - catch ( IOException ex ) - { - return new CheckInScmResult( null, "Error while making a temporary file for the commit message: " - + ex.getMessage(), null, false ); + File messageFile = FileUtils.createTempFile("maven-scm-", ".commit", null); + try { + FileUtils.fileWrite(messageFile.getAbsolutePath(), "UTF-8", message); + } catch (IOException ex) { + return new CheckInScmResult( + null, + "Error while making a temporary file for the commit message: " + ex.getMessage(), + null, + false); } - try - { - if ( !fileSet.getFileList().isEmpty() ) - { + try { + if (!fileSet.getFileList().isEmpty()) { // if specific fileSet is given, we have to git-add them first // otherwise we will use 'git-commit -a' later Commandline clAdd = null; - //SCM-714: Workaround for the Windows terminal command limit - if ( Os.isFamily( Os.FAMILY_WINDOWS ) ) - { - for ( File file: fileSet.getFileList() ) - { - clAdd = GitAddCommand.createCommandLine( fileSet.getBasedir(), - Collections.singletonList( file ) ); - exitCode = GitCommandLineUtils.execute( clAdd, stdout, stderr ); - - if ( exitCode != 0 ) - { + // SCM-714: Workaround for the Windows terminal command limit + if (Os.isFamily(Os.FAMILY_WINDOWS)) { + for (File file : fileSet.getFileList()) { + clAdd = GitAddCommand.createCommandLine(fileSet.getBasedir(), Collections.singletonList(file)); + exitCode = GitCommandLineUtils.execute(clAdd, stdout, stderr); + + if (exitCode != 0) { break; } } - } - else - { - clAdd = GitAddCommand.createCommandLine( fileSet.getBasedir(), fileSet.getFileList() ); - exitCode = GitCommandLineUtils.execute( clAdd, stdout, stderr ); + } else { + clAdd = GitAddCommand.createCommandLine(fileSet.getBasedir(), fileSet.getFileList()); + exitCode = GitCommandLineUtils.execute(clAdd, stdout, stderr); } - if ( exitCode != 0 ) - { - return new CheckInScmResult( clAdd.toString(), "The git-add command failed.", - stderr.getOutput(), false ); + if (exitCode != 0) { + return new CheckInScmResult( + clAdd.toString(), "The git-add command failed.", stderr.getOutput(), false); } - } // SCM-709: statusCommand uses repositoryRoot instead of workingDirectory, adjust it with // relativeRepositoryPath - URI relativeRepositoryPath = GitStatusCommand.getRelativeCWD( logger, fileSet ); + URI relativeRepositoryPath = GitStatusCommand.getRelativeCWD(logger, fileSet); // git-commit doesn't show single files, but only summary :/ // so we must run git-status and consume the output // borrow a few things from the git-status command - Commandline clStatus = GitStatusCommand.createCommandLine( repository, fileSet ); + Commandline clStatus = GitStatusCommand.createCommandLine(repository, fileSet); GitStatusConsumer statusConsumer = - new GitStatusConsumer( fileSet.getBasedir(), relativeRepositoryPath, fileSet ); - exitCode = GitCommandLineUtils.execute( clStatus, statusConsumer, stderr ); - if ( exitCode != 0 ) - { + new GitStatusConsumer(fileSet.getBasedir(), relativeRepositoryPath, fileSet); + exitCode = GitCommandLineUtils.execute(clStatus, statusConsumer, stderr); + if (exitCode != 0) { // git-status returns non-zero if nothing to do - if ( logger.isInfoEnabled() ) - { - logger.info( "nothing added to commit but untracked files present (use \"git add\" to " - + "track)" ); + if (logger.isInfoEnabled()) { + logger.info("nothing added to commit but untracked files present (use \"git add\" to " + "track)"); } } - if ( statusConsumer.getChangedFiles().isEmpty() ) - { - return new CheckInScmResult( null, statusConsumer.getChangedFiles() ); + if (statusConsumer.getChangedFiles().isEmpty()) { + return new CheckInScmResult(null, statusConsumer.getChangedFiles()); } - Commandline clCommit = createCommitCommandLine( repository, fileSet, messageFile, environmentVariables ); + Commandline clCommit = createCommitCommandLine(repository, fileSet, messageFile, environmentVariables); - exitCode = GitCommandLineUtils.execute( clCommit, stdout, stderr ); - if ( exitCode != 0 ) - { - return new CheckInScmResult( clCommit.toString(), "The git-commit command failed.", stderr.getOutput(), - false ); + exitCode = GitCommandLineUtils.execute(clCommit, stdout, stderr); + if (exitCode != 0) { + return new CheckInScmResult( + clCommit.toString(), "The git-commit command failed.", stderr.getOutput(), false); } - if ( repo.isPushChanges() ) - { - Commandline cl = createPushCommandLine( repository, fileSet, version ); + if (repo.isPushChanges()) { + Commandline cl = createPushCommandLine(repository, fileSet, version); - exitCode = GitCommandLineUtils.execute( cl, stdout, stderr ); - if ( exitCode != 0 ) - { - return new CheckInScmResult( cl.toString(), "The git-push command failed.", stderr.getOutput(), - false ); + exitCode = GitCommandLineUtils.execute(cl, stdout, stderr); + if (exitCode != 0) { + return new CheckInScmResult( + cl.toString(), "The git-push command failed.", stderr.getOutput(), false); } } - List checkedInFiles = new ArrayList<>( statusConsumer.getChangedFiles().size() ); + List checkedInFiles = + new ArrayList<>(statusConsumer.getChangedFiles().size()); // rewrite all detected files to now have status 'checked_in' - for ( ScmFile changedFile : statusConsumer.getChangedFiles() ) - { - ScmFile scmfile = new ScmFile( changedFile.getPath(), ScmFileStatus.CHECKED_IN ); + for (ScmFile changedFile : statusConsumer.getChangedFiles()) { + ScmFile scmfile = new ScmFile(changedFile.getPath(), ScmFileStatus.CHECKED_IN); - if ( fileSet.getFileList().isEmpty() ) - { - checkedInFiles.add( scmfile ); - } - else - { + if (fileSet.getFileList().isEmpty()) { + checkedInFiles.add(scmfile); + } else { // if a specific fileSet is given, we have to check if the file is really tracked - for ( File f : fileSet.getFileList() ) - { - if ( FilenameUtils.separatorsToUnix( f.getPath() ).equals( scmfile.getPath() ) ) - { - checkedInFiles.add( scmfile ); + for (File f : fileSet.getFileList()) { + if (FilenameUtils.separatorsToUnix(f.getPath()).equals(scmfile.getPath())) { + checkedInFiles.add(scmfile); } - } } } - return new CheckInScmResult( clCommit.toString(), checkedInFiles ); - } - finally - { - try - { - FileUtils.forceDelete( messageFile ); - } - catch ( IOException ex ) - { + return new CheckInScmResult(clCommit.toString(), checkedInFiles); + } finally { + try { + FileUtils.forceDelete(messageFile); + } catch (IOException ex) { // ignore } } - } // ---------------------------------------------------------------------- // // ---------------------------------------------------------------------- - public Commandline createPushCommandLine( GitScmProviderRepository repository, - ScmFileSet fileSet, ScmVersion version ) - throws ScmException - { - Commandline cl = GitCommandLineUtils.getBaseGitCommandLine( fileSet.getBasedir(), "push", repository, - environmentVariables ); + public Commandline createPushCommandLine( + GitScmProviderRepository repository, ScmFileSet fileSet, ScmVersion version) throws ScmException { + Commandline cl = GitCommandLineUtils.getBaseGitCommandLine( + fileSet.getBasedir(), "push", repository, environmentVariables); - String branch = GitBranchCommand.getCurrentBranch( repository, fileSet ); + String branch = GitBranchCommand.getCurrentBranch(repository, fileSet); - if ( branch == null || branch.length() == 0 ) - { - throw new ScmException( "Could not detect the current branch. Don't know where I should push to!" ); + if (branch == null || branch.length() == 0) { + throw new ScmException("Could not detect the current branch. Don't know where I should push to!"); } - cl.createArg().setValue( repository.getPushUrl() ); + cl.createArg().setValue(repository.getPushUrl()); - cl.createArg().setValue( "refs/heads/" + branch + ":" + "refs/heads/" + branch ); + cl.createArg().setValue("refs/heads/" + branch + ":" + "refs/heads/" + branch); return cl; } - public static Commandline createCommitCommandLine( GitScmProviderRepository repository, ScmFileSet fileSet, - File messageFile ) - throws ScmException - { - return createCommitCommandLine( repository, fileSet, messageFile, Collections.emptyMap() ); + public static Commandline createCommitCommandLine( + GitScmProviderRepository repository, ScmFileSet fileSet, File messageFile) throws ScmException { + return createCommitCommandLine(repository, fileSet, messageFile, Collections.emptyMap()); } - public static Commandline createCommitCommandLine( GitScmProviderRepository repository, ScmFileSet fileSet, - File messageFile, Map environmentVariables ) - throws ScmException - { - Commandline cl = GitCommandLineUtils.getBaseGitCommandLine( fileSet.getBasedir(), "commit" ); + public static Commandline createCommitCommandLine( + GitScmProviderRepository repository, + ScmFileSet fileSet, + File messageFile, + Map environmentVariables) + throws ScmException { + Commandline cl = GitCommandLineUtils.getBaseGitCommandLine(fileSet.getBasedir(), "commit"); - cl.createArg().setValue( "--verbose" ); + cl.createArg().setValue("--verbose"); - cl.createArg().setValue( "-F" ); + cl.createArg().setValue("-F"); - cl.createArg().setValue( messageFile.getAbsolutePath() ); + cl.createArg().setValue(messageFile.getAbsolutePath()); - if ( fileSet.getFileList().isEmpty() ) - { + if (fileSet.getFileList().isEmpty()) { // commit all tracked files - cl.createArg().setValue( "-a" ); + cl.createArg().setValue("-a"); } - if ( GitUtil.getSettings().isCommitNoVerify() ) - { - cl.createArg().setValue( "--no-verify" ); + if (GitUtil.getSettings().isCommitNoVerify()) { + cl.createArg().setValue("--no-verify"); } return cl; } - } diff --git a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/main/java/org/apache/maven/scm/provider/git/gitexe/command/checkout/GitCheckOutCommand.java b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/main/java/org/apache/maven/scm/provider/git/gitexe/command/checkout/GitCheckOutCommand.java index 74a06173a..5eee34e75 100644 --- a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/main/java/org/apache/maven/scm/provider/git/gitexe/command/checkout/GitCheckOutCommand.java +++ b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/main/java/org/apache/maven/scm/provider/git/gitexe/command/checkout/GitCheckOutCommand.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.git.gitexe.command.checkout; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider.git.gitexe.command.checkout; import java.io.File; import java.util.Map; @@ -49,14 +48,10 @@ * @author Mark Struberg * */ -public class GitCheckOutCommand - extends AbstractCheckOutCommand - implements GitCommand -{ +public class GitCheckOutCommand extends AbstractCheckOutCommand implements GitCommand { private final Map environmentVariables; - public GitCheckOutCommand( Map environmentVariables ) - { + public GitCheckOutCommand(Map environmentVariables) { super(); this.environmentVariables = environmentVariables; } @@ -70,20 +65,22 @@ public GitCheckOutCommand( Map environmentVariables ) * {@inheritDoc} */ @Override - public ScmResult executeCommand( ScmProviderRepository repo, ScmFileSet fileSet, - CommandParameters parameters ) - throws ScmException - { - ScmVersion version = parameters.getScmVersion( CommandParameter.SCM_VERSION, null ); - boolean binary = parameters.getBoolean( CommandParameter.BINARY, false ); - boolean shallow = parameters.getBoolean( CommandParameter.SHALLOW, false ); + public ScmResult executeCommand(ScmProviderRepository repo, ScmFileSet fileSet, CommandParameters parameters) + throws ScmException { + ScmVersion version = parameters.getScmVersion(CommandParameter.SCM_VERSION, null); + boolean binary = parameters.getBoolean(CommandParameter.BINARY, false); + boolean shallow = parameters.getBoolean(CommandParameter.SHALLOW, false); GitScmProviderRepository repository = (GitScmProviderRepository) repo; - if ( GitScmProviderRepository.PROTOCOL_FILE.equals( repository.getFetchInfo().getProtocol() ) - && repository.getFetchInfo().getPath().indexOf( fileSet.getBasedir().getPath() ) >= 0 ) - { - throw new ScmException( "remote repository must not be the working directory" ); + if (GitScmProviderRepository.PROTOCOL_FILE.equals( + repository.getFetchInfo().getProtocol()) + && repository + .getFetchInfo() + .getPath() + .indexOf(fileSet.getBasedir().getPath()) + >= 0) { + throw new ScmException("remote repository must not be the working directory"); } int exitCode; @@ -93,84 +90,75 @@ public ScmResult executeCommand( ScmProviderRepository repo, ScmFileSet fileSet, String lastCommandLine = "git-nothing-to-do"; - if ( !fileSet.getBasedir().exists() || !( new File( fileSet.getBasedir(), ".git" ).exists() ) ) - { - if ( fileSet.getBasedir().exists() ) - { + if (!fileSet.getBasedir().exists() || !(new File(fileSet.getBasedir(), ".git").exists())) { + if (fileSet.getBasedir().exists()) { // git refuses to clone otherwise fileSet.getBasedir().delete(); } // no git repo seems to exist, let's clone the original repo - Commandline clClone = createCloneCommand( repository, fileSet.getBasedir(), version, binary, shallow ); + Commandline clClone = createCloneCommand(repository, fileSet.getBasedir(), version, binary, shallow); - exitCode = GitCommandLineUtils.execute( clClone, stdout, stderr ); - if ( exitCode != 0 ) - { - return new CheckOutScmResult( clClone.toString(), "The git-clone command failed.", stderr.getOutput(), - false ); + exitCode = GitCommandLineUtils.execute(clClone, stdout, stderr); + if (exitCode != 0) { + return new CheckOutScmResult( + clClone.toString(), "The git-clone command failed.", stderr.getOutput(), false); } lastCommandLine = clClone.toString(); } - GitRemoteInfoCommand gitRemoteInfoCommand = new GitRemoteInfoCommand( environmentVariables ); + GitRemoteInfoCommand gitRemoteInfoCommand = new GitRemoteInfoCommand(environmentVariables); - RemoteInfoScmResult result = gitRemoteInfoCommand.executeRemoteInfoCommand( repository, null, null ); + RemoteInfoScmResult result = gitRemoteInfoCommand.executeRemoteInfoCommand(repository, null, null); - if ( fileSet.getBasedir().exists() && new File( fileSet.getBasedir(), ".git" ).exists() - && result.getBranches().size() > 0 ) - { + if (fileSet.getBasedir().exists() + && new File(fileSet.getBasedir(), ".git").exists() + && result.getBranches().size() > 0) { // git repo exists, so we must git-pull the changes - Commandline clPull = createPullCommand( repository, fileSet.getBasedir(), version ); + Commandline clPull = createPullCommand(repository, fileSet.getBasedir(), version); - exitCode = GitCommandLineUtils.execute( clPull, stdout, stderr ); - if ( exitCode != 0 ) - { - return new CheckOutScmResult( clPull.toString(), "The git-pull command failed.", stderr.getOutput(), - false ); + exitCode = GitCommandLineUtils.execute(clPull, stdout, stderr); + if (exitCode != 0) { + return new CheckOutScmResult( + clPull.toString(), "The git-pull command failed.", stderr.getOutput(), false); } lastCommandLine = clPull.toString(); // and now lets do the git-checkout itself - Commandline clCheckout = createCommandLine( repository, fileSet.getBasedir(), version ); + Commandline clCheckout = createCommandLine(repository, fileSet.getBasedir(), version); - exitCode = GitCommandLineUtils.execute( clCheckout, stdout, stderr ); - if ( exitCode != 0 ) - { - return new CheckOutScmResult( clCheckout.toString(), "The git-checkout command failed.", - stderr.getOutput(), false ); + exitCode = GitCommandLineUtils.execute(clCheckout, stdout, stderr); + if (exitCode != 0) { + return new CheckOutScmResult( + clCheckout.toString(), "The git-checkout command failed.", stderr.getOutput(), false); } lastCommandLine = clCheckout.toString(); } // and now search for the files - GitListConsumer listConsumer = - new GitListConsumer( fileSet.getBasedir(), ScmFileStatus.CHECKED_IN ); + GitListConsumer listConsumer = new GitListConsumer(fileSet.getBasedir(), ScmFileStatus.CHECKED_IN); - Commandline clList = GitListCommand.createCommandLine( repository, fileSet.getBasedir() ); + Commandline clList = GitListCommand.createCommandLine(repository, fileSet.getBasedir()); - exitCode = GitCommandLineUtils.execute( clList, listConsumer, stderr ); - if ( exitCode != 0 ) - { - return new CheckOutScmResult( clList.toString(), "The git-ls-files command failed.", stderr.getOutput(), - false ); + exitCode = GitCommandLineUtils.execute(clList, listConsumer, stderr); + if (exitCode != 0) { + return new CheckOutScmResult( + clList.toString(), "The git-ls-files command failed.", stderr.getOutput(), false); } - return new CheckOutScmResult( lastCommandLine, listConsumer.getListedFiles() ); + return new CheckOutScmResult(lastCommandLine, listConsumer.getListedFiles()); } // ---------------------------------------------------------------------- // // ---------------------------------------------------------------------- - public static Commandline createCommandLine( GitScmProviderRepository repository, File workingDirectory, - ScmVersion version ) - { - Commandline cl = GitCommandLineUtils.getBaseGitCommandLine( workingDirectory, "checkout" ); + public static Commandline createCommandLine( + GitScmProviderRepository repository, File workingDirectory, ScmVersion version) { + Commandline cl = GitCommandLineUtils.getBaseGitCommandLine(workingDirectory, "checkout"); - if ( version != null && StringUtils.isNotEmpty( version.getName() ) ) - { - cl.createArg().setValue( version.getName() ); + if (version != null && StringUtils.isNotEmpty(version.getName())) { + cl.createArg().setValue(version.getName()); } return cl; @@ -179,84 +167,75 @@ public static Commandline createCommandLine( GitScmProviderRepository repository /** * create a git-clone repository command */ - private Commandline createCloneCommand( GitScmProviderRepository repository, File workingDirectory, - ScmVersion version, boolean binary, boolean shallow ) - { - Commandline cl = GitCommandLineUtils.getBaseGitCommandLine( workingDirectory.getParentFile(), "clone", - repository, environmentVariables ); + private Commandline createCloneCommand( + GitScmProviderRepository repository, + File workingDirectory, + ScmVersion version, + boolean binary, + boolean shallow) { + Commandline cl = GitCommandLineUtils.getBaseGitCommandLine( + workingDirectory.getParentFile(), "clone", repository, environmentVariables); - forceBinary( cl, binary ); + forceBinary(cl, binary); - if ( shallow ) - { - cl.createArg().setValue( "--depth" ); + if (shallow) { + cl.createArg().setValue("--depth"); - cl.createArg().setValue( "1" ); + cl.createArg().setValue("1"); } - if ( version != null && ( version instanceof ScmBranch ) ) - { + if (version != null && (version instanceof ScmBranch)) { - cl.createArg().setValue( "--branch" ); + cl.createArg().setValue("--branch"); - cl.createArg().setValue( version.getName() ); + cl.createArg().setValue(version.getName()); } - cl.createArg().setValue( repository.getFetchUrl() ); + cl.createArg().setValue(repository.getFetchUrl()); - cl.createArg().setValue( workingDirectory.getName() ); + cl.createArg().setValue(workingDirectory.getName()); return cl; } - private void forceBinary( Commandline cl, boolean binary ) - { - if ( binary ) - { - cl.createArg().setValue( "-c" ); - cl.createArg().setValue( "core.autocrlf=false" ); + private void forceBinary(Commandline cl, boolean binary) { + if (binary) { + cl.createArg().setValue("-c"); + cl.createArg().setValue("core.autocrlf=false"); } } /** * create a git-pull repository command */ - private Commandline createPullCommand( GitScmProviderRepository repository, File workingDirectory, - ScmVersion version ) - { + private Commandline createPullCommand( + GitScmProviderRepository repository, File workingDirectory, ScmVersion version) { Commandline cl; - if ( version != null && StringUtils.isNotEmpty( version.getName() ) ) - { - if ( version instanceof ScmTag ) - { + if (version != null && StringUtils.isNotEmpty(version.getName())) { + if (version instanceof ScmTag) { // A tag will not be pulled but we only fetch all the commits from the upstream repo // This is done because checking out a tag might not happen on the current branch // but create a 'detached HEAD'. // In fact, a tag in git may be in multiple branches. This occurs if // you create a branch after the tag has been created - cl = GitCommandLineUtils.getBaseGitCommandLine( workingDirectory, "fetch", repository, - environmentVariables ); + cl = GitCommandLineUtils.getBaseGitCommandLine( + workingDirectory, "fetch", repository, environmentVariables); - cl.createArg().setValue( repository.getFetchUrl() ); - } - else - { - cl = GitCommandLineUtils.getBaseGitCommandLine( workingDirectory, "pull", repository, - environmentVariables ); + cl.createArg().setValue(repository.getFetchUrl()); + } else { + cl = GitCommandLineUtils.getBaseGitCommandLine( + workingDirectory, "pull", repository, environmentVariables); - cl.createArg().setValue( repository.getFetchUrl() ); + cl.createArg().setValue(repository.getFetchUrl()); - cl.createArg().setValue( version.getName() + ":" + version.getName() ); + cl.createArg().setValue(version.getName() + ":" + version.getName()); } - } - else - { - cl = GitCommandLineUtils.getBaseGitCommandLine( workingDirectory, "pull", repository, - environmentVariables ); + } else { + cl = GitCommandLineUtils.getBaseGitCommandLine(workingDirectory, "pull", repository, environmentVariables); - cl.createArg().setValue( repository.getFetchUrl() ); - cl.createArg().setValue( "master" ); + cl.createArg().setValue(repository.getFetchUrl()); + cl.createArg().setValue("master"); } return cl; } @@ -267,10 +246,9 @@ private Commandline createPullCommand( GitScmProviderRepository repository, File *

* {@inheritDoc} */ - protected CheckOutScmResult executeCheckOutCommand( ScmProviderRepository repo, ScmFileSet fileSet, - ScmVersion version, boolean recursive, boolean shallow ) - throws ScmException - { - throw new UnsupportedOperationException( "Should not get here" ); - } + protected CheckOutScmResult executeCheckOutCommand( + ScmProviderRepository repo, ScmFileSet fileSet, ScmVersion version, boolean recursive, boolean shallow) + throws ScmException { + throw new UnsupportedOperationException("Should not get here"); + } } diff --git a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/main/java/org/apache/maven/scm/provider/git/gitexe/command/diff/GitDiffCommand.java b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/main/java/org/apache/maven/scm/provider/git/gitexe/command/diff/GitDiffCommand.java index 66f9999a7..d4de1b9c5 100644 --- a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/main/java/org/apache/maven/scm/provider/git/gitexe/command/diff/GitDiffCommand.java +++ b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/main/java/org/apache/maven/scm/provider/git/gitexe/command/diff/GitDiffCommand.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.git.gitexe.command.diff; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,9 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider.git.gitexe.command.diff; + +import java.io.File; import org.apache.maven.scm.ScmException; import org.apache.maven.scm.ScmFileSet; @@ -32,45 +33,36 @@ import org.codehaus.plexus.util.cli.CommandLineUtils; import org.codehaus.plexus.util.cli.Commandline; -import java.io.File; - /** * @author Mark Struberg * */ -public class GitDiffCommand - extends AbstractDiffCommand - implements GitCommand -{ +public class GitDiffCommand extends AbstractDiffCommand implements GitCommand { /** {@inheritDoc} */ - protected DiffScmResult executeDiffCommand( ScmProviderRepository repo, ScmFileSet fileSet, - ScmVersion startVersion, ScmVersion endVersion ) - throws ScmException - { - GitDiffConsumer consumer = new GitDiffConsumer( fileSet.getBasedir() ); + protected DiffScmResult executeDiffCommand( + ScmProviderRepository repo, ScmFileSet fileSet, ScmVersion startVersion, ScmVersion endVersion) + throws ScmException { + GitDiffConsumer consumer = new GitDiffConsumer(fileSet.getBasedir()); CommandLineUtils.StringStreamConsumer stderr = new CommandLineUtils.StringStreamConsumer(); int exitCode; - Commandline clDiff2Index = createCommandLine( fileSet.getBasedir(), startVersion, endVersion, false ); + Commandline clDiff2Index = createCommandLine(fileSet.getBasedir(), startVersion, endVersion, false); - exitCode = GitCommandLineUtils.execute( clDiff2Index, consumer, stderr ); - if ( exitCode != 0 ) - { - return new DiffScmResult( clDiff2Index.toString(), "The git-diff command failed.", stderr.getOutput(), - false ); + exitCode = GitCommandLineUtils.execute(clDiff2Index, consumer, stderr); + if (exitCode != 0) { + return new DiffScmResult( + clDiff2Index.toString(), "The git-diff command failed.", stderr.getOutput(), false); } - Commandline clDiff2Head = createCommandLine( fileSet.getBasedir(), startVersion, endVersion, true ); + Commandline clDiff2Head = createCommandLine(fileSet.getBasedir(), startVersion, endVersion, true); - exitCode = GitCommandLineUtils.execute( clDiff2Head, consumer, stderr ); - if ( exitCode != 0 ) - { - return new DiffScmResult( clDiff2Head.toString(), "The git-diff command failed.", stderr.getOutput(), - false ); + exitCode = GitCommandLineUtils.execute(clDiff2Head, consumer, stderr); + if (exitCode != 0) { + return new DiffScmResult(clDiff2Head.toString(), "The git-diff command failed.", stderr.getOutput(), false); } - return new DiffScmResult( clDiff2Index.toString(), consumer.getChangedFiles(), consumer.getDifferences(), - consumer.getPatch() ); + return new DiffScmResult( + clDiff2Index.toString(), consumer.getChangedFiles(), consumer.getDifferences(), consumer.getPatch()); } // ---------------------------------------------------------------------- @@ -80,23 +72,19 @@ protected DiffScmResult executeDiffCommand( ScmProviderRepository repo, ScmFileS /** * @param cached if true diff the index to the head, else diff the tree to the index */ - public static Commandline createCommandLine( File workingDirectory, ScmVersion startVersion, ScmVersion endVersion, - boolean cached ) - { - Commandline cl = GitCommandLineUtils.getBaseGitCommandLine( workingDirectory, "diff" ); - - if ( cached ) - { - cl.createArg().setValue( "--cached" ); + public static Commandline createCommandLine( + File workingDirectory, ScmVersion startVersion, ScmVersion endVersion, boolean cached) { + Commandline cl = GitCommandLineUtils.getBaseGitCommandLine(workingDirectory, "diff"); + + if (cached) { + cl.createArg().setValue("--cached"); } - if ( startVersion != null && StringUtils.isNotEmpty( startVersion.getName() ) ) - { - cl.createArg().setValue( startVersion.getName() ); + if (startVersion != null && StringUtils.isNotEmpty(startVersion.getName())) { + cl.createArg().setValue(startVersion.getName()); } - if ( endVersion != null && StringUtils.isNotEmpty( endVersion.getName() ) ) - { - cl.createArg().setValue( endVersion.getName() ); + if (endVersion != null && StringUtils.isNotEmpty(endVersion.getName())) { + cl.createArg().setValue(endVersion.getName()); } return cl; @@ -109,14 +97,12 @@ public static Commandline createCommandLine( File workingDirectory, ScmVersion s * * @param workingDirectory */ - public static Commandline createDiffRawCommandLine( File workingDirectory, String sha1 ) - { - Commandline cl = GitCommandLineUtils.getBaseGitCommandLine( workingDirectory, "diff" ); + public static Commandline createDiffRawCommandLine(File workingDirectory, String sha1) { + Commandline cl = GitCommandLineUtils.getBaseGitCommandLine(workingDirectory, "diff"); - cl.createArg().setValue( "--raw" ); - cl.createArg().setValue( sha1 ); + cl.createArg().setValue("--raw"); + cl.createArg().setValue(sha1); return cl; } - } diff --git a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/main/java/org/apache/maven/scm/provider/git/gitexe/command/diff/GitDiffRawConsumer.java b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/main/java/org/apache/maven/scm/provider/git/gitexe/command/diff/GitDiffRawConsumer.java index 2f4b20efd..a7fa17de9 100644 --- a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/main/java/org/apache/maven/scm/provider/git/gitexe/command/diff/GitDiffRawConsumer.java +++ b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/main/java/org/apache/maven/scm/provider/git/gitexe/command/diff/GitDiffRawConsumer.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.git.gitexe.command.diff; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider.git.gitexe.command.diff; import java.util.ArrayList; import java.util.List; @@ -31,9 +30,7 @@ * @author Mark Struberg * */ -public class GitDiffRawConsumer - extends AbstractConsumer -{ +public class GitDiffRawConsumer extends AbstractConsumer { private final List changedFiles = new ArrayList<>(); // ---------------------------------------------------------------------- @@ -43,53 +40,41 @@ public class GitDiffRawConsumer /** * {@inheritDoc} */ - public void consumeLine( String line ) - { - if ( logger.isDebugEnabled() ) - { - logger.debug( line ); + public void consumeLine(String line) { + if (logger.isDebugEnabled()) { + logger.debug(line); } - if ( StringUtils.isEmpty( line ) ) - { + if (StringUtils.isEmpty(line)) { return; } ScmFileStatus status = null; - String[] parts = line.split( "\\s", 6 ); - if ( parts.length != 6 ) - { - logger.warn( "Skipping line because it doesn't contain the right status parameters: " + line ); + String[] parts = line.split("\\s", 6); + if (parts.length != 6) { + logger.warn("Skipping line because it doesn't contain the right status parameters: " + line); return; } - + String modus = parts[4]; String file = parts[5]; - if ( "A".equals( modus ) ) - { + if ("A".equals(modus)) { status = ScmFileStatus.ADDED; - } - else if ( "M".equals( modus ) ) - { + } else if ("M".equals(modus)) { // attention! 'M' is 'updated', and _not_ ScmFileStatus.MODIFIED (which is for 'modified locally') status = ScmFileStatus.UPDATED; - } - else if ( "D".equals( modus ) ) - { + } else if ("D".equals(modus)) { status = ScmFileStatus.DELETED; - } - else - { - logger.warn( "unknown status detected in line: " + line ); + } else { + logger.warn("unknown status detected in line: " + line); return; } - changedFiles.add( new ScmFile( file, status ) ); + changedFiles.add(new ScmFile(file, status)); } - public List getChangedFiles() - { + public List getChangedFiles() { return changedFiles; } } diff --git a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/main/java/org/apache/maven/scm/provider/git/gitexe/command/info/GitInfoCommand.java b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/main/java/org/apache/maven/scm/provider/git/gitexe/command/info/GitInfoCommand.java index d722a1d17..2251f2cb4 100644 --- a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/main/java/org/apache/maven/scm/provider/git/gitexe/command/info/GitInfoCommand.java +++ b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/main/java/org/apache/maven/scm/provider/git/gitexe/command/info/GitInfoCommand.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.git.gitexe.command.info; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider.git.gitexe.command.info; import org.apache.maven.scm.CommandParameter; import org.apache.maven.scm.CommandParameters; @@ -36,45 +35,37 @@ * @author Olivier Lamy * @since 1.5 */ -public class GitInfoCommand - extends AbstractCommand - implements GitCommand -{ +public class GitInfoCommand extends AbstractCommand implements GitCommand { public static final int NO_REVISION_LENGTH = -1; @Override - protected ScmResult executeCommand( ScmProviderRepository repository, ScmFileSet fileSet, - CommandParameters parameters ) - throws ScmException - { + protected ScmResult executeCommand( + ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters) throws ScmException { - GitInfoConsumer consumer = new GitInfoConsumer( fileSet ); + GitInfoConsumer consumer = new GitInfoConsumer(fileSet); CommandLineUtils.StringStreamConsumer stderr = new CommandLineUtils.StringStreamConsumer(); - Commandline cli = createCommandLine( repository, fileSet, parameters ); + Commandline cli = createCommandLine(repository, fileSet, parameters); - int exitCode = GitCommandLineUtils.execute( cli, consumer, stderr ); - if ( exitCode != 0 ) - { - return new InfoScmResult( cli.toString(), "The git rev-parse command failed.", stderr.getOutput(), false ); + int exitCode = GitCommandLineUtils.execute(cli, consumer, stderr); + if (exitCode != 0) { + return new InfoScmResult(cli.toString(), "The git rev-parse command failed.", stderr.getOutput(), false); } - return new InfoScmResult( cli.toString(), consumer.getInfoItems() ); + return new InfoScmResult(cli.toString(), consumer.getInfoItems()); } - public static Commandline createCommandLine( ScmProviderRepository repository, ScmFileSet fileSet, - CommandParameters parameters ) - throws ScmException - { - Commandline cli = GitCommandLineUtils.getBaseGitCommandLine( fileSet.getBasedir(), "rev-parse" ); - cli.createArg().setValue( "--verify" ); - final int revLength = getRevisionLength( parameters ); - if ( revLength > NO_REVISION_LENGTH )// set the --short key only if revision length parameter is passed and - // different from -1 + public static Commandline createCommandLine( + ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters) throws ScmException { + Commandline cli = GitCommandLineUtils.getBaseGitCommandLine(fileSet.getBasedir(), "rev-parse"); + cli.createArg().setValue("--verify"); + final int revLength = getRevisionLength(parameters); + if (revLength > NO_REVISION_LENGTH) // set the --short key only if revision length parameter is passed and + // different from -1 { - cli.createArg().setValue( "--short=" + revLength ); + cli.createArg().setValue("--short=" + revLength); } - cli.createArg().setValue( "HEAD" ); + cli.createArg().setValue("HEAD"); return cli; } @@ -88,18 +79,11 @@ public static Commandline createCommandLine( ScmProviderRepository repository, S * @throws ScmException * @since 1.7 */ - private static int getRevisionLength( final CommandParameters parameters ) - throws ScmException - { - if ( parameters == null ) - { + private static int getRevisionLength(final CommandParameters parameters) throws ScmException { + if (parameters == null) { return NO_REVISION_LENGTH; - } - else - { - return parameters.getInt( CommandParameter.SCM_SHORT_REVISION_LENGTH, NO_REVISION_LENGTH ); + } else { + return parameters.getInt(CommandParameter.SCM_SHORT_REVISION_LENGTH, NO_REVISION_LENGTH); } } - - } diff --git a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/main/java/org/apache/maven/scm/provider/git/gitexe/command/info/GitInfoConsumer.java b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/main/java/org/apache/maven/scm/provider/git/gitexe/command/info/GitInfoConsumer.java index 55c728d18..2f0f19708 100644 --- a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/main/java/org/apache/maven/scm/provider/git/gitexe/command/info/GitInfoConsumer.java +++ b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/main/java/org/apache/maven/scm/provider/git/gitexe/command/info/GitInfoConsumer.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.git.gitexe.command.info; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider.git.gitexe.command.info; import java.util.ArrayList; import java.util.List; @@ -31,48 +30,38 @@ * @author Olivier Lamy * @since 1.5 */ -public class GitInfoConsumer - extends AbstractConsumer -{ +public class GitInfoConsumer extends AbstractConsumer { - //$ git show - //commit cd3c0dfacb65955e6fbb35c56cc5b1bf8ce4f767 + // $ git show + // commit cd3c0dfacb65955e6fbb35c56cc5b1bf8ce4f767 - private final List infoItems = new ArrayList<>( 1 ); + private final List infoItems = new ArrayList<>(1); private final ScmFileSet scmFileSet; - public GitInfoConsumer( ScmFileSet scmFileSet ) - { + public GitInfoConsumer(ScmFileSet scmFileSet) { this.scmFileSet = scmFileSet; } /** * @see org.codehaus.plexus.util.cli.StreamConsumer#consumeLine(java.lang.String) */ - public void consumeLine( String line ) - { - if ( logger.isDebugEnabled() ) - { - logger.debug( "consume line " + line ); + public void consumeLine(String line) { + if (logger.isDebugEnabled()) { + logger.debug("consume line " + line); } - if ( infoItems.isEmpty() ) - { - if ( !StringUtils.isEmpty( line ) ) - { + if (infoItems.isEmpty()) { + if (!StringUtils.isEmpty(line)) { InfoItem infoItem = new InfoItem(); - infoItem.setRevision( StringUtils.trim( line ) ); - infoItem.setURL( scmFileSet.getBasedir().toPath().toUri().toASCIIString() ); - infoItems.add( infoItem ); + infoItem.setRevision(StringUtils.trim(line)); + infoItem.setURL(scmFileSet.getBasedir().toPath().toUri().toASCIIString()); + infoItems.add(infoItem); } } - } - public List getInfoItems() - { + public List getInfoItems() { return infoItems; } - } diff --git a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/main/java/org/apache/maven/scm/provider/git/gitexe/command/list/GitListCommand.java b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/main/java/org/apache/maven/scm/provider/git/gitexe/command/list/GitListCommand.java index 4b940e6f6..a7be9ea2d 100644 --- a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/main/java/org/apache/maven/scm/provider/git/gitexe/command/list/GitListCommand.java +++ b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/main/java/org/apache/maven/scm/provider/git/gitexe/command/list/GitListCommand.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.git.gitexe.command.list; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider.git.gitexe.command.list; import java.io.File; @@ -29,12 +28,9 @@ * @author Mark Struberg * */ -public class GitListCommand -{ - public static Commandline createCommandLine( GitScmProviderRepository repository, File workingDirectory ) - { +public class GitListCommand { + public static Commandline createCommandLine(GitScmProviderRepository repository, File workingDirectory) { - return GitCommandLineUtils.getBaseGitCommandLine( workingDirectory, "ls-files" ); + return GitCommandLineUtils.getBaseGitCommandLine(workingDirectory, "ls-files"); } - } diff --git a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/main/java/org/apache/maven/scm/provider/git/gitexe/command/list/GitListConsumer.java b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/main/java/org/apache/maven/scm/provider/git/gitexe/command/list/GitListConsumer.java index 6452fa0f4..ed8e3f27b 100644 --- a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/main/java/org/apache/maven/scm/provider/git/gitexe/command/list/GitListConsumer.java +++ b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/main/java/org/apache/maven/scm/provider/git/gitexe/command/list/GitListConsumer.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.git.gitexe.command.list; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,48 +16,44 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider.git.gitexe.command.list; + +import java.io.File; +import java.util.List; import org.apache.maven.scm.ScmFile; import org.apache.maven.scm.ScmFileStatus; import org.apache.maven.scm.provider.git.gitexe.command.AbstractFileCheckingConsumer; -import java.io.File; -import java.util.List; - /** * @author Mark Struberg * @author Olivier Lamy * */ -public class GitListConsumer - extends AbstractFileCheckingConsumer -{ +public class GitListConsumer extends AbstractFileCheckingConsumer { private final ScmFileStatus fileStatus; /** * @param workingDirectory * @param fileStatus will be used for each file found */ - public GitListConsumer( File workingDirectory, ScmFileStatus fileStatus ) - { - super( workingDirectory ); + public GitListConsumer(File workingDirectory, ScmFileStatus fileStatus) { + super(workingDirectory); this.fileStatus = fileStatus; } /** {@inheritDoc} */ - protected void parseLine( String line ) - { + protected void parseLine(String line) { - addFile( new ScmFile( line, fileStatus ) ); + addFile(new ScmFile(line, fileStatus)); } // ---------------------------------------------------------------------- // // ---------------------------------------------------------------------- - public List getListedFiles() - { + public List getListedFiles() { return getFiles(); } } diff --git a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/main/java/org/apache/maven/scm/provider/git/gitexe/command/remoteinfo/GitRemoteInfoCommand.java b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/main/java/org/apache/maven/scm/provider/git/gitexe/command/remoteinfo/GitRemoteInfoCommand.java index b3d73a81d..59757131c 100644 --- a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/main/java/org/apache/maven/scm/provider/git/gitexe/command/remoteinfo/GitRemoteInfoCommand.java +++ b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/main/java/org/apache/maven/scm/provider/git/gitexe/command/remoteinfo/GitRemoteInfoCommand.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.git.gitexe.command.remoteinfo; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider.git.gitexe.command.remoteinfo; import java.util.Map; @@ -36,35 +35,28 @@ /** * @author Bertrand Paquet */ -public class GitRemoteInfoCommand - extends AbstractRemoteInfoCommand - implements GitCommand -{ +public class GitRemoteInfoCommand extends AbstractRemoteInfoCommand implements GitCommand { private final Map environmentVariables; - public GitRemoteInfoCommand( Map environmentVariables ) - { + public GitRemoteInfoCommand(Map environmentVariables) { super(); this.environmentVariables = environmentVariables; } @Override - public RemoteInfoScmResult executeRemoteInfoCommand( ScmProviderRepository repository, ScmFileSet fileSet, - CommandParameters parameters ) - throws ScmException - { + public RemoteInfoScmResult executeRemoteInfoCommand( + ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters) throws ScmException { GitScmProviderRepository gitRepository = (GitScmProviderRepository) repository; CommandLineUtils.StringStreamConsumer stderr = new CommandLineUtils.StringStreamConsumer(); - Commandline clLsRemote = createCommandLine( gitRepository ); + Commandline clLsRemote = createCommandLine(gitRepository); - GitRemoteInfoConsumer consumer = new GitRemoteInfoConsumer( clLsRemote.toString() ); + GitRemoteInfoConsumer consumer = new GitRemoteInfoConsumer(clLsRemote.toString()); - int exitCode = GitCommandLineUtils.execute( clLsRemote, consumer, stderr ); - if ( exitCode != 0 ) - { - throw new ScmException( "unable to execute ls-remote on " + gitRepository.getFetchUrl() ); + int exitCode = GitCommandLineUtils.execute(clLsRemote, consumer, stderr); + if (exitCode != 0) { + throw new ScmException("unable to execute ls-remote on " + gitRepository.getFetchUrl()); } return consumer.getRemoteInfoScmResult(); @@ -74,17 +66,14 @@ public RemoteInfoScmResult executeRemoteInfoCommand( ScmProviderRepository repos // // ---------------------------------------------------------------------- - public Commandline createCommandLine( GitScmProviderRepository repository ) - { - Commandline cl = GitCommandLineUtils.getBaseGitCommandLine( null, "ls-remote", repository, - environmentVariables ); + public Commandline createCommandLine(GitScmProviderRepository repository) { + Commandline cl = GitCommandLineUtils.getBaseGitCommandLine(null, "ls-remote", repository, environmentVariables); - cl.setWorkingDirectory( System.getProperty( "java.io.tmpdir" ) ); + cl.setWorkingDirectory(System.getProperty("java.io.tmpdir")); String remoteUrl = repository.getPushUrl(); - cl.createArg().setValue( remoteUrl ); + cl.createArg().setValue(remoteUrl); return cl; } - } diff --git a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/main/java/org/apache/maven/scm/provider/git/gitexe/command/remoteinfo/GitRemoteInfoConsumer.java b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/main/java/org/apache/maven/scm/provider/git/gitexe/command/remoteinfo/GitRemoteInfoConsumer.java index c065391a0..3018a3784 100644 --- a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/main/java/org/apache/maven/scm/provider/git/gitexe/command/remoteinfo/GitRemoteInfoConsumer.java +++ b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/main/java/org/apache/maven/scm/provider/git/gitexe/command/remoteinfo/GitRemoteInfoConsumer.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.git.gitexe.command.remoteinfo; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,30 +16,29 @@ * specific language governing permissions and limitations * under the License. */ - -import org.apache.maven.scm.command.remoteinfo.RemoteInfoScmResult; -import org.apache.maven.scm.util.AbstractConsumer; +package org.apache.maven.scm.provider.git.gitexe.command.remoteinfo; import java.util.HashMap; import java.util.regex.Matcher; import java.util.regex.Pattern; +import org.apache.maven.scm.command.remoteinfo.RemoteInfoScmResult; +import org.apache.maven.scm.util.AbstractConsumer; + /** * @author Bertrand Paquet */ -public class GitRemoteInfoConsumer - extends AbstractConsumer -{ +public class GitRemoteInfoConsumer extends AbstractConsumer { /** * The pattern used to match branches */ - private static final Pattern BRANCH_PATTERN = Pattern.compile( "^(.*)\\s+refs/heads/(.*)" ); + private static final Pattern BRANCH_PATTERN = Pattern.compile("^(.*)\\s+refs/heads/(.*)"); /** * The pattern used to match tags */ - private static final Pattern TAGS_PATTERN = Pattern.compile( "^(.*)\\s+refs/tags/(.*)" ); + private static final Pattern TAGS_PATTERN = Pattern.compile("^(.*)\\s+refs/tags/(.*)"); private final RemoteInfoScmResult remoteInfoScmResult; @@ -49,10 +46,8 @@ public class GitRemoteInfoConsumer // // ---------------------------------------------------------------------- - public GitRemoteInfoConsumer( String commandLine ) - { - this.remoteInfoScmResult = - new RemoteInfoScmResult( commandLine, new HashMap<>(), new HashMap<>() ); + public GitRemoteInfoConsumer(String commandLine) { + this.remoteInfoScmResult = new RemoteInfoScmResult(commandLine, new HashMap<>(), new HashMap<>()); } // ---------------------------------------------------------------------- @@ -62,30 +57,23 @@ public GitRemoteInfoConsumer( String commandLine ) /** * {@inheritDoc} */ - public void consumeLine( String line ) - { - if ( logger.isDebugEnabled() ) - { - logger.debug( line ); - } - - Matcher matcher = BRANCH_PATTERN.matcher( line ); - if ( matcher.matches() ) - { - remoteInfoScmResult.getBranches().put( matcher.group( 2 ), matcher.group( 1 ) ); + public void consumeLine(String line) { + if (logger.isDebugEnabled()) { + logger.debug(line); } - - matcher = TAGS_PATTERN.matcher( line ); - if ( matcher.matches() ) - { - remoteInfoScmResult.getTags().put( matcher.group( 2 ), matcher.group( 1 ) ); + + Matcher matcher = BRANCH_PATTERN.matcher(line); + if (matcher.matches()) { + remoteInfoScmResult.getBranches().put(matcher.group(2), matcher.group(1)); } + matcher = TAGS_PATTERN.matcher(line); + if (matcher.matches()) { + remoteInfoScmResult.getTags().put(matcher.group(2), matcher.group(1)); + } } - public RemoteInfoScmResult getRemoteInfoScmResult() - { + public RemoteInfoScmResult getRemoteInfoScmResult() { return remoteInfoScmResult; } - -} \ No newline at end of file +} diff --git a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/main/java/org/apache/maven/scm/provider/git/gitexe/command/remove/GitRemoveCommand.java b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/main/java/org/apache/maven/scm/provider/git/gitexe/command/remove/GitRemoveCommand.java index ec4a7c8d9..8a3227367 100644 --- a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/main/java/org/apache/maven/scm/provider/git/gitexe/command/remove/GitRemoveCommand.java +++ b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/main/java/org/apache/maven/scm/provider/git/gitexe/command/remove/GitRemoveCommand.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.git.gitexe.command.remove; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,11 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider.git.gitexe.command.remove; + +import java.io.File; +import java.net.URI; +import java.util.List; import org.apache.maven.scm.ScmException; import org.apache.maven.scm.ScmFileSet; @@ -31,82 +34,63 @@ import org.codehaus.plexus.util.cli.CommandLineUtils; import org.codehaus.plexus.util.cli.Commandline; -import java.io.File; -import java.net.URI; -import java.util.List; - /** * @author Mark Struberg * @author Olivier Lamy * */ -public class GitRemoveCommand - extends AbstractRemoveCommand - implements GitCommand -{ +public class GitRemoveCommand extends AbstractRemoveCommand implements GitCommand { /** * {@inheritDoc} */ - protected ScmResult executeRemoveCommand( ScmProviderRepository repo, ScmFileSet fileSet, String message ) - throws ScmException - { + protected ScmResult executeRemoveCommand(ScmProviderRepository repo, ScmFileSet fileSet, String message) + throws ScmException { - if ( fileSet.getFileList().isEmpty() ) - { - throw new ScmException( "You must provide at least one file/directory to remove" ); + if (fileSet.getFileList().isEmpty()) { + throw new ScmException("You must provide at least one file/directory to remove"); } - Commandline cl = createCommandLine( fileSet.getBasedir(), fileSet.getFileList() ); + Commandline cl = createCommandLine(fileSet.getBasedir(), fileSet.getFileList()); // git-rm uses repositoryRoot instead of workingDirectory, adjust it with relativeRepositoryPath - URI relativeRepositoryPath = GitStatusCommand.getRelativeCWD( logger, fileSet ); - GitRemoveConsumer consumer = new GitRemoveConsumer( relativeRepositoryPath ); + URI relativeRepositoryPath = GitStatusCommand.getRelativeCWD(logger, fileSet); + GitRemoveConsumer consumer = new GitRemoveConsumer(relativeRepositoryPath); CommandLineUtils.StringStreamConsumer stderr = new CommandLineUtils.StringStreamConsumer(); int exitCode; - exitCode = GitCommandLineUtils.execute( cl, consumer, stderr ); - if ( exitCode != 0 ) - { - return new RemoveScmResult( cl.toString(), "The git command failed.", stderr.getOutput(), false ); + exitCode = GitCommandLineUtils.execute(cl, consumer, stderr); + if (exitCode != 0) { + return new RemoveScmResult(cl.toString(), "The git command failed.", stderr.getOutput(), false); } - return new RemoveScmResult( cl.toString(), consumer.getRemovedFiles() ); + return new RemoveScmResult(cl.toString(), consumer.getRemovedFiles()); } - public static Commandline createCommandLine( File workingDirectory, List files ) - throws ScmException - { - Commandline cl = GitCommandLineUtils.getBaseGitCommandLine( workingDirectory, "rm" ); + public static Commandline createCommandLine(File workingDirectory, List files) throws ScmException { + Commandline cl = GitCommandLineUtils.getBaseGitCommandLine(workingDirectory, "rm"); - for ( File file : files ) - { - if ( file.isAbsolute() ) - { - if ( file.isDirectory() ) - { - cl.createArg().setValue( "-r" ); + for (File file : files) { + if (file.isAbsolute()) { + if (file.isDirectory()) { + cl.createArg().setValue("-r"); break; } - } - else - { - File absFile = new File( workingDirectory, file.getPath() ); - if ( absFile.isDirectory() ) - { - cl.createArg().setValue( "-r" ); + } else { + File absFile = new File(workingDirectory, file.getPath()); + if (absFile.isDirectory()) { + cl.createArg().setValue("-r"); break; } } } // use this separator to make clear that the following parameters are files and options. - cl.createArg().setValue( "--" ); + cl.createArg().setValue("--"); - GitCommandLineUtils.addTarget( cl, files ); + GitCommandLineUtils.addTarget(cl, files); return cl; } - } diff --git a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/main/java/org/apache/maven/scm/provider/git/gitexe/command/remove/GitRemoveConsumer.java b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/main/java/org/apache/maven/scm/provider/git/gitexe/command/remove/GitRemoveConsumer.java index c3d385000..0ff9d55cb 100644 --- a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/main/java/org/apache/maven/scm/provider/git/gitexe/command/remove/GitRemoveConsumer.java +++ b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/main/java/org/apache/maven/scm/provider/git/gitexe/command/remove/GitRemoveConsumer.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.git.gitexe.command.remove; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,11 +16,7 @@ * specific language governing permissions and limitations * under the License. */ - -import org.apache.maven.scm.ScmFile; -import org.apache.maven.scm.ScmFileStatus; -import org.apache.maven.scm.provider.git.gitexe.command.status.GitStatusConsumer; -import org.apache.maven.scm.util.AbstractConsumer; +package org.apache.maven.scm.provider.git.gitexe.command.remove; import java.net.URI; import java.util.ArrayList; @@ -30,18 +24,21 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; +import org.apache.maven.scm.ScmFile; +import org.apache.maven.scm.ScmFileStatus; +import org.apache.maven.scm.provider.git.gitexe.command.status.GitStatusConsumer; +import org.apache.maven.scm.util.AbstractConsumer; + /** * @author Mark Struberg * @author Olivier Lamy * */ -public class GitRemoveConsumer - extends AbstractConsumer -{ +public class GitRemoveConsumer extends AbstractConsumer { /** * The pattern used to match deleted file lines */ - private static final Pattern REMOVED_PATTERN = Pattern.compile( "^rm\\s'(.*)'" ); + private static final Pattern REMOVED_PATTERN = Pattern.compile("^rm\\s'(.*)'"); private final List removedFiles = new ArrayList<>(); @@ -51,46 +48,36 @@ public class GitRemoveConsumer // StreamConsumer Implementation // ---------------------------------------------------------------------- - public GitRemoveConsumer() - { - this( null ); + public GitRemoveConsumer() { + this(null); } - public GitRemoveConsumer( URI relativeRepositoryPath ) - { + public GitRemoveConsumer(URI relativeRepositoryPath) { this.relativeRepositoryPath = relativeRepositoryPath; } /** * {@inheritDoc} */ - public void consumeLine( String line ) - { - if ( line.length() <= 2 ) - { + public void consumeLine(String line) { + if (line.length() <= 2) { return; } - Matcher matcher = REMOVED_PATTERN.matcher( line ); - if ( matcher.matches() ) - { - String file = GitStatusConsumer.resolvePath( matcher.group( 1 ), relativeRepositoryPath ); - removedFiles.add( new ScmFile( file, ScmFileStatus.DELETED ) ); - } - else - { - if ( logger.isInfoEnabled() ) - { - logger.info( "could not parse line: " + line ); + Matcher matcher = REMOVED_PATTERN.matcher(line); + if (matcher.matches()) { + String file = GitStatusConsumer.resolvePath(matcher.group(1), relativeRepositoryPath); + removedFiles.add(new ScmFile(file, ScmFileStatus.DELETED)); + } else { + if (logger.isInfoEnabled()) { + logger.info("could not parse line: " + line); } return; } } - public List getRemovedFiles() - { + public List getRemovedFiles() { return removedFiles; } - } diff --git a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/main/java/org/apache/maven/scm/provider/git/gitexe/command/status/GitStatusCommand.java b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/main/java/org/apache/maven/scm/provider/git/gitexe/command/status/GitStatusCommand.java index 3a61b728e..ac6086a20 100644 --- a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/main/java/org/apache/maven/scm/provider/git/gitexe/command/status/GitStatusCommand.java +++ b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/main/java/org/apache/maven/scm/provider/git/gitexe/command/status/GitStatusCommand.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.git.gitexe.command.status; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider.git.gitexe.command.status; import java.net.URI; @@ -37,36 +36,29 @@ * @author Brett Porter * */ -public class GitStatusCommand - extends AbstractStatusCommand - implements GitCommand -{ +public class GitStatusCommand extends AbstractStatusCommand implements GitCommand { /** {@inheritDoc} */ - protected StatusScmResult executeStatusCommand( ScmProviderRepository repo, ScmFileSet fileSet ) - throws ScmException - { + protected StatusScmResult executeStatusCommand(ScmProviderRepository repo, ScmFileSet fileSet) throws ScmException { int exitCode; CommandLineUtils.StringStreamConsumer stderr; - URI relativeRepositoryPath = getRelativeCWD( logger, fileSet ); + URI relativeRepositoryPath = getRelativeCWD(logger, fileSet); - Commandline cl = createCommandLine( (GitScmProviderRepository) repo, fileSet ); + Commandline cl = createCommandLine((GitScmProviderRepository) repo, fileSet); - GitStatusConsumer consumer = new GitStatusConsumer( fileSet.getBasedir(), relativeRepositoryPath, fileSet ); + GitStatusConsumer consumer = new GitStatusConsumer(fileSet.getBasedir(), relativeRepositoryPath, fileSet); stderr = new CommandLineUtils.StringStreamConsumer(); - exitCode = GitCommandLineUtils.execute( cl, consumer, stderr ); - if ( exitCode != 0 ) - { + exitCode = GitCommandLineUtils.execute(cl, consumer, stderr); + if (exitCode != 0) { // git-status returns non-zero if nothing to do - if ( logger.isInfoEnabled() ) - { - logger.info( "nothing added to commit but untracked files present (use \"git add\" to track)" ); + if (logger.isInfoEnabled()) { + logger.info("nothing added to commit but untracked files present (use \"git add\" to track)"); } } - return new StatusScmResult( cl.toString(), consumer.getChangedFiles() ); + return new StatusScmResult(cl.toString(), consumer.getChangedFiles()); } // ---------------------------------------------------------------------- @@ -81,43 +73,36 @@ protected StatusScmResult executeStatusCommand( ScmProviderRepository repo, ScmF * @return the relative URI. * @throws ScmException if execute() fails. */ - public static URI getRelativeCWD( Logger logger, ScmFileSet fileSet ) - throws ScmException - { - Commandline clRevparse = createRevparseShowPrefix( fileSet ); + public static URI getRelativeCWD(Logger logger, ScmFileSet fileSet) throws ScmException { + Commandline clRevparse = createRevparseShowPrefix(fileSet); CommandLineUtils.StringStreamConsumer stdout = new CommandLineUtils.StringStreamConsumer(); CommandLineUtils.StringStreamConsumer stderr = new CommandLineUtils.StringStreamConsumer(); URI relativeRepositoryPath = null; - int exitCode = GitCommandLineUtils.execute( clRevparse, stdout, stderr ); - if ( exitCode != 0 ) - { + int exitCode = GitCommandLineUtils.execute(clRevparse, stdout, stderr); + if (exitCode != 0) { // git-status returns non-zero if nothing to do - if ( logger.isInfoEnabled() ) - { - logger.info( "Could not resolve prefix" ); + if (logger.isInfoEnabled()) { + logger.info("Could not resolve prefix"); } - } - else - { - relativeRepositoryPath = GitStatusConsumer.uriFromPath( stdout.getOutput().trim() ); + } else { + relativeRepositoryPath = + GitStatusConsumer.uriFromPath(stdout.getOutput().trim()); } return relativeRepositoryPath; } - public static Commandline createCommandLine( GitScmProviderRepository repository, ScmFileSet fileSet ) - { - Commandline cl = GitCommandLineUtils.getBaseGitCommandLine( fileSet.getBasedir(), "status" ); - cl.addArguments( new String[] { "--porcelain", "." } ); + public static Commandline createCommandLine(GitScmProviderRepository repository, ScmFileSet fileSet) { + Commandline cl = GitCommandLineUtils.getBaseGitCommandLine(fileSet.getBasedir(), "status"); + cl.addArguments(new String[] {"--porcelain", "."}); return cl; } - public static Commandline createRevparseShowPrefix( ScmFileSet fileSet ) - { - Commandline cl = GitCommandLineUtils.getBaseGitCommandLine( fileSet.getBasedir(), "rev-parse" ); - cl.addArguments( new String[] { "--show-prefix" } ); + public static Commandline createRevparseShowPrefix(ScmFileSet fileSet) { + Commandline cl = GitCommandLineUtils.getBaseGitCommandLine(fileSet.getBasedir(), "rev-parse"); + cl.addArguments(new String[] {"--show-prefix"}); return cl; } } diff --git a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/main/java/org/apache/maven/scm/provider/git/gitexe/command/status/GitStatusConsumer.java b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/main/java/org/apache/maven/scm/provider/git/gitexe/command/status/GitStatusConsumer.java index 13f2764b1..173470fa9 100644 --- a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/main/java/org/apache/maven/scm/provider/git/gitexe/command/status/GitStatusConsumer.java +++ b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/main/java/org/apache/maven/scm/provider/git/gitexe/command/status/GitStatusConsumer.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.git.gitexe.command.status; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider.git.gitexe.command.status; import java.io.File; import java.io.UnsupportedEncodingException; @@ -29,37 +28,35 @@ import java.util.regex.Pattern; import org.apache.maven.scm.ScmFile; -import org.apache.maven.scm.ScmFileStatus; import org.apache.maven.scm.ScmFileSet; +import org.apache.maven.scm.ScmFileStatus; import org.apache.maven.scm.util.AbstractConsumer; import org.codehaus.plexus.util.StringUtils; /** * @author Mark Struberg */ -public class GitStatusConsumer - extends AbstractConsumer -{ +public class GitStatusConsumer extends AbstractConsumer { /** * The pattern used to match added file lines */ - private static final Pattern ADDED_PATTERN = Pattern.compile( "^A[ M]* (.*)$" ); + private static final Pattern ADDED_PATTERN = Pattern.compile("^A[ M]* (.*)$"); /** * The pattern used to match modified file lines */ - private static final Pattern MODIFIED_PATTERN = Pattern.compile( "^ *M[ M]* (.*)$" ); + private static final Pattern MODIFIED_PATTERN = Pattern.compile("^ *M[ M]* (.*)$"); /** * The pattern used to match deleted file lines */ - private static final Pattern DELETED_PATTERN = Pattern.compile( "^ *D * (.*)$" ); + private static final Pattern DELETED_PATTERN = Pattern.compile("^ *D * (.*)$"); /** * The pattern used to match renamed file lines */ - private static final Pattern RENAMED_PATTERN = Pattern.compile( "^R (.*) -> (.*)$" ); + private static final Pattern RENAMED_PATTERN = Pattern.compile("^R (.*) -> (.*)$"); private final File workingDirectory; @@ -81,8 +78,7 @@ public class GitStatusConsumer * * @param workingDirectory the working directory */ - public GitStatusConsumer( File workingDirectory ) - { + public GitStatusConsumer(File workingDirectory) { this.workingDirectory = workingDirectory; } @@ -98,9 +94,8 @@ public GitStatusConsumer( File workingDirectory ) * @since 1.9 * @see GitStatusCommand#createRevparseShowPrefix(ScmFileSet) */ - public GitStatusConsumer( File workingDirectory, URI relativeRepositoryPath ) - { - this( workingDirectory ); + public GitStatusConsumer(File workingDirectory, URI relativeRepositoryPath) { + this(workingDirectory); this.relativeRepositoryPath = relativeRepositoryPath; } @@ -116,9 +111,8 @@ public GitStatusConsumer( File workingDirectory, URI relativeRepositoryPath ) * @since 1.11.0 * @see GitStatusCommand#createRevparseShowPrefix(ScmFileSet) */ - public GitStatusConsumer( File workingDirectory, ScmFileSet scmFileSet ) - { - this( workingDirectory ); + public GitStatusConsumer(File workingDirectory, ScmFileSet scmFileSet) { + this(workingDirectory); this.scmFileSet = scmFileSet; } @@ -135,10 +129,8 @@ public GitStatusConsumer( File workingDirectory, ScmFileSet scmFileSet ) * @since 1.11.0 * @see GitStatusCommand#createRevparseShowPrefix(ScmFileSet) */ - public GitStatusConsumer( File workingDirectory, URI relativeRepositoryPath, - ScmFileSet scmFileSet ) - { - this( workingDirectory, scmFileSet ); + public GitStatusConsumer(File workingDirectory, URI relativeRepositoryPath, ScmFileSet scmFileSet) { + this(workingDirectory, scmFileSet); this.relativeRepositoryPath = relativeRepositoryPath; } @@ -149,14 +141,11 @@ public GitStatusConsumer( File workingDirectory, URI relativeRepositoryPath, /** * {@inheritDoc} */ - public void consumeLine( String line ) - { - if ( logger.isDebugEnabled() ) - { - logger.debug( line ); + public void consumeLine(String line) { + if (logger.isDebugEnabled()) { + logger.debug(line); } - if ( StringUtils.isEmpty( line ) ) - { + if (StringUtils.isEmpty(line)) { return; } @@ -165,130 +154,90 @@ public void consumeLine( String line ) List files = new ArrayList(); Matcher matcher; - if ( ( matcher = ADDED_PATTERN.matcher( line ) ).find() ) - { + if ((matcher = ADDED_PATTERN.matcher(line)).find()) { status = ScmFileStatus.ADDED; - files.add( resolvePath( matcher.group( 1 ), relativeRepositoryPath ) ); - } - else if ( ( matcher = MODIFIED_PATTERN.matcher( line ) ).find() ) - { + files.add(resolvePath(matcher.group(1), relativeRepositoryPath)); + } else if ((matcher = MODIFIED_PATTERN.matcher(line)).find()) { status = ScmFileStatus.MODIFIED; - files.add( resolvePath( matcher.group( 1 ), relativeRepositoryPath ) ); - } - else if ( ( matcher = DELETED_PATTERN.matcher( line ) ).find() ) - { + files.add(resolvePath(matcher.group(1), relativeRepositoryPath)); + } else if ((matcher = DELETED_PATTERN.matcher(line)).find()) { status = ScmFileStatus.DELETED; - files.add( resolvePath( matcher.group( 1 ), relativeRepositoryPath ) ); - } - else if ( ( matcher = RENAMED_PATTERN.matcher( line ) ).find() ) - { + files.add(resolvePath(matcher.group(1), relativeRepositoryPath)); + } else if ((matcher = RENAMED_PATTERN.matcher(line)).find()) { status = ScmFileStatus.RENAMED; - files.add( resolvePath( matcher.group( 1 ), relativeRepositoryPath ) ); - files.add( resolvePath( matcher.group( 2 ), relativeRepositoryPath ) ); - logger.debug( "RENAMED status for line '" + line + "' files added '" + matcher.group( 1 ) + "' '" - + matcher.group( 2 ) ); - } - else - { - logger.warn( "Ignoring unrecognized line: " + line ); + files.add(resolvePath(matcher.group(1), relativeRepositoryPath)); + files.add(resolvePath(matcher.group(2), relativeRepositoryPath)); + logger.debug("RENAMED status for line '" + line + "' files added '" + matcher.group(1) + "' '" + + matcher.group(2)); + } else { + logger.warn("Ignoring unrecognized line: " + line); return; } // If the file isn't a file; don't add it. - if ( !files.isEmpty() ) - { - if ( workingDirectory != null ) - { - if ( status == ScmFileStatus.RENAMED ) - { - String oldFilePath = files.get( 0 ); - String newFilePath = files.get( 1 ); - if ( isFile( oldFilePath ) ) - { - logger.debug( "file '" + oldFilePath + "' is a file" ); + if (!files.isEmpty()) { + if (workingDirectory != null) { + if (status == ScmFileStatus.RENAMED) { + String oldFilePath = files.get(0); + String newFilePath = files.get(1); + if (isFile(oldFilePath)) { + logger.debug("file '" + oldFilePath + "' is a file"); return; + } else { + logger.debug("file '" + oldFilePath + "' not a file"); } - else - { - logger.debug( "file '" + oldFilePath + "' not a file" ); - } - if ( !isFile( newFilePath ) ) - { - logger.debug( "file '" + newFilePath + "' not a file" ); + if (!isFile(newFilePath)) { + logger.debug("file '" + newFilePath + "' not a file"); return; + } else { + logger.debug("file '" + newFilePath + "' is a file"); } - else - { - logger.debug( "file '" + newFilePath + "' is a file" ); - } - } - else if ( status == ScmFileStatus.DELETED ) - { - if ( isFile( files.get( 0 ) ) ) - { + } else if (status == ScmFileStatus.DELETED) { + if (isFile(files.get(0))) { return; } - } - else - { - if ( !isFile( files.get( 0 ) ) ) - { + } else { + if (!isFile(files.get(0))) { return; } } } - for ( String file : files ) - { - if ( this.scmFileSet != null && !isFileNameInFileList( this.scmFileSet.getFileList(), file ) ) - { + for (String file : files) { + if (this.scmFileSet != null && !isFileNameInFileList(this.scmFileSet.getFileList(), file)) { // skip adding this file - } - else - { - changedFiles.add( new ScmFile( file, status ) ); + } else { + changedFiles.add(new ScmFile(file, status)); } } } } - private boolean isFileNameInFileList( List fileList, String fileName ) - { - if ( relativeRepositoryPath == null ) - { - return fileList.contains( new File( fileName ) ); - } - else - { - for ( File f : fileList ) - { - File file = new File( relativeRepositoryPath.getPath(), fileName ); - if ( file.getPath().endsWith( f.getName() ) ) - { + private boolean isFileNameInFileList(List fileList, String fileName) { + if (relativeRepositoryPath == null) { + return fileList.contains(new File(fileName)); + } else { + for (File f : fileList) { + File file = new File(relativeRepositoryPath.getPath(), fileName); + if (file.getPath().endsWith(f.getName())) { return true; } } return fileList.isEmpty(); } - } - private boolean isFile( String file ) - { - File targetFile = new File( workingDirectory, file ); + private boolean isFile(String file) { + File targetFile = new File(workingDirectory, file); return targetFile.isFile(); } - public static String resolvePath( String fileEntry, URI path ) - { + public static String resolvePath(String fileEntry, URI path) { /* Quotes may be included (from the git status line) when an fileEntry includes spaces */ - String cleanedEntry = stripQuotes( fileEntry ); - if ( path != null ) - { - return resolveURI( cleanedEntry, path ).getPath(); - } - else - { + String cleanedEntry = stripQuotes(fileEntry); + if (path != null) { + return resolveURI(cleanedEntry, path).getPath(); + } else { return cleanedEntry; } } @@ -299,12 +248,11 @@ public static String resolvePath( String fileEntry, URI path ) * @param path the path, must not be {@code null} * @return TODO */ - public static URI resolveURI( String fileEntry, URI path ) - { + public static URI resolveURI(String fileEntry, URI path) { // When using URI.create, spaces need to be escaped but not the slashes, so we can't use // URLEncoder.encode( String, String ) // new File( String ).toURI() results in an absolute URI while path is relative, so that can't be used either. - return path.relativize( uriFromPath( stripQuotes ( fileEntry ) ) ); + return path.relativize(uriFromPath(stripQuotes(fileEntry))); } /** @@ -314,30 +262,22 @@ public static URI resolveURI( String fileEntry, URI path ) * @param path the path. * @return the new URI */ - public static URI uriFromPath( String path ) - { - try - { - if ( path != null && path.indexOf( ':' ) != -1 ) - { + public static URI uriFromPath(String path) { + try { + if (path != null && path.indexOf(':') != -1) { // prefixing the path so the part preceding the colon does not become the scheme - String tmp = new URI( null, null, "/x" + path, null ).toString().substring( 2 ); + String tmp = new URI(null, null, "/x" + path, null).toString().substring(2); // the colon is not escaped by default - return new URI( tmp.replace( ":", "%3A" ) ); - } - else - { - return new URI( null, null, path, null ); + return new URI(tmp.replace(":", "%3A")); + } else { + return new URI(null, null, path, null); } - } - catch ( URISyntaxException x ) - { - throw new IllegalArgumentException( x.getMessage(), x ); + } catch (URISyntaxException x) { + throw new IllegalArgumentException(x.getMessage(), x); } } - public List getChangedFiles() - { + public List getChangedFiles() { return changedFiles; } @@ -345,12 +285,11 @@ public List getChangedFiles() * @param str the (potentially quoted) string, must not be {@code null} * @return the string with a pair of double quotes removed (if they existed) */ - private static String stripQuotes( String str ) - { + private static String stripQuotes(String str) { int strLen = str.length(); - return ( strLen > 0 && str.startsWith( "\"" ) && str.endsWith( "\"" ) ) - ? unescape( str.substring( 1, strLen - 1 ) ) - : str; + return (strLen > 0 && str.startsWith("\"") && str.endsWith("\"")) + ? unescape(str.substring(1, strLen - 1)) + : str; } /** @@ -359,34 +298,30 @@ private static String stripQuotes( String str ) * @param fileEntry * @return TODO */ - private static String unescape( String fileEntry ) - { + private static String unescape(String fileEntry) { // If there are no escaped characters, just return the input argument - int pos = fileEntry.indexOf( '\\' ); - if ( pos == -1 ) - { + int pos = fileEntry.indexOf('\\'); + if (pos == -1) { return fileEntry; } // We have escaped characters byte[] inba = fileEntry.getBytes(); - int inSub = 0; // Input subscript into fileEntry + int inSub = 0; // Input subscript into fileEntry byte[] outba = new byte[fileEntry.length()]; - int outSub = 0; // Output subscript into outba + int outSub = 0; // Output subscript into outba - while ( true ) - { - System.arraycopy( inba, inSub, outba, outSub, pos - inSub ); + while (true) { + System.arraycopy(inba, inSub, outba, outSub, pos - inSub); outSub += pos - inSub; inSub = pos + 1; - switch ( (char) inba[inSub++] ) - { + switch ((char) inba[inSub++]) { case '"': outba[outSub++] = '"'; break; case 'a': - outba[outSub++] = 7; // Bell + outba[outSub++] = 7; // Bell break; case 'b': @@ -402,7 +337,7 @@ private static String unescape( String fileEntry ) break; case 'v': - outba[outSub++] = 11; // Vertical tab + outba[outSub++] = 11; // Vertical tab break; case 'f': @@ -422,34 +357,31 @@ private static String unescape( String fileEntry ) case '2': case '3': // This assumes that the octal escape here is valid. - byte b = (byte) ( ( inba[inSub - 1] - '0' ) << 6 ); - b |= (byte) ( ( inba[inSub++] - '0' ) << 3 ); - b |= (byte) ( inba[inSub++] - '0' ); + byte b = (byte) ((inba[inSub - 1] - '0') << 6); + b |= (byte) ((inba[inSub++] - '0') << 3); + b |= (byte) (inba[inSub++] - '0'); outba[outSub++] = b; break; default: - //This is an invalid escape in a string. Just copy it. + // This is an invalid escape in a string. Just copy it. outba[outSub++] = '\\'; inSub--; break; } - pos = fileEntry.indexOf( '\\', inSub ); - if ( pos == -1 ) // No more backslashes; we're done + pos = fileEntry.indexOf('\\', inSub); + if (pos == -1) // No more backslashes; we're done { - System.arraycopy( inba, inSub, outba, outSub, inba.length - inSub ); + System.arraycopy(inba, inSub, outba, outSub, inba.length - inSub); outSub += inba.length - inSub; break; } } - try - { + try { // explicit say UTF-8, otherwise it'll fail at least on Windows cmdline - return new String( outba, 0, outSub, "UTF-8" ); - } - catch ( UnsupportedEncodingException e ) - { - throw new RuntimeException( e ); + return new String(outba, 0, outSub, "UTF-8"); + } catch (UnsupportedEncodingException e) { + throw new RuntimeException(e); } } } diff --git a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/main/java/org/apache/maven/scm/provider/git/gitexe/command/tag/GitTagCommand.java b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/main/java/org/apache/maven/scm/provider/git/gitexe/command/tag/GitTagCommand.java index a025b30db..b2c6ce645 100644 --- a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/main/java/org/apache/maven/scm/provider/git/gitexe/command/tag/GitTagCommand.java +++ b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/main/java/org/apache/maven/scm/provider/git/gitexe/command/tag/GitTagCommand.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.git.gitexe.command.tag; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider.git.gitexe.command.tag; import java.io.File; import java.io.IOException; @@ -45,48 +44,40 @@ * @author Mark Struberg * */ -public class GitTagCommand - extends AbstractTagCommand - implements GitCommand -{ - - public ScmResult executeTagCommand( ScmProviderRepository repo, ScmFileSet fileSet, String tag, String message ) - throws ScmException - { - return executeTagCommand( repo, fileSet, tag, new ScmTagParameters( message ) ); +public class GitTagCommand extends AbstractTagCommand implements GitCommand { + + public ScmResult executeTagCommand(ScmProviderRepository repo, ScmFileSet fileSet, String tag, String message) + throws ScmException { + return executeTagCommand(repo, fileSet, tag, new ScmTagParameters(message)); } - + /** {@inheritDoc} */ - public ScmResult executeTagCommand( ScmProviderRepository repo, ScmFileSet fileSet, String tag, - ScmTagParameters scmTagParameters ) - throws ScmException - { - if ( tag == null || StringUtils.isEmpty( tag.trim() ) ) - { - throw new ScmException( "tag name must be specified" ); + public ScmResult executeTagCommand( + ScmProviderRepository repo, ScmFileSet fileSet, String tag, ScmTagParameters scmTagParameters) + throws ScmException { + if (tag == null || StringUtils.isEmpty(tag.trim())) { + throw new ScmException("tag name must be specified"); } - if ( !fileSet.getFileList().isEmpty() ) - { - throw new ScmException( "This provider doesn't support tagging subsets of a directory" ); + if (!fileSet.getFileList().isEmpty()) { + throw new ScmException("This provider doesn't support tagging subsets of a directory"); } GitScmProviderRepository repository = (GitScmProviderRepository) repo; - File messageFile = FileUtils.createTempFile( "maven-scm-", ".commit", null ); + File messageFile = FileUtils.createTempFile("maven-scm-", ".commit", null); - try - { - FileUtils.fileWrite( messageFile.getAbsolutePath(), "UTF-8", scmTagParameters.getMessage() ); - } - catch ( IOException ex ) - { - return new TagScmResult( null, "Error while making a temporary file for the commit message: " - + ex.getMessage(), null, false ); + try { + FileUtils.fileWrite(messageFile.getAbsolutePath(), "UTF-8", scmTagParameters.getMessage()); + } catch (IOException ex) { + return new TagScmResult( + null, + "Error while making a temporary file for the commit message: " + ex.getMessage(), + null, + false); } - try - { + try { CommandLineUtils.StringStreamConsumer stdout = new CommandLineUtils.StringStreamConsumer(); CommandLineUtils.StringStreamConsumer stderr = new CommandLineUtils.StringStreamConsumer(); @@ -94,89 +85,73 @@ public ScmResult executeTagCommand( ScmProviderRepository repo, ScmFileSet fileS boolean sign = scmTagParameters.isSign(); - Commandline clTag = createCommandLine( repository, fileSet.getBasedir(), tag, messageFile, sign ); + Commandline clTag = createCommandLine(repository, fileSet.getBasedir(), tag, messageFile, sign); - exitCode = GitCommandLineUtils.execute( clTag, stdout, stderr ); - if ( exitCode != 0 ) - { - return new TagScmResult( clTag.toString(), "The git-tag command failed.", stderr.getOutput(), false ); + exitCode = GitCommandLineUtils.execute(clTag, stdout, stderr); + if (exitCode != 0) { + return new TagScmResult(clTag.toString(), "The git-tag command failed.", stderr.getOutput(), false); } - if ( repo.isPushChanges() ) - { + if (repo.isPushChanges()) { // and now push the tag to the configured upstream repository - Commandline clPush = createPushCommandLine( repository, fileSet, tag ); - - exitCode = GitCommandLineUtils.execute( clPush, stdout, stderr ); - if ( exitCode != 0 ) - { - return new TagScmResult( clPush.toString(), "The git-push command failed.", stderr.getOutput(), - false ); + Commandline clPush = createPushCommandLine(repository, fileSet, tag); + + exitCode = GitCommandLineUtils.execute(clPush, stdout, stderr); + if (exitCode != 0) { + return new TagScmResult( + clPush.toString(), "The git-push command failed.", stderr.getOutput(), false); } } - + // plus search for the tagged files - GitListConsumer listConsumer = - new GitListConsumer( fileSet.getBasedir(), ScmFileStatus.TAGGED ); + GitListConsumer listConsumer = new GitListConsumer(fileSet.getBasedir(), ScmFileStatus.TAGGED); - Commandline clList = GitListCommand.createCommandLine( repository, fileSet.getBasedir() ); + Commandline clList = GitListCommand.createCommandLine(repository, fileSet.getBasedir()); - exitCode = GitCommandLineUtils.execute( clList, listConsumer, stderr ); - if ( exitCode != 0 ) - { - return new CheckOutScmResult( clList.toString(), "The git-ls-files command failed.", - stderr.getOutput(), false ); + exitCode = GitCommandLineUtils.execute(clList, listConsumer, stderr); + if (exitCode != 0) { + return new CheckOutScmResult( + clList.toString(), "The git-ls-files command failed.", stderr.getOutput(), false); } - return new TagScmResult( clTag.toString(), listConsumer.getListedFiles() ); - } - finally - { - try - { - FileUtils.forceDelete( messageFile ); - } - catch ( IOException ex ) - { + return new TagScmResult(clTag.toString(), listConsumer.getListedFiles()); + } finally { + try { + FileUtils.forceDelete(messageFile); + } catch (IOException ex) { // ignore } } - } // ---------------------------------------------------------------------- // // ---------------------------------------------------------------------- - public static Commandline createCommandLine( GitScmProviderRepository repository, File workingDirectory, - String tag, File messageFile, boolean sign ) - { - Commandline cl = GitCommandLineUtils.getBaseGitCommandLine( workingDirectory, "tag" ); + public static Commandline createCommandLine( + GitScmProviderRepository repository, File workingDirectory, String tag, File messageFile, boolean sign) { + Commandline cl = GitCommandLineUtils.getBaseGitCommandLine(workingDirectory, "tag"); - if ( sign ) - { - cl.createArg().setValue( "-s" ); + if (sign) { + cl.createArg().setValue("-s"); } - cl.createArg().setValue( "-F" ); - cl.createArg().setValue( messageFile.getAbsolutePath() ); + cl.createArg().setValue("-F"); + cl.createArg().setValue(messageFile.getAbsolutePath()); // Note: this currently assumes you have the tag base checked out too - cl.createArg().setValue( tag ); + cl.createArg().setValue(tag); return cl; } - public static Commandline createPushCommandLine( GitScmProviderRepository repository, ScmFileSet fileSet, - String tag ) - throws ScmException - { - Commandline cl = GitCommandLineUtils.getBaseGitCommandLine( fileSet.getBasedir(), "push" ); + public static Commandline createPushCommandLine(GitScmProviderRepository repository, ScmFileSet fileSet, String tag) + throws ScmException { + Commandline cl = GitCommandLineUtils.getBaseGitCommandLine(fileSet.getBasedir(), "push"); - cl.createArg().setValue( repository.getPushUrl() ); - cl.createArg().setValue( "refs/tags/" + tag ); + cl.createArg().setValue(repository.getPushUrl()); + cl.createArg().setValue("refs/tags/" + tag); return cl; } - } diff --git a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/main/java/org/apache/maven/scm/provider/git/gitexe/command/untag/GitUntagCommand.java b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/main/java/org/apache/maven/scm/provider/git/gitexe/command/untag/GitUntagCommand.java index 9735ad947..48e4b42b1 100644 --- a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/main/java/org/apache/maven/scm/provider/git/gitexe/command/untag/GitUntagCommand.java +++ b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/main/java/org/apache/maven/scm/provider/git/gitexe/command/untag/GitUntagCommand.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.git.gitexe.command.untag; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider.git.gitexe.command.untag; import java.io.File; @@ -36,20 +35,14 @@ import org.codehaus.plexus.util.cli.Commandline; /** {@inheritDoc} */ -public class GitUntagCommand - extends AbstractUntagCommand - implements GitCommand -{ +public class GitUntagCommand extends AbstractUntagCommand implements GitCommand { /** {@inheritDoc} */ - public ScmResult executeUntagCommand( ScmProviderRepository repo, ScmFileSet fileSet, - ScmUntagParameters scmUntagParameters ) - throws ScmException - { + public ScmResult executeUntagCommand( + ScmProviderRepository repo, ScmFileSet fileSet, ScmUntagParameters scmUntagParameters) throws ScmException { String tag = scmUntagParameters.getTag(); - if ( tag == null || StringUtils.isEmpty( tag.trim() ) ) - { - throw new ScmException( "tag name must be specified" ); + if (tag == null || StringUtils.isEmpty(tag.trim())) { + throw new ScmException("tag name must be specified"); } GitScmProviderRepository repository = (GitScmProviderRepository) repo; @@ -59,55 +52,48 @@ public ScmResult executeUntagCommand( ScmProviderRepository repo, ScmFileSet fil int exitCode; - Commandline clTag = createCommandLine( repository, fileSet.getBasedir(), tag ); + Commandline clTag = createCommandLine(repository, fileSet.getBasedir(), tag); - exitCode = GitCommandLineUtils.execute( clTag, stdout, stderr ); - if ( exitCode != 0 ) - { - return new UntagScmResult( clTag.toString(), "The git-tag command failed.", stderr.getOutput(), false ); + exitCode = GitCommandLineUtils.execute(clTag, stdout, stderr); + if (exitCode != 0) { + return new UntagScmResult(clTag.toString(), "The git-tag command failed.", stderr.getOutput(), false); } - if ( repo.isPushChanges() ) - { + if (repo.isPushChanges()) { // and now push the tag to the configured upstream repository - Commandline clPush = createPushCommandLine( repository, fileSet, tag ); + Commandline clPush = createPushCommandLine(repository, fileSet, tag); - exitCode = GitCommandLineUtils.execute( clPush, stdout, stderr ); - if ( exitCode != 0 ) - { - return new UntagScmResult( clPush.toString(), "The git-push command failed.", stderr.getOutput(), - false ); + exitCode = GitCommandLineUtils.execute(clPush, stdout, stderr); + if (exitCode != 0) { + return new UntagScmResult(clPush.toString(), "The git-push command failed.", stderr.getOutput(), false); } } - return new UntagScmResult( clTag.toString() ); + return new UntagScmResult(clTag.toString()); } // ---------------------------------------------------------------------- // // ---------------------------------------------------------------------- - public static Commandline createCommandLine( GitScmProviderRepository repository, File workingDirectory, - String tag ) - { - Commandline cl = GitCommandLineUtils.getBaseGitCommandLine( workingDirectory, "tag" ); + public static Commandline createCommandLine( + GitScmProviderRepository repository, File workingDirectory, String tag) { + Commandline cl = GitCommandLineUtils.getBaseGitCommandLine(workingDirectory, "tag"); - cl.createArg().setValue( "-d" ); - cl.createArg().setValue( tag ); + cl.createArg().setValue("-d"); + cl.createArg().setValue(tag); return cl; } - public static Commandline createPushCommandLine( GitScmProviderRepository repository, ScmFileSet fileSet, - String tag ) - { - Commandline cl = GitCommandLineUtils.getBaseGitCommandLine( fileSet.getBasedir(), "push" ); + public static Commandline createPushCommandLine( + GitScmProviderRepository repository, ScmFileSet fileSet, String tag) { + Commandline cl = GitCommandLineUtils.getBaseGitCommandLine(fileSet.getBasedir(), "push"); - cl.createArg().setValue( "--delete" ); - cl.createArg().setValue( repository.getPushUrl() ); - cl.createArg().setValue( "refs/tags/" + tag ); + cl.createArg().setValue("--delete"); + cl.createArg().setValue(repository.getPushUrl()); + cl.createArg().setValue("refs/tags/" + tag); return cl; } - } diff --git a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/main/java/org/apache/maven/scm/provider/git/gitexe/command/update/GitLatestRevisionCommandConsumer.java b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/main/java/org/apache/maven/scm/provider/git/gitexe/command/update/GitLatestRevisionCommandConsumer.java index 271dc54bb..64cfa2987 100644 --- a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/main/java/org/apache/maven/scm/provider/git/gitexe/command/update/GitLatestRevisionCommandConsumer.java +++ b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/main/java/org/apache/maven/scm/provider/git/gitexe/command/update/GitLatestRevisionCommandConsumer.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.git.gitexe.command.update; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -18,45 +16,40 @@ * specific language governing permissions and limitations * under the License. */ - -import org.apache.maven.scm.util.AbstractConsumer; -import org.codehaus.plexus.util.StringUtils; +package org.apache.maven.scm.provider.git.gitexe.command.update; import java.util.regex.Matcher; import java.util.regex.Pattern; +import org.apache.maven.scm.util.AbstractConsumer; +import org.codehaus.plexus.util.StringUtils; + /** * @author Mark Struberg * */ -public class GitLatestRevisionCommandConsumer - extends AbstractConsumer -{ +public class GitLatestRevisionCommandConsumer extends AbstractConsumer { /** * The pattern used to match git log latest revision lines */ - private static final Pattern LATESTREV_PATTERN = Pattern.compile( "^commit \\s*(.*)" ); + private static final Pattern LATESTREV_PATTERN = Pattern.compile("^commit \\s*(.*)"); private String latestRevision; /** {@inheritDoc} */ - public void consumeLine( String line ) - { - if ( logger.isDebugEnabled() ) - { - logger.debug( "GitLatestRevisionCommandConsumer consumeLine : " + line ); + public void consumeLine(String line) { + if (logger.isDebugEnabled()) { + logger.debug("GitLatestRevisionCommandConsumer consumeLine : " + line); } - if ( line == null || StringUtils.isEmpty( line ) ) - { + if (line == null || StringUtils.isEmpty(line)) { return; } - processGetLatestRevision( line ); + processGetLatestRevision(line); } - public String getLatestRevision() - { + public String getLatestRevision() { return latestRevision; } @@ -65,14 +58,10 @@ public String getLatestRevision() * * @param line A line of text from the git log output */ - private void processGetLatestRevision( String line ) - { - Matcher matcher = LATESTREV_PATTERN.matcher( line ); - if ( matcher.matches() ) - { - latestRevision = matcher.group( 1 ); - + private void processGetLatestRevision(String line) { + Matcher matcher = LATESTREV_PATTERN.matcher(line); + if (matcher.matches()) { + latestRevision = matcher.group(1); } } - } diff --git a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/main/java/org/apache/maven/scm/provider/git/gitexe/command/update/GitUpdateCommand.java b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/main/java/org/apache/maven/scm/provider/git/gitexe/command/update/GitUpdateCommand.java index 794e450ac..1682b5d26 100644 --- a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/main/java/org/apache/maven/scm/provider/git/gitexe/command/update/GitUpdateCommand.java +++ b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/main/java/org/apache/maven/scm/provider/git/gitexe/command/update/GitUpdateCommand.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.git.gitexe.command.update; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -18,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider.git.gitexe.command.update; import java.io.File; @@ -45,21 +44,20 @@ * @since 10 august 2008 * */ -public class GitUpdateCommand - extends AbstractUpdateCommand - implements GitCommand -{ +public class GitUpdateCommand extends AbstractUpdateCommand implements GitCommand { /** {@inheritDoc} */ - protected UpdateScmResult executeUpdateCommand( ScmProviderRepository repo, ScmFileSet fileSet, - ScmVersion scmVersion ) - throws ScmException - { + protected UpdateScmResult executeUpdateCommand( + ScmProviderRepository repo, ScmFileSet fileSet, ScmVersion scmVersion) throws ScmException { GitScmProviderRepository repository = (GitScmProviderRepository) repo; - if ( GitScmProviderRepository.PROTOCOL_FILE.equals( repository.getFetchInfo().getProtocol() ) - && repository.getFetchInfo().getPath().indexOf( fileSet.getBasedir().getPath() ) >= 0 ) - { - throw new ScmException( "remote repository must not be the working directory" ); + if (GitScmProviderRepository.PROTOCOL_FILE.equals( + repository.getFetchInfo().getProtocol()) + && repository + .getFetchInfo() + .getPath() + .indexOf(fileSet.getBasedir().getPath()) + >= 0) { + throw new ScmException("remote repository must not be the working directory"); } int exitCode; @@ -68,68 +66,57 @@ protected UpdateScmResult executeUpdateCommand( ScmProviderRepository repo, ScmF CommandLineUtils.StringStreamConsumer stderr = new CommandLineUtils.StringStreamConsumer(); // fir we need to get the current reversion - Commandline clRev = createLatestRevisionCommandLine( repository, fileSet.getBasedir(), scmVersion ); + Commandline clRev = createLatestRevisionCommandLine(repository, fileSet.getBasedir(), scmVersion); GitLatestRevisionCommandConsumer consumerRev = new GitLatestRevisionCommandConsumer(); - exitCode = GitCommandLineUtils.execute( clRev, consumerRev, stderr ); - if ( exitCode != 0 ) - { - return new UpdateScmResult( clRev.toString(), "The git-log command failed.", - stderr.getOutput(), false ); + exitCode = GitCommandLineUtils.execute(clRev, consumerRev, stderr); + if (exitCode != 0) { + return new UpdateScmResult(clRev.toString(), "The git-log command failed.", stderr.getOutput(), false); } String origSha1 = consumerRev.getLatestRevision(); - Commandline cl = createCommandLine( repository, fileSet.getBasedir(), scmVersion ); - exitCode = GitCommandLineUtils.execute( cl, stdout, stderr ); - if ( exitCode != 0 ) - { - return new UpdateScmResult( cl.toString(), "The git-pull command failed.", - stderr.getOutput(), false ); + Commandline cl = createCommandLine(repository, fileSet.getBasedir(), scmVersion); + exitCode = GitCommandLineUtils.execute(cl, stdout, stderr); + if (exitCode != 0) { + return new UpdateScmResult(cl.toString(), "The git-pull command failed.", stderr.getOutput(), false); } // we also need to log exactly what has been updated GitDiffRawConsumer diffRawConsumer = new GitDiffRawConsumer(); - Commandline clDiffRaw = GitDiffCommand.createDiffRawCommandLine( fileSet.getBasedir(), origSha1 ); - exitCode = GitCommandLineUtils.execute( clDiffRaw, diffRawConsumer, stderr ); - if ( exitCode != 0 ) - { - return new UpdateScmResult( clDiffRaw.toString(), "The git-diff --raw command failed.", - stderr.getOutput(), false ); + Commandline clDiffRaw = GitDiffCommand.createDiffRawCommandLine(fileSet.getBasedir(), origSha1); + exitCode = GitCommandLineUtils.execute(clDiffRaw, diffRawConsumer, stderr); + if (exitCode != 0) { + return new UpdateScmResult( + clDiffRaw.toString(), "The git-diff --raw command failed.", stderr.getOutput(), false); } - // now let's get the latest version consumerRev = new GitLatestRevisionCommandConsumer(); - exitCode = GitCommandLineUtils.execute( clRev, consumerRev, stderr ); - if ( exitCode != 0 ) - { - return new UpdateScmResult( clRev.toString(), "The git-log command failed.", - stderr.getOutput(), false ); + exitCode = GitCommandLineUtils.execute(clRev, consumerRev, stderr); + if (exitCode != 0) { + return new UpdateScmResult(clRev.toString(), "The git-log command failed.", stderr.getOutput(), false); } String latestRevision = consumerRev.getLatestRevision(); - return new UpdateScmResultWithRevision( cl.toString(), diffRawConsumer.getChangedFiles(), latestRevision ); + return new UpdateScmResultWithRevision(cl.toString(), diffRawConsumer.getChangedFiles(), latestRevision); } /** {@inheritDoc} */ - protected ChangeLogCommand getChangeLogCommand() - { + protected ChangeLogCommand getChangeLogCommand() { return new GitChangeLogCommand(); } /** * create the command line for updating the current branch with the info from the foreign repository. */ - public static Commandline createCommandLine( GitScmProviderRepository repository, File workingDirectory, - ScmVersion scmVersion ) - { - Commandline cl = GitCommandLineUtils.getBaseGitCommandLine( workingDirectory, "pull" ); + public static Commandline createCommandLine( + GitScmProviderRepository repository, File workingDirectory, ScmVersion scmVersion) { + Commandline cl = GitCommandLineUtils.getBaseGitCommandLine(workingDirectory, "pull"); - cl.createArg().setLine( repository.getFetchUrl() ); + cl.createArg().setLine(repository.getFetchUrl()); // now set the branch where we would like to pull from - if ( scmVersion instanceof ScmBranch ) - { - cl.createArg().setLine( scmVersion.getName() ); + if (scmVersion instanceof ScmBranch) { + cl.createArg().setLine(scmVersion.getName()); } return cl; @@ -139,22 +126,22 @@ public static Commandline createCommandLine( GitScmProviderRepository repository * @param scmVersion a valid branch or null if the master branch should be taken * @return CommandLine for getting the latest commit on the given branch */ - public static Commandline createLatestRevisionCommandLine( GitScmProviderRepository repository, - File workingDirectory, ScmVersion scmVersion ) - { - Commandline cl = GitCommandLineUtils.getBaseGitCommandLine( workingDirectory, "log" ); + public static Commandline createLatestRevisionCommandLine( + GitScmProviderRepository repository, File workingDirectory, ScmVersion scmVersion) { + Commandline cl = GitCommandLineUtils.getBaseGitCommandLine(workingDirectory, "log"); // only show exactly 1 commit - cl.createArg().setValue( "-n1" ); + cl.createArg().setValue("-n1"); // same as --topo-order, but ensure ordering of merges - cl.createArg().setValue( "--date-order" ); + cl.createArg().setValue("--date-order"); - if ( scmVersion != null && scmVersion instanceof ScmBranch && scmVersion.getName() != null - && scmVersion.getName().length() > 0 ) - { + if (scmVersion != null + && scmVersion instanceof ScmBranch + && scmVersion.getName() != null + && scmVersion.getName().length() > 0) { // if any branch is given, lets take em - cl.createArg().setValue( scmVersion.getName() ); + cl.createArg().setValue(scmVersion.getName()); } // otherwise we work on HEAD/current branch diff --git a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/test/java/org/apache/maven/scm/provider/git/gitexe/command/GitCommandLineUtilsTest.java b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/test/java/org/apache/maven/scm/provider/git/gitexe/command/GitCommandLineUtilsTest.java index c1bc067c2..55e29c077 100644 --- a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/test/java/org/apache/maven/scm/provider/git/gitexe/command/GitCommandLineUtilsTest.java +++ b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/test/java/org/apache/maven/scm/provider/git/gitexe/command/GitCommandLineUtilsTest.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.git.gitexe.command; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,11 +16,7 @@ * specific language governing permissions and limitations * under the License. */ - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; -import static org.junit.Assume.assumeTrue; +package org.apache.maven.scm.provider.git.gitexe.command; import java.io.File; import java.text.MessageFormat; @@ -38,98 +32,99 @@ import org.codehaus.plexus.util.cli.Commandline; import org.junit.Test; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; +import static org.junit.Assume.assumeTrue; + /** * @author mfriedenhagen */ -public class GitCommandLineUtilsTest -{ +public class GitCommandLineUtilsTest { /** * Test of addTarget method, of class GitCommandLineUtils on Non-Windows * systems. */ @Test - public void testAddTargetNonWindows() - { - assumeTrue( !runsOnWindows() ); - final File workingDir = new File( "/prj" ); - final List filesToAdd = Arrays.asList( new File( "/prj/pom.xml" ), new File( "/prj/mod1/pom.xml" ) ); + public void testAddTargetNonWindows() { + assumeTrue(!runsOnWindows()); + final File workingDir = new File("/prj"); + final List filesToAdd = Arrays.asList(new File("/prj/pom.xml"), new File("/prj/mod1/pom.xml")); final String expectedArguments = "[add, pom.xml, mod1/pom.xml]"; - check( workingDir, filesToAdd, expectedArguments ); + check(workingDir, filesToAdd, expectedArguments); } /** * Test of addTarget method, of class GitCommandLineUtils on Windows. */ @Test - public void testAddTargetWindows() - { - assumeTrue( runsOnWindows() ); - final File workingDir = new File( "C:\\prj" ); + public void testAddTargetWindows() { + assumeTrue(runsOnWindows()); + final File workingDir = new File("C:\\prj"); // Note that the second file has a lowercase drive letter, see // https://jira.codehaus.org/browse/SCM-667 - final List filesToAdd = Arrays.asList( new File( "C:\\prj\\pom.xml" ), - new File( "c:\\prj\\mod1\\pom.xml" ) ); + final List filesToAdd = Arrays.asList(new File("C:\\prj\\pom.xml"), new File("c:\\prj\\mod1\\pom.xml")); final String expectedArguments = "[add, pom.xml, mod1/pom.xml]"; - check( workingDir, filesToAdd, expectedArguments ); + check(workingDir, filesToAdd, expectedArguments); } - private void check( final File workingDir, final List filesToAdd, final String expectedArguments ) - { - final Commandline cl = GitCommandLineUtils.getBaseGitCommandLine( workingDir, "add" ); - GitCommandLineUtils.addTarget( cl, filesToAdd ); - final String arguments = Arrays.toString( cl.getArguments() ); - assertEquals( 3, cl.getArguments().length ); - assertEquals( expectedArguments, arguments ); + private void check(final File workingDir, final List filesToAdd, final String expectedArguments) { + final Commandline cl = GitCommandLineUtils.getBaseGitCommandLine(workingDir, "add"); + GitCommandLineUtils.addTarget(cl, filesToAdd); + final String arguments = Arrays.toString(cl.getArguments()); + assertEquals(3, cl.getArguments().length); + assertEquals(expectedArguments, arguments); } @Test - public void testPasswordAnonymous() - throws Exception - { + public void testPasswordAnonymous() throws Exception { String commandLine = "git push https://user:password@foo.com/git/trunk refs/tags/my-tag-1"; - final Commandline cl = GitCommandLineUtils.getBaseGitCommandLine( new File( "." ), commandLine ); + final Commandline cl = GitCommandLineUtils.getBaseGitCommandLine(new File("."), commandLine); String[] commandLineArgs = cl.getShellCommandline(); // - for ( int i = 0; i < commandLineArgs.length; i++ ) - { - assertFalse( MessageFormat.format( "The target log message should not contain <{0}> but it contains <{1}>", - AnonymousCommandLine.PASSWORD_PLACE_HOLDER, commandLineArgs[i] ), - commandLineArgs[i].contains( AnonymousCommandLine.PASSWORD_PLACE_HOLDER ) ); + for (int i = 0; i < commandLineArgs.length; i++) { + assertFalse( + MessageFormat.format( + "The target log message should not contain <{0}> but it contains <{1}>", + AnonymousCommandLine.PASSWORD_PLACE_HOLDER, commandLineArgs[i]), + commandLineArgs[i].contains(AnonymousCommandLine.PASSWORD_PLACE_HOLDER)); } - final String scmUrlFakeForTest = "https://user:".concat( AnonymousCommandLine.PASSWORD_PLACE_HOLDER ).concat( - "@foo.com/git/trunk" ); + final String scmUrlFakeForTest = "https://user:" + .concat(AnonymousCommandLine.PASSWORD_PLACE_HOLDER) + .concat("@foo.com/git/trunk"); - assertTrue( MessageFormat.format( "The target log message should contain <{0}> but it contains <{1}>", - scmUrlFakeForTest, cl.toString() ), cl.toString().contains( scmUrlFakeForTest ) ); + assertTrue( + MessageFormat.format( + "The target log message should contain <{0}> but it contains <{1}>", + scmUrlFakeForTest, cl.toString()), + cl.toString().contains(scmUrlFakeForTest)); } @Test - public void testPrepareEnvVariablesForRepository() throws ScmException - { - GitScmProviderRepository repository = new GitScmProviderRepository( "http://localhost/repository.git" ); - assertEquals( Collections.emptyMap(), GitCommandLineUtils.prepareEnvVariablesForRepository( repository, null ) ); + public void testPrepareEnvVariablesForRepository() throws ScmException { + GitScmProviderRepository repository = new GitScmProviderRepository("http://localhost/repository.git"); + assertEquals(Collections.emptyMap(), GitCommandLineUtils.prepareEnvVariablesForRepository(repository, null)); Map testMap = new HashMap<>(); - testMap.put( "testKey", "testValue" ); - assertEquals( testMap, GitCommandLineUtils.prepareEnvVariablesForRepository( repository, testMap ) ); + testMap.put("testKey", "testValue"); + assertEquals(testMap, GitCommandLineUtils.prepareEnvVariablesForRepository(repository, testMap)); - repository.setPrivateKey( "my\\private\\key" ); + repository.setPrivateKey("my\\private\\key"); testMap.clear(); - testMap.put( "GIT_SSH_COMMAND", "ssh -o IdentitiesOnly=yes -i my/private/key" ); - assertEquals( testMap, GitCommandLineUtils.prepareEnvVariablesForRepository( repository, null ) ); + testMap.put("GIT_SSH_COMMAND", "ssh -o IdentitiesOnly=yes -i my/private/key"); + assertEquals(testMap, GitCommandLineUtils.prepareEnvVariablesForRepository(repository, null)); - testMap.put( "GIT_SSH_COMMAND", "ssh -o IdentitiesOnly=yes -i my/other/key" ); - assertEquals( testMap, GitCommandLineUtils.prepareEnvVariablesForRepository( repository, testMap ) ); + testMap.put("GIT_SSH_COMMAND", "ssh -o IdentitiesOnly=yes -i my/other/key"); + assertEquals(testMap, GitCommandLineUtils.prepareEnvVariablesForRepository(repository, testMap)); } - private boolean runsOnWindows() - { - return Os.isFamily( Os.FAMILY_WINDOWS ); + private boolean runsOnWindows() { + return Os.isFamily(Os.FAMILY_WINDOWS); } } diff --git a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/test/java/org/apache/maven/scm/provider/git/gitexe/command/add/GitExeAddCommandTest.java b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/test/java/org/apache/maven/scm/provider/git/gitexe/command/add/GitExeAddCommandTest.java index 3fe0d2414..e8cbbdd3e 100644 --- a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/test/java/org/apache/maven/scm/provider/git/gitexe/command/add/GitExeAddCommandTest.java +++ b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/test/java/org/apache/maven/scm/provider/git/gitexe/command/add/GitExeAddCommandTest.java @@ -1,13 +1,3 @@ -package org.apache.maven.scm.provider.git.gitexe.command.add; - -import java.io.File; -import java.util.ArrayList; -import java.util.List; - -import org.apache.maven.scm.ScmTestCase; -import org.codehaus.plexus.util.cli.Commandline; -import org.junit.Test; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -17,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -26,6 +16,15 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider.git.gitexe.command.add; + +import java.io.File; +import java.util.ArrayList; +import java.util.List; + +import org.apache.maven.scm.ScmTestCase; +import org.codehaus.plexus.util.cli.Commandline; +import org.junit.Test; /** * Check if the {@code GitAddCommand#createCommandLine(File, List)} returns the correct @@ -33,44 +32,37 @@ * @author Mark Struberg * */ -public class GitExeAddCommandTest - extends ScmTestCase -{ +public class GitExeAddCommandTest extends ScmTestCase { @Test - public void testAddCommandSingleFile() throws Exception - { + public void testAddCommandSingleFile() throws Exception { List files = new ArrayList(); - - files.add( new File( "myFile.java" ) ); - - testCommandLine( "scm:git:http://foo.com/git", files, "git add -- myFile.java" ); + + files.add(new File("myFile.java")); + + testCommandLine("scm:git:http://foo.com/git", files, "git add -- myFile.java"); } @Test - public void testAddCommandMultipleFiles() throws Exception - { + public void testAddCommandMultipleFiles() throws Exception { List files = new ArrayList(); - - files.add( new File( "myFile.java" ) ); - files.add( new File( "myFile2.java" ) ); - files.add( new File( "myFile3.java" ) ); - - testCommandLine( "scm:git:http://foo.com/git", files, "git add -- myFile.java myFile2.java myFile3.java" ); + + files.add(new File("myFile.java")); + files.add(new File("myFile2.java")); + files.add(new File("myFile3.java")); + + testCommandLine("scm:git:http://foo.com/git", files, "git add -- myFile.java myFile2.java myFile3.java"); } - + // ---------------------------------------------------------------------- // private helper functions // ---------------------------------------------------------------------- - private void testCommandLine( String scmUrl, List files, String commandLine ) - throws Exception - { - File workingDirectory = getTestFile( "target/git-add-command-test" ); + private void testCommandLine(String scmUrl, List files, String commandLine) throws Exception { + File workingDirectory = getTestFile("target/git-add-command-test"); - Commandline cl = GitAddCommand.createCommandLine(workingDirectory, files ); + Commandline cl = GitAddCommand.createCommandLine(workingDirectory, files); - assertCommandLine( commandLine, workingDirectory, cl ); + assertCommandLine(commandLine, workingDirectory, cl); } - } diff --git a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/test/java/org/apache/maven/scm/provider/git/gitexe/command/blame/GitBlameConsumerTest.java b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/test/java/org/apache/maven/scm/provider/git/gitexe/command/blame/GitBlameConsumerTest.java index e3f29a022..314a9d59a 100644 --- a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/test/java/org/apache/maven/scm/provider/git/gitexe/command/blame/GitBlameConsumerTest.java +++ b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/test/java/org/apache/maven/scm/provider/git/gitexe/command/blame/GitBlameConsumerTest.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.git.gitexe.command.blame; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,12 +16,7 @@ * specific language governing permissions and limitations * under the License. */ - -import org.apache.maven.scm.ScmTestCase; -import org.apache.maven.scm.command.blame.BlameLine; -import org.apache.maven.scm.util.ConsumerUtils; -import org.junit.Assert; -import org.junit.Test; +package org.apache.maven.scm.provider.git.gitexe.command.blame; import java.io.BufferedReader; import java.io.File; @@ -34,6 +27,12 @@ import java.util.List; import java.util.TimeZone; +import org.apache.maven.scm.ScmTestCase; +import org.apache.maven.scm.command.blame.BlameLine; +import org.apache.maven.scm.util.ConsumerUtils; +import org.junit.Assert; +import org.junit.Test; + import static org.junit.Assert.fail; /** @@ -41,35 +40,29 @@ * Depending on the underlying operating system we might get * slightly different output from a

git blame
commandline invocation. */ -public class GitBlameConsumerTest - extends ScmTestCase -{ +public class GitBlameConsumerTest extends ScmTestCase { @Test - public void testConsumerEasy() - throws Exception - { - GitBlameConsumer consumer = consumeFile( "/src/test/resources/git/blame/git-blame-3.out" ); + public void testConsumerEasy() throws Exception { + GitBlameConsumer consumer = consumeFile("/src/test/resources/git/blame/git-blame-3.out"); - Assert.assertEquals( 36, consumer.getLines().size() ); + Assert.assertEquals(36, consumer.getLines().size()); - BlameLine blameLine = consumer.getLines().get( 11 ); - Assert.assertEquals( "e670863b2b03e158c59f34af1fee20f91b2bd852", blameLine.getRevision() ); - Assert.assertEquals( "Mark Struberg", blameLine.getAuthor() ); - Assert.assertNotNull( blameLine.getDate() ); + BlameLine blameLine = consumer.getLines().get(11); + Assert.assertEquals("e670863b2b03e158c59f34af1fee20f91b2bd852", blameLine.getRevision()); + Assert.assertEquals("Mark Struberg", blameLine.getAuthor()); + Assert.assertNotNull(blameLine.getDate()); } @Test - public void testConsumer() - throws Exception - { - GitBlameConsumer consumer = consumeFile( "/src/test/resources/git/blame/git-blame.out" ); + public void testConsumer() throws Exception { + GitBlameConsumer consumer = consumeFile("/src/test/resources/git/blame/git-blame.out"); - Assert.assertEquals( 187, consumer.getLines().size() ); + Assert.assertEquals(187, consumer.getLines().size()); - BlameLine blameLine = consumer.getLines().get( 11 ); - Assert.assertEquals( "e670863b2b03e158c59f34af1fee20f91b2bd852", blameLine.getRevision() ); - Assert.assertEquals( "Mark Struberg", blameLine.getAuthor() ); - Assert.assertNotNull( blameLine.getDate() ); + BlameLine blameLine = consumer.getLines().get(11); + Assert.assertEquals("e670863b2b03e158c59f34af1fee20f91b2bd852", blameLine.getRevision()); + Assert.assertEquals("Mark Struberg", blameLine.getAuthor()); + Assert.assertNotNull(blameLine.getDate()); } /** @@ -77,12 +70,10 @@ public void testConsumer() * file which has no content. */ @Test - public void testConsumerEmptyFile() - throws Exception - { - GitBlameConsumer consumer = consumeFile( "/src/test/resources/git/blame/git-blame-empty.out" ); + public void testConsumerEmptyFile() throws Exception { + GitBlameConsumer consumer = consumeFile("/src/test/resources/git/blame/git-blame-empty.out"); - Assert.assertEquals( 0, consumer.getLines().size() ); + Assert.assertEquals(0, consumer.getLines().size()); } /** @@ -90,39 +81,35 @@ public void testConsumerEmptyFile() * file which didn't got added to the git repo yet. */ @Test - public void testConsumerOnNewFile() - throws Exception - { - GitBlameConsumer consumer = consumeFile( "/src/test/resources/git/blame/git-blame-new-file.out" ); - - Assert.assertEquals( 3, consumer.getLines().size() ); - BlameLine blameLine = consumer.getLines().get( 0 ); - Assert.assertNotNull( blameLine ); - Assert.assertEquals( "0000000000000000000000000000000000000000", blameLine.getRevision() ); - Assert.assertEquals( "Not Committed Yet", blameLine.getAuthor() ); + public void testConsumerOnNewFile() throws Exception { + GitBlameConsumer consumer = consumeFile("/src/test/resources/git/blame/git-blame-new-file.out"); + + Assert.assertEquals(3, consumer.getLines().size()); + BlameLine blameLine = consumer.getLines().get(0); + Assert.assertNotNull(blameLine); + Assert.assertEquals("0000000000000000000000000000000000000000", blameLine.getRevision()); + Assert.assertEquals("Not Committed Yet", blameLine.getAuthor()); } /** * Test a case where the committer and author are different persons */ @Test - public void testConsumerWithDifferentAuthor() - throws Exception - { - GitBlameConsumer consumer = consumeFile( "/src/test/resources/git/blame/git-blame-different-author.out" ); - - Assert.assertEquals( 93, consumer.getLines().size() ); - BlameLine blameLine = consumer.getLines().get( 0 ); - Assert.assertNotNull( blameLine ); - Assert.assertEquals( "39574726d20f62023d39311e6032c7ab0a9d3cdb", blameLine.getRevision() ); - Assert.assertEquals( "Mark Struberg", blameLine.getAuthor() ); - Assert.assertEquals( "Mark Struberg", blameLine.getCommitter() ); - - blameLine = consumer.getLines().get( 12 ); - Assert.assertNotNull( blameLine ); - Assert.assertEquals( "41e5bc05953781a5702f597a1a36c55371b517d3", blameLine.getRevision() ); - Assert.assertEquals( "Another User", blameLine.getAuthor() ); - Assert.assertEquals( "Mark Struberg", blameLine.getCommitter() ); + public void testConsumerWithDifferentAuthor() throws Exception { + GitBlameConsumer consumer = consumeFile("/src/test/resources/git/blame/git-blame-different-author.out"); + + Assert.assertEquals(93, consumer.getLines().size()); + BlameLine blameLine = consumer.getLines().get(0); + Assert.assertNotNull(blameLine); + Assert.assertEquals("39574726d20f62023d39311e6032c7ab0a9d3cdb", blameLine.getRevision()); + Assert.assertEquals("Mark Struberg", blameLine.getAuthor()); + Assert.assertEquals("Mark Struberg", blameLine.getCommitter()); + + blameLine = consumer.getLines().get(12); + Assert.assertNotNull(blameLine); + Assert.assertEquals("41e5bc05953781a5702f597a1a36c55371b517d3", blameLine.getRevision()); + Assert.assertEquals("Another User", blameLine.getAuthor()); + Assert.assertEquals("Mark Struberg", blameLine.getCommitter()); } /** @@ -130,51 +117,44 @@ public void testConsumerWithDifferentAuthor() * simplified git blame output. */ @Test - public void testConsumerCompareWithOriginal() throws Exception - { - GitBlameConsumer consumer = consumeFile( "/src/test/resources/git/blame/git-blame-2.out" ); - Assert.assertNotNull( consumer ); + public void testConsumerCompareWithOriginal() throws Exception { + GitBlameConsumer consumer = consumeFile("/src/test/resources/git/blame/git-blame-2.out"); + Assert.assertNotNull(consumer); List consumerLines = consumer.getLines(); Iterator consumerLineIt = consumerLines.iterator(); - File compareWithFile = getTestFile( "/src/test/resources/git/blame/git-blame-2.orig" ); - Assert.assertNotNull( compareWithFile ); + File compareWithFile = getTestFile("/src/test/resources/git/blame/git-blame-2.orig"); + Assert.assertNotNull(compareWithFile); - try ( BufferedReader r = new BufferedReader( new FileReader( compareWithFile ) ) ) - { + try (BufferedReader r = new BufferedReader(new FileReader(compareWithFile))) { String line; - SimpleDateFormat blameDateFormat = new SimpleDateFormat( "yyyy-MM-dd HH:mm:ss" ); - blameDateFormat.setTimeZone( TimeZone.getTimeZone( "GMT" ) ); - + SimpleDateFormat blameDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + blameDateFormat.setTimeZone(TimeZone.getTimeZone("GMT")); + int lineNr = 0; - - while ( ( line = r.readLine() ) != null && line.trim().length() > 0 ) - { - if ( !consumerLineIt.hasNext() ) - { - fail( "GitBlameConsumer lines do not match the original output!" ); + + while ((line = r.readLine()) != null && line.trim().length() > 0) { + if (!consumerLineIt.hasNext()) { + fail("GitBlameConsumer lines do not match the original output!"); } BlameLine blameLine = consumerLineIt.next(); - Assert.assertNotNull( blameLine ); - - String[] parts = line.split( "\t" ); - Assert.assertEquals( 3, parts.length ); - - Assert.assertEquals( "error in line " + lineNr, parts[0], blameLine.getRevision() ); - Assert.assertEquals( "error in line " + lineNr, parts[1], blameLine.getAuthor() ); - Assert.assertEquals( "error in line " + lineNr, parts[2], - blameDateFormat.format( blameLine.getDate() ) ); - + Assert.assertNotNull(blameLine); + + String[] parts = line.split("\t"); + Assert.assertEquals(3, parts.length); + + Assert.assertEquals("error in line " + lineNr, parts[0], blameLine.getRevision()); + Assert.assertEquals("error in line " + lineNr, parts[1], blameLine.getAuthor()); + Assert.assertEquals("error in line " + lineNr, parts[2], blameDateFormat.format(blameLine.getDate())); + lineNr++; } } - if ( consumerLineIt.hasNext() ) - { - fail( "GitBlameConsumer found more lines than in the original output!" ); + if (consumerLineIt.hasNext()) { + fail("GitBlameConsumer found more lines than in the original output!"); } - } /** @@ -184,15 +164,13 @@ public void testConsumerCompareWithOriginal() throws Exception * @return the resulting {@link GitBlameConsumer} * @throws IOException */ - private GitBlameConsumer consumeFile( String fileName ) throws IOException - { + private GitBlameConsumer consumeFile(String fileName) throws IOException { GitBlameConsumer consumer = new GitBlameConsumer(); - File f = getTestFile( fileName ); + File f = getTestFile(fileName); - ConsumerUtils.consumeFile( f, consumer ); + ConsumerUtils.consumeFile(f, consumer); return consumer; } - } diff --git a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/test/java/org/apache/maven/scm/provider/git/gitexe/command/blame/GitExeBlameCommandTckTest.java b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/test/java/org/apache/maven/scm/provider/git/gitexe/command/blame/GitExeBlameCommandTckTest.java index 2713fda25..e6d97abf7 100644 --- a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/test/java/org/apache/maven/scm/provider/git/gitexe/command/blame/GitExeBlameCommandTckTest.java +++ b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/test/java/org/apache/maven/scm/provider/git/gitexe/command/blame/GitExeBlameCommandTckTest.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.git.gitexe.command.blame; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,9 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider.git.gitexe.command.blame; + +import java.util.List; import org.apache.maven.scm.command.blame.BlameLine; import org.apache.maven.scm.command.blame.BlameScmResult; @@ -25,42 +26,32 @@ import org.apache.maven.scm.provider.git.command.blame.GitBlameCommandTckTest; import org.junit.Test; -import java.util.List; - import static org.apache.maven.scm.provider.git.GitScmTestUtils.GIT_COMMAND_LINE; import static org.junit.Assert.assertEquals; /** * @author Evgeny Mandrikov */ -public class GitExeBlameCommandTckTest - extends GitBlameCommandTckTest -{ +public class GitExeBlameCommandTckTest extends GitBlameCommandTckTest { @Override - public String getScmProviderCommand() - { + public String getScmProviderCommand() { return GIT_COMMAND_LINE; } - public String getScmUrl() - throws Exception - { - return GitScmTestUtils.getScmUrl( getRepositoryRoot(), "git" ); + public String getScmUrl() throws Exception { + return GitScmTestUtils.getScmUrl(getRepositoryRoot(), "git"); } @Test - public void testBlameCommand() - throws Exception - { + public void testBlameCommand() throws Exception { super.testBlameCommand(); } - protected void verifyResult( BlameScmResult result ) - { + protected void verifyResult(BlameScmResult result) { List lines = result.getLines(); - assertEquals( "Expected 1 line in blame", 1, lines.size() ); - BlameLine line = lines.get( 0 ); - assertEquals( "Mark Struberg", line.getAuthor() ); - assertEquals( "92f139dfec4d1dfb79c3cd2f94e83bf13129668b", line.getRevision() ); + assertEquals("Expected 1 line in blame", 1, lines.size()); + BlameLine line = lines.get(0); + assertEquals("Mark Struberg", line.getAuthor()); + assertEquals("92f139dfec4d1dfb79c3cd2f94e83bf13129668b", line.getRevision()); } } diff --git a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/test/java/org/apache/maven/scm/provider/git/gitexe/command/branch/GitExeBranchCommandTckTest.java b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/test/java/org/apache/maven/scm/provider/git/gitexe/command/branch/GitExeBranchCommandTckTest.java index d6083ef7d..57e8c6939 100644 --- a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/test/java/org/apache/maven/scm/provider/git/gitexe/command/branch/GitExeBranchCommandTckTest.java +++ b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/test/java/org/apache/maven/scm/provider/git/gitexe/command/branch/GitExeBranchCommandTckTest.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.git.gitexe.command.branch; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider.git.gitexe.command.branch; import org.apache.maven.scm.provider.git.GitScmTestUtils; import org.apache.maven.scm.provider.git.command.branch.GitBranchCommandTckTest; @@ -27,20 +26,14 @@ /** * @author Mark Struberg */ -public class GitExeBranchCommandTckTest - extends GitBranchCommandTckTest -{ +public class GitExeBranchCommandTckTest extends GitBranchCommandTckTest { @Override - public String getScmProviderCommand() - { + public String getScmProviderCommand() { return GIT_COMMAND_LINE; } /** {@inheritDoc} */ - public String getScmUrl() - throws Exception - { - return GitScmTestUtils.getScmUrl( getRepositoryRoot(), "git" ); + public String getScmUrl() throws Exception { + return GitScmTestUtils.getScmUrl(getRepositoryRoot(), "git"); } - } diff --git a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/test/java/org/apache/maven/scm/provider/git/gitexe/command/changelog/GitChangeLogCommandTest.java b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/test/java/org/apache/maven/scm/provider/git/gitexe/command/changelog/GitChangeLogCommandTest.java index be8de2aef..0a17d5ac6 100644 --- a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/test/java/org/apache/maven/scm/provider/git/gitexe/command/changelog/GitChangeLogCommandTest.java +++ b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/test/java/org/apache/maven/scm/provider/git/gitexe/command/changelog/GitChangeLogCommandTest.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.git.gitexe.command.changelog; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,11 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider.git.gitexe.command.changelog; + +import java.io.File; +import java.util.Calendar; +import java.util.Date; import org.apache.maven.scm.ScmBranch; import org.apache.maven.scm.ScmRevision; @@ -29,186 +32,209 @@ import org.junit.Before; import org.junit.Test; -import java.io.File; -import java.util.Calendar; -import java.util.Date; - /** * @author Emmanuel Venisse * */ -public class GitChangeLogCommandTest - extends ScmTestCase -{ +public class GitChangeLogCommandTest extends ScmTestCase { private File workingDirectory; @Before @Override - public void setUp() throws Exception - { + public void setUp() throws Exception { super.setUp(); - - workingDirectory = getTestFile( "target/git-update-command-test" ); + + workingDirectory = getTestFile("target/git-update-command-test"); } @Test - public void testCommandLineNoDates() - throws Exception - { - testCommandLine( "scm:git:http://foo.com/git", null, (Date) null, (Date) null, 40, - "git whatchanged --format=medium --decorate=short --raw --no-merges --date=iso --max-count=40 -- ." ); + public void testCommandLineNoDates() throws Exception { + testCommandLine( + "scm:git:http://foo.com/git", + null, + (Date) null, + (Date) null, + 40, + "git whatchanged --format=medium --decorate=short --raw --no-merges --date=iso --max-count=40 -- ."); } @Test - public void testCommandLineNoDatesLimitedCount() - throws Exception - { - testCommandLine( "scm:git:http://foo.com/git", null, (Date) null, (Date) null, - "git whatchanged --format=medium --decorate=short --raw --no-merges --date=iso -- ." ); + public void testCommandLineNoDatesLimitedCount() throws Exception { + testCommandLine( + "scm:git:http://foo.com/git", + null, + (Date) null, + (Date) null, + "git whatchanged --format=medium --decorate=short --raw --no-merges --date=iso -- ."); } @Test - public void testCommandLineWithDates() - throws Exception - { - Date startDate = getDate( 2003, Calendar.SEPTEMBER, 10, GMT_TIME_ZONE ); - Date endDate = getDate( 2007, Calendar.OCTOBER, 10, GMT_TIME_ZONE ); + public void testCommandLineWithDates() throws Exception { + Date startDate = getDate(2003, Calendar.SEPTEMBER, 10, GMT_TIME_ZONE); + Date endDate = getDate(2007, Calendar.OCTOBER, 10, GMT_TIME_ZONE); - testCommandLine( "scm:git:http://foo.com/git", null, startDate, endDate, - "git whatchanged --format=medium --decorate=short --raw --no-merges \"--since=2003-09-10 00:00:00 +0000\" \"--until=2007-10-10 00:00:00 +0000\" --date=iso -- ." ); + testCommandLine( + "scm:git:http://foo.com/git", + null, + startDate, + endDate, + "git whatchanged --format=medium --decorate=short --raw --no-merges \"--since=2003-09-10 00:00:00 +0000\" \"--until=2007-10-10 00:00:00 +0000\" --date=iso -- ."); } @Test - public void testCommandLineStartDateOnly() - throws Exception - { - Date startDate = getDate( 2003, Calendar.SEPTEMBER, 10, 1, 1, 1, GMT_TIME_ZONE ); + public void testCommandLineStartDateOnly() throws Exception { + Date startDate = getDate(2003, Calendar.SEPTEMBER, 10, 1, 1, 1, GMT_TIME_ZONE); - testCommandLine( "scm:git:http://foo.com/git", null, startDate, null, - "git whatchanged --format=medium --decorate=short --raw --no-merges \"--since=2003-09-10 01:01:01 +0000\" --date=iso -- ." ); + testCommandLine( + "scm:git:http://foo.com/git", + null, + startDate, + null, + "git whatchanged --format=medium --decorate=short --raw --no-merges \"--since=2003-09-10 01:01:01 +0000\" --date=iso -- ."); } @Test - public void testCommandLineDateFormat() - throws Exception - { - Date startDate = getDate( 2003, Calendar.SEPTEMBER, 10, 1, 1, 1, GMT_TIME_ZONE ); - Date endDate = getDate( 2005, Calendar.NOVEMBER, 13, 23, 23, 23, GMT_TIME_ZONE ); + public void testCommandLineDateFormat() throws Exception { + Date startDate = getDate(2003, Calendar.SEPTEMBER, 10, 1, 1, 1, GMT_TIME_ZONE); + Date endDate = getDate(2005, Calendar.NOVEMBER, 13, 23, 23, 23, GMT_TIME_ZONE); - testCommandLine( "scm:git:http://foo.com/git", null, startDate, endDate, - "git whatchanged --format=medium --decorate=short --raw --no-merges \"--since=2003-09-10 01:01:01 +0000\" \"--until=2005-11-13 23:23:23 +0000\" --date=iso -- ." ); + testCommandLine( + "scm:git:http://foo.com/git", + null, + startDate, + endDate, + "git whatchanged --format=medium --decorate=short --raw --no-merges \"--since=2003-09-10 01:01:01 +0000\" \"--until=2005-11-13 23:23:23 +0000\" --date=iso -- ."); } @Test - public void testCommandLineDateVersionRanges() - throws Exception - { - Date startDate = getDate( 2003, Calendar.SEPTEMBER, 10, 1, 1, 1, GMT_TIME_ZONE ); - Date endDate = getDate( 2005, Calendar.NOVEMBER, 13, 23, 23, 23, GMT_TIME_ZONE ); - - testCommandLine( "scm:git:http://foo.com/git", null, startDate, endDate, new ScmRevision( "1" ), new ScmRevision( "10" ), - "git whatchanged --format=medium --decorate=short --raw --no-merges \"--since=2003-09-10 01:01:01 +0000\" \"--until=2005-11-13 23:23:23 +0000\" --date=iso 1..10 -- ." ); + public void testCommandLineDateVersionRanges() throws Exception { + Date startDate = getDate(2003, Calendar.SEPTEMBER, 10, 1, 1, 1, GMT_TIME_ZONE); + Date endDate = getDate(2005, Calendar.NOVEMBER, 13, 23, 23, 23, GMT_TIME_ZONE); + + testCommandLine( + "scm:git:http://foo.com/git", + null, + startDate, + endDate, + new ScmRevision("1"), + new ScmRevision("10"), + "git whatchanged --format=medium --decorate=short --raw --no-merges \"--since=2003-09-10 01:01:01 +0000\" \"--until=2005-11-13 23:23:23 +0000\" --date=iso 1..10 -- ."); } @Test - public void testCommandLineEndDateOnly() - throws Exception - { - Date endDate = getDate( 2003, Calendar.NOVEMBER, 10, GMT_TIME_ZONE ); + public void testCommandLineEndDateOnly() throws Exception { + Date endDate = getDate(2003, Calendar.NOVEMBER, 10, GMT_TIME_ZONE); // Only specifying end date should print no dates at all - testCommandLine( "scm:git:http://foo.com/git", null, null, endDate, - "git whatchanged --format=medium --decorate=short --raw --no-merges \"--until=2003-11-10 00:00:00 +0000\" --date=iso -- ." ); + testCommandLine( + "scm:git:http://foo.com/git", + null, + null, + endDate, + "git whatchanged --format=medium --decorate=short --raw --no-merges \"--until=2003-11-10 00:00:00 +0000\" --date=iso -- ."); } @Test - public void testCommandLineWithBranchNoDates() - throws Exception - { - testCommandLine( "scm:git:http://foo.com/git", new ScmBranch( "my-test-branch" ), (Date) null, (Date) null, - "git whatchanged --format=medium --decorate=short --raw --no-merges --date=iso my-test-branch -- ." ); + public void testCommandLineWithBranchNoDates() throws Exception { + testCommandLine( + "scm:git:http://foo.com/git", + new ScmBranch("my-test-branch"), + (Date) null, + (Date) null, + "git whatchanged --format=medium --decorate=short --raw --no-merges --date=iso my-test-branch -- ."); } - @Test - public void testCommandLineWithStartVersion() - throws Exception - { - testCommandLine( "scm:git:http://foo.com/git", null, new ScmRevision( "1" ), null, - "git whatchanged --format=medium --decorate=short --raw --no-merges --date=iso 1.. -- ." ); + public void testCommandLineWithStartVersion() throws Exception { + testCommandLine( + "scm:git:http://foo.com/git", + null, + new ScmRevision("1"), + null, + "git whatchanged --format=medium --decorate=short --raw --no-merges --date=iso 1.. -- ."); } @Test - public void testCommandLineWithStartVersionAndEndVersion() - throws Exception - { - testCommandLine( "scm:git:http://foo.com/git", null, new ScmRevision( "1" ), new ScmRevision( "10" ), - "git whatchanged --format=medium --decorate=short --raw --no-merges --date=iso 1..10 -- ." ); + public void testCommandLineWithStartVersionAndEndVersion() throws Exception { + testCommandLine( + "scm:git:http://foo.com/git", + null, + new ScmRevision("1"), + new ScmRevision("10"), + "git whatchanged --format=medium --decorate=short --raw --no-merges --date=iso 1..10 -- ."); } @Test - public void testCommandLineWithStartVersionAndEndVersionEquals() - throws Exception - { - testCommandLine( "scm:git:http://foo.com/git", null, new ScmRevision( "1" ), new ScmRevision( "1" ), - "git whatchanged --format=medium --decorate=short --raw --no-merges --date=iso 1..1 -- ." ); + public void testCommandLineWithStartVersionAndEndVersionEquals() throws Exception { + testCommandLine( + "scm:git:http://foo.com/git", + null, + new ScmRevision("1"), + new ScmRevision("1"), + "git whatchanged --format=medium --decorate=short --raw --no-merges --date=iso 1..1 -- ."); } @Test - public void testCommandLineWithStartVersionAndEndVersionAndBranch() - throws Exception - { - testCommandLine( "scm:git:http://foo.com/git", new ScmBranch( "my-test-branch" ), new ScmRevision( "1" ), new ScmRevision( "10" ), - "git whatchanged --format=medium --decorate=short --raw --no-merges --date=iso 1..10 my-test-branch -- ." ); + public void testCommandLineWithStartVersionAndEndVersionAndBranch() throws Exception { + testCommandLine( + "scm:git:http://foo.com/git", + new ScmBranch("my-test-branch"), + new ScmRevision("1"), + new ScmRevision("10"), + "git whatchanged --format=medium --decorate=short --raw --no-merges --date=iso 1..10 my-test-branch -- ."); } // ---------------------------------------------------------------------- // private helper functions // ---------------------------------------------------------------------- - private void testCommandLine( String scmUrl, ScmBranch branch, Date startDate, Date endDate, String commandLine ) - throws Exception - { - testCommandLine( scmUrl, branch, startDate, endDate, null, commandLine ); + private void testCommandLine(String scmUrl, ScmBranch branch, Date startDate, Date endDate, String commandLine) + throws Exception { + testCommandLine(scmUrl, branch, startDate, endDate, null, commandLine); } - private void testCommandLine( String scmUrl, ScmBranch branch, Date startDate, Date endDate, Integer limit, String commandLine ) - throws Exception - { - ScmRepository repository = getScmManager().makeScmRepository( scmUrl ); + private void testCommandLine( + String scmUrl, ScmBranch branch, Date startDate, Date endDate, Integer limit, String commandLine) + throws Exception { + ScmRepository repository = getScmManager().makeScmRepository(scmUrl); GitScmProviderRepository gitRepository = (GitScmProviderRepository) repository.getProviderRepository(); - Commandline cl = GitChangeLogCommand.createCommandLine( gitRepository, workingDirectory, branch, startDate, - endDate, null, null, limit ); + Commandline cl = GitChangeLogCommand.createCommandLine( + gitRepository, workingDirectory, branch, startDate, endDate, null, null, limit); - assertCommandLine( commandLine, workingDirectory, cl ); + assertCommandLine(commandLine, workingDirectory, cl); } - private void testCommandLine( String scmUrl, ScmBranch branch, ScmVersion startVersion, ScmVersion endVersion, String commandLine ) - throws Exception - { - ScmRepository repository = getScmManager().makeScmRepository( scmUrl ); + private void testCommandLine( + String scmUrl, ScmBranch branch, ScmVersion startVersion, ScmVersion endVersion, String commandLine) + throws Exception { + ScmRepository repository = getScmManager().makeScmRepository(scmUrl); GitScmProviderRepository gitRepository = (GitScmProviderRepository) repository.getProviderRepository(); - Commandline cl = GitChangeLogCommand.createCommandLine( gitRepository, workingDirectory, branch, null, null, - startVersion, endVersion ); + Commandline cl = GitChangeLogCommand.createCommandLine( + gitRepository, workingDirectory, branch, null, null, startVersion, endVersion); - assertCommandLine( commandLine, workingDirectory, cl ); + assertCommandLine(commandLine, workingDirectory, cl); } - private void testCommandLine( String scmUrl, ScmBranch branch, Date startDate, Date endDate, - ScmVersion startVersion, ScmVersion endVersion, String commandLine ) - throws Exception - { - ScmRepository repository = getScmManager().makeScmRepository( scmUrl ); - + private void testCommandLine( + String scmUrl, + ScmBranch branch, + Date startDate, + Date endDate, + ScmVersion startVersion, + ScmVersion endVersion, + String commandLine) + throws Exception { + ScmRepository repository = getScmManager().makeScmRepository(scmUrl); + GitScmProviderRepository gitRepository = (GitScmProviderRepository) repository.getProviderRepository(); - - Commandline cl = GitChangeLogCommand.createCommandLine( gitRepository, workingDirectory, branch, startDate, endDate, - startVersion, endVersion ); - - assertCommandLine( commandLine, workingDirectory, cl ); + + Commandline cl = GitChangeLogCommand.createCommandLine( + gitRepository, workingDirectory, branch, startDate, endDate, startVersion, endVersion); + + assertCommandLine(commandLine, workingDirectory, cl); } } diff --git a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/test/java/org/apache/maven/scm/provider/git/gitexe/command/changelog/GitChangeLogConsumerTest.java b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/test/java/org/apache/maven/scm/provider/git/gitexe/command/changelog/GitChangeLogConsumerTest.java index aa419d9d3..ee5a7a5f4 100644 --- a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/test/java/org/apache/maven/scm/provider/git/gitexe/command/changelog/GitChangeLogConsumerTest.java +++ b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/test/java/org/apache/maven/scm/provider/git/gitexe/command/changelog/GitChangeLogConsumerTest.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.git.gitexe.command.changelog; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,13 +16,7 @@ * specific language governing permissions and limitations * under the License. */ - -import org.apache.maven.scm.ChangeFile; -import org.apache.maven.scm.ChangeSet; -import org.apache.maven.scm.ScmFileStatus; -import org.apache.maven.scm.ScmTestCase; -import org.apache.maven.scm.util.ConsumerUtils; -import org.junit.Test; +package org.apache.maven.scm.provider.git.gitexe.command.changelog; import java.io.File; import java.text.SimpleDateFormat; @@ -37,6 +29,13 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; +import org.apache.maven.scm.ChangeFile; +import org.apache.maven.scm.ChangeSet; +import org.apache.maven.scm.ScmFileStatus; +import org.apache.maven.scm.ScmTestCase; +import org.apache.maven.scm.util.ConsumerUtils; +import org.junit.Test; + import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; @@ -45,172 +44,160 @@ /** * @author Mark Struberg */ -public class GitChangeLogConsumerTest - extends ScmTestCase -{ +public class GitChangeLogConsumerTest extends ScmTestCase { @Test - public void testConsumer1() - throws Exception - { - //was Date: Tue Nov 27 16:16:28 2007 +0100 - //iso Date: 2007-11-24 01:13:10 +0100 - Pattern datePattern = Pattern.compile( "^Date:\\s*(.*)" );//new RE( "^Date:\\s*\\w-1\\w-1\\w-1\\s(.*)" ); - Matcher matcher = datePattern.matcher( "Date: 2007-11-24 01:13:10 +0100" ); + public void testConsumer1() throws Exception { + // was Date: Tue Nov 27 16:16:28 2007 +0100 + // iso Date: 2007-11-24 01:13:10 +0100 + Pattern datePattern = Pattern.compile("^Date:\\s*(.*)"); // new RE( "^Date:\\s*\\w-1\\w-1\\w-1\\s(.*)" ); + Matcher matcher = datePattern.matcher("Date: 2007-11-24 01:13:10 +0100"); - assertTrue( matcher.matches() ); - assertEquals("2007-11-24 01:13:10 +0100", matcher.group( 1 )); + assertTrue(matcher.matches()); + assertEquals("2007-11-24 01:13:10 +0100", matcher.group(1)); - GitChangeLogConsumer consumer = new GitChangeLogConsumer( null ); + GitChangeLogConsumer consumer = new GitChangeLogConsumer(null); - File f = getTestFile( "/src/test/resources/git/changelog/gitwhatchanged.gitlog" ); + File f = getTestFile("/src/test/resources/git/changelog/gitwhatchanged.gitlog"); - ConsumerUtils.consumeFile( f, consumer ); + ConsumerUtils.consumeFile(f, consumer); List modifications = consumer.getModifications(); - assertEquals( 6, modifications.size() ); + assertEquals(6, modifications.size()); - for ( Iterator i = modifications.iterator(); i.hasNext(); ) - { + for (Iterator i = modifications.iterator(); i.hasNext(); ) { ChangeSet entry = i.next(); - assertEquals( "Mark Struberg ", entry.getAuthor() ); + assertEquals("Mark Struberg ", entry.getAuthor()); - assertNotNull( entry.getDate() ); + assertNotNull(entry.getDate()); - assertTrue( entry.getComment() != null && entry.getComment().length() > 0 ); + assertTrue(entry.getComment() != null && entry.getComment().length() > 0); - assertNotNull( entry.getRevision() ); + assertNotNull(entry.getRevision()); - assertNotNull( entry.getFiles() ); - assertFalse( entry.getFiles().isEmpty() ); + assertNotNull(entry.getFiles()); + assertFalse(entry.getFiles().isEmpty()); } - ChangeSet entry = modifications.get( 3 ); + ChangeSet entry = modifications.get(3); - assertEquals( "Mark Struberg ", entry.getAuthor() ); + assertEquals("Mark Struberg ", entry.getAuthor()); - assertNotNull( entry.getDate() ); - SimpleDateFormat sdf = new SimpleDateFormat( "yyyy-MM-dd HH:mm:ss Z" ); - sdf.setTimeZone( GMT_TIME_ZONE ); + assertNotNull(entry.getDate()); + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss Z"); + sdf.setTimeZone(GMT_TIME_ZONE); - assertEquals( "2007-11-24 00:10:42 +0000", sdf.format( entry.getDate() ) ); + assertEquals("2007-11-24 00:10:42 +0000", sdf.format(entry.getDate())); - assertEquals( "895d423689da3b36d8e9106c0ecbf3d62433978c", entry.getRevision() ); + assertEquals("895d423689da3b36d8e9106c0ecbf3d62433978c", entry.getRevision()); - assertEquals( "/ added", entry.getComment() ); + assertEquals("/ added", entry.getComment()); - assertNotNull( entry.getFiles() ); - ChangeFile cf = entry.getFiles().get( 0 ); - assertEquals( "readme.txt", cf.getName() ); - assertTrue( cf.getRevision() != null && cf.getRevision().length() > 0 ); + assertNotNull(entry.getFiles()); + ChangeFile cf = entry.getFiles().get(0); + assertEquals("readme.txt", cf.getName()); + assertTrue(cf.getRevision() != null && cf.getRevision().length() > 0); } @Test - public void testConsumer2() - throws Exception - { - GitChangeLogConsumer consumer = new GitChangeLogConsumer( null ); + public void testConsumer2() throws Exception { + GitChangeLogConsumer consumer = new GitChangeLogConsumer(null); - File f = getTestFile( "/src/test/resources/git/changelog/gitwhatchanged2.gitlog" ); + File f = getTestFile("/src/test/resources/git/changelog/gitwhatchanged2.gitlog"); - ConsumerUtils.consumeFile( f, consumer ); + ConsumerUtils.consumeFile(f, consumer); List modifications = consumer.getModifications(); // must use *Linked* HashMap to have predictable toString final Map summary = new LinkedHashMap(); - for ( Iterator i = modifications.iterator(); i.hasNext(); ) - { + for (Iterator i = modifications.iterator(); i.hasNext(); ) { ChangeSet entry = i.next(); - assertEquals( "Mark Struberg ", entry.getAuthor() ); + assertEquals("Mark Struberg ", entry.getAuthor()); - assertNotNull( entry.getDate() ); + assertNotNull(entry.getDate()); - assertTrue( entry.getComment() != null && entry.getComment().length() > 0 ); + assertTrue(entry.getComment() != null && entry.getComment().length() > 0); - assertNotNull( entry.getRevision() ); + assertNotNull(entry.getRevision()); - assertNotNull( entry.getFiles() ); - assertFalse( entry.getFiles().isEmpty() ); + assertNotNull(entry.getFiles()); + assertFalse(entry.getFiles().isEmpty()); - for ( ChangeFile file : entry.getFiles() ) - { + for (ChangeFile file : entry.getFiles()) { final ScmFileStatus action = file.getAction(); - if ( !summary.containsKey( action ) ) - { - summary.put( action, new AtomicInteger() ); + if (!summary.containsKey(action)) { + summary.put(action, new AtomicInteger()); } - summary.get( action ).incrementAndGet(); + summary.get(action).incrementAndGet(); } } - assertEquals( "Action summary differs from expectations", "{modified=21, added=88, deleted=1}", - summary.toString() ); + assertEquals( + "Action summary differs from expectations", "{modified=21, added=88, deleted=1}", summary.toString()); - assertEquals( 8, modifications.size() ); + assertEquals(8, modifications.size()); - ChangeSet entry = modifications.get( 4 ); + ChangeSet entry = modifications.get(4); - assertEquals( "Mark Struberg ", entry.getAuthor() ); + assertEquals("Mark Struberg ", entry.getAuthor()); - assertNotNull( entry.getDate() ); - SimpleDateFormat sdf = new SimpleDateFormat( "yyyy-MM-dd HH:mm:ss Z" ); - sdf.setTimeZone( GMT_TIME_ZONE ); + assertNotNull(entry.getDate()); + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss Z"); + sdf.setTimeZone(GMT_TIME_ZONE); - assertEquals( "2007-11-27 13:05:36 +0000", sdf.format( entry.getDate() ) ); + assertEquals("2007-11-27 13:05:36 +0000", sdf.format(entry.getDate())); - assertEquals( "52733aa427041cafd760833cb068ffe897fd35db", entry.getRevision() ); + assertEquals("52733aa427041cafd760833cb068ffe897fd35db", entry.getRevision()); - assertEquals( "fixed a GitCommandLineUtil and provice first version of the checkin command.", - entry.getComment() ); + assertEquals( + "fixed a GitCommandLineUtil and provice first version of the checkin command.", entry.getComment()); - assertNotNull( entry.getFiles() ); + assertNotNull(entry.getFiles()); - assertEquals( 10, entry.getFiles().size() ); + assertEquals(10, entry.getFiles().size()); - ChangeFile cf = entry.getFiles().get( 0 ); + ChangeFile cf = entry.getFiles().get(0); assertEquals( - "maven-scm-provider-gitexe/src/main/java/org/apache/maven/scm/provider/git/gitexe/command/GitCommandLineUtils.java", - cf.getName() ); - assertTrue( cf.getRevision() != null && cf.getRevision().length() > 0 ); + "maven-scm-provider-gitexe/src/main/java/org/apache/maven/scm/provider/git/gitexe/command/GitCommandLineUtils.java", + cf.getName()); + assertTrue(cf.getRevision() != null && cf.getRevision().length() > 0); } - public void testGitLogConsumer3() - throws Exception - { - GitChangeLogConsumer consumer = new GitChangeLogConsumer( null ); + public void testGitLogConsumer3() throws Exception { + GitChangeLogConsumer consumer = new GitChangeLogConsumer(null); - File f = getTestFile( "/src/test/resources/git/changelog/gitlog3.gitlog" ); + File f = getTestFile("/src/test/resources/git/changelog/gitlog3.gitlog"); - ConsumerUtils.consumeFile( f, consumer ); + ConsumerUtils.consumeFile(f, consumer); List modifications = consumer.getModifications(); - assertEquals( 10, modifications.size() ); - - SimpleDateFormat sdf = new SimpleDateFormat( "yyyy-MM-dd HH:mm:ss Z" ); - sdf.setTimeZone( GMT_TIME_ZONE ); - - ChangeSet first = modifications.get( 0 ); - assertEquals( "Michael Osipov ", first.getAuthor() ); - assertEquals( "2022-01-08 20:02:12 +0000", sdf.format( first.getDate() ) ); - assertEquals( "[maven-release-plugin] prepare for next development iteration", first.getComment() ); - assertEquals( "4fc34cfa14f2e72506187b03a492ce55ed459d4c", first.getRevision() ); - assertEquals( Collections.emptyList(), first.getTags() ); - assertNotNull( first.getFiles() ); - assertFalse( first.getFiles().isEmpty() ); - - ChangeSet second = modifications.get( 1 ); - assertEquals( "Michael Osipov ", second.getAuthor() ); - assertEquals( "2022-01-08 20:02:01 +0000", sdf.format( second.getDate() ) ); - assertEquals( "[maven-release-plugin] prepare release maven-scm-2.0.0-M1", second.getComment() ); - assertEquals( "3a6d9817fe809c43eca588d7c0f4428254eae17c", second.getRevision() ); - assertEquals( Collections.singletonList("maven-scm-2.0.0-M1"), second.getTags() ); - assertNotNull( second.getFiles() ); - assertFalse( second.getFiles().isEmpty() ); + assertEquals(10, modifications.size()); + + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss Z"); + sdf.setTimeZone(GMT_TIME_ZONE); + + ChangeSet first = modifications.get(0); + assertEquals("Michael Osipov ", first.getAuthor()); + assertEquals("2022-01-08 20:02:12 +0000", sdf.format(first.getDate())); + assertEquals("[maven-release-plugin] prepare for next development iteration", first.getComment()); + assertEquals("4fc34cfa14f2e72506187b03a492ce55ed459d4c", first.getRevision()); + assertEquals(Collections.emptyList(), first.getTags()); + assertNotNull(first.getFiles()); + assertFalse(first.getFiles().isEmpty()); + + ChangeSet second = modifications.get(1); + assertEquals("Michael Osipov ", second.getAuthor()); + assertEquals("2022-01-08 20:02:01 +0000", sdf.format(second.getDate())); + assertEquals("[maven-release-plugin] prepare release maven-scm-2.0.0-M1", second.getComment()); + assertEquals("3a6d9817fe809c43eca588d7c0f4428254eae17c", second.getRevision()); + assertEquals(Collections.singletonList("maven-scm-2.0.0-M1"), second.getTags()); + assertNotNull(second.getFiles()); + assertFalse(second.getFiles().isEmpty()); } public void testTagAndBranchConsumer() { @@ -228,22 +215,21 @@ public void testTagAndBranchConsumer() { ":100644 100644 2019174 808473f M\tdocumentation/pom.xml", "" }; - GitChangeLogConsumer consumer = new GitChangeLogConsumer( null ); + GitChangeLogConsumer consumer = new GitChangeLogConsumer(null); - for ( String line : lines ) { - consumer.consumeLine( line ); + for (String line : lines) { + consumer.consumeLine(line); } List modifications = consumer.getModifications(); - assertEquals( 1, modifications.size() ); - ChangeSet changeSet = modifications.get( 0 ); - assertEquals( Collections.singletonList( "TestTag" ), changeSet.getTags() ); - assertEquals( "This\nis\na\nmultiline\ncomment", changeSet.getComment() ); + assertEquals(1, modifications.size()); + ChangeSet changeSet = modifications.get(0); + assertEquals(Collections.singletonList("TestTag"), changeSet.getTags()); + assertEquals("This\nis\na\nmultiline\ncomment", changeSet.getComment()); List files = changeSet.getFiles(); - assertEquals( 1, files.size() ); - ChangeFile changeFile = files.get (0 ); - assertEquals( "documentation/pom.xml", changeFile.getName() ); + assertEquals(1, files.size()); + ChangeFile changeFile = files.get(0); + assertEquals("documentation/pom.xml", changeFile.getName()); } - } diff --git a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/test/java/org/apache/maven/scm/provider/git/gitexe/command/changelog/GitExeChangeLogCommandTckTest.java b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/test/java/org/apache/maven/scm/provider/git/gitexe/command/changelog/GitExeChangeLogCommandTckTest.java index f966a3b02..17a51f2db 100644 --- a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/test/java/org/apache/maven/scm/provider/git/gitexe/command/changelog/GitExeChangeLogCommandTckTest.java +++ b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/test/java/org/apache/maven/scm/provider/git/gitexe/command/changelog/GitExeChangeLogCommandTckTest.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.git.gitexe.command.changelog; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider.git.gitexe.command.changelog; import org.apache.maven.scm.provider.git.GitScmTestUtils; import org.apache.maven.scm.provider.git.command.changelog.GitChangeLogCommandTckTest; @@ -27,19 +26,14 @@ /** * @author Mark Struberg */ -public class GitExeChangeLogCommandTckTest - extends GitChangeLogCommandTckTest -{ +public class GitExeChangeLogCommandTckTest extends GitChangeLogCommandTckTest { @Override - public String getScmProviderCommand() - { + public String getScmProviderCommand() { return GIT_COMMAND_LINE; } /** {@inheritDoc} */ - public String getScmUrl() - throws Exception - { - return GitScmTestUtils.getScmUrl( getRepositoryRoot(), "git" ); + public String getScmUrl() throws Exception { + return GitScmTestUtils.getScmUrl(getRepositoryRoot(), "git"); } } diff --git a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/test/java/org/apache/maven/scm/provider/git/gitexe/command/checkin/GitCheckInCommandNoBranchTest.java b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/test/java/org/apache/maven/scm/provider/git/gitexe/command/checkin/GitCheckInCommandNoBranchTest.java index 16ffecfc9..749885434 100644 --- a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/test/java/org/apache/maven/scm/provider/git/gitexe/command/checkin/GitCheckInCommandNoBranchTest.java +++ b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/test/java/org/apache/maven/scm/provider/git/gitexe/command/checkin/GitCheckInCommandNoBranchTest.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.git.gitexe.command.checkin; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,9 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider.git.gitexe.command.checkin; + +import java.io.File; import org.apache.maven.scm.ScmFileSet; import org.apache.maven.scm.ScmTestCase; @@ -31,79 +32,69 @@ import org.junit.Before; import org.junit.Test; -import java.io.File; - import static org.apache.maven.scm.provider.git.GitScmTestUtils.GIT_COMMAND_LINE; - import static org.junit.Assert.assertEquals; /** * @author Bertrand Paquet */ -public class GitCheckInCommandNoBranchTest - extends ScmTestCase -{ +public class GitCheckInCommandNoBranchTest extends ScmTestCase { private File workingDirectory; @Before @Override - public void setUp() - throws Exception - { + public void setUp() throws Exception { super.setUp(); - workingDirectory = new File( "target/checkin-nobranch" ); + workingDirectory = new File("target/checkin-nobranch"); } @Test - public void testCheckinNoBranch() - throws Exception - { - checkScmPresence( GIT_COMMAND_LINE ); + public void testCheckinNoBranch() throws Exception { + checkScmPresence(GIT_COMMAND_LINE); - File repo_orig = new File( "src/test/resources/repository_no_branch" ); - File repo = getTestFile( "target/git_copy" ); - FileUtils.deleteDirectory( repo ); - FileUtils.copyDirectoryStructure( repo_orig, repo ); + File repo_orig = new File("src/test/resources/repository_no_branch"); + File repo = getTestFile("target/git_copy"); + FileUtils.deleteDirectory(repo); + FileUtils.copyDirectoryStructure(repo_orig, repo); - ScmRepository scmRepository = getScmManager().makeScmRepository( - "scm:git:" + repo.toPath().toAbsolutePath().toUri().toASCIIString() ); + ScmRepository scmRepository = getScmManager() + .makeScmRepository( + "scm:git:" + repo.toPath().toAbsolutePath().toUri().toASCIIString()); - CheckOutScmResult checkOutScmResult = checkoutRepo( scmRepository ); + CheckOutScmResult checkOutScmResult = checkoutRepo(scmRepository); // Add a default user to the config - GitScmTestUtils.setDefaultUser( workingDirectory ); + GitScmTestUtils.setDefaultUser(workingDirectory); - assertEquals( 0, checkOutScmResult.getCheckedOutFiles().size() ); + assertEquals(0, checkOutScmResult.getCheckedOutFiles().size()); - File f = new File( workingDirectory.getAbsolutePath() + File.separator + "pom.xml" ); - FileUtils.fileWrite( f.getAbsolutePath(), "toto" ); + File f = new File(workingDirectory.getAbsolutePath() + File.separator + "pom.xml"); + FileUtils.fileWrite(f.getAbsolutePath(), "toto"); - ScmFileSet scmFileSet = new ScmFileSet( workingDirectory, new File( "pom.xml" ) ); - AddScmResult addResult = getScmManager().add( scmRepository, scmFileSet ); - assertResultIsSuccess( addResult ); + ScmFileSet scmFileSet = new ScmFileSet(workingDirectory, new File("pom.xml")); + AddScmResult addResult = getScmManager().add(scmRepository, scmFileSet); + assertResultIsSuccess(addResult); - CheckInScmResult checkInScmResult = getScmManager().checkIn( scmRepository, scmFileSet, "commit" ); - assertResultIsSuccess( checkInScmResult ); - assertEquals( 1, checkInScmResult.getCheckedInFiles().size() ); - assertEquals( "pom.xml", checkInScmResult.getCheckedInFiles().get( 0 ).getPath() ); + CheckInScmResult checkInScmResult = getScmManager().checkIn(scmRepository, scmFileSet, "commit"); + assertResultIsSuccess(checkInScmResult); + assertEquals(1, checkInScmResult.getCheckedInFiles().size()); + assertEquals("pom.xml", checkInScmResult.getCheckedInFiles().get(0).getPath()); - checkOutScmResult = checkoutRepo( scmRepository ); - assertResultIsSuccess( checkOutScmResult ); - assertEquals( 1, checkOutScmResult.getCheckedOutFiles().size() ); - assertEquals( "pom.xml", checkOutScmResult.getCheckedOutFiles().get( 0 ).getPath() ); + checkOutScmResult = checkoutRepo(scmRepository); + assertResultIsSuccess(checkOutScmResult); + assertEquals(1, checkOutScmResult.getCheckedOutFiles().size()); + assertEquals("pom.xml", checkOutScmResult.getCheckedOutFiles().get(0).getPath()); } - protected CheckOutScmResult checkoutRepo( ScmRepository scmRepository ) - throws Exception - { - FileUtils.deleteDirectory( workingDirectory ); + protected CheckOutScmResult checkoutRepo(ScmRepository scmRepository) throws Exception { + FileUtils.deleteDirectory(workingDirectory); CheckOutScmResult result = - getScmManager().checkOut( scmRepository, new ScmFileSet( workingDirectory ), (ScmVersion) null ); + getScmManager().checkOut(scmRepository, new ScmFileSet(workingDirectory), (ScmVersion) null); - assertResultIsSuccess( result ); + assertResultIsSuccess(result); return result; } } diff --git a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/test/java/org/apache/maven/scm/provider/git/gitexe/command/checkin/GitCheckInCommandTest.java b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/test/java/org/apache/maven/scm/provider/git/gitexe/command/checkin/GitCheckInCommandTest.java index ffd512702..066fbe2ee 100644 --- a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/test/java/org/apache/maven/scm/provider/git/gitexe/command/checkin/GitCheckInCommandTest.java +++ b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/test/java/org/apache/maven/scm/provider/git/gitexe/command/checkin/GitCheckInCommandTest.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.git.gitexe.command.checkin; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,9 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider.git.gitexe.command.checkin; + +import java.io.File; import org.apache.maven.scm.ScmFileSet; import org.apache.maven.scm.ScmTestCase; @@ -35,66 +36,51 @@ import org.junit.Before; import org.junit.Test; -import java.io.File; - import static org.apache.maven.scm.provider.git.GitScmTestUtils.GIT_COMMAND_LINE; - import static org.junit.Assert.assertTrue; /** * @author Trygve Laugstøl */ -public class GitCheckInCommandTest - extends ScmTestCase -{ +public class GitCheckInCommandTest extends ScmTestCase { private File messageFile; private String messageFileString; @Before @Override - public void setUp() - throws Exception - { + public void setUp() throws Exception { super.setUp(); - messageFile = new File( "commit-message" ); + messageFile = new File("commit-message"); String path = messageFile.getAbsolutePath(); - if ( path.indexOf( ' ' ) >= 0 ) - { + if (path.indexOf(' ') >= 0) { path = "\"" + path + "\""; } messageFileString = "-F " + path; } @Test - public void testCommandLineWithoutTag() - throws Exception - { - if ( GitUtil.getSettings().isCommitNoVerify() ) - { - testCommandLine( "scm:git:http://foo.com/git/trunk", "git commit --verbose " + messageFileString + " -a" + " --no-verify" ); - } - else - { - testCommandLine( "scm:git:http://foo.com/git/trunk", "git commit --verbose " + messageFileString + " -a" ); + public void testCommandLineWithoutTag() throws Exception { + if (GitUtil.getSettings().isCommitNoVerify()) { + testCommandLine( + "scm:git:http://foo.com/git/trunk", + "git commit --verbose " + messageFileString + " -a" + " --no-verify"); + } else { + testCommandLine("scm:git:http://foo.com/git/trunk", "git commit --verbose " + messageFileString + " -a"); } } @Test - public void testCommandLineWithUsername() - throws Exception - { - if ( GitUtil.getSettings().isCommitNoVerify() ) - { - testCommandLine( "scm:git:http://anonymous@foo.com/git/trunk", "git commit --verbose " + messageFileString - + " -a" + " --no-verify" ); - } - else - { - testCommandLine( "scm:git:http://anonymous@foo.com/git/trunk", "git commit --verbose " + messageFileString - + " -a" ); + public void testCommandLineWithUsername() throws Exception { + if (GitUtil.getSettings().isCommitNoVerify()) { + testCommandLine( + "scm:git:http://anonymous@foo.com/git/trunk", + "git commit --verbose " + messageFileString + " -a" + " --no-verify"); + } else { + testCommandLine( + "scm:git:http://anonymous@foo.com/git/trunk", "git commit --verbose " + messageFileString + " -a"); } } @@ -104,30 +90,33 @@ public void testCheckinAfterRename() throws Exception { File repo = getRepositoryRoot(); File checkedOutRepo = getWorkingCopy(); - checkScmPresence( GIT_COMMAND_LINE ); + checkScmPresence(GIT_COMMAND_LINE); GitScmTestUtils.initRepo("src/test/resources/repository/", getRepositoryRoot(), getWorkingDirectory()); - ScmRepository scmRepository = getScmManager().makeScmRepository( - "scm:git:" + repo.toPath().toAbsolutePath().toUri().toASCIIString() ); + ScmRepository scmRepository = getScmManager() + .makeScmRepository( + "scm:git:" + repo.toPath().toAbsolutePath().toUri().toASCIIString()); checkoutRepoInto(checkedOutRepo, scmRepository); // Add a default user to the config - GitScmTestUtils.setDefaultUser( checkedOutRepo ); + GitScmTestUtils.setDefaultUser(checkedOutRepo); // Creating foo/bar/wine.xml - File fooDir = new File( checkedOutRepo.getAbsolutePath(), "foo" ); + File fooDir = new File(checkedOutRepo.getAbsolutePath(), "foo"); fooDir.mkdir(); File barDir = new File(fooDir.getAbsolutePath(), "bar"); barDir.mkdir(); File wineFile = new File(barDir.getAbsolutePath(), "wine.xml"); - FileUtils.fileWrite( wineFile.getAbsolutePath(), "Lacoste castle" ); + FileUtils.fileWrite(wineFile.getAbsolutePath(), "Lacoste castle"); // Adding and commiting file - AddScmResult addResult = getScmManager().add( scmRepository, new ScmFileSet( checkedOutRepo, new File( "foo/bar/wine.xml" ) ) ); - assertResultIsSuccess( addResult ); - CheckInScmResult checkInScmResult = getScmManager().checkIn(scmRepository, new ScmFileSet(checkedOutRepo), "Created wine file"); - assertResultIsSuccess( checkInScmResult ); + AddScmResult addResult = + getScmManager().add(scmRepository, new ScmFileSet(checkedOutRepo, new File("foo/bar/wine.xml"))); + assertResultIsSuccess(addResult); + CheckInScmResult checkInScmResult = + getScmManager().checkIn(scmRepository, new ScmFileSet(checkedOutRepo), "Created wine file"); + assertResultIsSuccess(checkInScmResult); // Cloning foo/bar/wine.xml to foo/newbar/wine.xml File newBarDir = new File(fooDir.getAbsolutePath(), "newbar"); @@ -136,13 +125,17 @@ public void testCheckinAfterRename() throws Exception { FileUtils.copyFile(wineFile, movedWineFile); // Removing old file, adding new file and commiting... - RemoveScmResult removeResult = getScmManager().remove(scmRepository, new ScmFileSet(checkedOutRepo, new File("foo/bar/")), ""); + RemoveScmResult removeResult = + getScmManager().remove(scmRepository, new ScmFileSet(checkedOutRepo, new File("foo/bar/")), ""); assertResultIsSuccess(removeResult); addResult = getScmManager().add(scmRepository, new ScmFileSet(checkedOutRepo, new File("foo/newbar/wine.xml"))); assertResultIsSuccess(addResult); - checkInScmResult = getScmManager().checkIn(scmRepository, new ScmFileSet(checkedOutRepo), "moved wine.xml from foo/bar/ to foo/newbar/"); + checkInScmResult = getScmManager() + .checkIn(scmRepository, new ScmFileSet(checkedOutRepo), "moved wine.xml from foo/bar/ to foo/newbar/"); assertResultIsSuccess(checkInScmResult); - assertTrue("Renamed file has not been commited!", checkInScmResult.getCheckedInFiles().size() != 0); + assertTrue( + "Renamed file has not been commited!", + checkInScmResult.getCheckedInFiles().size() != 0); } // Test FileSet in configuration @@ -151,68 +144,67 @@ public void testCheckinWithFileSet() throws Exception { File repo = getRepositoryRoot(); File checkedOutRepo = getWorkingCopy(); - checkScmPresence( GIT_COMMAND_LINE ); + checkScmPresence(GIT_COMMAND_LINE); - GitScmTestUtils.initRepo( "src/test/resources/repository/", getRepositoryRoot(), getWorkingDirectory() ); + GitScmTestUtils.initRepo("src/test/resources/repository/", getRepositoryRoot(), getWorkingDirectory()); - ScmRepository scmRepository = getScmManager().makeScmRepository( - "scm:git:" + repo.toPath().toAbsolutePath().toUri().toASCIIString() ); - checkoutRepoInto( checkedOutRepo, scmRepository ); + ScmRepository scmRepository = getScmManager() + .makeScmRepository( + "scm:git:" + repo.toPath().toAbsolutePath().toUri().toASCIIString()); + checkoutRepoInto(checkedOutRepo, scmRepository); // Add a default user to the config - GitScmTestUtils.setDefaultUser( checkedOutRepo ); + GitScmTestUtils.setDefaultUser(checkedOutRepo); // Creating beer.xml and whiskey.xml - File beerFile = new File( checkedOutRepo.getAbsolutePath(), "beer.xml" ); - FileUtils.fileWrite( beerFile.getAbsolutePath(), "1/2 litre" ); - File whiskeyFile = new File( checkedOutRepo.getAbsolutePath(), "whiskey.xml" ); - FileUtils.fileWrite( whiskeyFile.getAbsolutePath(), "700 ml" ); + File beerFile = new File(checkedOutRepo.getAbsolutePath(), "beer.xml"); + FileUtils.fileWrite(beerFile.getAbsolutePath(), "1/2 litre"); + File whiskeyFile = new File(checkedOutRepo.getAbsolutePath(), "whiskey.xml"); + FileUtils.fileWrite(whiskeyFile.getAbsolutePath(), "700 ml"); // Adding and commiting beer and whiskey - AddScmResult addResult = getScmManager().add( scmRepository, new ScmFileSet( checkedOutRepo, "beer.xml,whiskey.xml" ) ); - assertResultIsSuccess( addResult ); - CheckInScmResult checkInScmResult = getScmManager().checkIn( scmRepository, - new ScmFileSet( checkedOutRepo, "beer.xml,whiskey.xml" ), "Created beer file" ); - assertResultIsSuccess( checkInScmResult ); + AddScmResult addResult = + getScmManager().add(scmRepository, new ScmFileSet(checkedOutRepo, "beer.xml,whiskey.xml")); + assertResultIsSuccess(addResult); + CheckInScmResult checkInScmResult = getScmManager() + .checkIn(scmRepository, new ScmFileSet(checkedOutRepo, "beer.xml,whiskey.xml"), "Created beer file"); + assertResultIsSuccess(checkInScmResult); // Editing beer and commiting whiskey, should commit nothingi, but succeed - FileUtils.fileWrite( beerFile.getAbsolutePath(), "1 litre" ); + FileUtils.fileWrite(beerFile.getAbsolutePath(), "1 litre"); - addResult = getScmManager().add( scmRepository, new ScmFileSet( checkedOutRepo, "whiskey.xml" ) ); - assertResultIsSuccess( addResult ); - checkInScmResult = getScmManager().checkIn( scmRepository, - new ScmFileSet( checkedOutRepo, "whiskey.xml" ), "Checking beer file"); - assertResultIsSuccess( checkInScmResult ); + addResult = getScmManager().add(scmRepository, new ScmFileSet(checkedOutRepo, "whiskey.xml")); + assertResultIsSuccess(addResult); + checkInScmResult = getScmManager() + .checkIn(scmRepository, new ScmFileSet(checkedOutRepo, "whiskey.xml"), "Checking beer file"); + assertResultIsSuccess(checkInScmResult); } // ---------------------------------------------------------------------- // // ---------------------------------------------------------------------- - private CheckOutScmResult checkoutRepoInto( File workingCopy, ScmRepository scmRepository ) - throws Exception { - FileUtils.deleteDirectory( workingCopy ); + private CheckOutScmResult checkoutRepoInto(File workingCopy, ScmRepository scmRepository) throws Exception { + FileUtils.deleteDirectory(workingCopy); workingCopy.mkdir(); CheckOutScmResult result = - getScmManager().checkOut( scmRepository, new ScmFileSet( workingCopy ), (ScmVersion) null ); + getScmManager().checkOut(scmRepository, new ScmFileSet(workingCopy), (ScmVersion) null); - assertResultIsSuccess( result ); + assertResultIsSuccess(result); return result; } - private void testCommandLine( String scmUrl, String commandLine ) - throws Exception - { - File workingDirectory = getTestFile( "target/git-checkin-command-test" ); + private void testCommandLine(String scmUrl, String commandLine) throws Exception { + File workingDirectory = getTestFile("target/git-checkin-command-test"); ScmRepository repository = getScmManager().makeScmRepository(scmUrl); GitScmProviderRepository gitRepository = (GitScmProviderRepository) repository.getProviderRepository(); Commandline cl = - GitCheckInCommand.createCommitCommandLine( gitRepository, new ScmFileSet( workingDirectory ), messageFile ); + GitCheckInCommand.createCommitCommandLine(gitRepository, new ScmFileSet(workingDirectory), messageFile); - assertCommandLine( commandLine, workingDirectory, cl ); + assertCommandLine(commandLine, workingDirectory, cl); } } diff --git a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/test/java/org/apache/maven/scm/provider/git/gitexe/command/checkin/GitExeCheckInCommandTckTest.java b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/test/java/org/apache/maven/scm/provider/git/gitexe/command/checkin/GitExeCheckInCommandTckTest.java index a97285b72..8f69c7b19 100644 --- a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/test/java/org/apache/maven/scm/provider/git/gitexe/command/checkin/GitExeCheckInCommandTckTest.java +++ b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/test/java/org/apache/maven/scm/provider/git/gitexe/command/checkin/GitExeCheckInCommandTckTest.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.git.gitexe.command.checkin; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider.git.gitexe.command.checkin; import org.apache.maven.scm.provider.git.GitScmTestUtils; import org.apache.maven.scm.provider.git.command.checkin.GitCheckInCommandTckTest; @@ -28,19 +27,14 @@ * @author Brett Porter * */ -public class GitExeCheckInCommandTckTest - extends GitCheckInCommandTckTest -{ +public class GitExeCheckInCommandTckTest extends GitCheckInCommandTckTest { @Override - public String getScmProviderCommand() - { + public String getScmProviderCommand() { return GIT_COMMAND_LINE; } /** {@inheritDoc} */ - public String getScmUrl() - throws Exception - { - return GitScmTestUtils.getScmUrl( getRepositoryRoot(), "git" ); + public String getScmUrl() throws Exception { + return GitScmTestUtils.getScmUrl(getRepositoryRoot(), "git"); } } diff --git a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/test/java/org/apache/maven/scm/provider/git/gitexe/command/checkout/GitCheckOutCommandTest.java b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/test/java/org/apache/maven/scm/provider/git/gitexe/command/checkout/GitCheckOutCommandTest.java index 23262e264..d5332854d 100644 --- a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/test/java/org/apache/maven/scm/provider/git/gitexe/command/checkout/GitCheckOutCommandTest.java +++ b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/test/java/org/apache/maven/scm/provider/git/gitexe/command/checkout/GitCheckOutCommandTest.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.git.gitexe.command.checkout; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,9 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider.git.gitexe.command.checkout; + +import java.io.File; import org.apache.maven.scm.ScmRevision; import org.apache.maven.scm.ScmTestCase; @@ -28,15 +29,11 @@ import org.junit.Before; import org.junit.Test; -import java.io.File; - /** * @author Emmanuel Venisse * */ -public class GitCheckOutCommandTest - extends ScmTestCase -{ +public class GitCheckOutCommandTest extends ScmTestCase { private File workingDirectory; // ---------------------------------------------------------------------- @@ -45,12 +42,10 @@ public class GitCheckOutCommandTest @Before @Override - public void setUp() - throws Exception - { + public void setUp() throws Exception { super.setUp(); - workingDirectory = getTestFile( "target/git-checkout-command-test" ); + workingDirectory = getTestFile("target/git-checkout-command-test"); } // ---------------------------------------------------------------------- @@ -58,26 +53,23 @@ public void setUp() // ---------------------------------------------------------------------- @Test - public void testCommandLineWithBranch() - throws Exception - { - testCommandLine( getScmManager(), "scm:git:http://foo.com/git", "mybranch", "git checkout mybranch" ); + public void testCommandLineWithBranch() throws Exception { + testCommandLine(getScmManager(), "scm:git:http://foo.com/git", "mybranch", "git checkout mybranch"); } // ---------------------------------------------------------------------- // // ---------------------------------------------------------------------- - private void testCommandLine( ScmManager scmManager, String scmUrl, String revision, String commandLine ) - throws Exception - { - ScmRepository repository = scmManager.makeScmRepository( scmUrl ); + private void testCommandLine(ScmManager scmManager, String scmUrl, String revision, String commandLine) + throws Exception { + ScmRepository repository = scmManager.makeScmRepository(scmUrl); GitScmProviderRepository gitRepository = (GitScmProviderRepository) repository.getProviderRepository(); Commandline cl = - GitCheckOutCommand.createCommandLine( gitRepository, workingDirectory, new ScmRevision( revision ) ); + GitCheckOutCommand.createCommandLine(gitRepository, workingDirectory, new ScmRevision(revision)); - assertCommandLine( commandLine, workingDirectory, cl ); + assertCommandLine(commandLine, workingDirectory, cl); } } diff --git a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/test/java/org/apache/maven/scm/provider/git/gitexe/command/checkout/GitExeCheckOutCommandNoBranchTest.java b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/test/java/org/apache/maven/scm/provider/git/gitexe/command/checkout/GitExeCheckOutCommandNoBranchTest.java index 0994da754..0521957b0 100644 --- a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/test/java/org/apache/maven/scm/provider/git/gitexe/command/checkout/GitExeCheckOutCommandNoBranchTest.java +++ b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/test/java/org/apache/maven/scm/provider/git/gitexe/command/checkout/GitExeCheckOutCommandNoBranchTest.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.git.gitexe.command.checkout; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,9 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider.git.gitexe.command.checkout; + +import java.io.File; import org.apache.maven.scm.ScmFileSet; import org.apache.maven.scm.ScmTestCase; @@ -28,19 +29,14 @@ import org.junit.Before; import org.junit.Test; -import java.io.File; - import static org.apache.maven.scm.provider.git.GitScmTestUtils.GIT_COMMAND_LINE; - import static org.junit.Assert.assertEquals; /** * @author Bertrand Paquet * */ -public class GitExeCheckOutCommandNoBranchTest - extends ScmTestCase -{ +public class GitExeCheckOutCommandNoBranchTest extends ScmTestCase { private File workingDirectory; private File repo; @@ -49,46 +45,39 @@ public class GitExeCheckOutCommandNoBranchTest @Before @Override - public void setUp() - throws Exception - { + public void setUp() throws Exception { super.setUp(); - workingDirectory = new File( "target/checkin-nobranch" ); - FileUtils.deleteDirectory( workingDirectory ); - repo = new File( "src/test/resources/repository_no_branch" ); + workingDirectory = new File("target/checkin-nobranch"); + FileUtils.deleteDirectory(workingDirectory); + repo = new File("src/test/resources/repository_no_branch"); - scmRepository = getScmManager().makeScmRepository( "scm:git:" + - repo.toPath().toAbsolutePath().toUri().toASCIIString() ); + scmRepository = getScmManager() + .makeScmRepository( + "scm:git:" + repo.toPath().toAbsolutePath().toUri().toASCIIString()); } @Test - public void testCheckoutNoBranch() - throws Exception - { - checkScmPresence( GIT_COMMAND_LINE ); + public void testCheckoutNoBranch() throws Exception { + checkScmPresence(GIT_COMMAND_LINE); CheckOutScmResult result = checkoutRepo(); - assertEquals( 0, result.getCheckedOutFiles().size() ); + assertEquals(0, result.getCheckedOutFiles().size()); } @Test - public void testDoubleCheckoutNoBranch() - throws Exception - { - checkScmPresence( GIT_COMMAND_LINE ); + public void testDoubleCheckoutNoBranch() throws Exception { + checkScmPresence(GIT_COMMAND_LINE); CheckOutScmResult result = checkoutRepo(); - assertEquals( 0, result.getCheckedOutFiles().size() ); + assertEquals(0, result.getCheckedOutFiles().size()); CheckOutScmResult result2 = checkoutRepo(); - assertEquals( 0, result2.getCheckedOutFiles().size() ); + assertEquals(0, result2.getCheckedOutFiles().size()); } - protected CheckOutScmResult checkoutRepo() - throws Exception - { + protected CheckOutScmResult checkoutRepo() throws Exception { CheckOutScmResult result = - getScmManager().checkOut( scmRepository, new ScmFileSet( workingDirectory ), (ScmVersion) null ); + getScmManager().checkOut(scmRepository, new ScmFileSet(workingDirectory), (ScmVersion) null); - assertResultIsSuccess( result ); + assertResultIsSuccess(result); return result; } } diff --git a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/test/java/org/apache/maven/scm/provider/git/gitexe/command/checkout/GitExeCheckOutCommandTckTest.java b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/test/java/org/apache/maven/scm/provider/git/gitexe/command/checkout/GitExeCheckOutCommandTckTest.java index eb2e76040..5f807d465 100644 --- a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/test/java/org/apache/maven/scm/provider/git/gitexe/command/checkout/GitExeCheckOutCommandTckTest.java +++ b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/test/java/org/apache/maven/scm/provider/git/gitexe/command/checkout/GitExeCheckOutCommandTckTest.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.git.gitexe.command.checkout; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider.git.gitexe.command.checkout; import org.apache.maven.scm.provider.git.command.checkout.GitCheckOutCommandTckTest; @@ -27,12 +26,9 @@ * @author Emmanuel Venisse * */ -public class GitExeCheckOutCommandTckTest - extends GitCheckOutCommandTckTest -{ +public class GitExeCheckOutCommandTckTest extends GitCheckOutCommandTckTest { @Override - public String getScmProviderCommand() - { + public String getScmProviderCommand() { return GIT_COMMAND_LINE; } } diff --git a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/test/java/org/apache/maven/scm/provider/git/gitexe/command/checkout/GitExeSshCheckOutCommandTckTest.java b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/test/java/org/apache/maven/scm/provider/git/gitexe/command/checkout/GitExeSshCheckOutCommandTckTest.java index f83d0488d..d8dda5353 100644 --- a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/test/java/org/apache/maven/scm/provider/git/gitexe/command/checkout/GitExeSshCheckOutCommandTckTest.java +++ b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/test/java/org/apache/maven/scm/provider/git/gitexe/command/checkout/GitExeSshCheckOutCommandTckTest.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.git.gitexe.command.checkout; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider.git.gitexe.command.checkout; import java.nio.file.Files; import java.nio.file.Path; @@ -32,40 +31,37 @@ /** * */ -public class GitExeSshCheckOutCommandTckTest - extends GitSshCheckOutCommandTckTest -{ +public class GitExeSshCheckOutCommandTckTest extends GitSshCheckOutCommandTckTest { private Path knownHostsFile; - public static final String VARIABLE_GIT_SSH_COMMAND = "GIT_SSH_COMMAND"; // https://git-scm.com/docs/git#Documentation/git.txt-codeGITSSHCOMMANDcode, requires git 2.3.0 or newer + public static final String VARIABLE_GIT_SSH_COMMAND = + "GIT_SSH_COMMAND"; // https://git-scm.com/docs/git#Documentation/git.txt-codeGITSSHCOMMANDcode, requires git + // 2.3.0 or newer - public GitExeSshCheckOutCommandTckTest() throws GeneralSecurityException - { + public GitExeSshCheckOutCommandTckTest() throws GeneralSecurityException { super(); } @Override - protected String getScmProvider() - { + protected String getScmProvider() { return "git"; } @Override - public void configureCredentials( ScmRepository repository, String passphrase ) throws Exception - { - super.configureCredentials( repository, passphrase ); + public void configureCredentials(ScmRepository repository, String passphrase) throws Exception { + super.configureCredentials(repository, passphrase); GitScmProviderRepository providerRepository = (GitScmProviderRepository) repository.getProviderRepository(); - GitExeScmProvider provider = (GitExeScmProvider) getScmManager().getProviderByRepository( getScmRepository() ); - knownHostsFile = Files.createTempFile( "known-hosts", null ); - provider.setEnvironmentVariable( VARIABLE_GIT_SSH_COMMAND, "ssh -o UserKnownHostsFile=" + knownHostsFile + - " -o StrictHostKeyChecking=no -o IdentitiesOnly=yes -i " + FilenameUtils.separatorsToUnix( providerRepository.getPrivateKey() ) ); + GitExeScmProvider provider = (GitExeScmProvider) getScmManager().getProviderByRepository(getScmRepository()); + knownHostsFile = Files.createTempFile("known-hosts", null); + provider.setEnvironmentVariable( + VARIABLE_GIT_SSH_COMMAND, + "ssh -o UserKnownHostsFile=" + knownHostsFile + " -o StrictHostKeyChecking=no -o IdentitiesOnly=yes -i " + + FilenameUtils.separatorsToUnix(providerRepository.getPrivateKey())); } @Override - public void removeRepo() throws Exception - { + public void removeRepo() throws Exception { super.removeRepo(); - Files.deleteIfExists( knownHostsFile ); + Files.deleteIfExists(knownHostsFile); } - } diff --git a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/test/java/org/apache/maven/scm/provider/git/gitexe/command/diff/GitDiffRawConsumerTest.java b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/test/java/org/apache/maven/scm/provider/git/gitexe/command/diff/GitDiffRawConsumerTest.java index 12f4924c9..d480242e1 100644 --- a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/test/java/org/apache/maven/scm/provider/git/gitexe/command/diff/GitDiffRawConsumerTest.java +++ b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/test/java/org/apache/maven/scm/provider/git/gitexe/command/diff/GitDiffRawConsumerTest.java @@ -1,17 +1,3 @@ -package org.apache.maven.scm.provider.git.gitexe.command.diff; - -import java.io.BufferedReader; -import java.io.File; -import java.io.Reader; -import java.util.List; - -import org.apache.maven.scm.ScmFile; -import org.apache.maven.scm.ScmTestCase; -import org.codehaus.plexus.util.ReaderFactory; -import org.junit.Test; - -import static org.junit.Assert.assertEquals; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -30,49 +16,50 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider.git.gitexe.command.diff; + +import java.io.BufferedReader; +import java.io.File; +import java.io.Reader; +import java.util.List; + +import org.apache.maven.scm.ScmFile; +import org.apache.maven.scm.ScmTestCase; +import org.codehaus.plexus.util.ReaderFactory; +import org.junit.Test; + +import static org.junit.Assert.assertEquals; /** * @author Mark Struberg */ -public class GitDiffRawConsumerTest - extends ScmTestCase -{ +public class GitDiffRawConsumerTest extends ScmTestCase { @Test - public void testUpToDate() - throws Exception - { + public void testUpToDate() throws Exception { GitDiffRawConsumer consumer = buildGitDiffRawConsumer("/src/test/resources/git/diff/git-diff-raw_long.out"); List changedFiles = consumer.getChangedFiles(); - assertEquals( 62, changedFiles.size() ); + assertEquals(62, changedFiles.size()); } - - // ---------------------------------------------------------------------- // private helper functions // ---------------------------------------------------------------------- - - private GitDiffRawConsumer buildGitDiffRawConsumer(String fileName) - throws Exception - { + private GitDiffRawConsumer buildGitDiffRawConsumer(String fileName) throws Exception { GitDiffRawConsumer consumer = new GitDiffRawConsumer(); - File f = getTestFile( fileName ); - Reader reader = ReaderFactory.newReader( f, "UTF-8" ); - BufferedReader r = new BufferedReader( reader ); + File f = getTestFile(fileName); + Reader reader = ReaderFactory.newReader(f, "UTF-8"); + BufferedReader r = new BufferedReader(reader); String line; - while ( ( line = r.readLine() ) != null ) - { - //System.out.println(" line " + line ); - consumer.consumeLine( line ); + while ((line = r.readLine()) != null) { + // System.out.println(" line " + line ); + consumer.consumeLine(line); } return consumer; } - - } diff --git a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/test/java/org/apache/maven/scm/provider/git/gitexe/command/diff/GitExeDiffCommandTckTest.java b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/test/java/org/apache/maven/scm/provider/git/gitexe/command/diff/GitExeDiffCommandTckTest.java index 37bfcda1f..0f2eec39e 100644 --- a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/test/java/org/apache/maven/scm/provider/git/gitexe/command/diff/GitExeDiffCommandTckTest.java +++ b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/test/java/org/apache/maven/scm/provider/git/gitexe/command/diff/GitExeDiffCommandTckTest.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.git.gitexe.command.diff; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider.git.gitexe.command.diff; import org.apache.maven.scm.provider.git.GitScmTestUtils; import org.apache.maven.scm.provider.git.command.diff.GitDiffCommandTckTest; @@ -27,21 +26,16 @@ /** * @author Mark Struberg */ -public class GitExeDiffCommandTckTest - extends GitDiffCommandTckTest -{ +public class GitExeDiffCommandTckTest extends GitDiffCommandTckTest { @Override - public String getScmProviderCommand() - { + public String getScmProviderCommand() { return GIT_COMMAND_LINE; } /** * {@inheritDoc} */ - public String getScmUrl() - throws Exception - { - return GitScmTestUtils.getScmUrl( getRepositoryRoot(), "git" ); + public String getScmUrl() throws Exception { + return GitScmTestUtils.getScmUrl(getRepositoryRoot(), "git"); } } diff --git a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/test/java/org/apache/maven/scm/provider/git/gitexe/command/info/GitInfoCommandTest.java b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/test/java/org/apache/maven/scm/provider/git/gitexe/command/info/GitInfoCommandTest.java index 8865bb834..e94b3a3ba 100644 --- a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/test/java/org/apache/maven/scm/provider/git/gitexe/command/info/GitInfoCommandTest.java +++ b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/test/java/org/apache/maven/scm/provider/git/gitexe/command/info/GitInfoCommandTest.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.git.gitexe.command.info; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,9 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider.git.gitexe.command.info; + +import java.io.File; import org.apache.maven.scm.CommandParameter; import org.apache.maven.scm.CommandParameters; @@ -29,10 +30,7 @@ import org.apache.maven.scm.provider.git.GitScmTestUtils; import org.junit.Test; -import java.io.File; - import static org.apache.maven.scm.provider.git.GitScmTestUtils.GIT_COMMAND_LINE; - import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; @@ -40,98 +38,90 @@ /** * @author Olivier Lamy */ -public class GitInfoCommandTest - extends ScmTestCase -{ +public class GitInfoCommandTest extends ScmTestCase { @Test - public void testInfoCommand() - throws Exception - { - checkScmPresence( GIT_COMMAND_LINE ); - - GitScmTestUtils.initRepo( "src/test/resources/git/info", getRepositoryRoot(), getWorkingCopy() ); - - ScmProvider provider = getScmManager().getProviderByUrl( getScmUrl() ); - ScmProviderRepository repository = provider.makeProviderScmRepository( getRepositoryRoot() ); - assertNotNull( repository ); - InfoScmResult result = - provider.info( repository, new ScmFileSet( getRepositoryRoot() ), new CommandParameters() ); - assertNotNull( result ); - assertEquals( "cd3c0dfacb65955e6fbb35c56cc5b1bf8ce4f767", result.getInfoItems().get( 0 ).getRevision() ); + public void testInfoCommand() throws Exception { + checkScmPresence(GIT_COMMAND_LINE); + + GitScmTestUtils.initRepo("src/test/resources/git/info", getRepositoryRoot(), getWorkingCopy()); + + ScmProvider provider = getScmManager().getProviderByUrl(getScmUrl()); + ScmProviderRepository repository = provider.makeProviderScmRepository(getRepositoryRoot()); + assertNotNull(repository); + InfoScmResult result = provider.info(repository, new ScmFileSet(getRepositoryRoot()), new CommandParameters()); + assertNotNull(result); + assertEquals( + "cd3c0dfacb65955e6fbb35c56cc5b1bf8ce4f767", + result.getInfoItems().get(0).getRevision()); // } @Test - public void testInfoCommandWithShortRevision() - throws Exception - { - checkScmPresence( GIT_COMMAND_LINE ); + public void testInfoCommandWithShortRevision() throws Exception { + checkScmPresence(GIT_COMMAND_LINE); - GitScmTestUtils.initRepo( "src/test/resources/git/info", getRepositoryRoot(), getWorkingCopy() ); + GitScmTestUtils.initRepo("src/test/resources/git/info", getRepositoryRoot(), getWorkingCopy()); - ScmProvider provider = getScmManager().getProviderByUrl( getScmUrl() ); - ScmProviderRepository repository = provider.makeProviderScmRepository( getRepositoryRoot() ); - assertNotNull( repository ); + ScmProvider provider = getScmManager().getProviderByUrl(getScmUrl()); + ScmProviderRepository repository = provider.makeProviderScmRepository(getRepositoryRoot()); + assertNotNull(repository); CommandParameters commandParameters = new CommandParameters(); - commandParameters.setInt( CommandParameter.SCM_SHORT_REVISION_LENGTH, 6 ); - InfoScmResult result = provider.info( repository, new ScmFileSet( getRepositoryRoot() ), commandParameters ); - assertNotNull( result ); - assertEquals( "revision must be short, exactly 6 digits ", "cd3c0d", - result.getInfoItems().get( 0 ).getRevision() ); + commandParameters.setInt(CommandParameter.SCM_SHORT_REVISION_LENGTH, 6); + InfoScmResult result = provider.info(repository, new ScmFileSet(getRepositoryRoot()), commandParameters); + assertNotNull(result); + assertEquals( + "revision must be short, exactly 6 digits ", + "cd3c0d", + result.getInfoItems().get(0).getRevision()); } @Test - public void testInfoCommandWithNegativeShortRevision() - throws Exception - { - checkScmPresence( GIT_COMMAND_LINE ); + public void testInfoCommandWithNegativeShortRevision() throws Exception { + checkScmPresence(GIT_COMMAND_LINE); - GitScmTestUtils.initRepo( "src/test/resources/git/info", getRepositoryRoot(), getWorkingCopy() ); + GitScmTestUtils.initRepo("src/test/resources/git/info", getRepositoryRoot(), getWorkingCopy()); - ScmProvider provider = getScmManager().getProviderByUrl( getScmUrl() ); - ScmProviderRepository repository = provider.makeProviderScmRepository( getRepositoryRoot() ); - assertNotNull( repository ); + ScmProvider provider = getScmManager().getProviderByUrl(getScmUrl()); + ScmProviderRepository repository = provider.makeProviderScmRepository(getRepositoryRoot()); + assertNotNull(repository); CommandParameters commandParameters = new CommandParameters(); - commandParameters.setInt( CommandParameter.SCM_SHORT_REVISION_LENGTH, GitInfoCommand.NO_REVISION_LENGTH ); - InfoScmResult result = provider.info( repository, new ScmFileSet( getRepositoryRoot() ), commandParameters ); - assertNotNull( result ); - assertEquals( "revision should not be short", "cd3c0dfacb65955e6fbb35c56cc5b1bf8ce4f767", - result.getInfoItems().get( 0 ).getRevision() ); + commandParameters.setInt(CommandParameter.SCM_SHORT_REVISION_LENGTH, GitInfoCommand.NO_REVISION_LENGTH); + InfoScmResult result = provider.info(repository, new ScmFileSet(getRepositoryRoot()), commandParameters); + assertNotNull(result); + assertEquals( + "revision should not be short", + "cd3c0dfacb65955e6fbb35c56cc5b1bf8ce4f767", + result.getInfoItems().get(0).getRevision()); } @Test - public void testInfoCommandWithZeroShortRevision() - throws Exception - { - checkScmPresence( GIT_COMMAND_LINE ); + public void testInfoCommandWithZeroShortRevision() throws Exception { + checkScmPresence(GIT_COMMAND_LINE); - GitScmTestUtils.initRepo( "src/test/resources/git/info", getRepositoryRoot(), getWorkingCopy() ); + GitScmTestUtils.initRepo("src/test/resources/git/info", getRepositoryRoot(), getWorkingCopy()); - ScmProvider provider = getScmManager().getProviderByUrl( getScmUrl() ); - ScmProviderRepository repository = provider.makeProviderScmRepository( getRepositoryRoot() ); - assertNotNull( repository ); + ScmProvider provider = getScmManager().getProviderByUrl(getScmUrl()); + ScmProviderRepository repository = provider.makeProviderScmRepository(getRepositoryRoot()); + assertNotNull(repository); CommandParameters commandParameters = new CommandParameters(); - commandParameters.setInt( CommandParameter.SCM_SHORT_REVISION_LENGTH, 0 ); - InfoScmResult result = provider.info( repository, new ScmFileSet( getRepositoryRoot() ), commandParameters ); - assertNotNull( result ); - assertTrue( "revision should be not empty, minimum 4 (see git help rev-parse --short)", - result.getInfoItems().get( 0 ).getRevision().length() >= 4 ); + commandParameters.setInt(CommandParameter.SCM_SHORT_REVISION_LENGTH, 0); + InfoScmResult result = provider.info(repository, new ScmFileSet(getRepositoryRoot()), commandParameters); + assertNotNull(result); + assertTrue( + "revision should be not empty, minimum 4 (see git help rev-parse --short)", + result.getInfoItems().get(0).getRevision().length() >= 4); } - protected File getRepositoryRoot() - { - return getTestFile( "target/scm-test/repository/git/info" ); + protected File getRepositoryRoot() { + return getTestFile("target/scm-test/repository/git/info"); } - public String getScmUrl() - throws Exception - { - return GitScmTestUtils.getScmUrl( getRepositoryRoot(), "git" ); + public String getScmUrl() throws Exception { + return GitScmTestUtils.getScmUrl(getRepositoryRoot(), "git"); } - protected File getWorkingCopy() - { - return getTestFile( "target/scm-test/git/info" ); + protected File getWorkingCopy() { + return getTestFile("target/scm-test/git/info"); } } diff --git a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/test/java/org/apache/maven/scm/provider/git/gitexe/command/remoteinfo/GitExeRemoteInfoCommandTckTest.java b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/test/java/org/apache/maven/scm/provider/git/gitexe/command/remoteinfo/GitExeRemoteInfoCommandTckTest.java index a96cd0bd9..32214e3ec 100644 --- a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/test/java/org/apache/maven/scm/provider/git/gitexe/command/remoteinfo/GitExeRemoteInfoCommandTckTest.java +++ b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/test/java/org/apache/maven/scm/provider/git/gitexe/command/remoteinfo/GitExeRemoteInfoCommandTckTest.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.git.gitexe.command.remoteinfo; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider.git.gitexe.command.remoteinfo; import org.apache.maven.scm.command.remoteinfo.RemoteInfoScmResult; import org.apache.maven.scm.provider.git.GitScmTestUtils; @@ -29,31 +28,25 @@ /** * @author Bertrand Paquet */ -public class GitExeRemoteInfoCommandTckTest - extends AbstractGitRemoteInfoCommandTckTest -{ +public class GitExeRemoteInfoCommandTckTest extends AbstractGitRemoteInfoCommandTckTest { @Override - public String getScmProviderCommand() - { + public String getScmProviderCommand() { return GIT_COMMAND_LINE; } @Override - protected void checkResult( RemoteInfoScmResult result ) - { - assertEquals( 1, result.getBranches().size() ); - assertEquals( "92f139dfec4d1dfb79c3cd2f94e83bf13129668b", result.getBranches().get( "master" ) ); + protected void checkResult(RemoteInfoScmResult result) { + assertEquals(1, result.getBranches().size()); + assertEquals( + "92f139dfec4d1dfb79c3cd2f94e83bf13129668b", result.getBranches().get("master")); - assertEquals( 0, result.getTags().size() ); + assertEquals(0, result.getTags().size()); } /** * {@inheritDoc} */ - public String getScmUrl() - throws Exception - { - return GitScmTestUtils.getScmUrl( getRepositoryRoot(), "git" ); + public String getScmUrl() throws Exception { + return GitScmTestUtils.getScmUrl(getRepositoryRoot(), "git"); } - -} \ No newline at end of file +} diff --git a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/test/java/org/apache/maven/scm/provider/git/gitexe/command/remoteinfo/GitRemoteInfoConsumerTest.java b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/test/java/org/apache/maven/scm/provider/git/gitexe/command/remoteinfo/GitRemoteInfoConsumerTest.java index e21074c9a..61281641b 100644 --- a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/test/java/org/apache/maven/scm/provider/git/gitexe/command/remoteinfo/GitRemoteInfoConsumerTest.java +++ b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/test/java/org/apache/maven/scm/provider/git/gitexe/command/remoteinfo/GitRemoteInfoConsumerTest.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.git.gitexe.command.remoteinfo; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider.git.gitexe.command.remoteinfo; import org.apache.maven.scm.ScmTestCase; import org.apache.maven.scm.command.remoteinfo.RemoteInfoScmResult; @@ -28,26 +27,26 @@ /** * @author Bertrand Paquet */ -public class GitRemoteInfoConsumerTest - extends ScmTestCase -{ +public class GitRemoteInfoConsumerTest extends ScmTestCase { @Test - public void testConsumerRemoteInfo() - { - GitRemoteInfoConsumer consumer = new GitRemoteInfoConsumer( null ); + public void testConsumerRemoteInfo() { + GitRemoteInfoConsumer consumer = new GitRemoteInfoConsumer(null); - consumer.consumeLine( "344581899752998038a74989142221ae08c381bc HEAD" ); - consumer.consumeLine( "344581899752998038a74989142221ae08c381bc refs/heads/master" ); - consumer.consumeLine( "9006c3dbaa9749aa435694f261638583c9088419 refs/tags/staging" ); + consumer.consumeLine("344581899752998038a74989142221ae08c381bc HEAD"); + consumer.consumeLine("344581899752998038a74989142221ae08c381bc refs/heads/master"); + consumer.consumeLine("9006c3dbaa9749aa435694f261638583c9088419 refs/tags/staging"); RemoteInfoScmResult remoteInfoScmResult = consumer.getRemoteInfoScmResult(); - assertEquals( 1, remoteInfoScmResult.getBranches().size() ); - assertEquals( "344581899752998038a74989142221ae08c381bc", remoteInfoScmResult.getBranches().get( "master" ) ); + assertEquals(1, remoteInfoScmResult.getBranches().size()); + assertEquals( + "344581899752998038a74989142221ae08c381bc", + remoteInfoScmResult.getBranches().get("master")); - assertEquals( 1, remoteInfoScmResult.getTags().size() ); - assertEquals( "9006c3dbaa9749aa435694f261638583c9088419", remoteInfoScmResult.getTags().get( "staging" ) ); + assertEquals(1, remoteInfoScmResult.getTags().size()); + assertEquals( + "9006c3dbaa9749aa435694f261638583c9088419", + remoteInfoScmResult.getTags().get("staging")); } - -} \ No newline at end of file +} diff --git a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/test/java/org/apache/maven/scm/provider/git/gitexe/command/remove/GitExeRemoveCommandTckTest.java b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/test/java/org/apache/maven/scm/provider/git/gitexe/command/remove/GitExeRemoveCommandTckTest.java index 4b74e0bfe..3ee579f04 100644 --- a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/test/java/org/apache/maven/scm/provider/git/gitexe/command/remove/GitExeRemoveCommandTckTest.java +++ b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/test/java/org/apache/maven/scm/provider/git/gitexe/command/remove/GitExeRemoveCommandTckTest.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.git.gitexe.command.remove; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,35 +16,29 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider.git.gitexe.command.remove; import java.io.File; import org.apache.maven.scm.command.checkout.CheckOutScmResult; -import org.apache.maven.scm.provider.git.command.remove.GitRemoveCommandTckTest; import org.apache.maven.scm.provider.git.GitScmTestUtils; +import org.apache.maven.scm.provider.git.command.remove.GitRemoveCommandTckTest; import org.apache.maven.scm.repository.ScmRepository; import static org.apache.maven.scm.provider.git.GitScmTestUtils.GIT_COMMAND_LINE; -public class GitExeRemoveCommandTckTest - extends GitRemoveCommandTckTest -{ +public class GitExeRemoveCommandTckTest extends GitRemoveCommandTckTest { @Override - public String getScmProviderCommand() - { + public String getScmProviderCommand() { return GIT_COMMAND_LINE; } @Override - protected CheckOutScmResult checkOut( File workingDirectory, ScmRepository repository ) throws Exception - { - try - { - return super.checkOut( workingDirectory, repository ); - } - finally - { - GitScmTestUtils.setDefaultUser( workingDirectory ); + protected CheckOutScmResult checkOut(File workingDirectory, ScmRepository repository) throws Exception { + try { + return super.checkOut(workingDirectory, repository); + } finally { + GitScmTestUtils.setDefaultUser(workingDirectory); } } } diff --git a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/test/java/org/apache/maven/scm/provider/git/gitexe/command/remove/GitRemoveCommandTest.java b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/test/java/org/apache/maven/scm/provider/git/gitexe/command/remove/GitRemoveCommandTest.java index 6d8fe4ad1..1c604a6d0 100644 --- a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/test/java/org/apache/maven/scm/provider/git/gitexe/command/remove/GitRemoveCommandTest.java +++ b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/test/java/org/apache/maven/scm/provider/git/gitexe/command/remove/GitRemoveCommandTest.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.git.gitexe.command.remove; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,79 +16,70 @@ * specific language governing permissions and limitations * under the License. */ - -import org.apache.maven.scm.ScmTestCase; -import org.codehaus.plexus.util.FileUtils; -import org.codehaus.plexus.util.cli.Commandline; -import org.junit.Test; +package org.apache.maven.scm.provider.git.gitexe.command.remove; import java.io.File; import java.io.IOException; import java.nio.file.Files; import java.util.Arrays; +import org.apache.maven.scm.ScmTestCase; +import org.codehaus.plexus.util.FileUtils; +import org.codehaus.plexus.util.cli.Commandline; +import org.junit.Test; + /** * @author Mark Struberg */ -public class GitRemoveCommandTest - extends ScmTestCase -{ +public class GitRemoveCommandTest extends ScmTestCase { @Test - public void testCommandRemoveWithFile() - throws Exception - { + public void testCommandRemoveWithFile() throws Exception { File workingDirectory = createTempDirectory(); - File toBeRemoved = new File( workingDirectory.getAbsolutePath() + File.separator + "toto.xml" ); - FileUtils.fileAppend( toBeRemoved.getAbsolutePath(), "data" ); + File toBeRemoved = new File(workingDirectory.getAbsolutePath() + File.separator + "toto.xml"); + FileUtils.fileAppend(toBeRemoved.getAbsolutePath(), "data"); - Commandline cl = GitRemoveCommand.createCommandLine( workingDirectory, Arrays.asList( toBeRemoved ) ); + Commandline cl = GitRemoveCommand.createCommandLine(workingDirectory, Arrays.asList(toBeRemoved)); - assertCommandLine( "git rm -- toto.xml", workingDirectory, cl ); + assertCommandLine("git rm -- toto.xml", workingDirectory, cl); - FileUtils.deleteDirectory( workingDirectory ); + FileUtils.deleteDirectory(workingDirectory); } @Test - public void testCommandRemoveWithDirectory() - throws Exception - { + public void testCommandRemoveWithDirectory() throws Exception { File workingDirectory = createTempDirectory(); - File toBeRemoved = new File( workingDirectory.getAbsolutePath() + File.separator + "toto" ); + File toBeRemoved = new File(workingDirectory.getAbsolutePath() + File.separator + "toto"); toBeRemoved.mkdir(); - Commandline cl = GitRemoveCommand.createCommandLine( workingDirectory, Arrays.asList( toBeRemoved ) ); + Commandline cl = GitRemoveCommand.createCommandLine(workingDirectory, Arrays.asList(toBeRemoved)); - assertCommandLine( "git rm -r -- toto", workingDirectory, cl ); + assertCommandLine("git rm -r -- toto", workingDirectory, cl); - FileUtils.deleteDirectory( workingDirectory ); + FileUtils.deleteDirectory(workingDirectory); } @Test - public void testCommandRemoveWithTwoDirectory() - throws Exception - { + public void testCommandRemoveWithTwoDirectory() throws Exception { File workingDirectory = createTempDirectory(); - File toBeRemoved1 = new File( workingDirectory.getAbsolutePath() + File.separator + "toto" ); + File toBeRemoved1 = new File(workingDirectory.getAbsolutePath() + File.separator + "toto"); toBeRemoved1.mkdir(); - File toBeRemoved2 = new File( workingDirectory.getAbsolutePath() + File.separator + "tata" ); + File toBeRemoved2 = new File(workingDirectory.getAbsolutePath() + File.separator + "tata"); toBeRemoved2.mkdir(); Commandline cl = - GitRemoveCommand.createCommandLine( workingDirectory, Arrays.asList( toBeRemoved1, toBeRemoved2 ) ); + GitRemoveCommand.createCommandLine(workingDirectory, Arrays.asList(toBeRemoved1, toBeRemoved2)); - assertCommandLine( "git rm -r -- toto tata", workingDirectory, cl ); + assertCommandLine("git rm -r -- toto tata", workingDirectory, cl); - FileUtils.deleteDirectory( workingDirectory ); + FileUtils.deleteDirectory(workingDirectory); } - private File createTempDirectory() - throws IOException - { + private File createTempDirectory() throws IOException { File dir = Files.createTempDirectory("gitexe" + "test").toFile(); return dir; } diff --git a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/test/java/org/apache/maven/scm/provider/git/gitexe/command/remove/GitRemoveConsumerTest.java b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/test/java/org/apache/maven/scm/provider/git/gitexe/command/remove/GitRemoveConsumerTest.java index bb9544bb5..cd51e0886 100644 --- a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/test/java/org/apache/maven/scm/provider/git/gitexe/command/remove/GitRemoveConsumerTest.java +++ b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/test/java/org/apache/maven/scm/provider/git/gitexe/command/remove/GitRemoveConsumerTest.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.git.gitexe.command.remove; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,10 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider.git.gitexe.command.remove; + +import java.io.File; +import java.util.List; import org.apache.maven.scm.ScmFile; import org.apache.maven.scm.ScmFileStatus; @@ -26,84 +28,71 @@ import org.apache.maven.scm.util.ConsumerUtils; import org.junit.Test; -import java.io.File; -import java.util.List; - import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; /** * @author Mark Struberg */ -public class GitRemoveConsumerTest - extends ScmTestCase -{ +public class GitRemoveConsumerTest extends ScmTestCase { @Test - public void testConsumerRemovedFile() - { + public void testConsumerRemovedFile() { GitRemoveConsumer consumer = new GitRemoveConsumer(); - consumer.consumeLine( "rm 'project.xml'" ); + consumer.consumeLine("rm 'project.xml'"); List changedFiles = consumer.getRemovedFiles(); - assertNotNull( changedFiles ); - assertEquals( 1, changedFiles.size() ); - assertEquals( "project.xml", changedFiles.get( 0 ).getPath() ); + assertNotNull(changedFiles); + assertEquals(1, changedFiles.size()); + assertEquals("project.xml", changedFiles.get(0).getPath()); } @Test - public void testConsumerRemovedFileInDifferentDir() - { - GitRemoveConsumer consumer = new GitRemoveConsumer( GitStatusConsumer.uriFromPath( "main" ) ); + public void testConsumerRemovedFileInDifferentDir() { + GitRemoveConsumer consumer = new GitRemoveConsumer(GitStatusConsumer.uriFromPath("main")); - consumer.consumeLine( "rm 'main/project.xml'" ); + consumer.consumeLine("rm 'main/project.xml'"); List changedFiles = consumer.getRemovedFiles(); - assertNotNull( changedFiles ); - assertEquals( 1, changedFiles.size() ); - assertEquals( "project.xml", changedFiles.get( 0 ).getPath() ); + assertNotNull(changedFiles); + assertEquals(1, changedFiles.size()); + assertEquals("project.xml", changedFiles.get(0).getPath()); } @Test - public void testLog1Consumer() - throws Exception - { + public void testLog1Consumer() throws Exception { GitRemoveConsumer consumer = new GitRemoveConsumer(); - File f = getTestFile( "/src/test/resources/git/remove/gitrm.gitlog" ); + File f = getTestFile("/src/test/resources/git/remove/gitrm.gitlog"); - ConsumerUtils.consumeFile( f, consumer ); + ConsumerUtils.consumeFile(f, consumer); List changedFiles = consumer.getRemovedFiles(); - assertEquals( 2, changedFiles.size() ); + assertEquals(2, changedFiles.size()); - testScmFile( (ScmFile) changedFiles.get( 0 ), "src/main/java/Application.java", ScmFileStatus.DELETED ); - testScmFile( (ScmFile) changedFiles.get( 1 ), "src/test/java/Test.java" , ScmFileStatus.DELETED ); + testScmFile((ScmFile) changedFiles.get(0), "src/main/java/Application.java", ScmFileStatus.DELETED); + testScmFile((ScmFile) changedFiles.get(1), "src/test/java/Test.java", ScmFileStatus.DELETED); } @Test - public void testEmptyLogConsumer() - throws Exception - { + public void testEmptyLogConsumer() throws Exception { GitRemoveConsumer consumer = new GitRemoveConsumer(); - File f = getTestFile( "/src/test/resources/git/remove/gitrm-empty.gitlog" ); + File f = getTestFile("/src/test/resources/git/remove/gitrm-empty.gitlog"); - ConsumerUtils.consumeFile( f, consumer ); + ConsumerUtils.consumeFile(f, consumer); List changedFiles = consumer.getRemovedFiles(); - assertEquals( 0, changedFiles.size() ); - } - - private void testScmFile( ScmFile fileToTest, String expectedFilePath, ScmFileStatus expectedStatus ) - { - assertEquals( expectedFilePath, fileToTest.getPath() ); - assertEquals( expectedStatus, fileToTest.getStatus() ); + assertEquals(0, changedFiles.size()); } + private void testScmFile(ScmFile fileToTest, String expectedFilePath, ScmFileStatus expectedStatus) { + assertEquals(expectedFilePath, fileToTest.getPath()); + assertEquals(expectedStatus, fileToTest.getStatus()); + } } diff --git a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/test/java/org/apache/maven/scm/provider/git/gitexe/command/status/GitExeStatusCommandTckTest.java b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/test/java/org/apache/maven/scm/provider/git/gitexe/command/status/GitExeStatusCommandTckTest.java index 715b3d165..63c4751dd 100644 --- a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/test/java/org/apache/maven/scm/provider/git/gitexe/command/status/GitExeStatusCommandTckTest.java +++ b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/test/java/org/apache/maven/scm/provider/git/gitexe/command/status/GitExeStatusCommandTckTest.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.git.gitexe.command.status; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider.git.gitexe.command.status; import org.apache.maven.scm.provider.git.GitScmTestUtils; import org.apache.maven.scm.provider.git.command.status.GitStatusCommandTckTest; @@ -28,19 +27,14 @@ * @author Brett Porter * */ -public class GitExeStatusCommandTckTest - extends GitStatusCommandTckTest -{ +public class GitExeStatusCommandTckTest extends GitStatusCommandTckTest { @Override - public String getScmProviderCommand() - { + public String getScmProviderCommand() { return GIT_COMMAND_LINE; } /** {@inheritDoc} */ - public String getScmUrl() - throws Exception - { - return GitScmTestUtils.getScmUrl( getRepositoryRoot(), "git" ); + public String getScmUrl() throws Exception { + return GitScmTestUtils.getScmUrl(getRepositoryRoot(), "git"); } } diff --git a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/test/java/org/apache/maven/scm/provider/git/gitexe/command/status/GitStatusConsumerTest.java b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/test/java/org/apache/maven/scm/provider/git/gitexe/command/status/GitStatusConsumerTest.java index 364e7f257..012fc3a9b 100644 --- a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/test/java/org/apache/maven/scm/provider/git/gitexe/command/status/GitStatusConsumerTest.java +++ b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/test/java/org/apache/maven/scm/provider/git/gitexe/command/status/GitStatusConsumerTest.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.git.gitexe.command.status; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider.git.gitexe.command.status; import java.io.BufferedReader; import java.io.File; @@ -31,8 +30,8 @@ import org.apache.commons.io.FileUtils; import org.apache.maven.scm.ScmFile; -import org.apache.maven.scm.ScmFileStatus; import org.apache.maven.scm.ScmFileSet; +import org.apache.maven.scm.ScmFileStatus; import org.apache.maven.scm.ScmTestCase; import org.junit.Test; @@ -42,544 +41,532 @@ /** * @author Mark Struberg */ -public class GitStatusConsumerTest - extends ScmTestCase -{ - - private List getChangedFiles( File gitlog ) - throws IOException - { - return getChangedFiles( gitlog, null ); +public class GitStatusConsumerTest extends ScmTestCase { + + private List getChangedFiles(File gitlog) throws IOException { + return getChangedFiles(gitlog, null); } - - private List getChangedFiles( File gitlog, URI relativeRepoPath ) - throws IOException - { - GitStatusConsumer consumer = new GitStatusConsumer( null, relativeRepoPath ); - - try ( BufferedReader r = new BufferedReader( - new InputStreamReader ( new FileInputStream( gitlog ), StandardCharsets.UTF_8 ) ) ) - { + + private List getChangedFiles(File gitlog, URI relativeRepoPath) throws IOException { + GitStatusConsumer consumer = new GitStatusConsumer(null, relativeRepoPath); + + try (BufferedReader r = + new BufferedReader(new InputStreamReader(new FileInputStream(gitlog), StandardCharsets.UTF_8))) { String line; - while ( ( line = r.readLine() ) != null ) - { - consumer.consumeLine( line ); + while ((line = r.readLine()) != null) { + consumer.consumeLine(line); } } return consumer.getChangedFiles(); } - private List getChangedFiles( String line, File workingDirectory ) - { - GitStatusConsumer consumer = new GitStatusConsumer( workingDirectory ); + private List getChangedFiles(String line, File workingDirectory) { + GitStatusConsumer consumer = new GitStatusConsumer(workingDirectory); - consumer.consumeLine( line ); + consumer.consumeLine(line); return consumer.getChangedFiles(); } - private List getChangedFiles( String line, File workingDirectory, URI relativeRepoPath ) - { - GitStatusConsumer consumer = new GitStatusConsumer( workingDirectory, relativeRepoPath ); + private List getChangedFiles(String line, File workingDirectory, URI relativeRepoPath) { + GitStatusConsumer consumer = new GitStatusConsumer(workingDirectory, relativeRepoPath); - consumer.consumeLine( line ); + consumer.consumeLine(line); return consumer.getChangedFiles(); } - private List getChangedFiles( String line, File workingDirectory, URI relativeRepoPath, - ScmFileSet scmFileSet ) - { - GitStatusConsumer consumer = - new GitStatusConsumer( workingDirectory, relativeRepoPath, scmFileSet ); + private List getChangedFiles( + String line, File workingDirectory, URI relativeRepoPath, ScmFileSet scmFileSet) { + GitStatusConsumer consumer = new GitStatusConsumer(workingDirectory, relativeRepoPath, scmFileSet); - consumer.consumeLine( line ); + consumer.consumeLine(line); return consumer.getChangedFiles(); } @Test - public void testConsumerUntrackedFile() - { - List changedFiles = getChangedFiles( "?? project.xml", null ); + public void testConsumerUntrackedFile() { + List changedFiles = getChangedFiles("?? project.xml", null); - assertNotNull( changedFiles ); - assertEquals( 0, changedFiles.size() ); + assertNotNull(changedFiles); + assertEquals(0, changedFiles.size()); - changedFiles = getChangedFiles( "?? \"test file with spaces and a special \\177 character.xml\"", null ); + changedFiles = getChangedFiles("?? \"test file with spaces and a special \\177 character.xml\"", null); - assertNotNull( changedFiles ); - assertEquals( 0, changedFiles.size() ); + assertNotNull(changedFiles); + assertEquals(0, changedFiles.size()); } @Test - public void testConsumerAddedFile() - { - List changedFiles = getChangedFiles( "A project.xml", null ); - - assertNotNull( changedFiles ); - assertEquals( 1, changedFiles.size() ); - assertEquals( "project.xml", changedFiles.get( 0 ).getPath() ); - - changedFiles = getChangedFiles( "A \"test file with spaces and a special \\177 character.xml\"", null ); - - assertNotNull( changedFiles ); - assertEquals( 1, changedFiles.size() ); - assertEquals("test file with spaces and a special \u007f character.xml", changedFiles.get( 0 ).getPath() ); + public void testConsumerAddedFile() { + List changedFiles = getChangedFiles("A project.xml", null); + + assertNotNull(changedFiles); + assertEquals(1, changedFiles.size()); + assertEquals("project.xml", changedFiles.get(0).getPath()); + + changedFiles = getChangedFiles("A \"test file with spaces and a special \\177 character.xml\"", null); + + assertNotNull(changedFiles); + assertEquals(1, changedFiles.size()); + assertEquals( + "test file with spaces and a special \u007f character.xml", + changedFiles.get(0).getPath()); } @Test - public void testConsumerAddedAndModifiedFile() - { - List changedFiles = getChangedFiles( "AM project.xml", null ); - - assertNotNull( changedFiles ); - assertEquals( 1, changedFiles.size() ); - testScmFile( changedFiles.get( 0 ), "project.xml", ScmFileStatus.ADDED ); - - changedFiles = getChangedFiles( "AM \"test file with spaces and a special \\177 character.xml\"", null ); - - assertNotNull( changedFiles ); - assertEquals( 1, changedFiles.size() ); - testScmFile( changedFiles.get( 0 ), - "test file with spaces and a special \u007f character.xml", ScmFileStatus.ADDED ); + public void testConsumerAddedAndModifiedFile() { + List changedFiles = getChangedFiles("AM project.xml", null); + + assertNotNull(changedFiles); + assertEquals(1, changedFiles.size()); + testScmFile(changedFiles.get(0), "project.xml", ScmFileStatus.ADDED); + + changedFiles = getChangedFiles("AM \"test file with spaces and a special \\177 character.xml\"", null); + + assertNotNull(changedFiles); + assertEquals(1, changedFiles.size()); + testScmFile( + changedFiles.get(0), "test file with spaces and a special \u007f character.xml", ScmFileStatus.ADDED); } @Test - public void testConsumerAddedFileWithDirectoryAndNoFile() - throws IOException - { + public void testConsumerAddedFileWithDirectoryAndNoFile() throws IOException { File dir = createTempDirectory(); - List changedFiles = getChangedFiles( "A project.xml", dir ); + List changedFiles = getChangedFiles("A project.xml", dir); - assertNotNull( changedFiles ); - assertEquals( 0, changedFiles.size() ); + assertNotNull(changedFiles); + assertEquals(0, changedFiles.size()); - changedFiles = getChangedFiles( "A \"test file with spaces and a special \\177 character.xml\"", dir ); + changedFiles = getChangedFiles("A \"test file with spaces and a special \\177 character.xml\"", dir); - assertNotNull( changedFiles ); - assertEquals( 0, changedFiles.size() ); + assertNotNull(changedFiles); + assertEquals(0, changedFiles.size()); - FileUtils.deleteDirectory( dir ); + FileUtils.deleteDirectory(dir); } @Test - public void testConsumerAddedFileWithDirectoryAndFile() - throws IOException - { + public void testConsumerAddedFileWithDirectoryAndFile() throws IOException { File dir = createTempDirectory(); - FileUtils.write( new File( dir, "project.xml" ), "data", StandardCharsets.UTF_8 ); + FileUtils.write(new File(dir, "project.xml"), "data", StandardCharsets.UTF_8); - List changedFiles = getChangedFiles( "A project.xml", dir ); + List changedFiles = getChangedFiles("A project.xml", dir); - assertNotNull( changedFiles ); - assertEquals( 1, changedFiles.size() ); - assertEquals( "project.xml", changedFiles.get( 0 ).getPath() ); + assertNotNull(changedFiles); + assertEquals(1, changedFiles.size()); + assertEquals("project.xml", changedFiles.get(0).getPath()); - FileUtils.write( new File( dir, "test file with spaces and a special \u007f character.xml" ), - "data", StandardCharsets.UTF_8 ); + FileUtils.write( + new File(dir, "test file with spaces and a special \u007f character.xml"), + "data", + StandardCharsets.UTF_8); - changedFiles = getChangedFiles( "A \"test file with spaces and a special \\177 character.xml\"", dir ); + changedFiles = getChangedFiles("A \"test file with spaces and a special \\177 character.xml\"", dir); - assertNotNull( changedFiles ); - assertEquals( 1, changedFiles.size() ); - assertEquals("test file with spaces and a special \u007f character.xml", changedFiles.get( 0 ).getPath() ); + assertNotNull(changedFiles); + assertEquals(1, changedFiles.size()); + assertEquals( + "test file with spaces and a special \u007f character.xml", + changedFiles.get(0).getPath()); - FileUtils.deleteDirectory( dir ); + FileUtils.deleteDirectory(dir); } @Test - public void testConsumerModifiedFile() - { - List changedFiles = getChangedFiles( "M project.xml", null ); + public void testConsumerModifiedFile() { + List changedFiles = getChangedFiles("M project.xml", null); - assertNotNull( changedFiles ); - assertEquals( 1, changedFiles.size() ); - assertEquals( "project.xml", changedFiles.get( 0 ).getPath() ); + assertNotNull(changedFiles); + assertEquals(1, changedFiles.size()); + assertEquals("project.xml", changedFiles.get(0).getPath()); - changedFiles = getChangedFiles( "M \"test file with spaces and a special \\177 character.xml\"", null ); + changedFiles = getChangedFiles("M \"test file with spaces and a special \\177 character.xml\"", null); - assertNotNull( changedFiles ); - assertEquals( 1, changedFiles.size() ); - assertEquals("test file with spaces and a special \u007f character.xml", changedFiles.get( 0 ).getPath() ); + assertNotNull(changedFiles); + assertEquals(1, changedFiles.size()); + assertEquals( + "test file with spaces and a special \u007f character.xml", + changedFiles.get(0).getPath()); } @Test - public void testURI() - throws Exception - { + public void testURI() throws Exception { String path = "Not%Scheme:/sub dir"; - URI u = GitStatusConsumer.uriFromPath( path ); - assertEquals( path, u.getPath() ); + URI u = GitStatusConsumer.uriFromPath(path); + assertEquals(path, u.getPath()); } @Test - public void testConsumerWithFileSet() - throws IOException - { + public void testConsumerWithFileSet() throws IOException { File dir = createTempDirectory(); - FileUtils.write( new File( dir, "project.xml" ), "data", StandardCharsets.UTF_8 ); - FileUtils.write( new File( dir, "pom.xml" ), "more data", StandardCharsets.UTF_8 ); - File subdir = new File( dir.getAbsolutePath(), "subDir" ); + FileUtils.write(new File(dir, "project.xml"), "data", StandardCharsets.UTF_8); + FileUtils.write(new File(dir, "pom.xml"), "more data", StandardCharsets.UTF_8); + File subdir = new File(dir.getAbsolutePath(), "subDir"); subdir.mkdir(); - FileUtils.write( new File( subdir, "something.xml" ), "data", StandardCharsets.UTF_8 ); + FileUtils.write(new File(subdir, "something.xml"), "data", StandardCharsets.UTF_8); - ScmFileSet scmFileSet = new ScmFileSet( dir, null, "project.xml" ); - List changedFiles = getChangedFiles( "M project.xml", dir, null, scmFileSet ); - assertEquals( 0, changedFiles.size() ); + ScmFileSet scmFileSet = new ScmFileSet(dir, null, "project.xml"); + List changedFiles = getChangedFiles("M project.xml", dir, null, scmFileSet); + assertEquals(0, changedFiles.size()); - scmFileSet = new ScmFileSet( dir, "pom.xml" ); - changedFiles = getChangedFiles( "M pom.xml", dir, null, scmFileSet ); - assertEquals( 1, changedFiles.size() ); + scmFileSet = new ScmFileSet(dir, "pom.xml"); + changedFiles = getChangedFiles("M pom.xml", dir, null, scmFileSet); + assertEquals(1, changedFiles.size()); - scmFileSet = new ScmFileSet( subdir, "something.xml", "pom.xml" ); - changedFiles = getChangedFiles( "M subDir/something.xml", dir, dir.toURI(), scmFileSet ); - assertEquals( 1, changedFiles.size() ); + scmFileSet = new ScmFileSet(subdir, "something.xml", "pom.xml"); + changedFiles = getChangedFiles("M subDir/something.xml", dir, dir.toURI(), scmFileSet); + assertEquals(1, changedFiles.size()); } - // SCM-740 + // SCM-740 @Test - public void testConsumerModifiedFileInComplexDirectorySetup() throws IOException { + public void testConsumerModifiedFileInComplexDirectorySetup() throws IOException { - File dir = createTempDirectory(); - URI relativeCWD = URI.create( "" ); - File subdir = new File( dir, "subDirectory" ); - subdir.mkdir(); - FileUtils.write( new File( subdir, "project.xml" ), "data", StandardCharsets.UTF_8 ); + File dir = createTempDirectory(); + URI relativeCWD = URI.create(""); + File subdir = new File(dir, "subDirectory"); + subdir.mkdir(); + FileUtils.write(new File(subdir, "project.xml"), "data", StandardCharsets.UTF_8); - List changedFiles = getChangedFiles( "M subDirectory/project.xml", dir, relativeCWD ); + List changedFiles = getChangedFiles("M subDirectory/project.xml", dir, relativeCWD); - assertNotNull( changedFiles ); - assertEquals( 1, changedFiles.size() ); - assertEquals( "subDirectory/project.xml", changedFiles.get( 0 ).getPath() ); + assertNotNull(changedFiles); + assertEquals(1, changedFiles.size()); + assertEquals("subDirectory/project.xml", changedFiles.get(0).getPath()); - FileUtils.write( new File( subdir, - "test file with spaces and a déjà vu character.xml" ), "data", StandardCharsets.UTF_8 ); + FileUtils.write( + new File(subdir, "test file with spaces and a déjà vu character.xml"), "data", StandardCharsets.UTF_8); - changedFiles = - getChangedFiles( "M \"subDirectory/test file with spaces and a déjà vu character.xml\"", dir, relativeCWD ); + changedFiles = getChangedFiles( + "M \"subDirectory/test file with spaces and a déjà vu character.xml\"", dir, relativeCWD); - assertNotNull( changedFiles ); - assertEquals( 1, changedFiles.size() ); - assertEquals( "subDirectory/test file with spaces and a déjà vu character.xml", changedFiles.get( 0 ).getPath() ); + assertNotNull(changedFiles); + assertEquals(1, changedFiles.size()); + assertEquals( + "subDirectory/test file with spaces and a déjà vu character.xml", + changedFiles.get(0).getPath()); - FileUtils.deleteDirectory( dir ); - } + FileUtils.deleteDirectory(dir); + } @Test - public void testConsumerModifiedFileInComplexDirectoryWithSpaces() throws IOException { + public void testConsumerModifiedFileInComplexDirectoryWithSpaces() throws IOException { - File dir = createTempDirectory(); - URI relativeCWD = URI.create( "" ); - File subdir = new File( dir, "sub Directory déjà vu special" ); - subdir.mkdir(); - FileUtils.write( new File( subdir, "project.xml" ), "data", StandardCharsets.UTF_8 ); + File dir = createTempDirectory(); + URI relativeCWD = URI.create(""); + File subdir = new File(dir, "sub Directory déjà vu special"); + subdir.mkdir(); + FileUtils.write(new File(subdir, "project.xml"), "data", StandardCharsets.UTF_8); - List changedFiles = - getChangedFiles( "M \"sub Directory déjà vu special/project.xml\"", dir, relativeCWD ); + List changedFiles = + getChangedFiles("M \"sub Directory déjà vu special/project.xml\"", dir, relativeCWD); - assertNotNull( changedFiles ); - assertEquals( 1, changedFiles.size() ); - assertEquals( "sub Directory déjà vu special/project.xml", changedFiles.get( 0 ).getPath() ); + assertNotNull(changedFiles); + assertEquals(1, changedFiles.size()); + assertEquals( + "sub Directory déjà vu special/project.xml", changedFiles.get(0).getPath()); - FileUtils.write( new File( subdir, "test file with spaces and a déjà vu character.xml" ), - "data", StandardCharsets.UTF_8 ); + FileUtils.write( + new File(subdir, "test file with spaces and a déjà vu character.xml"), "data", StandardCharsets.UTF_8); - changedFiles = - getChangedFiles( "M \"sub Directory déjà vu special/test file with spaces and a déjà vu character.xml\"", - dir, relativeCWD ); + changedFiles = getChangedFiles( + "M \"sub Directory déjà vu special/test file with spaces and a déjà vu character.xml\"", + dir, + relativeCWD); - assertNotNull( changedFiles ); - assertEquals( 1, changedFiles.size() ); - assertEquals( "sub Directory déjà vu special/test file with spaces and a déjà vu character.xml", - changedFiles.get( 0 ).getPath() ); + assertNotNull(changedFiles); + assertEquals(1, changedFiles.size()); + assertEquals( + "sub Directory déjà vu special/test file with spaces and a déjà vu character.xml", + changedFiles.get(0).getPath()); - FileUtils.deleteDirectory( dir ); - } + FileUtils.deleteDirectory(dir); + } @Test - public void testConsumerModifiedFileUnstaged() - { - List changedFiles = getChangedFiles( "M project.xml", null ); + public void testConsumerModifiedFileUnstaged() { + List changedFiles = getChangedFiles("M project.xml", null); - assertNotNull( changedFiles ); - assertEquals( 1, changedFiles.size() ); - testScmFile( changedFiles.get( 0 ), "project.xml", ScmFileStatus.MODIFIED); + assertNotNull(changedFiles); + assertEquals(1, changedFiles.size()); + testScmFile(changedFiles.get(0), "project.xml", ScmFileStatus.MODIFIED); - changedFiles = getChangedFiles( "M \"test file with spaces and a special \\177 character.xml\"", null ); + changedFiles = getChangedFiles("M \"test file with spaces and a special \\177 character.xml\"", null); - assertNotNull( changedFiles ); - assertEquals( 1, changedFiles.size() ); - testScmFile( changedFiles.get( 0 ), "test file with spaces and a special \u007f character.xml", - ScmFileStatus.MODIFIED ); + assertNotNull(changedFiles); + assertEquals(1, changedFiles.size()); + testScmFile( + changedFiles.get(0), + "test file with spaces and a special \u007f character.xml", + ScmFileStatus.MODIFIED); } @Test - public void testConsumerModifiedFileBothStagedAndUnstaged() - { - List changedFiles = getChangedFiles( "MM project.xml", null ); + public void testConsumerModifiedFileBothStagedAndUnstaged() { + List changedFiles = getChangedFiles("MM project.xml", null); - assertNotNull( changedFiles ); - assertEquals( 1, changedFiles.size() ); - testScmFile( changedFiles.get( 0 ), "project.xml", ScmFileStatus.MODIFIED); + assertNotNull(changedFiles); + assertEquals(1, changedFiles.size()); + testScmFile(changedFiles.get(0), "project.xml", ScmFileStatus.MODIFIED); - changedFiles = getChangedFiles( "MM \"test file with spaces and a special \\177 character.xml\"", null ); + changedFiles = getChangedFiles("MM \"test file with spaces and a special \\177 character.xml\"", null); - assertNotNull( changedFiles ); - assertEquals( 1, changedFiles.size() ); - testScmFile( changedFiles.get( 0 ), "test file with spaces and a special \u007f character.xml", - ScmFileStatus.MODIFIED ); + assertNotNull(changedFiles); + assertEquals(1, changedFiles.size()); + testScmFile( + changedFiles.get(0), + "test file with spaces and a special \u007f character.xml", + ScmFileStatus.MODIFIED); } @Test - public void testConsumerModifiedFileWithDirectoryAndNoFile() - throws IOException - { + public void testConsumerModifiedFileWithDirectoryAndNoFile() throws IOException { File dir = createTempDirectory(); - List changedFiles = getChangedFiles( "M project.xml", dir ); + List changedFiles = getChangedFiles("M project.xml", dir); - assertNotNull( changedFiles ); - assertEquals( 0, changedFiles.size() ); + assertNotNull(changedFiles); + assertEquals(0, changedFiles.size()); - changedFiles = getChangedFiles( "M \"test file with spaces and a special \\177 character.xml\"", dir ); + changedFiles = getChangedFiles("M \"test file with spaces and a special \\177 character.xml\"", dir); - assertNotNull( changedFiles ); - assertEquals( 0, changedFiles.size() ); + assertNotNull(changedFiles); + assertEquals(0, changedFiles.size()); - FileUtils.deleteDirectory( dir ); + FileUtils.deleteDirectory(dir); } @Test - public void testConsumerModifiedFileWithDirectoryAndFile() - throws IOException - { + public void testConsumerModifiedFileWithDirectoryAndFile() throws IOException { File dir = createTempDirectory(); - FileUtils.write( new File( dir, "project.xml" ), "data", StandardCharsets.UTF_8 ); + FileUtils.write(new File(dir, "project.xml"), "data", StandardCharsets.UTF_8); - List changedFiles = getChangedFiles( "M project.xml", dir ); + List changedFiles = getChangedFiles("M project.xml", dir); - assertNotNull( changedFiles ); - assertEquals( 1, changedFiles.size() ); - assertEquals( "project.xml", changedFiles.get( 0 ).getPath() ); + assertNotNull(changedFiles); + assertEquals(1, changedFiles.size()); + assertEquals("project.xml", changedFiles.get(0).getPath()); - FileUtils.write( new File( dir, "test file with spaces and a special \u007f character.xml" ), "data", - StandardCharsets.UTF_8 ); + FileUtils.write( + new File(dir, "test file with spaces and a special \u007f character.xml"), + "data", + StandardCharsets.UTF_8); - changedFiles = getChangedFiles( "M \"test file with spaces and a special \\177 character.xml\"", dir ); + changedFiles = getChangedFiles("M \"test file with spaces and a special \\177 character.xml\"", dir); - assertNotNull( changedFiles ); - assertEquals( 1, changedFiles.size() ); - assertEquals( "test file with spaces and a special \u007f character.xml", changedFiles.get( 0 ).getPath() ); + assertNotNull(changedFiles); + assertEquals(1, changedFiles.size()); + assertEquals( + "test file with spaces and a special \u007f character.xml", + changedFiles.get(0).getPath()); - FileUtils.deleteDirectory( dir ); + FileUtils.deleteDirectory(dir); } @Test - public void testConsumerRemovedFile() - { - List changedFiles = getChangedFiles( "D Capfile", null ); + public void testConsumerRemovedFile() { + List changedFiles = getChangedFiles("D Capfile", null); - assertNotNull( changedFiles ); - assertEquals( 1, changedFiles.size() ); - assertEquals( "Capfile", changedFiles.get( 0 ).getPath() ); + assertNotNull(changedFiles); + assertEquals(1, changedFiles.size()); + assertEquals("Capfile", changedFiles.get(0).getPath()); - changedFiles = getChangedFiles( "D \"test file with spaces and a déjà vu character.xml\"", null ); + changedFiles = getChangedFiles("D \"test file with spaces and a déjà vu character.xml\"", null); - assertNotNull( changedFiles ); - assertEquals( 1, changedFiles.size() ); - assertEquals( "test file with spaces and a déjà vu character.xml", changedFiles.get( 0 ).getPath() ); + assertNotNull(changedFiles); + assertEquals(1, changedFiles.size()); + assertEquals( + "test file with spaces and a déjà vu character.xml", + changedFiles.get(0).getPath()); } @Test - public void testConsumerRemovedFileUnstaged() - { - List changedFiles = getChangedFiles( "D Capfile", null ); + public void testConsumerRemovedFileUnstaged() { + List changedFiles = getChangedFiles("D Capfile", null); - assertNotNull( changedFiles ); - assertEquals( 1, changedFiles.size() ); - assertEquals( ScmFileStatus.DELETED, changedFiles.get( 0 ).getStatus() ); + assertNotNull(changedFiles); + assertEquals(1, changedFiles.size()); + assertEquals(ScmFileStatus.DELETED, changedFiles.get(0).getStatus()); - changedFiles = getChangedFiles( "D \"test file with spaces and a special \\177 character.xml\"", null ); + changedFiles = getChangedFiles("D \"test file with spaces and a special \\177 character.xml\"", null); - assertNotNull( changedFiles ); - assertEquals( 1, changedFiles.size() ); - assertEquals( ScmFileStatus.DELETED, changedFiles.get( 0 ).getStatus() ); + assertNotNull(changedFiles); + assertEquals(1, changedFiles.size()); + assertEquals(ScmFileStatus.DELETED, changedFiles.get(0).getStatus()); } @Test - public void testConsumerRemovedFileWithDirectoryAndNoFile() - throws IOException - { + public void testConsumerRemovedFileWithDirectoryAndNoFile() throws IOException { File dir = createTempDirectory(); - List changedFiles = getChangedFiles( "D Capfile", dir ); + List changedFiles = getChangedFiles("D Capfile", dir); + + assertNotNull(changedFiles); + assertEquals(1, changedFiles.size()); + assertEquals("Capfile", changedFiles.get(0).getPath()); - assertNotNull( changedFiles ); - assertEquals( 1, changedFiles.size() ); - assertEquals( "Capfile", changedFiles.get( 0 ).getPath() ); + changedFiles = getChangedFiles("D \"test file with spaces and a special \\177 character.xml\"", dir); - changedFiles = getChangedFiles( "D \"test file with spaces and a special \\177 character.xml\"", dir ); + assertNotNull(changedFiles); + assertEquals(1, changedFiles.size()); + assertEquals( + "test file with spaces and a special \u007f character.xml", + changedFiles.get(0).getPath()); - assertNotNull( changedFiles ); - assertEquals( 1, changedFiles.size() ); - assertEquals( "test file with spaces and a special \u007f character.xml", changedFiles.get( 0 ).getPath() ); - - FileUtils.deleteDirectory( dir ); + FileUtils.deleteDirectory(dir); } @Test - public void testConsumerRemovedFileWithDirectoryAndFile() - throws IOException - { + public void testConsumerRemovedFileWithDirectoryAndFile() throws IOException { File dir = createTempDirectory(); - FileUtils.write( new File( dir, "Capfile" ), "data", StandardCharsets.UTF_8 ); + FileUtils.write(new File(dir, "Capfile"), "data", StandardCharsets.UTF_8); - List changedFiles = getChangedFiles( "D Capfile", dir ); + List changedFiles = getChangedFiles("D Capfile", dir); - assertNotNull( changedFiles ); - assertEquals( 0, changedFiles.size() ); + assertNotNull(changedFiles); + assertEquals(0, changedFiles.size()); - FileUtils.write( new File( dir, "test file with spaces and a special \u007f character.xml" ), "data", - StandardCharsets.UTF_8 ); + FileUtils.write( + new File(dir, "test file with spaces and a special \u007f character.xml"), + "data", + StandardCharsets.UTF_8); - changedFiles = getChangedFiles( "D \"test file with spaces and a special \\177 character.xml\"", dir ); + changedFiles = getChangedFiles("D \"test file with spaces and a special \\177 character.xml\"", dir); - assertNotNull( changedFiles ); - assertEquals( 0, changedFiles.size() ); - FileUtils.deleteDirectory( dir ); + assertNotNull(changedFiles); + assertEquals(0, changedFiles.size()); + FileUtils.deleteDirectory(dir); } // Test reproducing SCM-694 @Test - public void testConsumerRenamedFile() - throws Exception - { + public void testConsumerRenamedFile() throws Exception { File dir = createTempDirectory(); - File tmpFile = new File( dir, "NewCapFile" ); + File tmpFile = new File(dir, "NewCapFile"); - FileUtils.write( tmpFile, "data", StandardCharsets.UTF_8 ); + FileUtils.write(tmpFile, "data", StandardCharsets.UTF_8); - List changedFiles = getChangedFiles( "R OldCapfile -> NewCapFile", dir ); + List changedFiles = getChangedFiles("R OldCapfile -> NewCapFile", dir); - assertNotNull( changedFiles ); - assertEquals( 2, changedFiles.size() ); - assertEquals( "OldCapfile", changedFiles.get(0).getPath() ); - assertEquals( "NewCapFile", changedFiles.get(1).getPath() ); + assertNotNull(changedFiles); + assertEquals(2, changedFiles.size()); + assertEquals("OldCapfile", changedFiles.get(0).getPath()); + assertEquals("NewCapFile", changedFiles.get(1).getPath()); - tmpFile = new File( dir, "New test file with spaces and a special \u007f character.xml" ); + tmpFile = new File(dir, "New test file with spaces and a special \u007f character.xml"); - FileUtils.write( tmpFile, "data", StandardCharsets.UTF_8 ); + FileUtils.write(tmpFile, "data", StandardCharsets.UTF_8); - changedFiles = - getChangedFiles( "R \"Old test file with spaces and a special \\177 character.xml\" -> \"New test file with spaces and a special \\177 character.xml\"", - dir ); + changedFiles = getChangedFiles( + "R \"Old test file with spaces and a special \\177 character.xml\" -> \"New test file with spaces and a special \\177 character.xml\"", + dir); - assertNotNull( changedFiles ); - assertEquals( 2, changedFiles.size() ); - assertEquals( "Old test file with spaces and a special \u007f character.xml", changedFiles.get(0).getPath() ); - assertEquals( "New test file with spaces and a special \u007f character.xml", changedFiles.get(1).getPath() ); - FileUtils.deleteDirectory( dir ); + assertNotNull(changedFiles); + assertEquals(2, changedFiles.size()); + assertEquals( + "Old test file with spaces and a special \u007f character.xml", + changedFiles.get(0).getPath()); + assertEquals( + "New test file with spaces and a special \u007f character.xml", + changedFiles.get(1).getPath()); + FileUtils.deleteDirectory(dir); } @Test - public void testLog1Consumer() - throws Exception - { - List changedFiles = getChangedFiles( getTestFile( "/src/test/resources/git/status/gitstatus1.gitlog" ) ); + public void testLog1Consumer() throws Exception { + List changedFiles = getChangedFiles(getTestFile("/src/test/resources/git/status/gitstatus1.gitlog")); - assertEquals( 4, changedFiles.size() ); + assertEquals(4, changedFiles.size()); - testScmFile( changedFiles.get( 0 ), "project.xml", ScmFileStatus.ADDED ); - testScmFile( changedFiles.get( 1 ), "readme.txt", ScmFileStatus.MODIFIED ); - testScmFile( changedFiles.get( 2 ), "d\u00e9j\u00e0 vu.xml", ScmFileStatus.ADDED ); - testScmFile( changedFiles.get( 3 ), "d\u00e9j\u00e0 vu.txt", ScmFileStatus.MODIFIED ); + testScmFile(changedFiles.get(0), "project.xml", ScmFileStatus.ADDED); + testScmFile(changedFiles.get(1), "readme.txt", ScmFileStatus.MODIFIED); + testScmFile(changedFiles.get(2), "d\u00e9j\u00e0 vu.xml", ScmFileStatus.ADDED); + testScmFile(changedFiles.get(3), "d\u00e9j\u00e0 vu.txt", ScmFileStatus.MODIFIED); } @Test - public void testEmptyLogConsumer() - throws Exception - { - List changedFiles = getChangedFiles( getTestFile( "/src/test/resources/git/status/gitstatus-empty.gitlog" ) ); + public void testEmptyLogConsumer() throws Exception { + List changedFiles = + getChangedFiles(getTestFile("/src/test/resources/git/status/gitstatus-empty.gitlog")); - assertEquals( 0, changedFiles.size() ); + assertEquals(0, changedFiles.size()); } @Test - public void testLog2Consumer() - throws Exception - { - List changedFiles = getChangedFiles( getTestFile( "/src/test/resources/git/status/gitstatus2.gitlog" ) ); - - assertEquals( 4, changedFiles.size() ); - - testScmFile( changedFiles.get( 0 ), - "maven-scm-provider-gitexe/src/main/java/org/apache/maven/scm/provider/git/gitexe/command/add/GitAddCommand.java", - ScmFileStatus.MODIFIED ); - testScmFile( changedFiles.get( 1 ), - "maven-scm-provider-gitexe/src/main/java/org/apache/maven/scm/provider/git/gitexe/command/checkin/GitCheckInCommand.java", - ScmFileStatus.MODIFIED ); - testScmFile( changedFiles.get( 2 ), - "maven-scm-provider-gitexe/src/main/java/org/apache/maven/scm/provider/git/gitexe/command/checkin/GitCheckInConsumer.java", - ScmFileStatus.DELETED ); - testScmFile( changedFiles.get( 3 ), - "maven-scm-provider-gitexe/src/main/java/org/apache/maven/scm/provider/git/gitexe/command/status/GitStatusConsumer.java", - ScmFileStatus.MODIFIED ); + public void testLog2Consumer() throws Exception { + List changedFiles = getChangedFiles(getTestFile("/src/test/resources/git/status/gitstatus2.gitlog")); + + assertEquals(4, changedFiles.size()); + + testScmFile( + changedFiles.get(0), + "maven-scm-provider-gitexe/src/main/java/org/apache/maven/scm/provider/git/gitexe/command/add/GitAddCommand.java", + ScmFileStatus.MODIFIED); + testScmFile( + changedFiles.get(1), + "maven-scm-provider-gitexe/src/main/java/org/apache/maven/scm/provider/git/gitexe/command/checkin/GitCheckInCommand.java", + ScmFileStatus.MODIFIED); + testScmFile( + changedFiles.get(2), + "maven-scm-provider-gitexe/src/main/java/org/apache/maven/scm/provider/git/gitexe/command/checkin/GitCheckInConsumer.java", + ScmFileStatus.DELETED); + testScmFile( + changedFiles.get(3), + "maven-scm-provider-gitexe/src/main/java/org/apache/maven/scm/provider/git/gitexe/command/status/GitStatusConsumer.java", + ScmFileStatus.MODIFIED); } // SCM-709 @Test - public void testResolvePath() - { - File repositoryRoot = getTestFile( "repo" ); - File workingDirectory = getTestFile( "repo/work" ); + public void testResolvePath() { + File repositoryRoot = getTestFile("repo"); + File workingDirectory = getTestFile("repo/work"); - URI path = repositoryRoot.toURI().relativize( workingDirectory.toURI() ); + URI path = repositoryRoot.toURI().relativize(workingDirectory.toURI()); - assertEquals( "work", path.getPath() ); + assertEquals("work", path.getPath()); + + assertEquals("pom.xml", GitStatusConsumer.resolvePath("work/pom.xml", path)); + assertEquals("work/pom.xml", GitStatusConsumer.resolvePath("work/pom.xml", null)); - assertEquals( "pom.xml", GitStatusConsumer.resolvePath( "work/pom.xml", path ) ); - assertEquals( "work/pom.xml", GitStatusConsumer.resolvePath( "work/pom.xml", null ) ); - // spaces in path - repositoryRoot = getTestFile( "repo" ); - workingDirectory = getTestFile( "repo/work with spaces" ); + repositoryRoot = getTestFile("repo"); + workingDirectory = getTestFile("repo/work with spaces"); - path = repositoryRoot.toURI().relativize( workingDirectory.toURI() ); + path = repositoryRoot.toURI().relativize(workingDirectory.toURI()); - assertEquals( "work with spaces", path.getPath() ); + assertEquals("work with spaces", path.getPath()); - assertEquals( "pom.xml", GitStatusConsumer.resolvePath( "work with spaces/pom.xml", path ) ); - assertEquals( "work with spaces/pom.xml", GitStatusConsumer.resolvePath( "work with spaces/pom.xml", null ) ); + assertEquals("pom.xml", GitStatusConsumer.resolvePath("work with spaces/pom.xml", path)); + assertEquals("work with spaces/pom.xml", GitStatusConsumer.resolvePath("work with spaces/pom.xml", null)); // spaces in path with quotes - repositoryRoot = getTestFile( "repo" ); - workingDirectory = getTestFile( "repo/work with spaces and quotes" ); + repositoryRoot = getTestFile("repo"); + workingDirectory = getTestFile("repo/work with spaces and quotes"); - path = repositoryRoot.toURI().relativize( workingDirectory.toURI() ); + path = repositoryRoot.toURI().relativize(workingDirectory.toURI()); - assertEquals( "work with spaces and quotes", path.getPath() ); + assertEquals("work with spaces and quotes", path.getPath()); - assertEquals( "pom.xml", GitStatusConsumer.resolvePath( "\"work with spaces and quotes/pom.xml\"", path ) ); - assertEquals( "work with spaces and quotes/pom.xml", - GitStatusConsumer.resolvePath( "\"work with spaces and quotes/pom.xml\"", null ) ); + assertEquals("pom.xml", GitStatusConsumer.resolvePath("\"work with spaces and quotes/pom.xml\"", path)); + assertEquals( + "work with spaces and quotes/pom.xml", + GitStatusConsumer.resolvePath("\"work with spaces and quotes/pom.xml\"", null)); } - private void testScmFile( ScmFile fileToTest, String expectedFilePath, ScmFileStatus expectedStatus ) - { - assertEquals( expectedFilePath, fileToTest.getPath() ); - assertEquals( expectedStatus, fileToTest.getStatus() ); + private void testScmFile(ScmFile fileToTest, String expectedFilePath, ScmFileStatus expectedStatus) { + assertEquals(expectedFilePath, fileToTest.getPath()); + assertEquals(expectedStatus, fileToTest.getStatus()); } - private File createTempDirectory() - throws IOException - { + private File createTempDirectory() throws IOException { File dir = Files.createTempDirectory("gitexe" + "test").toFile(); return dir; } - } diff --git a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/test/java/org/apache/maven/scm/provider/git/gitexe/command/tag/GitExeTagCommandTckTest.java b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/test/java/org/apache/maven/scm/provider/git/gitexe/command/tag/GitExeTagCommandTckTest.java index 5d5c9f2fd..710c9d558 100644 --- a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/test/java/org/apache/maven/scm/provider/git/gitexe/command/tag/GitExeTagCommandTckTest.java +++ b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/test/java/org/apache/maven/scm/provider/git/gitexe/command/tag/GitExeTagCommandTckTest.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.git.gitexe.command.tag; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider.git.gitexe.command.tag; import org.apache.maven.scm.provider.git.GitScmTestUtils; import org.apache.maven.scm.provider.git.command.tag.GitTagCommandTckTest; @@ -30,19 +29,14 @@ * @author Brett Porter * */ -public class GitExeTagCommandTckTest - extends GitTagCommandTckTest -{ +public class GitExeTagCommandTckTest extends GitTagCommandTckTest { @Override - public String getScmProviderCommand() - { + public String getScmProviderCommand() { return GIT_COMMAND_LINE; } /** {@inheritDoc} */ - public String getScmUrl() - throws Exception - { - return GitScmTestUtils.getScmUrl( getRepositoryRoot(), "git" ); + public String getScmUrl() throws Exception { + return GitScmTestUtils.getScmUrl(getRepositoryRoot(), "git"); } } diff --git a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/test/java/org/apache/maven/scm/provider/git/gitexe/command/tag/GitTagCommandTest.java b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/test/java/org/apache/maven/scm/provider/git/gitexe/command/tag/GitTagCommandTest.java index ca7681609..7bafee418 100644 --- a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/test/java/org/apache/maven/scm/provider/git/gitexe/command/tag/GitTagCommandTest.java +++ b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/test/java/org/apache/maven/scm/provider/git/gitexe/command/tag/GitTagCommandTest.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.git.gitexe.command.tag; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,9 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider.git.gitexe.command.tag; + +import java.io.File; import org.apache.maven.scm.ScmTestCase; import org.apache.maven.scm.provider.git.repository.GitScmProviderRepository; @@ -26,73 +27,65 @@ import org.junit.Before; import org.junit.Test; -import java.io.File; - /** * @author Mark Struberg */ -public class GitTagCommandTest - extends ScmTestCase -{ +public class GitTagCommandTest extends ScmTestCase { private File messageFile; private String messageFileString; @Before @Override - public void setUp() - throws Exception - { + public void setUp() throws Exception { super.setUp(); - messageFile = new File( "commit-message" ); + messageFile = new File("commit-message"); String path = messageFile.getAbsolutePath(); - if ( path.indexOf( ' ' ) >= 0 ) - { + if (path.indexOf(' ') >= 0) { path = "\"" + path + "\""; } messageFileString = "-F " + path; } @Test - public void testCommandLineTag() - throws Exception - { - testCommandLine( "scm:git:http://foo.com/git/trunk", "my-tag-1", "git tag " + messageFileString + " my-tag-1", false ); + public void testCommandLineTag() throws Exception { + testCommandLine( + "scm:git:http://foo.com/git/trunk", "my-tag-1", "git tag " + messageFileString + " my-tag-1", false); } @Test - public void testCommandLineWithUsernameAndTag() - throws Exception - { - testCommandLine( "scm:git:http://anonymous@foo.com/git/trunk", "my-tag-1", - "git tag " + messageFileString + " my-tag-1", false ); + public void testCommandLineWithUsernameAndTag() throws Exception { + testCommandLine( + "scm:git:http://anonymous@foo.com/git/trunk", + "my-tag-1", + "git tag " + messageFileString + " my-tag-1", + false); } @Test - public void testCommandLineWithUsernameAndTagAndSign() - throws Exception - { - testCommandLine( "scm:git:http://anonymous@foo.com/git/trunk", "my-tag-1", - "git tag -s " + messageFileString + " my-tag-1", true ); + public void testCommandLineWithUsernameAndTagAndSign() throws Exception { + testCommandLine( + "scm:git:http://anonymous@foo.com/git/trunk", + "my-tag-1", + "git tag -s " + messageFileString + " my-tag-1", + true); } // ---------------------------------------------------------------------- // // ---------------------------------------------------------------------- - private void testCommandLine( String scmUrl, String tag, String commandLine, boolean sign ) - throws Exception - { - File workingDirectory = getTestFile( "target/git-checkin-command-test" ); + private void testCommandLine(String scmUrl, String tag, String commandLine, boolean sign) throws Exception { + File workingDirectory = getTestFile("target/git-checkin-command-test"); - ScmRepository repository = getScmManager().makeScmRepository( scmUrl ); + ScmRepository repository = getScmManager().makeScmRepository(scmUrl); GitScmProviderRepository gitRepository = (GitScmProviderRepository) repository.getProviderRepository(); - Commandline cl = GitTagCommand.createCommandLine( gitRepository, workingDirectory, tag, messageFile, sign ); + Commandline cl = GitTagCommand.createCommandLine(gitRepository, workingDirectory, tag, messageFile, sign); - assertCommandLine( commandLine, workingDirectory, cl ); + assertCommandLine(commandLine, workingDirectory, cl); } } diff --git a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/test/java/org/apache/maven/scm/provider/git/gitexe/command/untag/GitExeUntagCommandTckTest.java b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/test/java/org/apache/maven/scm/provider/git/gitexe/command/untag/GitExeUntagCommandTckTest.java index ceaed3fda..55a0a6f47 100644 --- a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/test/java/org/apache/maven/scm/provider/git/gitexe/command/untag/GitExeUntagCommandTckTest.java +++ b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/test/java/org/apache/maven/scm/provider/git/gitexe/command/untag/GitExeUntagCommandTckTest.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.git.gitexe.command.untag; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,25 +16,21 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider.git.gitexe.command.untag; import org.apache.maven.scm.provider.git.GitScmTestUtils; import org.apache.maven.scm.provider.git.command.untag.GitUntagCommandTckTest; import static org.apache.maven.scm.provider.git.GitScmTestUtils.GIT_COMMAND_LINE; -public class GitExeUntagCommandTckTest - extends GitUntagCommandTckTest -{ +public class GitExeUntagCommandTckTest extends GitUntagCommandTckTest { @Override - public String getScmProviderCommand() - { + public String getScmProviderCommand() { return GIT_COMMAND_LINE; } /** {@inheritDoc} */ - public String getScmUrl() - throws Exception - { - return GitScmTestUtils.getScmUrl( getRepositoryRoot(), "git" ); + public String getScmUrl() throws Exception { + return GitScmTestUtils.getScmUrl(getRepositoryRoot(), "git"); } } diff --git a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/test/java/org/apache/maven/scm/provider/git/gitexe/command/update/GitExeUpdateCommandTckTest.java b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/test/java/org/apache/maven/scm/provider/git/gitexe/command/update/GitExeUpdateCommandTckTest.java index 3ea904acc..c9b7b7722 100644 --- a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/test/java/org/apache/maven/scm/provider/git/gitexe/command/update/GitExeUpdateCommandTckTest.java +++ b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/test/java/org/apache/maven/scm/provider/git/gitexe/command/update/GitExeUpdateCommandTckTest.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.git.gitexe.command.update; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider.git.gitexe.command.update; import org.apache.maven.scm.provider.git.GitScmTestUtils; import org.apache.maven.scm.provider.git.command.update.GitUpdateCommandTckTest; @@ -28,19 +27,14 @@ * @author Mark Struberg * */ -public class GitExeUpdateCommandTckTest - extends GitUpdateCommandTckTest -{ +public class GitExeUpdateCommandTckTest extends GitUpdateCommandTckTest { @Override - public String getScmProviderCommand() - { + public String getScmProviderCommand() { return GIT_COMMAND_LINE; } /** {@inheritDoc} */ - public String getScmUrl() - throws Exception - { - return GitScmTestUtils.getScmUrl( getRepositoryRoot(), "git" ); + public String getScmUrl() throws Exception { + return GitScmTestUtils.getScmUrl(getRepositoryRoot(), "git"); } } diff --git a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/test/java/org/apache/maven/scm/provider/git/gitexe/command/update/GitLatestRevisionCommandConsumerTest.java b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/test/java/org/apache/maven/scm/provider/git/gitexe/command/update/GitLatestRevisionCommandConsumerTest.java index 55fd8edab..3a5d5b463 100644 --- a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/test/java/org/apache/maven/scm/provider/git/gitexe/command/update/GitLatestRevisionCommandConsumerTest.java +++ b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/test/java/org/apache/maven/scm/provider/git/gitexe/command/update/GitLatestRevisionCommandConsumerTest.java @@ -1,16 +1,3 @@ -package org.apache.maven.scm.provider.git.gitexe.command.update; - -import java.io.BufferedReader; -import java.io.File; -import java.io.Reader; - -import org.apache.maven.scm.ScmTestCase; -import org.codehaus.plexus.util.ReaderFactory; -import org.junit.Test; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -29,53 +16,56 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider.git.gitexe.command.update; + +import java.io.BufferedReader; +import java.io.File; +import java.io.Reader; + +import org.apache.maven.scm.ScmTestCase; +import org.codehaus.plexus.util.ReaderFactory; +import org.junit.Test; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; /** * @author Mark Struberg * @since 1.2 * */ -public class GitLatestRevisionCommandConsumerTest - extends ScmTestCase -{ +public class GitLatestRevisionCommandConsumerTest extends ScmTestCase { @Test - public void testUpToDate() - throws Exception - { + public void testUpToDate() throws Exception { - GitLatestRevisionCommandConsumer consumer = buildGitLatestRevisionCommandConsumer( "/src/test/resources/git/update/git-update-latest-rev.out" ); + GitLatestRevisionCommandConsumer consumer = + buildGitLatestRevisionCommandConsumer("/src/test/resources/git/update/git-update-latest-rev.out"); String latestRev = consumer.getLatestRevision(); - assertNotNull( latestRev ); - assertEquals( "a300c56a341bae8d0eb5ec4ed5551a11c75a5a6e", latestRev ); + assertNotNull(latestRev); + assertEquals("a300c56a341bae8d0eb5ec4ed5551a11c75a5a6e", latestRev); } - // utils methods - private GitLatestRevisionCommandConsumer buildGitLatestRevisionCommandConsumer( String fileName ) - throws Exception - { + private GitLatestRevisionCommandConsumer buildGitLatestRevisionCommandConsumer(String fileName) throws Exception { GitLatestRevisionCommandConsumer consumer = new GitLatestRevisionCommandConsumer(); - BufferedReader r = getGitLogBufferedReader( fileName ); + BufferedReader r = getGitLogBufferedReader(fileName); String line; - while ( ( line = r.readLine() ) != null ) - { - //System.out.println(" line " + line ); - consumer.consumeLine( line ); + while ((line = r.readLine()) != null) { + // System.out.println(" line " + line ); + consumer.consumeLine(line); } return consumer; } - private BufferedReader getGitLogBufferedReader( String fileName ) - throws Exception - { - File f = getTestFile( fileName ); - Reader reader = ReaderFactory.newReader( f, "UTF-8" ); - return new BufferedReader( reader ); + private BufferedReader getGitLogBufferedReader(String fileName) throws Exception { + File f = getTestFile(fileName); + Reader reader = ReaderFactory.newReader(f, "UTF-8"); + return new BufferedReader(reader); } } diff --git a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/test/java/org/apache/maven/scm/provider/git/gitexe/command/update/GitUpdateCommandTest.java b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/test/java/org/apache/maven/scm/provider/git/gitexe/command/update/GitUpdateCommandTest.java index c1f546ccb..92407ab93 100644 --- a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/test/java/org/apache/maven/scm/provider/git/gitexe/command/update/GitUpdateCommandTest.java +++ b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/test/java/org/apache/maven/scm/provider/git/gitexe/command/update/GitUpdateCommandTest.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.git.gitexe.command.update; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,9 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider.git.gitexe.command.update; + +import java.io.File; import org.apache.maven.scm.ScmBranch; import org.apache.maven.scm.ScmTestCase; @@ -27,66 +28,52 @@ import org.codehaus.plexus.util.cli.Commandline; import org.junit.Test; -import java.io.File; - /** * @author Mark Struberg * */ -public class GitUpdateCommandTest - extends ScmTestCase -{ +public class GitUpdateCommandTest extends ScmTestCase { @Test - public void testCommandLineNoBranch() - throws Exception - { - testCommandLine( "scm:git:http://foo.com/git", null, "git pull http://foo.com/git" ); + public void testCommandLineNoBranch() throws Exception { + testCommandLine("scm:git:http://foo.com/git", null, "git pull http://foo.com/git"); } @Test - public void testCommandLineWithBranch() - throws Exception - { - testCommandLine( "scm:git:http://foo.com/git", new ScmBranch( "mybranch" ), "git pull http://foo.com/git mybranch" ); + public void testCommandLineWithBranch() throws Exception { + testCommandLine( + "scm:git:http://foo.com/git", new ScmBranch("mybranch"), "git pull http://foo.com/git mybranch"); } @Test - public void testCommandLineLatestRevision() - throws Exception - { - testLatestRevisionCommandLine( "scm:git:http://foo.com/git", null, "git log -n1 --date-order" ); + public void testCommandLineLatestRevision() throws Exception { + testLatestRevisionCommandLine("scm:git:http://foo.com/git", null, "git log -n1 --date-order"); } - + // ---------------------------------------------------------------------- // private helper functions // ---------------------------------------------------------------------- - private void testCommandLine( String scmUrl, ScmVersion branch, String commandLine ) - throws Exception - { - File workingDirectory = getTestFile( "target/git-update-command-test" ); + private void testCommandLine(String scmUrl, ScmVersion branch, String commandLine) throws Exception { + File workingDirectory = getTestFile("target/git-update-command-test"); - ScmRepository repository = getScmManager().makeScmRepository( scmUrl ); + ScmRepository repository = getScmManager().makeScmRepository(scmUrl); GitScmProviderRepository gitRepository = (GitScmProviderRepository) repository.getProviderRepository(); - Commandline cl = GitUpdateCommand.createCommandLine( gitRepository, workingDirectory, branch ); + Commandline cl = GitUpdateCommand.createCommandLine(gitRepository, workingDirectory, branch); - assertCommandLine( commandLine, workingDirectory, cl ); + assertCommandLine(commandLine, workingDirectory, cl); } - private void testLatestRevisionCommandLine( String scmUrl, ScmBranch branch, String commandLine ) - throws Exception - { - File workingDirectory = getTestFile( "target/git-update-command-test" ); - - ScmRepository repository = getScmManager().makeScmRepository( scmUrl ); - + private void testLatestRevisionCommandLine(String scmUrl, ScmBranch branch, String commandLine) throws Exception { + File workingDirectory = getTestFile("target/git-update-command-test"); + + ScmRepository repository = getScmManager().makeScmRepository(scmUrl); + GitScmProviderRepository gitRepository = (GitScmProviderRepository) repository.getProviderRepository(); - - Commandline cl = GitUpdateCommand.createLatestRevisionCommandLine( gitRepository, workingDirectory, branch ); - - assertCommandLine( commandLine, workingDirectory, cl ); - } + Commandline cl = GitUpdateCommand.createLatestRevisionCommandLine(gitRepository, workingDirectory, branch); + + assertCommandLine(commandLine, workingDirectory, cl); + } } diff --git a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gittest/pom.xml b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gittest/pom.xml index c73637286..2770b379d 100644 --- a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gittest/pom.xml +++ b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gittest/pom.xml @@ -1,5 +1,4 @@ - - 4.0.0 @@ -44,7 +42,7 @@ org.apache.maven.scm - maven-scm-provider-git-commons + maven-scm-provider-git-commons org.codehaus.plexus diff --git a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gittest/src/main/java/org/apache/maven/scm/provider/git/GitScmTestUtils.java b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gittest/src/main/java/org/apache/maven/scm/provider/git/GitScmTestUtils.java index 56c812888..7131c83fa 100644 --- a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gittest/src/main/java/org/apache/maven/scm/provider/git/GitScmTestUtils.java +++ b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gittest/src/main/java/org/apache/maven/scm/provider/git/GitScmTestUtils.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.git; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,124 +16,96 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider.git; import java.io.File; import java.io.FileWriter; import java.io.IOException; import org.apache.maven.scm.PlexusJUnit4TestSupport; -import org.junit.Assert; - import org.codehaus.plexus.util.FileUtils; import org.codehaus.plexus.util.cli.CommandLineException; +import org.junit.Assert; /** * @author Trygve Laugstøl * */ -public final class GitScmTestUtils -{ +public final class GitScmTestUtils { /** 'git' command line */ public static final String GIT_COMMAND_LINE = "git"; - private GitScmTestUtils() - { - } + private GitScmTestUtils() {} - public static void initRepo( File repository, File workingDirectory, File assertionDirectory ) - throws IOException - { - initRepo( "src/test/repository/", repository, workingDirectory ); + public static void initRepo(File repository, File workingDirectory, File assertionDirectory) throws IOException { + initRepo("src/test/repository/", repository, workingDirectory); - FileUtils.deleteDirectory( assertionDirectory ); + FileUtils.deleteDirectory(assertionDirectory); - Assert.assertTrue( assertionDirectory.mkdirs() ); + Assert.assertTrue(assertionDirectory.mkdirs()); } - public static void initRepo( String source, File repository, File workingDirectory ) - throws IOException - { + public static void initRepo(String source, File repository, File workingDirectory) throws IOException { // Copy the repository to target - File src = PlexusJUnit4TestSupport.getTestFile( source ); + File src = PlexusJUnit4TestSupport.getTestFile(source); - FileUtils.deleteDirectory( repository ); + FileUtils.deleteDirectory(repository); - Assert.assertTrue( repository.mkdirs() ); + Assert.assertTrue(repository.mkdirs()); - FileUtils.copyDirectoryStructure( src, repository ); + FileUtils.copyDirectoryStructure(src, repository); - File dotGitDirectory = new File( src, "dotgit" ); + File dotGitDirectory = new File(src, "dotgit"); - if ( dotGitDirectory.exists() ) - { - FileUtils.copyDirectoryStructure( dotGitDirectory, new File( repository, ".git" ) ); + if (dotGitDirectory.exists()) { + FileUtils.copyDirectoryStructure(dotGitDirectory, new File(repository, ".git")); } - FileUtils.deleteDirectory( workingDirectory ); + FileUtils.deleteDirectory(workingDirectory); - Assert.assertTrue( workingDirectory.mkdirs() ); + Assert.assertTrue(workingDirectory.mkdirs()); } - public static String getScmUrl( File repositoryRootFile, String provider ) - throws CommandLineException - { - return "scm:" + provider + ":" + repositoryRootFile.toPath().toAbsolutePath().toUri().toASCIIString(); + public static String getScmUrl(File repositoryRootFile, String provider) throws CommandLineException { + return "scm:" + provider + ":" + + repositoryRootFile.toPath().toAbsolutePath().toUri().toASCIIString(); } - - public static void deleteAllDirectories( File startDirectory, String pattern ) - throws IOException - { - if ( startDirectory.isDirectory() ) - { + public static void deleteAllDirectories(File startDirectory, String pattern) throws IOException { + if (startDirectory.isDirectory()) { File[] childs = startDirectory.listFiles(); - for ( int i = 0; i < childs.length; i++ ) - { + for (int i = 0; i < childs.length; i++) { File child = childs[i]; - if ( child.isDirectory() ) - { - if ( child.getName().equals( pattern ) ) - { - FileUtils.deleteDirectory( child ); - } - else - { - deleteAllDirectories( child, pattern ); + if (child.isDirectory()) { + if (child.getName().equals(pattern)) { + FileUtils.deleteDirectory(child); + } else { + deleteAllDirectories(child, pattern); } } } } } - public static void setDefaultUser( File repositoryRootFile ) - { - File gitConfigFile = new File( new File( repositoryRootFile, ".git" ), "config" ); + public static void setDefaultUser(File repositoryRootFile) { + File gitConfigFile = new File(new File(repositoryRootFile, ".git"), "config"); FileWriter fw = null; - try - { - fw = new FileWriter( gitConfigFile , true ); - fw.append( "[user]\n" ); - fw.append( "\tname = John Doe\n" ); - fw.append( "\temail = john.doe@nowhere.com\n" ); + try { + fw = new FileWriter(gitConfigFile, true); + fw.append("[user]\n"); + fw.append("\tname = John Doe\n"); + fw.append("\temail = john.doe@nowhere.com\n"); fw.flush(); fw.close(); - } - catch ( IOException e ) - { - System.err.println( "cannot setup a default user for tests purpose inside " + gitConfigFile ); + } catch (IOException e) { + System.err.println("cannot setup a default user for tests purpose inside " + gitConfigFile); e.printStackTrace(); - } - finally - { - if ( fw != null ) - { - try - { + } finally { + if (fw != null) { + try { fw.close(); - } - catch ( IOException ignore ) - { + } catch (IOException ignore) { // ignored } } diff --git a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gittest/src/main/java/org/apache/maven/scm/provider/git/command/blame/GitBlameCommandTckTest.java b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gittest/src/main/java/org/apache/maven/scm/provider/git/command/blame/GitBlameCommandTckTest.java index b654e4635..d7caa4d32 100644 --- a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gittest/src/main/java/org/apache/maven/scm/provider/git/command/blame/GitBlameCommandTckTest.java +++ b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gittest/src/main/java/org/apache/maven/scm/provider/git/command/blame/GitBlameCommandTckTest.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.git.command.blame; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,37 +16,30 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider.git.command.blame; + +import java.io.File; import org.apache.maven.scm.command.checkout.CheckOutScmResult; import org.apache.maven.scm.provider.git.GitScmTestUtils; import org.apache.maven.scm.repository.ScmRepository; import org.apache.maven.scm.tck.command.blame.BlameCommandTckTest; -import java.io.File; - /** * @author Evgeny Mandrikov * @since 1.4 */ -public abstract class GitBlameCommandTckTest - extends BlameCommandTckTest -{ - public void initRepo() - throws Exception - { - GitScmTestUtils.initRepo( "src/test/resources/repository/", getRepositoryRoot(), getWorkingDirectory() ); +public abstract class GitBlameCommandTckTest extends BlameCommandTckTest { + public void initRepo() throws Exception { + GitScmTestUtils.initRepo("src/test/resources/repository/", getRepositoryRoot(), getWorkingDirectory()); } @Override - protected CheckOutScmResult checkOut( File workingDirectory, ScmRepository repository ) throws Exception - { - try - { - return super.checkOut( workingDirectory, repository ); - } - finally - { - GitScmTestUtils.setDefaultUser( workingDirectory ); + protected CheckOutScmResult checkOut(File workingDirectory, ScmRepository repository) throws Exception { + try { + return super.checkOut(workingDirectory, repository); + } finally { + GitScmTestUtils.setDefaultUser(workingDirectory); } } } diff --git a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gittest/src/main/java/org/apache/maven/scm/provider/git/command/branch/GitBranchCommandTckTest.java b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gittest/src/main/java/org/apache/maven/scm/provider/git/command/branch/GitBranchCommandTckTest.java index 105a3db0c..0989720fe 100644 --- a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gittest/src/main/java/org/apache/maven/scm/provider/git/command/branch/GitBranchCommandTckTest.java +++ b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gittest/src/main/java/org/apache/maven/scm/provider/git/command/branch/GitBranchCommandTckTest.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.git.command.branch; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,38 +16,31 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider.git.command.branch; + +import java.io.File; import org.apache.maven.scm.command.checkout.CheckOutScmResult; import org.apache.maven.scm.provider.git.GitScmTestUtils; import org.apache.maven.scm.repository.ScmRepository; import org.apache.maven.scm.tck.command.branch.BranchCommandTckTest; -import java.io.File; - /** * @author Mark Struberg * */ -public abstract class GitBranchCommandTckTest - extends BranchCommandTckTest -{ +public abstract class GitBranchCommandTckTest extends BranchCommandTckTest { /** {@inheritDoc} */ - public void initRepo() - throws Exception - { - GitScmTestUtils.initRepo( "src/test/resources/repository/", getRepositoryRoot(), getWorkingDirectory() ); + public void initRepo() throws Exception { + GitScmTestUtils.initRepo("src/test/resources/repository/", getRepositoryRoot(), getWorkingDirectory()); } @Override - protected CheckOutScmResult checkOut( File workingDirectory, ScmRepository repository ) throws Exception - { - try - { - return super.checkOut( workingDirectory, repository ); - } - finally - { - GitScmTestUtils.setDefaultUser( workingDirectory ); + protected CheckOutScmResult checkOut(File workingDirectory, ScmRepository repository) throws Exception { + try { + return super.checkOut(workingDirectory, repository); + } finally { + GitScmTestUtils.setDefaultUser(workingDirectory); } } } diff --git a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gittest/src/main/java/org/apache/maven/scm/provider/git/command/changelog/GitChangeLogCommandTckTest.java b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gittest/src/main/java/org/apache/maven/scm/provider/git/command/changelog/GitChangeLogCommandTckTest.java index 759b1c3cc..ec3d20620 100644 --- a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gittest/src/main/java/org/apache/maven/scm/provider/git/command/changelog/GitChangeLogCommandTckTest.java +++ b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gittest/src/main/java/org/apache/maven/scm/provider/git/command/changelog/GitChangeLogCommandTckTest.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.git.command.changelog; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,13 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider.git.command.changelog; + +import java.io.File; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; import org.apache.maven.scm.ChangeSet; import org.apache.maven.scm.ScmFileSet; @@ -31,12 +36,6 @@ import org.apache.maven.scm.tck.command.changelog.ChangeLogCommandTckTest; import org.junit.Test; -import java.io.File; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.List; - import static org.hamcrest.CoreMatchers.startsWith; import static org.hamcrest.MatcherAssert.assertThat; import static org.junit.Assert.assertEquals; @@ -44,219 +43,196 @@ /** * @author Mark Struberg */ -public abstract class GitChangeLogCommandTckTest - extends ChangeLogCommandTckTest -{ +public abstract class GitChangeLogCommandTckTest extends ChangeLogCommandTckTest { public static final long SLEEP_TIME_IN_MILLIS = 250L; /** {@inheritDoc} */ - public void initRepo() - throws Exception - { - GitScmTestUtils.initRepo( "src/test/resources/linear-changelog/", getRepositoryRoot(), getWorkingCopy() ); + public void initRepo() throws Exception { + GitScmTestUtils.initRepo("src/test/resources/linear-changelog/", getRepositoryRoot(), getWorkingCopy()); } @Override - protected CheckOutScmResult checkOut( File workingDirectory, ScmRepository repository ) throws Exception - { - try - { - return super.checkOut( workingDirectory, repository ); - } - finally - { - GitScmTestUtils.setDefaultUser( workingDirectory ); + protected CheckOutScmResult checkOut(File workingDirectory, ScmRepository repository) throws Exception { + try { + return super.checkOut(workingDirectory, repository); + } finally { + GitScmTestUtils.setDefaultUser(workingDirectory); } } @Test - public void testChangeLogCommandFromHeadAncestorAndHead() - throws Exception - { - Thread.sleep( SLEEP_TIME_IN_MILLIS ); + public void testChangeLogCommandFromHeadAncestorAndHead() throws Exception { + Thread.sleep(SLEEP_TIME_IN_MILLIS); ScmRepository scmRepository = getScmRepository(); - ScmProvider provider = getScmManager().getProviderByRepository( scmRepository ); - ScmFileSet fileSet = new ScmFileSet( getWorkingCopy() ); + ScmProvider provider = getScmManager().getProviderByRepository(scmRepository); + ScmFileSet fileSet = new ScmFileSet(getWorkingCopy()); - ChangeLogScmRequest clr = new ChangeLogScmRequest( scmRepository, fileSet ); + ChangeLogScmRequest clr = new ChangeLogScmRequest(scmRepository, fileSet); String startVersion = "HEAD~1"; - clr.setStartRevision( new ScmRevision( startVersion ) ); + clr.setStartRevision(new ScmRevision(startVersion)); String endVersion = "HEAD"; - clr.setEndRevision( new ScmRevision( endVersion ) ); - ChangeLogScmResult changelogResult = provider.changeLog( clr ); + clr.setEndRevision(new ScmRevision(endVersion)); + ChangeLogScmResult changelogResult = provider.changeLog(clr); List logEntries = changelogResult.getChangeLog().getChangeSets(); - assertEquals( String.format( "changelog for %s..%s returned bad number of commits", startVersion, endVersion ), - 1, logEntries.size() ); + assertEquals( + String.format("changelog for %s..%s returned bad number of commits", startVersion, endVersion), + 1, + logEntries.size()); - - assertThat( "bad head commit SHA1 retrieved", logEntries.get( 0 ).getRevision(), startsWith( "464921b" ) ); + assertThat("bad head commit SHA1 retrieved", logEntries.get(0).getRevision(), startsWith("464921b")); } @Test - public void testChangeLogCommandFromHeadToHead() - throws Exception - { - Thread.sleep( SLEEP_TIME_IN_MILLIS ); + public void testChangeLogCommandFromHeadToHead() throws Exception { + Thread.sleep(SLEEP_TIME_IN_MILLIS); ScmRepository scmRepository = getScmRepository(); - ScmProvider provider = getScmManager().getProviderByRepository( scmRepository ); - ScmFileSet fileSet = new ScmFileSet( getWorkingCopy() ); + ScmProvider provider = getScmManager().getProviderByRepository(scmRepository); + ScmFileSet fileSet = new ScmFileSet(getWorkingCopy()); - ChangeLogScmRequest clr = new ChangeLogScmRequest( scmRepository, fileSet ); + ChangeLogScmRequest clr = new ChangeLogScmRequest(scmRepository, fileSet); String startVersion = "HEAD"; - clr.setStartRevision( new ScmRevision( startVersion ) ); + clr.setStartRevision(new ScmRevision(startVersion)); String endVersion = "HEAD"; - clr.setEndRevision( new ScmRevision( endVersion ) ); - ChangeLogScmResult changelogResult = provider.changeLog( clr ); + clr.setEndRevision(new ScmRevision(endVersion)); + ChangeLogScmResult changelogResult = provider.changeLog(clr); List logEntries = changelogResult.getChangeLog().getChangeSets(); - assertEquals( String.format( "changelog for %s..%s returned bad number of commits", startVersion, endVersion ), - 0, logEntries.size() ); + assertEquals( + String.format("changelog for %s..%s returned bad number of commits", startVersion, endVersion), + 0, + logEntries.size()); } @Test - public void testChangeLogCommandFromUndefinedToHead() - throws Exception - { - Thread.sleep( SLEEP_TIME_IN_MILLIS ); + public void testChangeLogCommandFromUndefinedToHead() throws Exception { + Thread.sleep(SLEEP_TIME_IN_MILLIS); ScmRepository scmRepository = getScmRepository(); - ScmProvider provider = getScmManager().getProviderByRepository( scmRepository ); - ScmFileSet fileSet = new ScmFileSet( getWorkingCopy() ); + ScmProvider provider = getScmManager().getProviderByRepository(scmRepository); + ScmFileSet fileSet = new ScmFileSet(getWorkingCopy()); - ChangeLogScmRequest clr = new ChangeLogScmRequest( scmRepository, fileSet ); + ChangeLogScmRequest clr = new ChangeLogScmRequest(scmRepository, fileSet); String endVersion = "HEAD"; - clr.setEndRevision( new ScmRevision( endVersion ) ); - ChangeLogScmResult changelogResult = provider.changeLog( clr ); + clr.setEndRevision(new ScmRevision(endVersion)); + ChangeLogScmResult changelogResult = provider.changeLog(clr); List logEntries = changelogResult.getChangeLog().getChangeSets(); - assertEquals( String.format( "changelog for ..%s returned bad number of commits", endVersion ), - 0, logEntries.size() ); + assertEquals( + String.format("changelog for ..%s returned bad number of commits", endVersion), 0, logEntries.size()); } @Test - public void testChangeLogCommandFromVersionToUndefined() - throws Exception - { - Thread.sleep( SLEEP_TIME_IN_MILLIS ); + public void testChangeLogCommandFromVersionToUndefined() throws Exception { + Thread.sleep(SLEEP_TIME_IN_MILLIS); ScmRepository scmRepository = getScmRepository(); - ScmProvider provider = getScmManager().getProviderByRepository( scmRepository ); - ScmFileSet fileSet = new ScmFileSet( getWorkingCopy() ); + ScmProvider provider = getScmManager().getProviderByRepository(scmRepository); + ScmFileSet fileSet = new ScmFileSet(getWorkingCopy()); - ChangeLogScmRequest clr = new ChangeLogScmRequest( scmRepository, fileSet ); + ChangeLogScmRequest clr = new ChangeLogScmRequest(scmRepository, fileSet); String startVersion = "e3864d9"; - clr.setStartRevision( new ScmRevision( startVersion ) ); - ChangeLogScmResult changelogResult = provider.changeLog( clr ); + clr.setStartRevision(new ScmRevision(startVersion)); + ChangeLogScmResult changelogResult = provider.changeLog(clr); List logEntries = changelogResult.getChangeLog().getChangeSets(); - assertEquals( String.format( "changelog for %s.. returned bad number of commits", startVersion ), - 2, logEntries.size() ); + assertEquals( + String.format("changelog for %s.. returned bad number of commits", startVersion), 2, logEntries.size()); - assertThat( "bad commit SHA1 retrieved", logEntries.get( 0 ).getRevision(), startsWith( "464921b" ) ); - assertThat( "bad commit SHA1 retrieved", logEntries.get( 1 ).getRevision(), startsWith( "db46d63" ) ); + assertThat("bad commit SHA1 retrieved", logEntries.get(0).getRevision(), startsWith("464921b")); + assertThat("bad commit SHA1 retrieved", logEntries.get(1).getRevision(), startsWith("db46d63")); } @Test - public void testChangeLogCommandFromVoneToVtwo() - throws Exception - { - Thread.sleep( SLEEP_TIME_IN_MILLIS ); + public void testChangeLogCommandFromVoneToVtwo() throws Exception { + Thread.sleep(SLEEP_TIME_IN_MILLIS); ScmRepository scmRepository = getScmRepository(); - ScmProvider provider = getScmManager().getProviderByRepository( scmRepository ); - ScmFileSet fileSet = new ScmFileSet( getWorkingCopy() ); + ScmProvider provider = getScmManager().getProviderByRepository(scmRepository); + ScmFileSet fileSet = new ScmFileSet(getWorkingCopy()); - ChangeLogScmRequest clr = new ChangeLogScmRequest( scmRepository, fileSet ); + ChangeLogScmRequest clr = new ChangeLogScmRequest(scmRepository, fileSet); String startVersion = "0f1e817"; - clr.setStartRevision( new ScmRevision( startVersion ) ); + clr.setStartRevision(new ScmRevision(startVersion)); String endVersion = "db46d63"; - clr.setEndRevision( new ScmRevision( endVersion ) ); - ChangeLogScmResult changelogResult = provider.changeLog( clr ); + clr.setEndRevision(new ScmRevision(endVersion)); + ChangeLogScmResult changelogResult = provider.changeLog(clr); List logEntries = changelogResult.getChangeLog().getChangeSets(); - assertEquals( String.format( "changelog for %s.. returned bad number of commits", startVersion ), - 2, logEntries.size() ); + assertEquals( + String.format("changelog for %s.. returned bad number of commits", startVersion), 2, logEntries.size()); - assertThat( "bad commit SHA1 retrieved", logEntries.get( 0 ).getRevision(), startsWith( "db46d63" ) ); - assertThat( "bad commit SHA1 retrieved", logEntries.get( 1 ).getRevision(), startsWith( "e3864d9" ) ); + assertThat("bad commit SHA1 retrieved", logEntries.get(0).getRevision(), startsWith("db46d63")); + assertThat("bad commit SHA1 retrieved", logEntries.get(1).getRevision(), startsWith("e3864d9")); } @Test - public void testChangeLogCommandWithStartEndInBadOrder() - throws Exception - { - Thread.sleep( SLEEP_TIME_IN_MILLIS ); + public void testChangeLogCommandWithStartEndInBadOrder() throws Exception { + Thread.sleep(SLEEP_TIME_IN_MILLIS); ScmRepository scmRepository = getScmRepository(); - ScmProvider provider = getScmManager().getProviderByRepository( scmRepository ); - ScmFileSet fileSet = new ScmFileSet( getWorkingCopy() ); + ScmProvider provider = getScmManager().getProviderByRepository(scmRepository); + ScmFileSet fileSet = new ScmFileSet(getWorkingCopy()); - ChangeLogScmRequest clr = new ChangeLogScmRequest( scmRepository, fileSet ); + ChangeLogScmRequest clr = new ChangeLogScmRequest(scmRepository, fileSet); String startVersion = "db46d63"; - clr.setStartRevision( new ScmRevision( startVersion ) ); + clr.setStartRevision(new ScmRevision(startVersion)); String endVersion = "0f1e817"; - clr.setEndRevision( new ScmRevision( endVersion ) ); - ChangeLogScmResult changelogResult = provider.changeLog( clr ); + clr.setEndRevision(new ScmRevision(endVersion)); + ChangeLogScmResult changelogResult = provider.changeLog(clr); List logEntries = changelogResult.getChangeLog().getChangeSets(); - assertEquals( String.format( "changelog for %s..%s should return no commits", startVersion, endVersion ), - 0, logEntries.size() ); + assertEquals( + String.format("changelog for %s..%s should return no commits", startVersion, endVersion), + 0, + logEntries.size()); } @Test - public void testChangeLogCommandFromHeadToStartOfRepository() - throws Exception - { - Thread.sleep( SLEEP_TIME_IN_MILLIS ); + public void testChangeLogCommandFromHeadToStartOfRepository() throws Exception { + Thread.sleep(SLEEP_TIME_IN_MILLIS); ScmRepository scmRepository = getScmRepository(); - ScmProvider provider = getScmManager().getProviderByRepository( scmRepository ); - ScmFileSet fileSet = new ScmFileSet( getWorkingCopy() ); + ScmProvider provider = getScmManager().getProviderByRepository(scmRepository); + ScmFileSet fileSet = new ScmFileSet(getWorkingCopy()); - ChangeLogScmRequest clr = new ChangeLogScmRequest( scmRepository, fileSet ); + ChangeLogScmRequest clr = new ChangeLogScmRequest(scmRepository, fileSet); String version = "HEAD"; - clr.setRevision( new ScmRevision( version ) ); - ChangeLogScmResult changelogResult = provider.changeLog( clr ); + clr.setRevision(new ScmRevision(version)); + ChangeLogScmResult changelogResult = provider.changeLog(clr); List logEntries = changelogResult.getChangeLog().getChangeSets(); - assertEquals( String.format( "changelog for %s returned bad number of commits", version ), - 5, logEntries.size() ); + assertEquals(String.format("changelog for %s returned bad number of commits", version), 5, logEntries.size()); } @Test - public void testChangeLogCommandFromVersionToStartOfRepository() - throws Exception - { - Thread.sleep( SLEEP_TIME_IN_MILLIS ); + public void testChangeLogCommandFromVersionToStartOfRepository() throws Exception { + Thread.sleep(SLEEP_TIME_IN_MILLIS); ScmRepository scmRepository = getScmRepository(); - ScmProvider provider = getScmManager().getProviderByRepository( scmRepository ); - ScmFileSet fileSet = new ScmFileSet( getWorkingCopy() ); + ScmProvider provider = getScmManager().getProviderByRepository(scmRepository); + ScmFileSet fileSet = new ScmFileSet(getWorkingCopy()); - ChangeLogScmRequest clr = new ChangeLogScmRequest( scmRepository, fileSet ); + ChangeLogScmRequest clr = new ChangeLogScmRequest(scmRepository, fileSet); String version = "db46d63"; - clr.setRevision( new ScmRevision( version ) ); - ChangeLogScmResult changelogResult = provider.changeLog( clr ); + clr.setRevision(new ScmRevision(version)); + ChangeLogScmResult changelogResult = provider.changeLog(clr); List logEntries = changelogResult.getChangeLog().getChangeSets(); - assertEquals( String.format( "changelog for %s returned bad number of commits", version ), - 4, logEntries.size() ); + assertEquals(String.format("changelog for %s returned bad number of commits", version), 4, logEntries.size()); - assertThat( "bad commit SHA1 retrieved", logEntries.get( 0 ).getRevision(), startsWith( "db46d63" ) ); - assertThat( "bad commit SHA1 retrieved", logEntries.get( 1 ).getRevision(), startsWith( "e3864d9" ) ); - assertThat( "bad commit SHA1 retrieved", logEntries.get( 2 ).getRevision(), startsWith( "0f1e817" ) ); - assertThat( "bad commit SHA1 retrieved", logEntries.get( 3 ).getRevision(), startsWith( "e75cb5a" ) ); + assertThat("bad commit SHA1 retrieved", logEntries.get(0).getRevision(), startsWith("db46d63")); + assertThat("bad commit SHA1 retrieved", logEntries.get(1).getRevision(), startsWith("e3864d9")); + assertThat("bad commit SHA1 retrieved", logEntries.get(2).getRevision(), startsWith("0f1e817")); + assertThat("bad commit SHA1 retrieved", logEntries.get(3).getRevision(), startsWith("e75cb5a")); - List tags4 = Arrays.asList( "Tag4a", "Tag4b" ); - List tags2 = Collections.singletonList( "Tag2" ); + List tags4 = Arrays.asList("Tag4a", "Tag4b"); + List tags2 = Collections.singletonList("Tag2"); List noTags = Collections.emptyList(); - assertEquals( "Incorrect tags found", tags4, sorted( logEntries.get( 0 ).getTags() ) ); - assertEquals( "Incorrect tags found", noTags, sorted( logEntries.get( 1 ).getTags() ) ); - assertEquals( "Incorrect tags found", tags2, sorted( logEntries.get( 2 ).getTags() ) ); - assertEquals( "Incorrect tags found", noTags, sorted( logEntries.get( 3 ).getTags() ) ); + assertEquals("Incorrect tags found", tags4, sorted(logEntries.get(0).getTags())); + assertEquals("Incorrect tags found", noTags, sorted(logEntries.get(1).getTags())); + assertEquals("Incorrect tags found", tags2, sorted(logEntries.get(2).getTags())); + assertEquals("Incorrect tags found", noTags, sorted(logEntries.get(3).getTags())); } - private List sorted( List input ) - { - List result = new ArrayList<>( input ); - Collections.sort( result ); + private List sorted(List input) { + List result = new ArrayList<>(input); + Collections.sort(result); return result; } - } diff --git a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gittest/src/main/java/org/apache/maven/scm/provider/git/command/checkin/GitCheckInCommandTckTest.java b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gittest/src/main/java/org/apache/maven/scm/provider/git/command/checkin/GitCheckInCommandTckTest.java index bf6383b7e..0dc8694cb 100644 --- a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gittest/src/main/java/org/apache/maven/scm/provider/git/command/checkin/GitCheckInCommandTckTest.java +++ b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gittest/src/main/java/org/apache/maven/scm/provider/git/command/checkin/GitCheckInCommandTckTest.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.git.command.checkin; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,39 +16,32 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider.git.command.checkin; + +import java.io.File; import org.apache.maven.scm.command.checkout.CheckOutScmResult; import org.apache.maven.scm.provider.git.GitScmTestUtils; import org.apache.maven.scm.repository.ScmRepository; import org.apache.maven.scm.tck.command.checkin.CheckInCommandTckTest; -import java.io.File; - /** * @author Mark Struberg * */ -public abstract class GitCheckInCommandTckTest - extends CheckInCommandTckTest -{ +public abstract class GitCheckInCommandTckTest extends CheckInCommandTckTest { /** {@inheritDoc} */ - public void initRepo() - throws Exception - { - GitScmTestUtils.initRepo( "src/test/resources/repository/", getRepositoryRoot(), getWorkingDirectory() ); + public void initRepo() throws Exception { + GitScmTestUtils.initRepo("src/test/resources/repository/", getRepositoryRoot(), getWorkingDirectory()); } @Override - protected CheckOutScmResult checkOut( File workingDirectory, ScmRepository repository ) throws Exception - { - try - { - return super.checkOut( workingDirectory, repository ); - } - finally - { - GitScmTestUtils.setDefaultUser( workingDirectory ); + protected CheckOutScmResult checkOut(File workingDirectory, ScmRepository repository) throws Exception { + try { + return super.checkOut(workingDirectory, repository); + } finally { + GitScmTestUtils.setDefaultUser(workingDirectory); } } } diff --git a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gittest/src/main/java/org/apache/maven/scm/provider/git/command/checkout/GitCheckOutCommandTckTest.java b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gittest/src/main/java/org/apache/maven/scm/provider/git/command/checkout/GitCheckOutCommandTckTest.java index 83b965b76..cd1e20388 100644 --- a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gittest/src/main/java/org/apache/maven/scm/provider/git/command/checkout/GitCheckOutCommandTckTest.java +++ b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gittest/src/main/java/org/apache/maven/scm/provider/git/command/checkout/GitCheckOutCommandTckTest.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.git.command.checkout; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ - +package org.apache.maven.scm.provider.git.command.checkout; import org.apache.maven.scm.provider.git.GitScmTestUtils; import org.apache.maven.scm.tck.command.checkout.CheckOutCommandTckTest; @@ -27,21 +25,14 @@ * @author Mark Struberg * */ -public class GitCheckOutCommandTckTest - extends CheckOutCommandTckTest -{ +public class GitCheckOutCommandTckTest extends CheckOutCommandTckTest { /** {@inheritDoc} */ - public String getScmUrl() - throws Exception - { - return GitScmTestUtils.getScmUrl( getRepositoryRoot(), "git" ); + public String getScmUrl() throws Exception { + return GitScmTestUtils.getScmUrl(getRepositoryRoot(), "git"); } /** {@inheritDoc} */ - public void initRepo() - throws Exception - { - GitScmTestUtils.initRepo( "src/test/resources/repository/", getRepositoryRoot(), getWorkingDirectory() ); + public void initRepo() throws Exception { + GitScmTestUtils.initRepo("src/test/resources/repository/", getRepositoryRoot(), getWorkingDirectory()); } - } diff --git a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gittest/src/main/java/org/apache/maven/scm/provider/git/command/checkout/GitSshCheckOutCommandTckTest.java b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gittest/src/main/java/org/apache/maven/scm/provider/git/command/checkout/GitSshCheckOutCommandTckTest.java index 376d8acf2..bdc65625c 100644 --- a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gittest/src/main/java/org/apache/maven/scm/provider/git/command/checkout/GitSshCheckOutCommandTckTest.java +++ b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gittest/src/main/java/org/apache/maven/scm/provider/git/command/checkout/GitSshCheckOutCommandTckTest.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.git.command.checkout; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider.git.command.checkout; import java.io.IOException; import java.io.OutputStream; @@ -59,9 +58,7 @@ /** * */ -public abstract class GitSshCheckOutCommandTckTest - extends CheckOutCommandTckTest -{ +public abstract class GitSshCheckOutCommandTckTest extends CheckOutCommandTckTest { protected final SshServer sshServer; protected final KeyPair keyPair; protected final List acceptedPublicKeys; @@ -69,119 +66,97 @@ public abstract class GitSshCheckOutCommandTckTest @Rule public TemporaryFolder tmpDirectory = new TemporaryFolder(); - protected GitSshCheckOutCommandTckTest() throws GeneralSecurityException - { - sshServer = CoreTestSupportUtils.setupTestServer( getClass() ); - keyPair = CommonTestSupportUtils.generateKeyPair( KeyUtils.RSA_ALGORITHM, 2048 ); - acceptedPublicKeys = new ArrayList<>(); - acceptedPublicKeys.add( keyPair.getPublic() ); - PublickeyAuthenticator authenticator = new KeySetPublickeyAuthenticator( "onlykey", - acceptedPublicKeys ); - sshServer.setPublickeyAuthenticator( authenticator ); + protected GitSshCheckOutCommandTckTest() throws GeneralSecurityException { + sshServer = CoreTestSupportUtils.setupTestServer(getClass()); + keyPair = CommonTestSupportUtils.generateKeyPair(KeyUtils.RSA_ALGORITHM, 2048); + acceptedPublicKeys = new ArrayList<>(); + acceptedPublicKeys.add(keyPair.getPublic()); + PublickeyAuthenticator authenticator = new KeySetPublickeyAuthenticator("onlykey", acceptedPublicKeys); + sshServer.setPublickeyAuthenticator(authenticator); } - void writePrivateKeyAsPkcs8( Path file, String passphrase ) - throws IOException, GeneralSecurityException - { + void writePrivateKeyAsPkcs8(Path file, String passphrase) throws IOException, GeneralSecurityException { // encryption only optional - if ( passphrase != null ) - { + if (passphrase != null) { // encryption with format outlined in https://dnaeon.github.io/openssh-private-key-binary-format/ OpenSSHKeyPairResourceWriter writer = new OpenSSHKeyPairResourceWriter(); OpenSSHKeyEncryptionContext context = new OpenSSHKeyEncryptionContext(); - context.setCipherType( "192" ); - context.setPassword( passphrase ); - try ( OutputStream output = Files.newOutputStream( file ) ) - { - writer.writePrivateKey( keyPair, "comment", context, output ); + context.setCipherType("192"); + context.setPassword(passphrase); + try (OutputStream output = Files.newOutputStream(file)) { + writer.writePrivateKey(keyPair, "comment", context, output); } - } - else - { + } else { // wrap unencrypted private key as regular PKCS8 private key - PKCS8Generator pkcs8Generator = new JcaPKCS8Generator( keyPair.getPrivate(), null ); + PKCS8Generator pkcs8Generator = new JcaPKCS8Generator(keyPair.getPrivate(), null); PemObject pemObject = pkcs8Generator.generate(); - try ( Writer writer = Files.newBufferedWriter( file ); - JcaPEMWriter pw = new JcaPEMWriter( writer ) ) - { - pw.writeObject( pemObject ); + try (Writer writer = Files.newBufferedWriter(file); + JcaPEMWriter pw = new JcaPEMWriter(writer)) { + pw.writeObject(pemObject); } } - if ( file.getFileSystem().supportedFileAttributeViews().contains( "posix" ) ) - { + if (file.getFileSystem().supportedFileAttributeViews().contains("posix")) { // must only be readable/writeable by me - Files.setPosixFilePermissions( file, PosixFilePermissions.fromString( "rwx------" ) ); + Files.setPosixFilePermissions(file, PosixFilePermissions.fromString("rwx------")); } } protected abstract String getScmProvider(); /** {@inheritDoc} */ - public String getScmUrl() - throws Exception - { + public String getScmUrl() throws Exception { return "scm:" + getScmProvider() + ":ssh://localhost:" + sshServer.getPort() + "/repository"; } - public void configureCredentials( ScmRepository repository, String passphrase ) - throws Exception - { + public void configureCredentials(ScmRepository repository, String passphrase) throws Exception { ScmProviderRepositoryWithHost providerRepository = - ScmProviderRepositoryWithHost.class.cast( repository.getProviderRepository() ); + ScmProviderRepositoryWithHost.class.cast(repository.getProviderRepository()); // store as file Path privateKeyFile = tmpDirectory.newFile().toPath(); - writePrivateKeyAsPkcs8( privateKeyFile, passphrase ); - providerRepository.setPrivateKey( privateKeyFile.toString() ); - providerRepository.setPassphrase( passphrase ); // may be null + writePrivateKeyAsPkcs8(privateKeyFile, passphrase); + providerRepository.setPrivateKey(privateKeyFile.toString()); + providerRepository.setPassphrase(passphrase); // may be null } /** {@inheritDoc} */ - public void initRepo() - throws Exception - { - GitScmTestUtils.initRepo( "src/test/resources/repository/", getRepositoryRoot(), getWorkingDirectory() ); + public void initRepo() throws Exception { + GitScmTestUtils.initRepo("src/test/resources/repository/", getRepositoryRoot(), getWorkingDirectory()); - GitLocationResolver gitLocationResolver = new GitLocationResolver() - { + GitLocationResolver gitLocationResolver = new GitLocationResolver() { @Override - public Path resolveRootDirectory( String command, String[] args, ServerSession session, FileSystem fs ) - throws IOException - { + public Path resolveRootDirectory(String command, String[] args, ServerSession session, FileSystem fs) + throws IOException { return getRepositoryRoot().getParentFile().toPath(); } }; - sshServer.setCommandFactory( new GitPackCommandFactory( gitLocationResolver ) ); + sshServer.setCommandFactory(new GitPackCommandFactory(gitLocationResolver)); sshServer.start(); // as checkout also already happens in setup() make sure to configure credentials here as well - configureCredentials( getScmRepository(), null ); + configureCredentials(getScmRepository(), null); } @Override - public void removeRepo() throws Exception - { + public void removeRepo() throws Exception { sshServer.stop(); super.removeRepo(); } @Override @Test - public void testCheckOutCommandTest() - throws Exception - { - configureCredentials( getScmRepository(), null ); + public void testCheckOutCommandTest() throws Exception { + configureCredentials(getScmRepository(), null); super.testCheckOutCommandTest(); } @Test - public void testCheckOutCommandWithPassphraseTest() throws Exception - { + public void testCheckOutCommandWithPassphraseTest() throws Exception { // TODO: currently no easy way to pass passphrase in gitexe - Assume.assumeTrue( "Ignore test with passphrase for provider " + getScmProvider(), - "jgit".equals( getScmProvider() ) ); - configureCredentials( getScmRepository(), "mySecret" ); + Assume.assumeTrue( + "Ignore test with passphrase for provider " + getScmProvider(), "jgit".equals(getScmProvider())); + configureCredentials(getScmRepository(), "mySecret"); super.testCheckOutCommandTest(); } } diff --git a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gittest/src/main/java/org/apache/maven/scm/provider/git/command/diff/GitDiffCommandTckTest.java b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gittest/src/main/java/org/apache/maven/scm/provider/git/command/diff/GitDiffCommandTckTest.java index e3c80c6df..df0623e45 100644 --- a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gittest/src/main/java/org/apache/maven/scm/provider/git/command/diff/GitDiffCommandTckTest.java +++ b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gittest/src/main/java/org/apache/maven/scm/provider/git/command/diff/GitDiffCommandTckTest.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.git.command.diff; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider.git.command.diff; import org.apache.maven.scm.provider.git.GitScmTestUtils; import org.apache.maven.scm.tck.command.diff.DiffCommandTckTest; @@ -26,13 +25,9 @@ * @author Mark Struberg * */ -public abstract class GitDiffCommandTckTest - extends DiffCommandTckTest -{ +public abstract class GitDiffCommandTckTest extends DiffCommandTckTest { /** {@inheritDoc} */ - public void initRepo() - throws Exception - { - GitScmTestUtils.initRepo( "src/test/resources/repository/", getRepositoryRoot(), getWorkingDirectory() ); + public void initRepo() throws Exception { + GitScmTestUtils.initRepo("src/test/resources/repository/", getRepositoryRoot(), getWorkingDirectory()); } } diff --git a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gittest/src/main/java/org/apache/maven/scm/provider/git/command/list/GitListCommandTckTest.java b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gittest/src/main/java/org/apache/maven/scm/provider/git/command/list/GitListCommandTckTest.java index 1c999a2ef..d472e91f2 100644 --- a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gittest/src/main/java/org/apache/maven/scm/provider/git/command/list/GitListCommandTckTest.java +++ b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gittest/src/main/java/org/apache/maven/scm/provider/git/command/list/GitListCommandTckTest.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.git.command.list; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider.git.command.list; import org.apache.maven.scm.provider.git.GitScmTestUtils; import org.apache.maven.scm.tck.command.list.ListCommandTckTest; @@ -26,13 +25,9 @@ * @author Mark Struberg * */ -public abstract class GitListCommandTckTest - extends ListCommandTckTest -{ +public abstract class GitListCommandTckTest extends ListCommandTckTest { /** {@inheritDoc} */ - public void initRepo() - throws Exception - { - GitScmTestUtils.initRepo( "src/test/resources/repository/", getRepositoryRoot(), getWorkingDirectory() ); + public void initRepo() throws Exception { + GitScmTestUtils.initRepo("src/test/resources/repository/", getRepositoryRoot(), getWorkingDirectory()); } } diff --git a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gittest/src/main/java/org/apache/maven/scm/provider/git/command/remoteinfo/AbstractGitRemoteInfoCommandTckTest.java b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gittest/src/main/java/org/apache/maven/scm/provider/git/command/remoteinfo/AbstractGitRemoteInfoCommandTckTest.java index 53c49d307..2a4da96ca 100644 --- a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gittest/src/main/java/org/apache/maven/scm/provider/git/command/remoteinfo/AbstractGitRemoteInfoCommandTckTest.java +++ b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gittest/src/main/java/org/apache/maven/scm/provider/git/command/remoteinfo/AbstractGitRemoteInfoCommandTckTest.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.git.command.remoteinfo; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider.git.command.remoteinfo; import org.apache.maven.scm.provider.ScmProviderRepository; import org.apache.maven.scm.provider.git.GitScmTestUtils; @@ -27,24 +26,17 @@ /** * @author Bertrand Paquet */ -public abstract class AbstractGitRemoteInfoCommandTckTest - extends AbstractRemoteInfoCommandTckTest -{ +public abstract class AbstractGitRemoteInfoCommandTckTest extends AbstractRemoteInfoCommandTckTest { @Override - protected ScmProviderRepository getScmProviderRepository() - throws Exception - { - return new GitScmProviderRepository( getScmUrl().substring( "scm:git:".length() ) ); + protected ScmProviderRepository getScmProviderRepository() throws Exception { + return new GitScmProviderRepository(getScmUrl().substring("scm:git:".length())); } /** * {@inheritDoc} */ - public void initRepo() - throws Exception - { - GitScmTestUtils.initRepo( "src/test/resources/repository/", getRepositoryRoot(), getWorkingDirectory() ); + public void initRepo() throws Exception { + GitScmTestUtils.initRepo("src/test/resources/repository/", getRepositoryRoot(), getWorkingDirectory()); } - -} \ No newline at end of file +} diff --git a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gittest/src/main/java/org/apache/maven/scm/provider/git/command/remove/GitRemoveCommandTckTest.java b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gittest/src/main/java/org/apache/maven/scm/provider/git/command/remove/GitRemoveCommandTckTest.java index 38ee122da..27670b6e9 100644 --- a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gittest/src/main/java/org/apache/maven/scm/provider/git/command/remove/GitRemoveCommandTckTest.java +++ b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gittest/src/main/java/org/apache/maven/scm/provider/git/command/remove/GitRemoveCommandTckTest.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.git.command.remove; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider.git.command.remove; import org.apache.maven.scm.provider.git.GitScmTestUtils; import org.apache.maven.scm.tck.command.remove.RemoveCommandTckTest; @@ -27,20 +26,14 @@ * * @author Georg Tsakumagos */ -public abstract class GitRemoveCommandTckTest - extends RemoveCommandTckTest -{ +public abstract class GitRemoveCommandTckTest extends RemoveCommandTckTest { /** {@inheritDoc} */ - public String getScmUrl() - throws Exception - { - return GitScmTestUtils.getScmUrl( getRepositoryRoot(), "git" ); + public String getScmUrl() throws Exception { + return GitScmTestUtils.getScmUrl(getRepositoryRoot(), "git"); } /** {@inheritDoc} */ - public void initRepo() - throws Exception - { - GitScmTestUtils.initRepo( "src/test/resources/repository/", getRepositoryRoot(), getWorkingDirectory() ); + public void initRepo() throws Exception { + GitScmTestUtils.initRepo("src/test/resources/repository/", getRepositoryRoot(), getWorkingDirectory()); } } diff --git a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gittest/src/main/java/org/apache/maven/scm/provider/git/command/status/GitStatusCommandTckTest.java b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gittest/src/main/java/org/apache/maven/scm/provider/git/command/status/GitStatusCommandTckTest.java index ce8d93608..08711aaf9 100644 --- a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gittest/src/main/java/org/apache/maven/scm/provider/git/command/status/GitStatusCommandTckTest.java +++ b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gittest/src/main/java/org/apache/maven/scm/provider/git/command/status/GitStatusCommandTckTest.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.git.command.status; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,38 +16,31 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider.git.command.status; + +import java.io.File; import org.apache.maven.scm.command.checkout.CheckOutScmResult; import org.apache.maven.scm.provider.git.GitScmTestUtils; import org.apache.maven.scm.repository.ScmRepository; import org.apache.maven.scm.tck.command.status.StatusCommandTckTest; -import java.io.File; - /** * @author Mark Struberg * */ -public abstract class GitStatusCommandTckTest - extends StatusCommandTckTest -{ +public abstract class GitStatusCommandTckTest extends StatusCommandTckTest { /** {@inheritDoc} */ - public void initRepo() - throws Exception - { - GitScmTestUtils.initRepo( "src/test/resources/repository/", getRepositoryRoot(), getWorkingDirectory() ); + public void initRepo() throws Exception { + GitScmTestUtils.initRepo("src/test/resources/repository/", getRepositoryRoot(), getWorkingDirectory()); } @Override - protected CheckOutScmResult checkOut( File workingDirectory, ScmRepository repository ) throws Exception - { - try - { - return super.checkOut( workingDirectory, repository ); - } - finally - { - GitScmTestUtils.setDefaultUser( workingDirectory ); + protected CheckOutScmResult checkOut(File workingDirectory, ScmRepository repository) throws Exception { + try { + return super.checkOut(workingDirectory, repository); + } finally { + GitScmTestUtils.setDefaultUser(workingDirectory); } } } diff --git a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gittest/src/main/java/org/apache/maven/scm/provider/git/command/tag/GitTagCommandTckTest.java b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gittest/src/main/java/org/apache/maven/scm/provider/git/command/tag/GitTagCommandTckTest.java index d74105a9c..28006adb0 100644 --- a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gittest/src/main/java/org/apache/maven/scm/provider/git/command/tag/GitTagCommandTckTest.java +++ b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gittest/src/main/java/org/apache/maven/scm/provider/git/command/tag/GitTagCommandTckTest.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.git.command.tag; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,38 +16,31 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider.git.command.tag; + +import java.io.File; import org.apache.maven.scm.command.checkout.CheckOutScmResult; import org.apache.maven.scm.provider.git.GitScmTestUtils; import org.apache.maven.scm.repository.ScmRepository; import org.apache.maven.scm.tck.command.tag.TagCommandTckTest; -import java.io.File; - /** * @author Mark Struberg * */ -public abstract class GitTagCommandTckTest - extends TagCommandTckTest -{ +public abstract class GitTagCommandTckTest extends TagCommandTckTest { /** {@inheritDoc} */ - public void initRepo() - throws Exception - { - GitScmTestUtils.initRepo( "src/test/resources/repository/", getRepositoryRoot(), getWorkingDirectory() ); + public void initRepo() throws Exception { + GitScmTestUtils.initRepo("src/test/resources/repository/", getRepositoryRoot(), getWorkingDirectory()); } @Override - protected CheckOutScmResult checkOut( File workingDirectory, ScmRepository repository ) throws Exception - { - try - { - return super.checkOut( workingDirectory, repository ); - } - finally - { - GitScmTestUtils.setDefaultUser( workingDirectory ); + protected CheckOutScmResult checkOut(File workingDirectory, ScmRepository repository) throws Exception { + try { + return super.checkOut(workingDirectory, repository); + } finally { + GitScmTestUtils.setDefaultUser(workingDirectory); } } } diff --git a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gittest/src/main/java/org/apache/maven/scm/provider/git/command/untag/GitUntagCommandTckTest.java b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gittest/src/main/java/org/apache/maven/scm/provider/git/command/untag/GitUntagCommandTckTest.java index 7eff053e1..b1d2c89b2 100644 --- a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gittest/src/main/java/org/apache/maven/scm/provider/git/command/untag/GitUntagCommandTckTest.java +++ b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gittest/src/main/java/org/apache/maven/scm/provider/git/command/untag/GitUntagCommandTckTest.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.git.command.untag; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,34 +16,28 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider.git.command.untag; import java.io.File; + import org.apache.maven.scm.command.checkout.CheckOutScmResult; import org.apache.maven.scm.provider.git.GitScmTestUtils; import org.apache.maven.scm.repository.ScmRepository; import org.apache.maven.scm.tck.command.untag.UntagCommandTckTest; /** {@inheritDoc} */ -public abstract class GitUntagCommandTckTest - extends UntagCommandTckTest -{ +public abstract class GitUntagCommandTckTest extends UntagCommandTckTest { /** {@inheritDoc} */ - public void initRepo() - throws Exception - { - GitScmTestUtils.initRepo( "src/test/resources/repository/", getRepositoryRoot(), getWorkingDirectory() ); + public void initRepo() throws Exception { + GitScmTestUtils.initRepo("src/test/resources/repository/", getRepositoryRoot(), getWorkingDirectory()); } @Override - protected CheckOutScmResult checkOut( File workingDirectory, ScmRepository repository ) throws Exception - { - try - { - return super.checkOut( workingDirectory, repository ); - } - finally - { - GitScmTestUtils.setDefaultUser( workingDirectory ); + protected CheckOutScmResult checkOut(File workingDirectory, ScmRepository repository) throws Exception { + try { + return super.checkOut(workingDirectory, repository); + } finally { + GitScmTestUtils.setDefaultUser(workingDirectory); } } } diff --git a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gittest/src/main/java/org/apache/maven/scm/provider/git/command/update/GitUpdateCommandTckTest.java b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gittest/src/main/java/org/apache/maven/scm/provider/git/command/update/GitUpdateCommandTckTest.java index 12583f653..998a874f9 100644 --- a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gittest/src/main/java/org/apache/maven/scm/provider/git/command/update/GitUpdateCommandTckTest.java +++ b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gittest/src/main/java/org/apache/maven/scm/provider/git/command/update/GitUpdateCommandTckTest.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.git.command.update; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,38 +16,31 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider.git.command.update; + +import java.io.File; import org.apache.maven.scm.command.checkout.CheckOutScmResult; import org.apache.maven.scm.provider.git.GitScmTestUtils; import org.apache.maven.scm.repository.ScmRepository; import org.apache.maven.scm.tck.command.update.UpdateCommandTckTest; -import java.io.File; - /** * @author Mark Struberg * */ -public abstract class GitUpdateCommandTckTest - extends UpdateCommandTckTest -{ +public abstract class GitUpdateCommandTckTest extends UpdateCommandTckTest { /** {@inheritDoc} */ - public void initRepo() - throws Exception - { - GitScmTestUtils.initRepo( "src/test/resources/repository/", getRepositoryRoot(), getWorkingCopy() ); + public void initRepo() throws Exception { + GitScmTestUtils.initRepo("src/test/resources/repository/", getRepositoryRoot(), getWorkingCopy()); } @Override - protected CheckOutScmResult checkOut( File workingDirectory, ScmRepository repository ) throws Exception - { - try - { - return super.checkOut( workingDirectory, repository ); - } - finally - { - GitScmTestUtils.setDefaultUser( workingDirectory ); + protected CheckOutScmResult checkOut(File workingDirectory, ScmRepository repository) throws Exception { + try { + return super.checkOut(workingDirectory, repository); + } finally { + GitScmTestUtils.setDefaultUser(workingDirectory); } } } diff --git a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-jgit/pom.xml b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-jgit/pom.xml index 60b5b454a..7b4bc269f 100644 --- a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-jgit/pom.xml +++ b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-jgit/pom.xml @@ -1,5 +1,4 @@ - - 4.0.0 @@ -30,13 +28,12 @@ maven-scm-provider-jgit Maven SCM Git Provider - JGit Impl. - - JGIT implementation for SCM Git Provider. - see http://eclipse.org/jgit/ - + JGIT implementation for SCM Git Provider. + see http://eclipse.org/jgit/ - 5.13.1.202206130422-r + 5.13.1.202206130422-r + @@ -111,7 +108,8 @@ org.apache.maven.plugins maven-surefire-plugin - false + false + nothing diff --git a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-jgit/src/main/java/org/apache/maven/scm/provider/git/jgit/JGitScmProvider.java b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-jgit/src/main/java/org/apache/maven/scm/provider/git/jgit/JGitScmProvider.java index 874b62403..2bc872cf5 100644 --- a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-jgit/src/main/java/org/apache/maven/scm/provider/git/jgit/JGitScmProvider.java +++ b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-jgit/src/main/java/org/apache/maven/scm/provider/git/jgit/JGitScmProvider.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.git.jgit; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider.git.jgit; import javax.inject.Inject; import javax.inject.Named; @@ -55,31 +54,26 @@ * @since 1.9 */ @Singleton -@Named( "jgit" ) -public class JGitScmProvider - extends AbstractGitScmProvider -{ +@Named("jgit") +public class JGitScmProvider extends AbstractGitScmProvider { private final PlexusInteractivityCredentialsProvider credentialsProvider; @Inject - public JGitScmProvider( Prompter prompter ) - { - credentialsProvider = new PlexusInteractivityCredentialsProvider( prompter ); - CredentialsProvider.setDefault( credentialsProvider ); + public JGitScmProvider(Prompter prompter) { + credentialsProvider = new PlexusInteractivityCredentialsProvider(prompter); + CredentialsProvider.setDefault(credentialsProvider); } @Override - public void setInteractive( boolean interactive ) - { - credentialsProvider.setInteractive( interactive ); + public void setInteractive(boolean interactive) { + credentialsProvider.setInteractive(interactive); } /** * {@inheritDoc} */ @Override - protected GitCommand getAddCommand() - { + protected GitCommand getAddCommand() { return new JGitAddCommand(); } @@ -87,8 +81,7 @@ protected GitCommand getAddCommand() * {@inheritDoc} */ @Override - protected GitCommand getBranchCommand() - { + protected GitCommand getBranchCommand() { return new JGitBranchCommand(); } @@ -96,8 +89,7 @@ protected GitCommand getBranchCommand() * {@inheritDoc} */ @Override - protected GitCommand getChangeLogCommand() - { + protected GitCommand getChangeLogCommand() { return new JGitChangeLogCommand(); } @@ -105,8 +97,7 @@ protected GitCommand getChangeLogCommand() * {@inheritDoc} */ @Override - protected GitCommand getCheckInCommand() - { + protected GitCommand getCheckInCommand() { return new JGitCheckInCommand(); } @@ -114,8 +105,7 @@ protected GitCommand getCheckInCommand() * {@inheritDoc} */ @Override - protected GitCommand getCheckOutCommand() - { + protected GitCommand getCheckOutCommand() { return new JGitCheckOutCommand(); } @@ -123,8 +113,7 @@ protected GitCommand getCheckOutCommand() * {@inheritDoc} */ @Override - protected GitCommand getDiffCommand() - { + protected GitCommand getDiffCommand() { return new JGitDiffCommand(); } @@ -132,17 +121,15 @@ protected GitCommand getDiffCommand() * {@inheritDoc} */ @Override - protected GitCommand getExportCommand() - { - throw new UnsupportedOperationException( "getExportCommand" ); + protected GitCommand getExportCommand() { + throw new UnsupportedOperationException("getExportCommand"); } /** * {@inheritDoc} */ @Override - protected GitCommand getRemoveCommand() - { + protected GitCommand getRemoveCommand() { return new JGitRemoveCommand(); } @@ -150,8 +137,7 @@ protected GitCommand getRemoveCommand() * {@inheritDoc} */ @Override - protected GitCommand getStatusCommand() - { + protected GitCommand getStatusCommand() { return new JGitStatusCommand(); } @@ -159,8 +145,7 @@ protected GitCommand getStatusCommand() * {@inheritDoc} */ @Override - protected GitCommand getTagCommand() - { + protected GitCommand getTagCommand() { return new JGitTagCommand(); } @@ -168,8 +153,7 @@ protected GitCommand getTagCommand() * {@inheritDoc} */ @Override - protected GitCommand getUntagCommand() - { + protected GitCommand getUntagCommand() { return new JGitUntagCommand(); } @@ -177,16 +161,14 @@ protected GitCommand getUntagCommand() * {@inheritDoc} */ @Override - protected GitCommand getUpdateCommand() - { - throw new UnsupportedOperationException( "getUpdateCommand" ); + protected GitCommand getUpdateCommand() { + throw new UnsupportedOperationException("getUpdateCommand"); } /** * {@inheritDoc} */ - protected GitCommand getListCommand() - { + protected GitCommand getListCommand() { return new JGitListCommand(); } @@ -194,8 +176,7 @@ protected GitCommand getListCommand() * {@inheritDoc} */ @Override - public GitCommand getInfoCommand() - { + public GitCommand getInfoCommand() { return new JGitInfoCommand(); } @@ -203,30 +184,25 @@ public GitCommand getInfoCommand() * {@inheritDoc} */ @Override - protected String getRepositoryURL( File path ) - throws ScmException - { + protected String getRepositoryURL(File path) throws ScmException { // Note: I need to supply just 1 absolute path, but ScmFileSet won't let // me without // a basedir (which isn't used here anyway), so use a dummy file. - InfoScmResult result = info( null, new ScmFileSet( new File( "" ), path ), null ); + InfoScmResult result = info(null, new ScmFileSet(new File(""), path), null); - if ( result.getInfoItems().size() != 1 ) - { - throw new ScmRepositoryException( - "Cannot find URL: " + ( result.getInfoItems().size() == 0 ? "no" : "multiple" ) - + " items returned by the info command" ); + if (result.getInfoItems().size() != 1) { + throw new ScmRepositoryException("Cannot find URL: " + + (result.getInfoItems().size() == 0 ? "no" : "multiple") + " items returned by the info command"); } - return ( result.getInfoItems().get( 0 ) ).getURL(); + return (result.getInfoItems().get(0)).getURL(); } /** * {@inheritDoc} */ @Override - protected GitCommand getBlameCommand() - { + protected GitCommand getBlameCommand() { return new JGitBlameCommand(); } @@ -234,8 +210,7 @@ protected GitCommand getBlameCommand() * {@inheritDoc} */ @Override - protected GitCommand getRemoteInfoCommand() - { + protected GitCommand getRemoteInfoCommand() { return new JGitRemoteInfoCommand(); } } diff --git a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-jgit/src/main/java/org/apache/maven/scm/provider/git/jgit/command/JGitTransportConfigCallback.java b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-jgit/src/main/java/org/apache/maven/scm/provider/git/jgit/command/JGitTransportConfigCallback.java index 7c8c72726..f7349189a 100644 --- a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-jgit/src/main/java/org/apache/maven/scm/provider/git/jgit/command/JGitTransportConfigCallback.java +++ b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-jgit/src/main/java/org/apache/maven/scm/provider/git/jgit/command/JGitTransportConfigCallback.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.git.jgit.command; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider.git.jgit.command; import org.eclipse.jgit.api.TransportConfigCallback; import org.eclipse.jgit.transport.SshTransport; @@ -28,23 +27,18 @@ * Implementation of {@link TransportConfigCallback} which adds * a public/private key identity to ssh URLs if configured. */ -public class JGitTransportConfigCallback implements TransportConfigCallback -{ +public class JGitTransportConfigCallback implements TransportConfigCallback { private final SshdSessionFactory sshSessionFactory; - public JGitTransportConfigCallback( SshdSessionFactory sshSessionFactory ) - { + public JGitTransportConfigCallback(SshdSessionFactory sshSessionFactory) { this.sshSessionFactory = sshSessionFactory; } @Override - public void configure( Transport transport ) - { - if ( transport instanceof SshTransport ) - { + public void configure(Transport transport) { + if (transport instanceof SshTransport) { SshTransport sshTransport = (SshTransport) transport; - sshTransport.setSshSessionFactory( sshSessionFactory ); + sshTransport.setSshSessionFactory(sshSessionFactory); } } - } diff --git a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-jgit/src/main/java/org/apache/maven/scm/provider/git/jgit/command/JGitUtils.java b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-jgit/src/main/java/org/apache/maven/scm/provider/git/jgit/command/JGitUtils.java index 74039e6aa..1331377a8 100644 --- a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-jgit/src/main/java/org/apache/maven/scm/provider/git/jgit/command/JGitUtils.java +++ b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-jgit/src/main/java/org/apache/maven/scm/provider/git/jgit/command/JGitUtils.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.git.jgit.command; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,20 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider.git.jgit.command; + +import java.io.File; +import java.io.IOException; +import java.io.UnsupportedEncodingException; +import java.net.URI; +import java.net.URLEncoder; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Date; +import java.util.HashSet; +import java.util.List; +import java.util.Set; +import java.util.function.BiConsumer; import org.apache.maven.scm.ScmFile; import org.apache.maven.scm.ScmFileSet; @@ -63,18 +75,6 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import java.io.File; -import java.io.IOException; -import java.io.UnsupportedEncodingException; -import java.net.URI; -import java.net.URLEncoder; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Date; -import java.util.HashSet; -import java.util.List; -import java.util.Set; -import java.util.function.BiConsumer; import static org.eclipse.jgit.lib.Constants.R_TAGS; /** @@ -84,12 +84,10 @@ * @author Dominik Bartholdi (imod) * @since 1.9 */ -public class JGitUtils -{ - private static final Logger LOGGER = LoggerFactory.getLogger( JGitUtils.class ); +public class JGitUtils { + private static final Logger LOGGER = LoggerFactory.getLogger(JGitUtils.class); - private JGitUtils() - { + private JGitUtils() { // no op } @@ -98,19 +96,20 @@ private JGitUtils() * @param basedir The directory to start with * @throws IOException If the repository cannot be opened */ - public static Git openRepo( File basedir ) throws IOException - { - return new Git( new RepositoryBuilder().readEnvironment().findGitDir( basedir ).setMustExist( true ).build() ); + public static Git openRepo(File basedir) throws IOException { + return new Git(new RepositoryBuilder() + .readEnvironment() + .findGitDir(basedir) + .setMustExist(true) + .build()); } /** * Closes the repository wrapped by the passed git object * @param git */ - public static void closeRepo( Git git ) - { - if ( git != null && git.getRepository() != null ) - { + public static void closeRepo(Git git) { + if (git != null && git.getRepository() != null) { git.getRepository().close(); } } @@ -120,8 +119,7 @@ public static void closeRepo( Git git ) * * @return a ProgressMonitor for use */ - public static ProgressMonitor getMonitor() - { + public static ProgressMonitor getMonitor() { // X TODO write an own ProgressMonitor which logs to ScmLogger! return new TextProgressMonitor(); } @@ -137,30 +135,27 @@ public static ProgressMonitor getMonitor() * @return {@link CredentialsProvider} in case there are credentials * informations configured in the repository. */ - public static CredentialsProvider prepareSession( Git git, GitScmProviderRepository repository ) - { + public static CredentialsProvider prepareSession(Git git, GitScmProviderRepository repository) { StoredConfig config = git.getRepository().getConfig(); - config.setString( "remote", "origin", "url", repository.getFetchUrl() ); - config.setString( "remote", "origin", "pushURL", repository.getPushUrl() ); + config.setString("remote", "origin", "url", repository.getFetchUrl()); + config.setString("remote", "origin", "pushURL", repository.getPushUrl()); // make sure we do not log any passwords to the output - String password = - StringUtils.isNotBlank( repository.getPassword() ) ? repository.getPassword().trim() : "no-pwd-defined"; + String password = StringUtils.isNotBlank(repository.getPassword()) + ? repository.getPassword().trim() + : "no-pwd-defined"; // if password contains special characters it won't match below. // Try encoding before match. (Passwords without will be unaffected) - try - { - password = URLEncoder.encode( password, "UTF-8" ); - } - catch ( UnsupportedEncodingException e ) - { + try { + password = URLEncoder.encode(password, "UTF-8"); + } catch (UnsupportedEncodingException e) { // UTF-8 should be valid // TODO use a logger - System.out.println( "Ignore UnsupportedEncodingException when trying to encode password" ); + System.out.println("Ignore UnsupportedEncodingException when trying to encode password"); } - LOGGER.info( "fetch url: " + repository.getFetchUrl().replace( password, "******" ) ); - LOGGER.info( "push url: " + repository.getPushUrl().replace( password, "******" ) ); - return getCredentials( repository ); + LOGGER.info("fetch url: " + repository.getFetchUrl().replace(password, "******")); + LOGGER.info("push url: " + repository.getPushUrl().replace(password, "******")); + return getCredentials(repository); } /** @@ -173,34 +168,29 @@ public static CredentialsProvider prepareSession( Git git, GitScmProviderReposit * @return null if there is not enough info to create a * provider with */ - public static CredentialsProvider getCredentials( GitScmProviderRepository repository ) - { - if ( StringUtils.isNotBlank( repository.getUser() ) && StringUtils.isNotBlank( repository.getPassword() ) ) - { - return new UsernamePasswordCredentialsProvider( repository.getUser().trim(), - repository.getPassword().trim() ); + public static CredentialsProvider getCredentials(GitScmProviderRepository repository) { + if (StringUtils.isNotBlank(repository.getUser()) && StringUtils.isNotBlank(repository.getPassword())) { + return new UsernamePasswordCredentialsProvider( + repository.getUser().trim(), repository.getPassword().trim()); } - return null; } - public static Iterable push( Git git, GitScmProviderRepository repo, RefSpec refSpec ) - throws GitAPIException, InvalidRemoteException, TransportException - { - CredentialsProvider credentials = prepareSession( git, repo ); - PushCommand command = git.push().setRefSpecs( refSpec ).setCredentialsProvider( credentials ) + public static Iterable push(Git git, GitScmProviderRepository repo, RefSpec refSpec) + throws GitAPIException, InvalidRemoteException, TransportException { + CredentialsProvider credentials = prepareSession(git, repo); + PushCommand command = git.push() + .setRefSpecs(refSpec) + .setCredentialsProvider(credentials) .setTransportConfigCallback( - new JGitTransportConfigCallback( new ScmProviderAwareSshdSessionFactory( repo, LOGGER ) ) - ); + new JGitTransportConfigCallback(new ScmProviderAwareSshdSessionFactory(repo, LOGGER))); Iterable pushResultList = command.call(); - for ( PushResult pushResult : pushResultList ) - { + for (PushResult pushResult : pushResultList) { Collection ru = pushResult.getRemoteUpdates(); - for ( RemoteRefUpdate remoteRefUpdate : ru ) - { - LOGGER.info( remoteRefUpdate.getStatus() + " - " + remoteRefUpdate ); + for (RemoteRefUpdate remoteRefUpdate : ru) { + LOGGER.info(remoteRefUpdate.getStatus() + " - " + remoteRefUpdate); } } return pushResultList; @@ -212,12 +202,10 @@ public static Iterable push( Git git, GitScmProviderRepository repo, * @param repo * @return false if there are no commits */ - public static boolean hasCommits( Repository repo ) - { - if ( repo != null && repo.getDirectory().exists() ) - { - return ( new File( repo.getDirectory(), "objects" ).list().length > 2 ) || ( - new File( repo.getDirectory(), "objects/pack" ).list().length > 0 ); + public static boolean hasCommits(Repository repo) { + if (repo != null && repo.getDirectory().exists()) { + return (new File(repo.getDirectory(), "objects").list().length > 2) + || (new File(repo.getDirectory(), "objects/pack").list().length > 0); } return false; } @@ -233,10 +221,9 @@ public static boolean hasCommits( Repository repo ) * @throws CorruptObjectException * @throws IOException */ - public static List getFilesInCommit( Repository repository, RevCommit commit ) - throws MissingObjectException, IncorrectObjectTypeException, CorruptObjectException, IOException - { - return getFilesInCommit( repository, commit, null ); + public static List getFilesInCommit(Repository repository, RevCommit commit) + throws MissingObjectException, IncorrectObjectTypeException, CorruptObjectException, IOException { + return getFilesInCommit(repository, commit, null); } /** @@ -253,34 +240,27 @@ public static List getFilesInCommit( Repository repository, RevCommit c * @throws CorruptObjectException * @throws IOException */ - public static List getFilesInCommit( Repository repository, RevCommit commit, File baseDir ) - throws MissingObjectException, IncorrectObjectTypeException, CorruptObjectException, IOException - { + public static List getFilesInCommit(Repository repository, RevCommit commit, File baseDir) + throws MissingObjectException, IncorrectObjectTypeException, CorruptObjectException, IOException { List list = new ArrayList<>(); - if ( JGitUtils.hasCommits( repository ) ) - { - - try ( RevWalk rw = new RevWalk( repository ); - DiffFormatter df = new DiffFormatter( DisabledOutputStream.INSTANCE ) ) - { - RevCommit realParent = commit.getParentCount() > 0 ? commit.getParent( 0 ) : commit; - RevCommit parent = rw.parseCommit( realParent.getId() ); - df.setRepository( repository ); - df.setDiffComparator( RawTextComparator.DEFAULT ); - df.setDetectRenames( true ); - List diffs = df.scan( parent.getTree(), commit.getTree() ); - for ( DiffEntry diff : diffs ) - { + if (JGitUtils.hasCommits(repository)) { + + try (RevWalk rw = new RevWalk(repository); + DiffFormatter df = new DiffFormatter(DisabledOutputStream.INSTANCE)) { + RevCommit realParent = commit.getParentCount() > 0 ? commit.getParent(0) : commit; + RevCommit parent = rw.parseCommit(realParent.getId()); + df.setRepository(repository); + df.setDiffComparator(RawTextComparator.DEFAULT); + df.setDetectRenames(true); + List diffs = df.scan(parent.getTree(), commit.getTree()); + for (DiffEntry diff : diffs) { final String path; - if ( baseDir != null ) - { - path = relativize ( baseDir.toURI(), new File( repository.getWorkTree(), diff.getNewPath() ) ); - } - else - { + if (baseDir != null) { + path = relativize(baseDir.toURI(), new File(repository.getWorkTree(), diff.getNewPath())); + } else { path = diff.getNewPath(); } - list.add( new ScmFile( path, ScmFileStatus.CHECKED_IN ) ); + list.add(new ScmFile(path, ScmFileStatus.CHECKED_IN)); } } } @@ -293,10 +273,8 @@ public static List getFilesInCommit( Repository repository, RevCommit c * @param changeType * @return the matching ScmFileStatus */ - public static ScmFileStatus getScmFileStatus( ChangeType changeType ) - { - switch ( changeType ) - { + public static ScmFileStatus getScmFileStatus(ChangeType changeType) { + switch (changeType) { case ADD: return ScmFileStatus.ADDED; case MODIFY: @@ -321,27 +299,26 @@ public static ScmFileStatus getScmFileStatus( ChangeType changeType ) * @return a list of added files * @throws GitAPIException */ - public static List addAllFiles( Git git, ScmFileSet fileSet ) - throws GitAPIException - { + public static List addAllFiles(Git git, ScmFileSet fileSet) throws GitAPIException { URI workingCopyRootUri = git.getRepository().getWorkTree().toURI(); AddCommand add = git.add(); - callWithRepositoryRelativeFilePath( ( relativeFile, absoluteFile ) -> - { - if ( absoluteFile.exists() ) - { - add.addFilepattern( relativeFile ); - } - }, workingCopyRootUri, fileSet ); + callWithRepositoryRelativeFilePath( + (relativeFile, absoluteFile) -> { + if (absoluteFile.exists()) { + add.addFilepattern(relativeFile); + } + }, + workingCopyRootUri, + fileSet); add.call(); Status status = git.status().call(); Set allInIndex = new HashSet<>(); - allInIndex.addAll( status.getAdded() ); - allInIndex.addAll( status.getChanged() ); - return getScmFilesForAllFileSetFilesContainedInRepoPath( workingCopyRootUri, fileSet, allInIndex, - ScmFileStatus.ADDED ); + allInIndex.addAll(status.getAdded()); + allInIndex.addAll(status.getChanged()); + return getScmFilesForAllFileSetFilesContainedInRepoPath( + workingCopyRootUri, fileSet, allInIndex, ScmFileStatus.ADDED); } /** @@ -353,20 +330,18 @@ public static List addAllFiles( Git git, ScmFileSet fileSet ) * @return a list of removed files * @throws GitAPIException */ - public static List removeAllFiles( Git git, ScmFileSet fileSet ) - throws GitAPIException - { + public static List removeAllFiles(Git git, ScmFileSet fileSet) throws GitAPIException { URI workingCopyRootUri = git.getRepository().getWorkTree().toURI(); RmCommand remove = git.rm(); - callWithRepositoryRelativeFilePath( ( relativeFile, absoluteFile ) -> - remove.addFilepattern( relativeFile ), workingCopyRootUri, fileSet ); + callWithRepositoryRelativeFilePath( + (relativeFile, absoluteFile) -> remove.addFilepattern(relativeFile), workingCopyRootUri, fileSet); remove.call(); Status status = git.status().call(); - Set allInIndex = new HashSet<>( status.getRemoved() ); - return getScmFilesForAllFileSetFilesContainedInRepoPath( workingCopyRootUri, fileSet, allInIndex, - ScmFileStatus.DELETED ); + Set allInIndex = new HashSet<>(status.getRemoved()); + return getScmFilesForAllFileSetFilesContainedInRepoPath( + workingCopyRootUri, fileSet, allInIndex, ScmFileStatus.DELETED); } /** @@ -376,47 +351,39 @@ public static List removeAllFiles( Git git, ScmFileSet fileSet ) * @param git the git repository * @param fileSet the file set to traverse */ - private static void callWithRepositoryRelativeFilePath( BiConsumer fileCallback, - URI workingCopyRootUri, ScmFileSet fileSet ) - { - for ( File file : fileSet.getFileList() ) - { - if ( !file.isAbsolute() ) - { - file = new File( fileSet.getBasedir().getPath(), file.getPath() ); + private static void callWithRepositoryRelativeFilePath( + BiConsumer fileCallback, URI workingCopyRootUri, ScmFileSet fileSet) { + for (File file : fileSet.getFileList()) { + if (!file.isAbsolute()) { + file = new File(fileSet.getBasedir().getPath(), file.getPath()); } - String path = relativize( workingCopyRootUri, file ); - fileCallback.accept( path, file ); + String path = relativize(workingCopyRootUri, file); + fileCallback.accept(path, file); } } - private static List getScmFilesForAllFileSetFilesContainedInRepoPath( URI workingCopyRootUri, - ScmFileSet fileSet, - Set repoFilePaths, - ScmFileStatus fileStatus ) - { - List files = new ArrayList<>( repoFilePaths.size() ); - callWithRepositoryRelativeFilePath( ( relativeFile, absoluteFile ) -> - { - // check if repo relative path is contained - if ( repoFilePaths.contains( relativeFile ) ) - { - // returned ScmFiles should be relative to given fileset's basedir - ScmFile scmfile = new ScmFile( relativize( fileSet.getBasedir().toURI(), absoluteFile ), - fileStatus ); - files.add( scmfile ); - } - }, - workingCopyRootUri, fileSet ); + private static List getScmFilesForAllFileSetFilesContainedInRepoPath( + URI workingCopyRootUri, ScmFileSet fileSet, Set repoFilePaths, ScmFileStatus fileStatus) { + List files = new ArrayList<>(repoFilePaths.size()); + callWithRepositoryRelativeFilePath( + (relativeFile, absoluteFile) -> { + // check if repo relative path is contained + if (repoFilePaths.contains(relativeFile)) { + // returned ScmFiles should be relative to given fileset's basedir + ScmFile scmfile = + new ScmFile(relativize(fileSet.getBasedir().toURI(), absoluteFile), fileStatus); + files.add(scmfile); + } + }, + workingCopyRootUri, + fileSet); return files; } - private static String relativize( URI baseUri, File f ) - { + private static String relativize(URI baseUri, File f) { String path = f.getPath(); - if ( f.isAbsolute() ) - { - path = baseUri.relativize( new File( path ).toURI() ).getPath(); + if (f.isAbsolute()) { + path = baseUri.relativize(new File(path).toURI()).getPath(); } return path; } @@ -436,98 +403,85 @@ private static String relativize( URI baseUri, File f ) * @throws MissingObjectException * @throws IncorrectObjectTypeException */ - public static List getRevCommits( Repository repo, RevSort[] sortings, String fromRev, String toRev, - final Date fromDate, final Date toDate, int maxLines ) - throws IOException, MissingObjectException, IncorrectObjectTypeException - { + public static List getRevCommits( + Repository repo, + RevSort[] sortings, + String fromRev, + String toRev, + final Date fromDate, + final Date toDate, + int maxLines) + throws IOException, MissingObjectException, IncorrectObjectTypeException { List revs = new ArrayList<>(); - ObjectId fromRevId = fromRev != null ? repo.resolve( fromRev ) : null; - ObjectId toRevId = toRev != null ? repo.resolve( toRev ) : null; + ObjectId fromRevId = fromRev != null ? repo.resolve(fromRev) : null; + ObjectId toRevId = toRev != null ? repo.resolve(toRev) : null; - if ( sortings == null || sortings.length == 0 ) - { - sortings = new RevSort[]{ RevSort.TOPO, RevSort.COMMIT_TIME_DESC }; + if (sortings == null || sortings.length == 0) { + sortings = new RevSort[] {RevSort.TOPO, RevSort.COMMIT_TIME_DESC}; } - try ( RevWalk walk = new RevWalk( repo ) ) - { - for ( final RevSort s : sortings ) - { - walk.sort( s, true ); + try (RevWalk walk = new RevWalk(repo)) { + for (final RevSort s : sortings) { + walk.sort(s, true); } - if ( fromDate != null && toDate != null ) - { - //walk.setRevFilter( CommitTimeRevFilter.between( fromDate, toDate ) ); - walk.setRevFilter( new RevFilter() - { + if (fromDate != null && toDate != null) { + // walk.setRevFilter( CommitTimeRevFilter.between( fromDate, toDate ) ); + walk.setRevFilter(new RevFilter() { @Override - public boolean include( RevWalk walker, RevCommit cmit ) - throws StopWalkException, MissingObjectException, IncorrectObjectTypeException, IOException - { + public boolean include(RevWalk walker, RevCommit cmit) + throws StopWalkException, MissingObjectException, IncorrectObjectTypeException, + IOException { int cmtTime = cmit.getCommitTime(); - return ( cmtTime >= ( fromDate.getTime() / 1000 ) ) - && ( cmtTime <= ( toDate.getTime() / 1000 ) ); + return (cmtTime >= (fromDate.getTime() / 1000)) && (cmtTime <= (toDate.getTime() / 1000)); } @Override - public RevFilter clone() - { + public RevFilter clone() { return this; } - } ); - } - else - { - if ( fromDate != null ) - { - walk.setRevFilter( CommitTimeRevFilter.after( fromDate ) ); + }); + } else { + if (fromDate != null) { + walk.setRevFilter(CommitTimeRevFilter.after(fromDate)); } - if ( toDate != null ) - { - walk.setRevFilter( CommitTimeRevFilter.before( toDate ) ); + if (toDate != null) { + walk.setRevFilter(CommitTimeRevFilter.before(toDate)); } } - if ( fromRevId != null ) - { - RevCommit c = walk.parseCommit( fromRevId ); - c.add( RevFlag.UNINTERESTING ); - RevCommit real = walk.parseCommit( c ); - walk.markUninteresting( real ); + if (fromRevId != null) { + RevCommit c = walk.parseCommit(fromRevId); + c.add(RevFlag.UNINTERESTING); + RevCommit real = walk.parseCommit(c); + walk.markUninteresting(real); } - if ( toRevId != null ) - { - RevCommit c = walk.parseCommit( toRevId ); - c.remove( RevFlag.UNINTERESTING ); - RevCommit real = walk.parseCommit( c ); - walk.markStart( real ); - } - else - { - final ObjectId head = repo.resolve( Constants.HEAD ); - if ( head == null ) - { - throw new RuntimeException( "Cannot resolve " + Constants.HEAD ); + if (toRevId != null) { + RevCommit c = walk.parseCommit(toRevId); + c.remove(RevFlag.UNINTERESTING); + RevCommit real = walk.parseCommit(c); + walk.markStart(real); + } else { + final ObjectId head = repo.resolve(Constants.HEAD); + if (head == null) { + throw new RuntimeException("Cannot resolve " + Constants.HEAD); } - RevCommit real = walk.parseCommit( head ); - walk.markStart( real ); + RevCommit real = walk.parseCommit(head); + walk.markStart(real); } int n = 0; - for ( final RevCommit c : walk ) - { + for (final RevCommit c : walk) { n++; - if ( maxLines != -1 && n > maxLines ) - { + if (maxLines != -1 && n > maxLines) { break; } - revs.add( c ); + revs.add(c); } return revs; } @@ -540,26 +494,21 @@ public RevFilter clone() * @param commit the commit for which we want the tags * @return a list of tags, might be empty, and never null */ - public static List getTags( Repository repo, RevCommit commit ) throws IOException - { - List refList = repo.getRefDatabase().getRefsByPrefix( R_TAGS ); + public static List getTags(Repository repo, RevCommit commit) throws IOException { + List refList = repo.getRefDatabase().getRefsByPrefix(R_TAGS); - try ( RevWalk revWalk = new RevWalk( repo ) ) - { + try (RevWalk revWalk = new RevWalk(repo)) { ObjectId commitId = commit.getId(); List result = new ArrayList<>(); - for ( Ref ref : refList ) - { + for (Ref ref : refList) { ObjectId tagId = ref.getObjectId(); - RevCommit tagCommit = revWalk.parseCommit( tagId ); - if ( commitId.equals( tagCommit.getId() ) ) - { - result.add( ref.getName().substring( R_TAGS.length() ) ); + RevCommit tagCommit = revWalk.parseCommit(tagId); + if (commitId.equals(tagCommit.getId())) { + result.add(ref.getName().substring(R_TAGS.length())); } } return result; } } - } diff --git a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-jgit/src/main/java/org/apache/maven/scm/provider/git/jgit/command/PlexusInteractivityCredentialsProvider.java b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-jgit/src/main/java/org/apache/maven/scm/provider/git/jgit/command/PlexusInteractivityCredentialsProvider.java index 78eec8180..f7b3dae31 100644 --- a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-jgit/src/main/java/org/apache/maven/scm/provider/git/jgit/command/PlexusInteractivityCredentialsProvider.java +++ b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-jgit/src/main/java/org/apache/maven/scm/provider/git/jgit/command/PlexusInteractivityCredentialsProvider.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.git.jgit.command; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ - +package org.apache.maven.scm.provider.git.jgit.command; import java.util.Arrays; @@ -33,101 +31,74 @@ * {@link CredentialsProvider} leveraging the {@link Prompter} component. * */ -public class PlexusInteractivityCredentialsProvider extends CredentialsProvider -{ +public class PlexusInteractivityCredentialsProvider extends CredentialsProvider { private boolean interactive; private final Prompter prompter; - public PlexusInteractivityCredentialsProvider( Prompter prompter ) - { + public PlexusInteractivityCredentialsProvider(Prompter prompter) { this.interactive = true; this.prompter = prompter; } @Override - public boolean get( URIish uri, CredentialItem... items ) - { - for ( CredentialItem item : items ) - { - try - { - get( uri, item ); - } - catch ( PrompterException e ) - { - throw new IllegalStateException( "Cannot prompt user", e ); + public boolean get(URIish uri, CredentialItem... items) { + for (CredentialItem item : items) { + try { + get(uri, item); + } catch (PrompterException e) { + throw new IllegalStateException("Cannot prompt user", e); } } return true; } - private void get( URIish uri, CredentialItem item ) throws PrompterException - { - if ( item instanceof CredentialItem.InformationalMessage ) - { + private void get(URIish uri, CredentialItem item) throws PrompterException { + if (item instanceof CredentialItem.InformationalMessage) { // works even in non-interactive mode - prompter.showMessage( item.getPromptText() ); - } - else - { - if ( !interactive ) - { - throw new UnsupportedCredentialItem( uri, - "Cannot provide '" + item.getClass() + "' in non-interactive mode" ); + prompter.showMessage(item.getPromptText()); + } else { + if (!interactive) { + throw new UnsupportedCredentialItem( + uri, "Cannot provide '" + item.getClass() + "' in non-interactive mode"); } - if ( item instanceof CredentialItem.YesNoType ) - { - CredentialItem.YesNoType yesNoItem = ( CredentialItem.YesNoType ) item; - String value = prompter.prompt( item.getPromptText(), Arrays.asList( "yes", "no" ) ); - yesNoItem.setValue( value.equals( "yes" ) ); - } - else if ( item instanceof CredentialItem.Password ) - { - CredentialItem.Password passwordItem = ( CredentialItem.Password ) item; - String password = prompter.promptForPassword( passwordItem.getPromptText() ); - passwordItem.setValue( password.toCharArray() ); - } - else if ( item instanceof CredentialItem.Username ) - { - CredentialItem.Username usernameItem = ( CredentialItem.Username ) item; - String username = prompter.prompt( usernameItem.getPromptText() ); - usernameItem.setValue( username ); - } - else if ( item instanceof CredentialItem.StringType ) - { - CredentialItem.StringType stringItem = ( CredentialItem.StringType ) item; - String value = prompter.prompt( stringItem.getPromptText() ); - stringItem.setValue( value ); - } - else if ( item instanceof CredentialItem.CharArrayType ) - { - CredentialItem.CharArrayType charArrayItem = ( CredentialItem.CharArrayType ) item; - String value = prompter.prompt( charArrayItem.getPromptText() ); - charArrayItem.setValue( value.toCharArray() ); - } - else - { - throw new UnsupportedCredentialItem( uri, "This provider does not support items of type '" - + item.getClass() + "'" ); + if (item instanceof CredentialItem.YesNoType) { + CredentialItem.YesNoType yesNoItem = (CredentialItem.YesNoType) item; + String value = prompter.prompt(item.getPromptText(), Arrays.asList("yes", "no")); + yesNoItem.setValue(value.equals("yes")); + } else if (item instanceof CredentialItem.Password) { + CredentialItem.Password passwordItem = (CredentialItem.Password) item; + String password = prompter.promptForPassword(passwordItem.getPromptText()); + passwordItem.setValue(password.toCharArray()); + } else if (item instanceof CredentialItem.Username) { + CredentialItem.Username usernameItem = (CredentialItem.Username) item; + String username = prompter.prompt(usernameItem.getPromptText()); + usernameItem.setValue(username); + } else if (item instanceof CredentialItem.StringType) { + CredentialItem.StringType stringItem = (CredentialItem.StringType) item; + String value = prompter.prompt(stringItem.getPromptText()); + stringItem.setValue(value); + } else if (item instanceof CredentialItem.CharArrayType) { + CredentialItem.CharArrayType charArrayItem = (CredentialItem.CharArrayType) item; + String value = prompter.prompt(charArrayItem.getPromptText()); + charArrayItem.setValue(value.toCharArray()); + } else { + throw new UnsupportedCredentialItem( + uri, "This provider does not support items of type '" + item.getClass() + "'"); } } } - public void setInteractive( boolean interactive ) - { + public void setInteractive(boolean interactive) { this.interactive = interactive; } @Override - public boolean isInteractive() - { + public boolean isInteractive() { return interactive; } @Override - public boolean supports( CredentialItem... items ) - { + public boolean supports(CredentialItem... items) { return true; } - } diff --git a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-jgit/src/main/java/org/apache/maven/scm/provider/git/jgit/command/ScmProviderAwareSshdSessionFactory.java b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-jgit/src/main/java/org/apache/maven/scm/provider/git/jgit/command/ScmProviderAwareSshdSessionFactory.java index b5d247243..8fda08f00 100644 --- a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-jgit/src/main/java/org/apache/maven/scm/provider/git/jgit/command/ScmProviderAwareSshdSessionFactory.java +++ b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-jgit/src/main/java/org/apache/maven/scm/provider/git/jgit/command/ScmProviderAwareSshdSessionFactory.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.git.jgit.command; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider.git.jgit.command; import java.io.File; import java.io.IOException; @@ -39,54 +38,41 @@ * {@link SshdSessionFactory} considering the settings from {@link GitScmProviderRepository}. * */ -public class ScmProviderAwareSshdSessionFactory extends SshdSessionFactory -{ +public class ScmProviderAwareSshdSessionFactory extends SshdSessionFactory { private final GitScmProviderRepository repo; private final Logger logger; - public ScmProviderAwareSshdSessionFactory( GitScmProviderRepository repo, Logger logger ) - { + public ScmProviderAwareSshdSessionFactory(GitScmProviderRepository repo, Logger logger) { this.repo = repo; this.logger = logger; } @Override - protected List getDefaultIdentities( File sshDir ) - { - if ( !StringUtils.isEmptyOrNull( repo.getPrivateKey() ) ) - { - logger.debug( "Using private key at {}", repo.getPrivateKey() ); - return Collections.singletonList( Paths.get( repo.getPrivateKey() ) ); - } - else - { - return super.getDefaultIdentities( sshDir ); + protected List getDefaultIdentities(File sshDir) { + if (!StringUtils.isEmptyOrNull(repo.getPrivateKey())) { + logger.debug("Using private key at {}", repo.getPrivateKey()); + return Collections.singletonList(Paths.get(repo.getPrivateKey())); + } else { + return super.getDefaultIdentities(sshDir); } } @Override - protected KeyPasswordProvider createKeyPasswordProvider( CredentialsProvider provider ) - { - if ( repo.getPassphrase() != null ) - { - return new IdentityPasswordProvider( provider ) - { + protected KeyPasswordProvider createKeyPasswordProvider(CredentialsProvider provider) { + if (repo.getPassphrase() != null) { + return new IdentityPasswordProvider(provider) { @Override - public char[] getPassphrase( URIish uri, int attempt ) throws IOException - { - if ( attempt > 0 ) - { - throw new IOException( "Passphrase was not correct in first attempt, " - + "canceling further attempts!" ); + public char[] getPassphrase(URIish uri, int attempt) throws IOException { + if (attempt > 0) { + throw new IOException( + "Passphrase was not correct in first attempt, " + "canceling further attempts!"); } - logger.debug( "Using stored passphrase" ); + logger.debug("Using stored passphrase"); return repo.getPassphrase().toCharArray(); } }; - } - else - { - return super.createKeyPasswordProvider( provider ); + } else { + return super.createKeyPasswordProvider(provider); } } -} \ No newline at end of file +} diff --git a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-jgit/src/main/java/org/apache/maven/scm/provider/git/jgit/command/add/JGitAddCommand.java b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-jgit/src/main/java/org/apache/maven/scm/provider/git/jgit/command/add/JGitAddCommand.java index a234cb230..75396dd47 100644 --- a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-jgit/src/main/java/org/apache/maven/scm/provider/git/jgit/command/add/JGitAddCommand.java +++ b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-jgit/src/main/java/org/apache/maven/scm/provider/git/jgit/command/add/JGitAddCommand.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.git.jgit.command.add; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,9 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider.git.jgit.command.add; + +import java.util.List; import org.apache.maven.scm.ScmException; import org.apache.maven.scm.ScmFile; @@ -30,56 +31,39 @@ import org.apache.maven.scm.provider.git.jgit.command.JGitUtils; import org.eclipse.jgit.api.Git; -import java.util.List; - /** * @author Mark Struberg * @author Dominik Bartholdi (imod) * @since 1.9 */ -public class JGitAddCommand - extends AbstractAddCommand - implements GitCommand -{ +public class JGitAddCommand extends AbstractAddCommand implements GitCommand { /** * {@inheritDoc} */ - protected ScmResult executeAddCommand( ScmProviderRepository repo, ScmFileSet fileSet, String message, - boolean binary ) - throws ScmException - { + protected ScmResult executeAddCommand( + ScmProviderRepository repo, ScmFileSet fileSet, String message, boolean binary) throws ScmException { - if ( fileSet.getFileList().isEmpty() ) - { - throw new ScmException( "You must provide at least one file/directory to add (e.g. -Dincludes=...)" ); + if (fileSet.getFileList().isEmpty()) { + throw new ScmException("You must provide at least one file/directory to add (e.g. -Dincludes=...)"); } Git git = null; - try - { - git = JGitUtils.openRepo( fileSet.getBasedir() ); + try { + git = JGitUtils.openRepo(fileSet.getBasedir()); - List addedFiles = JGitUtils.addAllFiles( git, fileSet ); + List addedFiles = JGitUtils.addAllFiles(git, fileSet); - if ( logger.isDebugEnabled() ) - { - for ( ScmFile scmFile : addedFiles ) - { - logger.info( "added file: " + scmFile ); + if (logger.isDebugEnabled()) { + for (ScmFile scmFile : addedFiles) { + logger.info("added file: " + scmFile); } } - return new AddScmResult( "JGit add", addedFiles ); + return new AddScmResult("JGit add", addedFiles); + } catch (Exception e) { + throw new ScmException("JGit add failure!", e); + } finally { + JGitUtils.closeRepo(git); } - catch ( Exception e ) - { - throw new ScmException( "JGit add failure!", e ); - } - finally - { - JGitUtils.closeRepo( git ); - } - } - } diff --git a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-jgit/src/main/java/org/apache/maven/scm/provider/git/jgit/command/blame/JGitBlameCommand.java b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-jgit/src/main/java/org/apache/maven/scm/provider/git/jgit/command/blame/JGitBlameCommand.java index 4cdc0954c..d1ba02512 100644 --- a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-jgit/src/main/java/org/apache/maven/scm/provider/git/jgit/command/blame/JGitBlameCommand.java +++ b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-jgit/src/main/java/org/apache/maven/scm/provider/git/jgit/command/blame/JGitBlameCommand.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.git.jgit.command.blame; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,11 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider.git.jgit.command.blame; + +import java.io.File; +import java.util.ArrayList; +import java.util.List; import org.apache.maven.scm.ScmException; import org.apache.maven.scm.ScmFileSet; @@ -30,53 +33,38 @@ import org.eclipse.jgit.api.Git; import org.eclipse.jgit.blame.BlameResult; -import java.io.File; -import java.util.ArrayList; -import java.util.List; - /** * @author Dominik Bartholdi (imod) * @since 1.9 */ -public class JGitBlameCommand - extends AbstractBlameCommand - implements GitCommand -{ +public class JGitBlameCommand extends AbstractBlameCommand implements GitCommand { @Override - public BlameScmResult executeBlameCommand( ScmProviderRepository repo, ScmFileSet workingDirectory, - String filename ) - throws ScmException - { + public BlameScmResult executeBlameCommand(ScmProviderRepository repo, ScmFileSet workingDirectory, String filename) + throws ScmException { Git git = null; File basedir = workingDirectory.getBasedir(); - try - { - git = JGitUtils.openRepo( basedir ); - BlameResult blameResult = git.blame().setFilePath( filename ).call(); + try { + git = JGitUtils.openRepo(basedir); + BlameResult blameResult = git.blame().setFilePath(filename).call(); List lines = new ArrayList(); int i = 0; - while ( ( i = blameResult.computeNext() ) != -1 ) - { - lines.add( new BlameLine( blameResult.getSourceAuthor( i ).getWhen(), - blameResult.getSourceCommit( i ).getName(), - blameResult.getSourceAuthor( i ).getName(), - blameResult.getSourceCommitter( i ).getName() ) ); + while ((i = blameResult.computeNext()) != -1) { + lines.add(new BlameLine( + blameResult.getSourceAuthor(i).getWhen(), + blameResult.getSourceCommit(i).getName(), + blameResult.getSourceAuthor(i).getName(), + blameResult.getSourceCommitter(i).getName())); } - return new BlameScmResult( "JGit blame", lines ); - } - catch ( Exception e ) - { - throw new ScmException( "JGit blame failure!", e ); - } - finally - { - JGitUtils.closeRepo( git ); + return new BlameScmResult("JGit blame", lines); + } catch (Exception e) { + throw new ScmException("JGit blame failure!", e); + } finally { + JGitUtils.closeRepo(git); } } - } diff --git a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-jgit/src/main/java/org/apache/maven/scm/provider/git/jgit/command/branch/JGitBranchCommand.java b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-jgit/src/main/java/org/apache/maven/scm/provider/git/jgit/command/branch/JGitBranchCommand.java index b2a016adf..50de9ac0f 100644 --- a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-jgit/src/main/java/org/apache/maven/scm/provider/git/jgit/command/branch/JGitBranchCommand.java +++ b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-jgit/src/main/java/org/apache/maven/scm/provider/git/jgit/command/branch/JGitBranchCommand.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.git.jgit.command.branch; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,13 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider.git.jgit.command.branch; + +import java.util.ArrayList; +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; +import java.util.Set; import org.apache.maven.scm.ScmException; import org.apache.maven.scm.ScmFile; @@ -41,106 +46,80 @@ import org.eclipse.jgit.transport.RefSpec; import org.eclipse.jgit.treewalk.TreeWalk; -import java.util.ArrayList; -import java.util.HashSet; -import java.util.Iterator; -import java.util.List; -import java.util.Set; - /** * @author Dominik Bartholdi (imod) * @since 1.9 */ -public class JGitBranchCommand - extends AbstractBranchCommand - implements GitCommand -{ +public class JGitBranchCommand extends AbstractBranchCommand implements GitCommand { /** * {@inheritDoc} */ @Override - protected ScmResult executeBranchCommand( ScmProviderRepository repo, ScmFileSet fileSet, String branch, - String message ) - throws ScmException - { - if ( branch == null || StringUtils.isEmpty( branch.trim() ) ) - { - throw new ScmException( "branch name must be specified" ); + protected ScmResult executeBranchCommand( + ScmProviderRepository repo, ScmFileSet fileSet, String branch, String message) throws ScmException { + if (branch == null || StringUtils.isEmpty(branch.trim())) { + throw new ScmException("branch name must be specified"); } - if ( !fileSet.getFileList().isEmpty() ) - { - throw new ScmException( "This provider doesn't support branching subsets of a directory" ); + if (!fileSet.getFileList().isEmpty()) { + throw new ScmException("This provider doesn't support branching subsets of a directory"); } Git git = null; - try - { - git = JGitUtils.openRepo( fileSet.getBasedir() ); - Ref branchResult = git.branchCreate().setName( branch ).call(); - logger.info( "created [" + branchResult.getName() + "]" ); + try { + git = JGitUtils.openRepo(fileSet.getBasedir()); + Ref branchResult = git.branchCreate().setName(branch).call(); + logger.info("created [" + branchResult.getName() + "]"); - if ( logger.isDebugEnabled() ) - { - for ( String branchName : getShortLocalBranchNames( git ) ) - { - logger.debug( "local branch available: " + branchName ); + if (logger.isDebugEnabled()) { + for (String branchName : getShortLocalBranchNames(git)) { + logger.debug("local branch available: " + branchName); } } - if ( repo.isPushChanges() ) - { - logger.info( "push branch [" + branch + "] to remote..." ); - JGitUtils.push( git, (GitScmProviderRepository) repo, new RefSpec( Constants.R_HEADS - + branch ) ); + if (repo.isPushChanges()) { + logger.info("push branch [" + branch + "] to remote..."); + JGitUtils.push(git, (GitScmProviderRepository) repo, new RefSpec(Constants.R_HEADS + branch)); } // search for the tagged files - final RevWalk revWalk = new RevWalk( git.getRepository() ); - RevCommit commit = revWalk.parseCommit( branchResult.getObjectId() ); + final RevWalk revWalk = new RevWalk(git.getRepository()); + RevCommit commit = revWalk.parseCommit(branchResult.getObjectId()); revWalk.close(); - final TreeWalk walk = new TreeWalk( git.getRepository() ); + final TreeWalk walk = new TreeWalk(git.getRepository()); walk.reset(); // drop the first empty tree, which we do not need here - walk.setRecursive( true ); - walk.addTree( commit.getTree() ); + walk.setRecursive(true); + walk.addTree(commit.getTree()); List files = new ArrayList<>(); - while ( walk.next() ) - { - files.add( new ScmFile( walk.getPathString(), ScmFileStatus.CHECKED_OUT ) ); + while (walk.next()) { + files.add(new ScmFile(walk.getPathString(), ScmFileStatus.CHECKED_OUT)); } walk.close(); - return new BranchScmResult( "JGit branch", files ); + return new BranchScmResult("JGit branch", files); - } - catch ( Exception e ) - { - throw new ScmException( "JGit branch failed!", e ); - } - finally - { - JGitUtils.closeRepo( git ); + } catch (Exception e) { + throw new ScmException("JGit branch failed!", e); + } finally { + JGitUtils.closeRepo(git); } } /** * gets a set of names of the available branches in the given repo - * + * * @param git the repo to list the branches for * @return set of short branch names * @throws GitAPIException */ - public static Set getShortLocalBranchNames( Git git ) - throws GitAPIException - { + public static Set getShortLocalBranchNames(Git git) throws GitAPIException { Set branches = new HashSet<>(); Iterator iter = git.branchList().call().iterator(); - while ( iter.hasNext() ) - { - branches.add( Repository.shortenRefName( iter.next().getName() ) ); + while (iter.hasNext()) { + branches.add(Repository.shortenRefName(iter.next().getName())); } return branches; } diff --git a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-jgit/src/main/java/org/apache/maven/scm/provider/git/jgit/command/changelog/JGitChangeLogCommand.java b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-jgit/src/main/java/org/apache/maven/scm/provider/git/jgit/command/changelog/JGitChangeLogCommand.java index bf3df71e0..b32ae91d1 100644 --- a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-jgit/src/main/java/org/apache/maven/scm/provider/git/jgit/command/changelog/JGitChangeLogCommand.java +++ b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-jgit/src/main/java/org/apache/maven/scm/provider/git/jgit/command/changelog/JGitChangeLogCommand.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.git.jgit.command.changelog; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,13 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider.git.jgit.command.changelog; + +import java.io.File; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; import org.apache.maven.scm.ChangeSet; import org.apache.maven.scm.ScmBranch; @@ -37,12 +42,6 @@ import org.eclipse.jgit.revwalk.RevCommit; import org.eclipse.jgit.revwalk.RevSort; -import java.io.File; -import java.io.IOException; -import java.util.ArrayList; -import java.util.Date; -import java.util.List; - import static org.apache.maven.scm.provider.git.jgit.command.JGitUtils.getTags; /** @@ -50,159 +49,156 @@ * @author Dominik Bartholdi (imod) * @since 1.9 */ -public class JGitChangeLogCommand - extends AbstractChangeLogCommand - implements GitCommand -{ +public class JGitChangeLogCommand extends AbstractChangeLogCommand implements GitCommand { /** * {@inheritDoc} */ - protected ChangeLogScmResult executeChangeLogCommand( ScmProviderRepository repo, ScmFileSet fileSet, - ScmVersion startVersion, ScmVersion endVersion, - String datePattern ) - throws ScmException - { - return executeChangeLogCommand( repo, fileSet, null, null, null, datePattern, startVersion, endVersion ); + protected ChangeLogScmResult executeChangeLogCommand( + ScmProviderRepository repo, + ScmFileSet fileSet, + ScmVersion startVersion, + ScmVersion endVersion, + String datePattern) + throws ScmException { + return executeChangeLogCommand(repo, fileSet, null, null, null, datePattern, startVersion, endVersion); } @Override - protected ChangeLogScmResult executeChangeLogCommand( ScmProviderRepository repository, ScmFileSet fileSet, - ScmVersion version, String datePattern ) - throws ScmException - { - return executeChangeLogCommand( repository, fileSet, null, null, null, datePattern, null, null, version ); + protected ChangeLogScmResult executeChangeLogCommand( + ScmProviderRepository repository, ScmFileSet fileSet, ScmVersion version, String datePattern) + throws ScmException { + return executeChangeLogCommand(repository, fileSet, null, null, null, datePattern, null, null, version); } /** * {@inheritDoc} */ - protected ChangeLogScmResult executeChangeLogCommand( ScmProviderRepository repo, ScmFileSet fileSet, - Date startDate, Date endDate, ScmBranch branch, - String datePattern ) - throws ScmException - { - return executeChangeLogCommand( repo, fileSet, startDate, endDate, branch, datePattern, null, null ); + protected ChangeLogScmResult executeChangeLogCommand( + ScmProviderRepository repo, + ScmFileSet fileSet, + Date startDate, + Date endDate, + ScmBranch branch, + String datePattern) + throws ScmException { + return executeChangeLogCommand(repo, fileSet, startDate, endDate, branch, datePattern, null, null); } - protected ChangeLogScmResult executeChangeLogCommand( ScmProviderRepository repo, ScmFileSet fileSet, - Date startDate, Date endDate, ScmBranch branch, - String datePattern, ScmVersion startVersion, - ScmVersion endVersion ) - throws ScmException - { - return executeChangeLogCommand( repo, fileSet, startDate, endDate, branch, datePattern, - startVersion, endVersion, null ); + protected ChangeLogScmResult executeChangeLogCommand( + ScmProviderRepository repo, + ScmFileSet fileSet, + Date startDate, + Date endDate, + ScmBranch branch, + String datePattern, + ScmVersion startVersion, + ScmVersion endVersion) + throws ScmException { + return executeChangeLogCommand( + repo, fileSet, startDate, endDate, branch, datePattern, startVersion, endVersion, null); } - protected ChangeLogScmResult executeChangeLogCommand( ScmProviderRepository repo, ScmFileSet fileSet, - Date startDate, Date endDate, ScmBranch branch, - String datePattern, ScmVersion startVersion, - ScmVersion endVersion, ScmVersion version ) - throws ScmException - { + protected ChangeLogScmResult executeChangeLogCommand( + ScmProviderRepository repo, + ScmFileSet fileSet, + Date startDate, + Date endDate, + ScmBranch branch, + String datePattern, + ScmVersion startVersion, + ScmVersion endVersion, + ScmVersion version) + throws ScmException { Git git = null; boolean isARangeChangeLog = startVersion != null || endVersion != null; - try - { - git = JGitUtils.openRepo( fileSet.getBasedir() ); + try { + git = JGitUtils.openRepo(fileSet.getBasedir()); boolean versionOnly = startVersion == null && endVersion == null && version != null; String startRev; String endRev; - if ( versionOnly ) - { + if (versionOnly) { startRev = null; endRev = version.getName(); - } - else - { - startRev = startVersion != null ? startVersion.getName() : ( isARangeChangeLog ? "HEAD" : null ); - endRev = endVersion != null ? endVersion.getName() : ( isARangeChangeLog ? "HEAD" : null ); + } else { + startRev = startVersion != null ? startVersion.getName() : (isARangeChangeLog ? "HEAD" : null); + endRev = endVersion != null ? endVersion.getName() : (isARangeChangeLog ? "HEAD" : null); } List gitChanges = - this.whatchanged( git.getRepository(), null, startRev, endRev, startDate, endDate, -1 ); + this.whatchanged(git.getRepository(), null, startRev, endRev, startDate, endDate, -1); - List modifications = new ArrayList<>( gitChanges.size() ); + List modifications = new ArrayList<>(gitChanges.size()); - for ( ChangeEntry change : gitChanges ) - { + for (ChangeEntry change : gitChanges) { ChangeSet scmChange = new ChangeSet(); - scmChange.setAuthor( change.getAuthorName() ); - scmChange.setComment( change.getBody() ); - scmChange.setDate( change.getAuthorDate() ); - scmChange.setRevision( change.getCommitHash() ); - scmChange.setTags( change.getTags() ); + scmChange.setAuthor(change.getAuthorName()); + scmChange.setComment(change.getBody()); + scmChange.setDate(change.getAuthorDate()); + scmChange.setRevision(change.getCommitHash()); + scmChange.setTags(change.getTags()); // X TODO scmChange.setFiles( change.get ) - modifications.add( scmChange ); + modifications.add(scmChange); } - ChangeLogSet changeLogSet = new ChangeLogSet( modifications, startDate, endDate ); - changeLogSet.setStartVersion( startVersion ); - changeLogSet.setEndVersion( endVersion ); + ChangeLogSet changeLogSet = new ChangeLogSet(modifications, startDate, endDate); + changeLogSet.setStartVersion(startVersion); + changeLogSet.setEndVersion(endVersion); - return new ChangeLogScmResult( "JGit changelog", changeLogSet ); - } - catch ( Exception e ) - { - throw new ScmException( "JGit changelog failure!", e ); - } - finally - { - JGitUtils.closeRepo( git ); + return new ChangeLogScmResult("JGit changelog", changeLogSet); + } catch (Exception e) { + throw new ScmException("JGit changelog failure!", e); + } finally { + JGitUtils.closeRepo(git); } } - public List whatchanged( Repository repo, RevSort[] sortings, String fromRev, String toRev, - Date fromDate, Date toDate, int maxLines ) - throws MissingObjectException, IncorrectObjectTypeException, IOException - { - List revs = JGitUtils.getRevCommits( repo, sortings, fromRev, toRev, fromDate, toDate, maxLines ); - List changes = new ArrayList<>( revs.size() ); + public List whatchanged( + Repository repo, RevSort[] sortings, String fromRev, String toRev, Date fromDate, Date toDate, int maxLines) + throws MissingObjectException, IncorrectObjectTypeException, IOException { + List revs = JGitUtils.getRevCommits(repo, sortings, fromRev, toRev, fromDate, toDate, maxLines); + List changes = new ArrayList<>(revs.size()); - if ( fromRev != null && fromRev.equals( toRev ) ) - { + if (fromRev != null && fromRev.equals(toRev)) { // there are no changes between 2 identical versions return changes; } - for ( RevCommit c : revs ) - { + for (RevCommit c : revs) { ChangeEntry ce = new ChangeEntry(); - ce.setAuthorDate( c.getAuthorIdent().getWhen() ); - ce.setAuthorEmail( c.getAuthorIdent().getEmailAddress() ); - ce.setAuthorName( c.getAuthorIdent().getName() ); - ce.setCommitterDate( c.getCommitterIdent().getWhen() ); - ce.setCommitterEmail( c.getCommitterIdent().getEmailAddress() ); - ce.setCommitterName( c.getCommitterIdent().getName() ); + ce.setAuthorDate(c.getAuthorIdent().getWhen()); + ce.setAuthorEmail(c.getAuthorIdent().getEmailAddress()); + ce.setAuthorName(c.getAuthorIdent().getName()); + ce.setCommitterDate(c.getCommitterIdent().getWhen()); + ce.setCommitterEmail(c.getCommitterIdent().getEmailAddress()); + ce.setCommitterName(c.getCommitterIdent().getName()); - ce.setSubject( c.getShortMessage() ); - ce.setBody( c.getFullMessage() ); + ce.setSubject(c.getShortMessage()); + ce.setBody(c.getFullMessage()); - ce.setCommitHash( c.getId().name() ); - ce.setTreeHash( c.getTree().getId().name() ); + ce.setCommitHash(c.getId().name()); + ce.setTreeHash(c.getTree().getId().name()); - ce.setTags( getTags( repo, c ) ); + ce.setTags(getTags(repo, c)); // X TODO missing: file list - changes.add( ce ); + changes.add(ce); } return changes; } /** - * + * */ - public static final class ChangeEntry - { + public static final class ChangeEntry { private String commitHash; private String treeHash; @@ -224,126 +220,102 @@ public static final class ChangeEntry private String body; private List files; - + private List tags; - public String getCommitHash() - { + public String getCommitHash() { return commitHash; } - public void setCommitHash( String commitHash ) - { + public void setCommitHash(String commitHash) { this.commitHash = commitHash; } - public String getTreeHash() - { + public String getTreeHash() { return treeHash; } - public void setTreeHash( String treeHash ) - { + public void setTreeHash(String treeHash) { this.treeHash = treeHash; } - public String getAuthorName() - { + public String getAuthorName() { return authorName; } - public void setAuthorName( String authorName ) - { + public void setAuthorName(String authorName) { this.authorName = authorName; } - public String getAuthorEmail() - { + public String getAuthorEmail() { return authorEmail; } - public void setAuthorEmail( String authorEmail ) - { + public void setAuthorEmail(String authorEmail) { this.authorEmail = authorEmail; } - public Date getAuthorDate() - { + public Date getAuthorDate() { return authorDate; } - public void setAuthorDate( Date authorDate ) - { + public void setAuthorDate(Date authorDate) { this.authorDate = authorDate; } - public String getCommitterName() - { + public String getCommitterName() { return committerName; } - public void setCommitterName( String committerName ) - { + public void setCommitterName(String committerName) { this.committerName = committerName; } - public String getCommitterEmail() - { + public String getCommitterEmail() { return committerEmail; } - public void setCommitterEmail( String committerEmail ) - { + public void setCommitterEmail(String committerEmail) { this.committerEmail = committerEmail; } - public Date getCommitterDate() - { + public Date getCommitterDate() { return committerDate; } - public void setCommitterDate( Date committerDate ) - { + public void setCommitterDate(Date committerDate) { this.committerDate = committerDate; } - public String getSubject() - { + public String getSubject() { return subject; } - public void setSubject( String subject ) - { + public void setSubject(String subject) { this.subject = subject; } - public String getBody() - { + public String getBody() { return body; } - public void setBody( String body ) - { + public void setBody(String body) { this.body = body; } - public List getFiles() - { + public List getFiles() { return files; } - public void setFiles( List files ) - { + public void setFiles(List files) { this.files = files; } - public List getTags() - { + public List getTags() { return tags; } - public void setTags( List tags ) - { + public void setTags(List tags) { this.tags = tags; } } diff --git a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-jgit/src/main/java/org/apache/maven/scm/provider/git/jgit/command/checkin/JGitCheckInCommand.java b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-jgit/src/main/java/org/apache/maven/scm/provider/git/jgit/command/checkin/JGitCheckInCommand.java index cedfd0314..535dd67e8 100644 --- a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-jgit/src/main/java/org/apache/maven/scm/provider/git/jgit/command/checkin/JGitCheckInCommand.java +++ b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-jgit/src/main/java/org/apache/maven/scm/provider/git/jgit/command/checkin/JGitCheckInCommand.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.git.jgit.command.checkin; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,14 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider.git.jgit.command.checkin; + +import java.io.File; +import java.net.InetAddress; +import java.net.UnknownHostException; +import java.util.Collections; +import java.util.List; +import java.util.Set; import org.apache.maven.scm.ScmException; import org.apache.maven.scm.ScmFile; @@ -39,13 +45,6 @@ import org.eclipse.jgit.revwalk.RevCommit; import org.eclipse.jgit.transport.RefSpec; -import java.io.File; -import java.net.InetAddress; -import java.net.UnknownHostException; -import java.util.Collections; -import java.util.List; -import java.util.Set; - /** * This provider uses the following strategy to discover the committer and author name/mail for a commit: *
    @@ -58,15 +57,12 @@ * git config --global maven-scm.maildomain mycomp.com
    * you can also enforce the usage of the username for the author and committer:
    * git config --global maven-scm.forceUsername true
    - * + * * @author Mark Struberg * @author Dominik Bartholdi (imod) * @since 1.9 */ -public class JGitCheckInCommand - extends AbstractCheckInCommand - implements GitCommand -{ +public class JGitCheckInCommand extends AbstractCheckInCommand implements GitCommand { protected static final String GIT_MAVEN_SECTION = "maven-scm"; @@ -77,55 +73,41 @@ public class JGitCheckInCommand /** * {@inheritDoc} */ - protected CheckInScmResult executeCheckInCommand( ScmProviderRepository repo, ScmFileSet fileSet, String message, - ScmVersion version ) - throws ScmException - { + protected CheckInScmResult executeCheckInCommand( + ScmProviderRepository repo, ScmFileSet fileSet, String message, ScmVersion version) throws ScmException { Git git = null; - try - { + try { File basedir = fileSet.getBasedir(); - git = JGitUtils.openRepo( basedir ); + git = JGitUtils.openRepo(basedir); boolean doCommit = false; - if ( !fileSet.getFileList().isEmpty() ) - { + if (!fileSet.getFileList().isEmpty()) { // add files first - doCommit = JGitUtils.addAllFiles( git, fileSet ).size() > 0; - if ( !doCommit ) - { + doCommit = JGitUtils.addAllFiles(git, fileSet).size() > 0; + if (!doCommit) { doCommit = git.status().call().hasUncommittedChanges(); } - } - else - { + } else { // add all tracked files which are modified manually Status status = git.status().call(); Set changeds = git.status().call().getModified(); - if ( changeds.isEmpty() ) - { - if ( !status.hasUncommittedChanges() ) - { + if (changeds.isEmpty()) { + if (!status.hasUncommittedChanges()) { // warn there is nothing to add - logger.warn( "There are neither files to be added nor any uncommitted changes" ); + logger.warn("There are neither files to be added nor any uncommitted changes"); doCommit = false; - } - else - { - logger.debug( "There are uncommitted changes in the git index" ); + } else { + logger.debug("There are uncommitted changes in the git index"); doCommit = true; } - } - else - { + } else { // TODO: gitexe only adds if fileSet is not empty AddCommand add = git.add(); - for ( String changed : changeds ) - { - logger.debug( "Add manually: {}", changed ); - add.addFilepattern( changed ); + for (String changed : changeds) { + logger.debug("Add manually: {}", changed); + add.addFilepattern(changed); doCommit = true; } add.call(); @@ -133,167 +115,140 @@ protected CheckInScmResult executeCheckInCommand( ScmProviderRepository repo, Sc } List checkedInFiles = Collections.emptyList(); - if ( doCommit ) - { - UserInfo author = getAuthor( repo, git ); - UserInfo committer = getCommitter( repo, git ); + if (doCommit) { + UserInfo author = getAuthor(repo, git); + UserInfo committer = getCommitter(repo, git); - CommitCommand command = git.commit().setMessage( message ).setAuthor( author.name, author.email ); - command.setCommitter( committer.name, committer.email ); + CommitCommand command = git.commit().setMessage(message).setAuthor(author.name, author.email); + command.setCommitter(committer.name, committer.email); RevCommit commitRev = command.call(); - logger.info( "commit done: " + commitRev.getShortMessage() ); - checkedInFiles = JGitUtils.getFilesInCommit( git.getRepository(), commitRev, fileSet.getBasedir() ); - if ( logger.isDebugEnabled() ) - { - for ( ScmFile scmFile : checkedInFiles ) - { - logger.debug( "in commit: " + scmFile ); + logger.info("commit done: " + commitRev.getShortMessage()); + checkedInFiles = JGitUtils.getFilesInCommit(git.getRepository(), commitRev, fileSet.getBasedir()); + if (logger.isDebugEnabled()) { + for (ScmFile scmFile : checkedInFiles) { + logger.debug("in commit: " + scmFile); } } } - if ( repo.isPushChanges() ) - { + if (repo.isPushChanges()) { String branch = version != null ? version.getName() : null; - if ( StringUtils.isBlank( branch ) ) - { + if (StringUtils.isBlank(branch)) { branch = git.getRepository().getBranch(); } - RefSpec refSpec = new RefSpec( Constants.R_HEADS + branch + ":" + Constants.R_HEADS + branch ); - logger.info( "push changes to remote... " + refSpec ); - JGitUtils.push( git, (GitScmProviderRepository) repo, refSpec ); + RefSpec refSpec = new RefSpec(Constants.R_HEADS + branch + ":" + Constants.R_HEADS + branch); + logger.info("push changes to remote... " + refSpec); + JGitUtils.push(git, (GitScmProviderRepository) repo, refSpec); } - return new CheckInScmResult( "JGit checkin", checkedInFiles ); - } - catch ( Exception e ) - { - throw new ScmException( "JGit checkin failure!", e ); - } - finally - { - JGitUtils.closeRepo( git ); + return new CheckInScmResult("JGit checkin", checkedInFiles); + } catch (Exception e) { + throw new ScmException("JGit checkin failure!", e); + } finally { + JGitUtils.closeRepo(git); } } - private static final class UserInfo - { + private static final class UserInfo { final String name; final String email; - UserInfo( String name, String email ) - { + UserInfo(String name, String email) { this.name = name; this.email = email; } } - private UserInfo getCommitter( ScmProviderRepository repo, Git git ) - { - boolean forceMvnUser = git.getRepository().getConfig().getBoolean( GIT_MAVEN_SECTION, GIT_FORCE, false ); + private UserInfo getCommitter(ScmProviderRepository repo, Git git) { + boolean forceMvnUser = git.getRepository().getConfig().getBoolean(GIT_MAVEN_SECTION, GIT_FORCE, false); // git config - UserConfig user = git.getRepository().getConfig().get( UserConfig.KEY ); + UserConfig user = git.getRepository().getConfig().get(UserConfig.KEY); String committerName = null; - if ( !forceMvnUser && !user.isCommitterNameImplicit() ) - { + if (!forceMvnUser && !user.isCommitterNameImplicit()) { committerName = user.getCommitterName(); } // mvn parameter - if ( StringUtils.isBlank( committerName ) ) - { + if (StringUtils.isBlank(committerName)) { committerName = repo.getUser(); } // git default - if ( StringUtils.isBlank( committerName ) ) - { + if (StringUtils.isBlank(committerName)) { committerName = user.getCommitterName(); } // git config String committerMail = null; - if ( !user.isCommitterEmailImplicit() ) - { + if (!user.isCommitterEmailImplicit()) { committerMail = user.getCommitterEmail(); } - if ( StringUtils.isBlank( committerMail ) ) - { - String defaultDomain = git.getRepository().getConfig().getString( GIT_MAVEN_SECTION, null, GIT_MAILDOMAIN ); - defaultDomain = StringUtils.isNotBlank( defaultDomain ) ? defaultDomain : getHostname(); + if (StringUtils.isBlank(committerMail)) { + String defaultDomain = git.getRepository().getConfig().getString(GIT_MAVEN_SECTION, null, GIT_MAILDOMAIN); + defaultDomain = StringUtils.isNotBlank(defaultDomain) ? defaultDomain : getHostname(); // mvn parameter (constructed with username) or git default - committerMail = - StringUtils.isNotBlank( repo.getUser() ) ? repo.getUser() + "@" + defaultDomain - : user.getCommitterEmail(); + committerMail = StringUtils.isNotBlank(repo.getUser()) + ? repo.getUser() + "@" + defaultDomain + : user.getCommitterEmail(); } - return new UserInfo( committerName, committerMail ); + return new UserInfo(committerName, committerMail); } - private UserInfo getAuthor( ScmProviderRepository repo, Git git ) - { - boolean forceMvnUser = git.getRepository().getConfig().getBoolean( GIT_MAVEN_SECTION, GIT_FORCE, false ); + private UserInfo getAuthor(ScmProviderRepository repo, Git git) { + boolean forceMvnUser = git.getRepository().getConfig().getBoolean(GIT_MAVEN_SECTION, GIT_FORCE, false); // git config - UserConfig user = git.getRepository().getConfig().get( UserConfig.KEY ); + UserConfig user = git.getRepository().getConfig().get(UserConfig.KEY); String authorName = null; - if ( !forceMvnUser && !user.isAuthorNameImplicit() ) - { + if (!forceMvnUser && !user.isAuthorNameImplicit()) { authorName = user.getAuthorName(); } // mvn parameter - if ( StringUtils.isBlank( authorName ) ) - { + if (StringUtils.isBlank(authorName)) { authorName = repo.getUser(); } // git default - if ( StringUtils.isBlank( authorName ) ) - { + if (StringUtils.isBlank(authorName)) { authorName = user.getAuthorName(); } // git config String authorMail = null; - if ( !user.isAuthorEmailImplicit() ) - { + if (!user.isAuthorEmailImplicit()) { authorMail = user.getAuthorEmail(); } - if ( StringUtils.isBlank( authorMail ) ) - { - String defaultDomain = git.getRepository().getConfig().getString( GIT_MAVEN_SECTION, null, GIT_MAILDOMAIN ); - defaultDomain = StringUtils.isNotBlank( defaultDomain ) ? defaultDomain : getHostname(); + if (StringUtils.isBlank(authorMail)) { + String defaultDomain = git.getRepository().getConfig().getString(GIT_MAVEN_SECTION, null, GIT_MAILDOMAIN); + defaultDomain = StringUtils.isNotBlank(defaultDomain) ? defaultDomain : getHostname(); // mvn parameter (constructed with username) or git default - authorMail = - StringUtils.isNotBlank( repo.getUser() ) ? repo.getUser() + "@" + defaultDomain : user.getAuthorEmail(); + authorMail = StringUtils.isNotBlank(repo.getUser()) + ? repo.getUser() + "@" + defaultDomain + : user.getAuthorEmail(); } - return new UserInfo( authorName, authorMail ); + return new UserInfo(authorName, authorMail); } - private String getHostname() - { + private String getHostname() { String hostname; - try - { + try { InetAddress localhost = java.net.InetAddress.getLocalHost(); hostname = localhost.getHostName(); - } - catch ( UnknownHostException e ) - { - logger.warn( "failed to resolve hostname to create mail address, " - + "defaulting to 'maven-scm-provider-jgit'" ); + } catch (UnknownHostException e) { + logger.warn( + "failed to resolve hostname to create mail address, " + "defaulting to 'maven-scm-provider-jgit'"); hostname = "maven-scm-provider-jgit"; } return hostname; } - } diff --git a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-jgit/src/main/java/org/apache/maven/scm/provider/git/jgit/command/checkout/JGitCheckOutCommand.java b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-jgit/src/main/java/org/apache/maven/scm/provider/git/jgit/command/checkout/JGitCheckOutCommand.java index a701ccd91..6ce820d1f 100644 --- a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-jgit/src/main/java/org/apache/maven/scm/provider/git/jgit/command/checkout/JGitCheckOutCommand.java +++ b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-jgit/src/main/java/org/apache/maven/scm/provider/git/jgit/command/checkout/JGitCheckOutCommand.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.git.jgit.command.checkout; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ - +package org.apache.maven.scm.provider.git.jgit.command.checkout; import java.io.File; import java.util.ArrayList; @@ -63,20 +61,16 @@ * @author Dominik Bartholdi (imod) * @since 1.9 */ -public class JGitCheckOutCommand - extends AbstractCheckOutCommand - implements GitCommand -{ +public class JGitCheckOutCommand extends AbstractCheckOutCommand implements GitCommand { private BiFunction sshSessionFactorySupplier; - public JGitCheckOutCommand() - { + public JGitCheckOutCommand() { sshSessionFactorySupplier = ScmProviderAwareSshdSessionFactory::new; } public void setSshSessionFactorySupplier( - BiFunction sshSessionFactorySupplier ) - { + BiFunction + sshSessionFactorySupplier) { this.sshSessionFactorySupplier = sshSessionFactorySupplier; } @@ -86,148 +80,135 @@ public void setSshSessionFactorySupplier( *

    * {@inheritDoc} */ - protected CheckOutScmResult executeCheckOutCommand( ScmProviderRepository repo, ScmFileSet fileSet, - ScmVersion version, boolean recursive, boolean shallow ) - throws ScmException - { + protected CheckOutScmResult executeCheckOutCommand( + ScmProviderRepository repo, ScmFileSet fileSet, ScmVersion version, boolean recursive, boolean shallow) + throws ScmException { GitScmProviderRepository repository = (GitScmProviderRepository) repo; - if ( GitScmProviderRepository.PROTOCOL_FILE.equals( repository.getFetchInfo().getProtocol() ) - && repository.getFetchInfo().getPath().indexOf( fileSet.getBasedir().getPath() ) >= 0 ) - { - throw new ScmException( "remote repository must not be the working directory" ); + if (GitScmProviderRepository.PROTOCOL_FILE.equals( + repository.getFetchInfo().getProtocol()) + && repository + .getFetchInfo() + .getPath() + .indexOf(fileSet.getBasedir().getPath()) + >= 0) { + throw new ScmException("remote repository must not be the working directory"); } Git git = null; - try - { + try { ProgressMonitor monitor = JGitUtils.getMonitor(); String branch = version != null ? version.getName() : null; - if ( StringUtils.isBlank( branch ) ) - { + if (StringUtils.isBlank(branch)) { branch = Constants.MASTER; } TransportConfigCallback transportConfigCallback = new JGitTransportConfigCallback( - sshSessionFactorySupplier.apply( (GitScmProviderRepository) repo, logger ) ); + sshSessionFactorySupplier.apply((GitScmProviderRepository) repo, logger)); - logger.debug( "try checkout of branch: " + branch ); + logger.debug("try checkout of branch: " + branch); - if ( !fileSet.getBasedir().exists() || !( new File( fileSet.getBasedir(), ".git" ).exists() ) ) - { - if ( fileSet.getBasedir().exists() ) - { + if (!fileSet.getBasedir().exists() || !(new File(fileSet.getBasedir(), ".git").exists())) { + if (fileSet.getBasedir().exists()) { // git refuses to clone otherwise fileSet.getBasedir().delete(); } // FIXME only if windauze WindowCacheConfig cfg = new WindowCacheConfig(); - cfg.setPackedGitMMAP( false ); + cfg.setPackedGitMMAP(false); cfg.install(); // no git repo seems to exist, let's clone the original repo - CredentialsProvider credentials = JGitUtils.getCredentials( (GitScmProviderRepository) repo ); - logger.info( "cloning [" + branch + "] to " + fileSet.getBasedir() ); - CloneCommand command = Git.cloneRepository().setURI( repository.getFetchUrl() ); + CredentialsProvider credentials = JGitUtils.getCredentials((GitScmProviderRepository) repo); + logger.info("cloning [" + branch + "] to " + fileSet.getBasedir()); + CloneCommand command = Git.cloneRepository().setURI(repository.getFetchUrl()); - command.setCredentialsProvider( credentials ).setBranch( branch ).setDirectory( fileSet.getBasedir() ); + command.setCredentialsProvider(credentials).setBranch(branch).setDirectory(fileSet.getBasedir()); - command.setTransportConfigCallback( transportConfigCallback ); + command.setTransportConfigCallback(transportConfigCallback); - command.setProgressMonitor( monitor ); + command.setProgressMonitor(monitor); git = command.call(); } JGitRemoteInfoCommand remoteInfoCommand = new JGitRemoteInfoCommand(); - remoteInfoCommand.setSshSessionFactorySupplier( sshSessionFactorySupplier ); - RemoteInfoScmResult result = remoteInfoCommand.executeRemoteInfoCommand( repository, fileSet, null ); + remoteInfoCommand.setSshSessionFactorySupplier(sshSessionFactorySupplier); + RemoteInfoScmResult result = remoteInfoCommand.executeRemoteInfoCommand(repository, fileSet, null); - if ( git == null ) - { + if (git == null) { // deliberately not using JGitUtils.openRepo(), the caller told us exactly where to checkout - git = Git.open( fileSet.getBasedir() ); + git = Git.open(fileSet.getBasedir()); } - if ( fileSet.getBasedir().exists() && new File( fileSet.getBasedir(), ".git" ).exists() - && result.getBranches().size() > 0 ) - { + if (fileSet.getBasedir().exists() + && new File(fileSet.getBasedir(), ".git").exists() + && result.getBranches().size() > 0) { // git repo exists, so we must git-pull the changes - CredentialsProvider credentials = JGitUtils.prepareSession( git, repository ); + CredentialsProvider credentials = JGitUtils.prepareSession(git, repository); - if ( version != null && StringUtils.isNotEmpty( version.getName() ) && ( version instanceof ScmTag ) ) - { + if (version != null && StringUtils.isNotEmpty(version.getName()) && (version instanceof ScmTag)) { // A tag will not be pulled but we only fetch all the commits from the upstream repo // This is done because checking out a tag might not happen on the current branch // but create a 'detached HEAD'. // In fact, a tag in git may be in multiple branches. This occurs if // you create a branch after the tag has been created - logger.debug( "fetch..." ); - FetchCommand command = git.fetch().setCredentialsProvider( credentials ) - .setProgressMonitor( monitor ); - command.setTransportConfigCallback( transportConfigCallback ); + logger.debug("fetch..."); + FetchCommand command = + git.fetch().setCredentialsProvider(credentials).setProgressMonitor(monitor); + command.setTransportConfigCallback(transportConfigCallback); command.call(); - } - else - { - logger.debug( "pull..." ); - PullCommand command = git.pull().setCredentialsProvider( credentials ) - .setProgressMonitor( monitor ); - command.setTransportConfigCallback( transportConfigCallback ); + } else { + logger.debug("pull..."); + PullCommand command = + git.pull().setCredentialsProvider(credentials).setProgressMonitor(monitor); + command.setTransportConfigCallback(transportConfigCallback); command.call(); } } - Set localBranchNames = JGitBranchCommand.getShortLocalBranchNames( git ); - if ( version instanceof ScmTag ) - { - logger.info( "checkout tag [" + branch + "] at " + fileSet.getBasedir() ); - git.checkout().setName( branch ).call(); - } - else if ( localBranchNames.contains( branch ) ) - { - logger.info( "checkout [" + branch + "] at " + fileSet.getBasedir() ); - git.checkout().setName( branch ).call(); - } - else - { - logger.info( "checkout remote branch [" + branch + "] at " + fileSet.getBasedir() ); - git.checkout().setName( branch ).setCreateBranch( true ).setStartPoint( Constants.DEFAULT_REMOTE_NAME - + "/" + branch ).call(); + Set localBranchNames = JGitBranchCommand.getShortLocalBranchNames(git); + if (version instanceof ScmTag) { + logger.info("checkout tag [" + branch + "] at " + fileSet.getBasedir()); + git.checkout().setName(branch).call(); + } else if (localBranchNames.contains(branch)) { + logger.info("checkout [" + branch + "] at " + fileSet.getBasedir()); + git.checkout().setName(branch).call(); + } else { + logger.info("checkout remote branch [" + branch + "] at " + fileSet.getBasedir()); + git.checkout() + .setName(branch) + .setCreateBranch(true) + .setStartPoint(Constants.DEFAULT_REMOTE_NAME + "/" + branch) + .call(); } - RevWalk revWalk = new RevWalk( git.getRepository() ); - RevCommit commit = revWalk.parseCommit( git.getRepository().resolve( Constants.HEAD ) ); + RevWalk revWalk = new RevWalk(git.getRepository()); + RevCommit commit = revWalk.parseCommit(git.getRepository().resolve(Constants.HEAD)); revWalk.close(); - final TreeWalk walk = new TreeWalk( git.getRepository() ); + final TreeWalk walk = new TreeWalk(git.getRepository()); walk.reset(); // drop the first empty tree, which we do not need here - walk.setRecursive( true ); - walk.addTree( commit.getTree() ); + walk.setRecursive(true); + walk.addTree(commit.getTree()); List listedFiles = new ArrayList<>(); - while ( walk.next() ) - { - listedFiles.add( new ScmFile( walk.getPathString(), ScmFileStatus.CHECKED_OUT ) ); + while (walk.next()) { + listedFiles.add(new ScmFile(walk.getPathString(), ScmFileStatus.CHECKED_OUT)); } walk.close(); - logger.debug( "current branch: " + git.getRepository().getBranch() ); + logger.debug("current branch: " + git.getRepository().getBranch()); - return new CheckOutScmResult( "checkout via JGit", listedFiles ); - } - catch ( Exception e ) - { - throw new ScmException( "JGit checkout failure!", e ); - } - finally - { - JGitUtils.closeRepo( git ); + return new CheckOutScmResult("checkout via JGit", listedFiles); + } catch (Exception e) { + throw new ScmException("JGit checkout failure!", e); + } finally { + JGitUtils.closeRepo(git); } } - } diff --git a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-jgit/src/main/java/org/apache/maven/scm/provider/git/jgit/command/diff/JGitDiffCommand.java b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-jgit/src/main/java/org/apache/maven/scm/provider/git/jgit/command/diff/JGitDiffCommand.java index 38ba75850..8fe64572c 100644 --- a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-jgit/src/main/java/org/apache/maven/scm/provider/git/jgit/command/diff/JGitDiffCommand.java +++ b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-jgit/src/main/java/org/apache/maven/scm/provider/git/jgit/command/diff/JGitDiffCommand.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.git.jgit.command.diff; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,11 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider.git.jgit.command.diff; + +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.OutputStream; import org.apache.maven.scm.ScmException; import org.apache.maven.scm.ScmFileSet; @@ -38,96 +41,86 @@ import org.eclipse.jgit.treewalk.AbstractTreeIterator; import org.eclipse.jgit.treewalk.CanonicalTreeParser; -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.OutputStream; - /** * @author Dominik Bartholdi (imod) * @since 1.9 */ -public class JGitDiffCommand - extends AbstractDiffCommand - implements GitCommand -{ +public class JGitDiffCommand extends AbstractDiffCommand implements GitCommand { @Override - protected DiffScmResult executeDiffCommand( ScmProviderRepository repository, ScmFileSet fileSet, - ScmVersion startRevision, ScmVersion endRevision ) - throws ScmException - { + protected DiffScmResult executeDiffCommand( + ScmProviderRepository repository, ScmFileSet fileSet, ScmVersion startRevision, ScmVersion endRevision) + throws ScmException { Git git = null; - try - { - git = JGitUtils.openRepo( fileSet.getBasedir() ); - DiffScmResult diff = callDiff( git, startRevision, endRevision ); + try { + git = JGitUtils.openRepo(fileSet.getBasedir()); + DiffScmResult diff = callDiff(git, startRevision, endRevision); git.getRepository().close(); return diff; - } - catch ( Exception e ) - { - throw new ScmException( "JGit diff failure!", e ); - } - finally - { - JGitUtils.closeRepo( git ); + } catch (Exception e) { + throw new ScmException("JGit diff failure!", e); + } finally { + JGitUtils.closeRepo(git); } } - public DiffScmResult callDiff( Git git, ScmVersion startRevision, ScmVersion endRevision ) - throws IOException, GitAPIException, ScmException - { + public DiffScmResult callDiff(Git git, ScmVersion startRevision, ScmVersion endRevision) + throws IOException, GitAPIException, ScmException { AbstractTreeIterator oldTree = null; - if ( startRevision != null && StringUtils.isNotEmpty( startRevision.getName().trim() ) ) - { + if (startRevision != null + && StringUtils.isNotEmpty(startRevision.getName().trim())) { String startRev = startRevision.getName().trim(); - oldTree = getTreeIterator( git.getRepository(), startRev ); + oldTree = getTreeIterator(git.getRepository(), startRev); } AbstractTreeIterator newTree = null; - if ( endRevision != null && StringUtils.isNotEmpty( endRevision.getName().trim() ) ) - { + if (endRevision != null && StringUtils.isNotEmpty(endRevision.getName().trim())) { String endRev = endRevision.getName().trim(); - newTree = getTreeIterator( git.getRepository(), endRev ); + newTree = getTreeIterator(git.getRepository(), endRev); } OutputStream out = new ByteArrayOutputStream(); - git.diff().setOutputStream( out ).setOldTree( oldTree ).setNewTree( newTree ).setCached( false ).call(); - git.diff().setOutputStream( out ).setOldTree( oldTree ).setNewTree( newTree ).setCached( true ).call(); + git.diff() + .setOutputStream(out) + .setOldTree(oldTree) + .setNewTree(newTree) + .setCached(false) + .call(); + git.diff() + .setOutputStream(out) + .setOldTree(oldTree) + .setNewTree(newTree) + .setCached(true) + .call(); out.flush(); - GitDiffConsumer consumer = new GitDiffConsumer( null ); + GitDiffConsumer consumer = new GitDiffConsumer(null); String fullDiff = out.toString(); out.close(); - String[] lines = fullDiff.split( "\n" ); - for ( String aLine : lines ) - { - consumer.consumeLine( aLine ); + String[] lines = fullDiff.split("\n"); + for (String aLine : lines) { + consumer.consumeLine(aLine); } - return new DiffScmResult( "JGit diff", consumer.getChangedFiles(), consumer.getDifferences(), - consumer.getPatch() ); + return new DiffScmResult( + "JGit diff", consumer.getChangedFiles(), consumer.getDifferences(), consumer.getPatch()); } - private AbstractTreeIterator getTreeIterator( Repository repo, String name ) - throws IOException - { - final ObjectId id = repo.resolve( name ); - if ( id == null ) - { - throw new IllegalArgumentException( name ); + private AbstractTreeIterator getTreeIterator(Repository repo, String name) throws IOException { + final ObjectId id = repo.resolve(name); + if (id == null) { + throw new IllegalArgumentException(name); } final CanonicalTreeParser p = new CanonicalTreeParser(); - - try ( ObjectReader or = repo.newObjectReader(); - RevWalk revWalk = new RevWalk( repo ) ) - { - p.reset( or, revWalk.parseTree( id ) ); + + try (ObjectReader or = repo.newObjectReader(); + RevWalk revWalk = new RevWalk(repo)) { + p.reset(or, revWalk.parseTree(id)); return p; } } diff --git a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-jgit/src/main/java/org/apache/maven/scm/provider/git/jgit/command/info/JGitInfoCommand.java b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-jgit/src/main/java/org/apache/maven/scm/provider/git/jgit/command/info/JGitInfoCommand.java index b28b4f543..f5f7c57d9 100644 --- a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-jgit/src/main/java/org/apache/maven/scm/provider/git/jgit/command/info/JGitInfoCommand.java +++ b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-jgit/src/main/java/org/apache/maven/scm/provider/git/jgit/command/info/JGitInfoCommand.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.git.jgit.command.info; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ - +package org.apache.maven.scm.provider.git.jgit.command.info; import java.io.File; import java.util.Collections; @@ -40,38 +38,29 @@ /** * @since 1.9.5 */ -public class JGitInfoCommand - extends AbstractCommand - implements GitCommand -{ +public class JGitInfoCommand extends AbstractCommand implements GitCommand { @Override - protected ScmResult executeCommand( ScmProviderRepository repository, ScmFileSet fileSet, - CommandParameters parameters ) - throws ScmException - { + protected ScmResult executeCommand( + ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters) throws ScmException { Git git = null; - try - { + try { File basedir = fileSet.getBasedir(); - git = Git.open( basedir ); + git = Git.open(basedir); - ObjectId objectId = git.getRepository().resolve( "HEAD" ); + ObjectId objectId = git.getRepository().resolve("HEAD"); InfoItem infoItem = new InfoItem(); - infoItem.setRevision( StringUtils.trim( objectId.name() ) ); - infoItem.setURL( basedir.toPath().toUri().toASCIIString() ); + infoItem.setRevision(StringUtils.trim(objectId.name())); + infoItem.setURL(basedir.toPath().toUri().toASCIIString()); - return new InfoScmResult( Collections.singletonList( infoItem ), - new ScmResult( "JGit.resolve(HEAD)", "", objectId.toString(), true ) ); - } - catch ( Exception e ) - { - throw new ScmException( "JGit resolve failure!", e ); - } - finally - { - JGitUtils.closeRepo( git ); + return new InfoScmResult( + Collections.singletonList(infoItem), + new ScmResult("JGit.resolve(HEAD)", "", objectId.toString(), true)); + } catch (Exception e) { + throw new ScmException("JGit resolve failure!", e); + } finally { + JGitUtils.closeRepo(git); } } } diff --git a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-jgit/src/main/java/org/apache/maven/scm/provider/git/jgit/command/list/JGitListCommand.java b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-jgit/src/main/java/org/apache/maven/scm/provider/git/jgit/command/list/JGitListCommand.java index 234ab018b..2edeabdf2 100644 --- a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-jgit/src/main/java/org/apache/maven/scm/provider/git/jgit/command/list/JGitListCommand.java +++ b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-jgit/src/main/java/org/apache/maven/scm/provider/git/jgit/command/list/JGitListCommand.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.git.jgit.command.list; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,12 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider.git.jgit.command.list; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; +import java.util.function.BiFunction; import org.apache.maven.scm.ScmException; import org.apache.maven.scm.ScmFile; @@ -37,67 +41,51 @@ import org.eclipse.jgit.transport.CredentialsProvider; import org.slf4j.Logger; -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; -import java.util.function.BiFunction; - /** * @author Dominik Bartholdi (imod) * @since 1.9 */ -public class JGitListCommand - extends AbstractListCommand - implements GitCommand -{ +public class JGitListCommand extends AbstractListCommand implements GitCommand { private BiFunction sshSessionFactorySupplier; - public JGitListCommand() - { + public JGitListCommand() { sshSessionFactorySupplier = ScmProviderAwareSshdSessionFactory::new; } public void setSshSessionFactorySupplier( - BiFunction sshSessionFactorySupplier ) - { + BiFunction + sshSessionFactorySupplier) { this.sshSessionFactorySupplier = sshSessionFactorySupplier; } @Override - protected ListScmResult executeListCommand( ScmProviderRepository repo, ScmFileSet fileSet, boolean recursive, - ScmVersion scmVersion ) - throws ScmException - { + protected ListScmResult executeListCommand( + ScmProviderRepository repo, ScmFileSet fileSet, boolean recursive, ScmVersion scmVersion) + throws ScmException { Git git = null; - try - { - git = JGitUtils.openRepo( fileSet.getBasedir() ); - CredentialsProvider credentials = - JGitUtils.prepareSession( git, (GitScmProviderRepository) repo ); + try { + git = JGitUtils.openRepo(fileSet.getBasedir()); + CredentialsProvider credentials = JGitUtils.prepareSession(git, (GitScmProviderRepository) repo); List list = new ArrayList<>(); - Collection lsResult = git.lsRemote().setCredentialsProvider( credentials ) - .setTransportConfigCallback( - new JGitTransportConfigCallback( - sshSessionFactorySupplier.apply( (GitScmProviderRepository) repo, logger ) ) ) + Collection lsResult = git.lsRemote() + .setCredentialsProvider(credentials) + .setTransportConfigCallback(new JGitTransportConfigCallback( + sshSessionFactorySupplier.apply((GitScmProviderRepository) repo, logger))) .call(); - for ( Ref ref : lsResult ) - { - logger.debug( ref.getObjectId().getName() + " " + ref.getTarget().getName() ); - list.add( new ScmFile( ref.getName(), ScmFileStatus.CHECKED_IN ) ); + for (Ref ref : lsResult) { + logger.debug( + ref.getObjectId().getName() + " " + ref.getTarget().getName()); + list.add(new ScmFile(ref.getName(), ScmFileStatus.CHECKED_IN)); } - return new ListScmResult( "JGit ls-remote", list ); - } - catch ( Exception e ) - { - throw new ScmException( "JGit ls-remote failure!", e ); - } - finally - { - JGitUtils.closeRepo( git ); + return new ListScmResult("JGit ls-remote", list); + } catch (Exception e) { + throw new ScmException("JGit ls-remote failure!", e); + } finally { + JGitUtils.closeRepo(git); } } } diff --git a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-jgit/src/main/java/org/apache/maven/scm/provider/git/jgit/command/remoteinfo/JGitRemoteInfoCommand.java b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-jgit/src/main/java/org/apache/maven/scm/provider/git/jgit/command/remoteinfo/JGitRemoteInfoCommand.java index 62b64a9a3..f02dbb305 100644 --- a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-jgit/src/main/java/org/apache/maven/scm/provider/git/jgit/command/remoteinfo/JGitRemoteInfoCommand.java +++ b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-jgit/src/main/java/org/apache/maven/scm/provider/git/jgit/command/remoteinfo/JGitRemoteInfoCommand.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.git.jgit.command.remoteinfo; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,12 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider.git.jgit.command.remoteinfo; + +import java.util.Collection; +import java.util.HashMap; +import java.util.Map; +import java.util.function.BiFunction; import org.apache.maven.scm.CommandParameters; import org.apache.maven.scm.ScmException; @@ -37,75 +41,61 @@ import org.eclipse.jgit.transport.CredentialsProvider; import org.slf4j.Logger; -import java.util.Collection; -import java.util.HashMap; -import java.util.Map; -import java.util.function.BiFunction; - /** * @author Dominik Bartholdi (imod) * @since 1.9 */ -public class JGitRemoteInfoCommand - extends AbstractRemoteInfoCommand - implements GitCommand -{ +public class JGitRemoteInfoCommand extends AbstractRemoteInfoCommand implements GitCommand { private BiFunction sshSessionFactorySupplier; - public JGitRemoteInfoCommand() - { + public JGitRemoteInfoCommand() { sshSessionFactorySupplier = ScmProviderAwareSshdSessionFactory::new; } public void setSshSessionFactorySupplier( - BiFunction sshSessionFactorySupplier ) - { + BiFunction + sshSessionFactorySupplier) { this.sshSessionFactorySupplier = sshSessionFactorySupplier; } @Override - public RemoteInfoScmResult executeRemoteInfoCommand( ScmProviderRepository repository, ScmFileSet fileSet, - CommandParameters parameters ) - throws ScmException - { + public RemoteInfoScmResult executeRemoteInfoCommand( + ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters) throws ScmException { GitScmProviderRepository repo = (GitScmProviderRepository) repository; Git git = null; - try - { - git = JGitUtils.openRepo( fileSet.getBasedir() ); - CredentialsProvider credentials = JGitUtils.getCredentials( repo ); + try { + git = JGitUtils.openRepo(fileSet.getBasedir()); + CredentialsProvider credentials = JGitUtils.getCredentials(repo); - LsRemoteCommand lsCommand = - git.lsRemote().setRemote( repo.getPushUrl() ).setCredentialsProvider( credentials ) - .setTransportConfigCallback( - new JGitTransportConfigCallback( sshSessionFactorySupplier.apply( repo, logger ) ) - ); + LsRemoteCommand lsCommand = git.lsRemote() + .setRemote(repo.getPushUrl()) + .setCredentialsProvider(credentials) + .setTransportConfigCallback( + new JGitTransportConfigCallback(sshSessionFactorySupplier.apply(repo, logger))); Map tag = new HashMap<>(); - Collection allTags = lsCommand.setHeads( false ).setTags( true ).call(); - for ( Ref ref : allTags ) - { - tag.put( Repository.shortenRefName( ref.getName() ), ref.getObjectId().name() ); + Collection allTags = lsCommand.setHeads(false).setTags(true).call(); + for (Ref ref : allTags) { + tag.put( + Repository.shortenRefName(ref.getName()), + ref.getObjectId().name()); } Map heads = new HashMap<>(); - Collection allHeads = lsCommand.setHeads( true ).setTags( false ).call(); - for ( Ref ref : allHeads ) - { - heads.put( Repository.shortenRefName( ref.getName() ), ref.getObjectId().name() ); + Collection allHeads = lsCommand.setHeads(true).setTags(false).call(); + for (Ref ref : allHeads) { + heads.put( + Repository.shortenRefName(ref.getName()), + ref.getObjectId().name()); } - return new RemoteInfoScmResult( "JGit remoteinfo", heads, tag ); - } - catch ( Exception e ) - { - throw new ScmException( "JGit remoteinfo failure!", e ); - } - finally - { - JGitUtils.closeRepo( git ); + return new RemoteInfoScmResult("JGit remoteinfo", heads, tag); + } catch (Exception e) { + throw new ScmException("JGit remoteinfo failure!", e); + } finally { + JGitUtils.closeRepo(git); } } } diff --git a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-jgit/src/main/java/org/apache/maven/scm/provider/git/jgit/command/remove/JGitRemoveCommand.java b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-jgit/src/main/java/org/apache/maven/scm/provider/git/jgit/command/remove/JGitRemoveCommand.java index 21e0e52f7..4e47e7a3d 100644 --- a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-jgit/src/main/java/org/apache/maven/scm/provider/git/jgit/command/remove/JGitRemoveCommand.java +++ b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-jgit/src/main/java/org/apache/maven/scm/provider/git/jgit/command/remove/JGitRemoveCommand.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.git.jgit.command.remove; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider.git.jgit.command.remove; import java.util.List; @@ -36,46 +35,33 @@ * @author Georg Tsakumagos * @since 2.0.0-M2 */ -public class JGitRemoveCommand - extends AbstractRemoveCommand - implements GitCommand -{ +public class JGitRemoveCommand extends AbstractRemoveCommand implements GitCommand { @Override - protected ScmResult executeRemoveCommand( ScmProviderRepository repository, ScmFileSet fileSet, String message ) - throws ScmException - { + protected ScmResult executeRemoveCommand(ScmProviderRepository repository, ScmFileSet fileSet, String message) + throws ScmException { - if ( fileSet.getFileList().isEmpty() ) - { - throw new ScmException( "You must provide at least one file/directory to remove" ); + if (fileSet.getFileList().isEmpty()) { + throw new ScmException("You must provide at least one file/directory to remove"); } Git git = null; - try - { - git = JGitUtils.openRepo( fileSet.getBasedir() ); + try { + git = JGitUtils.openRepo(fileSet.getBasedir()); - List removedFiles = JGitUtils.removeAllFiles( git, fileSet ); + List removedFiles = JGitUtils.removeAllFiles(git, fileSet); - if ( logger.isDebugEnabled() ) - { - for ( ScmFile scmFile : removedFiles ) - { - logger.info( "Removed file: " + scmFile ); + if (logger.isDebugEnabled()) { + for (ScmFile scmFile : removedFiles) { + logger.info("Removed file: " + scmFile); } } - return new RemoveScmResult( "JGit remove", removedFiles ); + return new RemoveScmResult("JGit remove", removedFiles); - } - catch ( Exception e ) - { - throw new ScmException( "JGit remove failure!", e ); - } - finally - { - JGitUtils.closeRepo( git ); + } catch (Exception e) { + throw new ScmException("JGit remove failure!", e); + } finally { + JGitUtils.closeRepo(git); } } - } diff --git a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-jgit/src/main/java/org/apache/maven/scm/provider/git/jgit/command/status/JGitStatusCommand.java b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-jgit/src/main/java/org/apache/maven/scm/provider/git/jgit/command/status/JGitStatusCommand.java index 1c7fcf679..baf6dadcb 100644 --- a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-jgit/src/main/java/org/apache/maven/scm/provider/git/jgit/command/status/JGitStatusCommand.java +++ b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-jgit/src/main/java/org/apache/maven/scm/provider/git/jgit/command/status/JGitStatusCommand.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.git.jgit.command.status; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,11 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider.git.jgit.command.status; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; import org.apache.maven.scm.ScmException; import org.apache.maven.scm.ScmFile; @@ -31,60 +34,43 @@ import org.eclipse.jgit.api.Git; import org.eclipse.jgit.api.Status; -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; - /** * @author Mark Struberg * @author Dominik Bartholdi (imod) * @since 1.9 */ -public class JGitStatusCommand - extends AbstractStatusCommand - implements GitCommand -{ +public class JGitStatusCommand extends AbstractStatusCommand implements GitCommand { /** * {@inheritDoc} */ - protected StatusScmResult executeStatusCommand( ScmProviderRepository repo, ScmFileSet fileSet ) - throws ScmException - { + protected StatusScmResult executeStatusCommand(ScmProviderRepository repo, ScmFileSet fileSet) throws ScmException { Git git = null; - try - { - git = JGitUtils.openRepo( fileSet.getBasedir() ); + try { + git = JGitUtils.openRepo(fileSet.getBasedir()); Status status = git.status().call(); - List changedFiles = getFileStati( status ); + List changedFiles = getFileStati(status); - return new StatusScmResult( "JGit status", changedFiles ); - } - catch ( Exception e ) - { - throw new ScmException( "JGit status failure!", e ); - } - finally - { - JGitUtils.closeRepo( git ); + return new StatusScmResult("JGit status", changedFiles); + } catch (Exception e) { + throw new ScmException("JGit status failure!", e); + } finally { + JGitUtils.closeRepo(git); } } - private List getFileStati( Status status ) - { + private List getFileStati(Status status) { List all = new ArrayList<>(); - addAsScmFiles( all, status.getAdded(), ScmFileStatus.ADDED ); - addAsScmFiles( all, status.getChanged(), ScmFileStatus.UPDATED ); - addAsScmFiles( all, status.getConflicting(), ScmFileStatus.CONFLICT ); - addAsScmFiles( all, status.getModified(), ScmFileStatus.MODIFIED ); - addAsScmFiles( all, status.getRemoved(), ScmFileStatus.DELETED ); + addAsScmFiles(all, status.getAdded(), ScmFileStatus.ADDED); + addAsScmFiles(all, status.getChanged(), ScmFileStatus.UPDATED); + addAsScmFiles(all, status.getConflicting(), ScmFileStatus.CONFLICT); + addAsScmFiles(all, status.getModified(), ScmFileStatus.MODIFIED); + addAsScmFiles(all, status.getRemoved(), ScmFileStatus.DELETED); return all; } - private void addAsScmFiles( Collection all, Collection files, ScmFileStatus status ) - { - for ( String f : files ) - { - all.add( new ScmFile( f, status ) ); + private void addAsScmFiles(Collection all, Collection files, ScmFileStatus status) { + for (String f : files) { + all.add(new ScmFile(f, status)); } } } diff --git a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-jgit/src/main/java/org/apache/maven/scm/provider/git/jgit/command/tag/JGitTagCommand.java b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-jgit/src/main/java/org/apache/maven/scm/provider/git/jgit/command/tag/JGitTagCommand.java index f4659ef21..74dec3e0f 100644 --- a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-jgit/src/main/java/org/apache/maven/scm/provider/git/jgit/command/tag/JGitTagCommand.java +++ b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-jgit/src/main/java/org/apache/maven/scm/provider/git/jgit/command/tag/JGitTagCommand.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.git.jgit.command.tag; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,10 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider.git.jgit.command.tag; + +import java.util.ArrayList; +import java.util.List; import org.apache.maven.scm.ScmException; import org.apache.maven.scm.ScmFile; @@ -40,87 +42,72 @@ import org.eclipse.jgit.transport.RefSpec; import org.eclipse.jgit.treewalk.TreeWalk; -import java.util.ArrayList; -import java.util.List; - /** * @author Mark Struberg * @author Dominik Bartholdi (imod) * @since 1.9 */ -public class JGitTagCommand - extends AbstractTagCommand - implements GitCommand -{ +public class JGitTagCommand extends AbstractTagCommand implements GitCommand { - public ScmResult executeTagCommand( ScmProviderRepository repo, ScmFileSet fileSet, String tag, String message ) - throws ScmException - { - return executeTagCommand( repo, fileSet, tag, new ScmTagParameters( message ) ); + public ScmResult executeTagCommand(ScmProviderRepository repo, ScmFileSet fileSet, String tag, String message) + throws ScmException { + return executeTagCommand(repo, fileSet, tag, new ScmTagParameters(message)); } /** * {@inheritDoc} */ - public ScmResult executeTagCommand( ScmProviderRepository repo, ScmFileSet fileSet, String tag, - ScmTagParameters scmTagParameters ) - throws ScmException - { - if ( tag == null || StringUtils.isEmpty( tag.trim() ) ) - { - throw new ScmException( "tag name must be specified" ); + public ScmResult executeTagCommand( + ScmProviderRepository repo, ScmFileSet fileSet, String tag, ScmTagParameters scmTagParameters) + throws ScmException { + if (tag == null || StringUtils.isEmpty(tag.trim())) { + throw new ScmException("tag name must be specified"); } - if ( !fileSet.getFileList().isEmpty() ) - { - throw new ScmException( "This provider doesn't support tagging subsets of a directory" ); + if (!fileSet.getFileList().isEmpty()) { + throw new ScmException("This provider doesn't support tagging subsets of a directory"); } - String escapedTagName = tag.trim().replace( ' ', '_' ); + String escapedTagName = tag.trim().replace(' ', '_'); Git git = null; - try - { - git = JGitUtils.openRepo( fileSet.getBasedir() ); + try { + git = JGitUtils.openRepo(fileSet.getBasedir()); // tag the revision String tagMessage = scmTagParameters.getMessage(); - Ref tagRef = git.tag().setName( escapedTagName ).setMessage( tagMessage ).setForceUpdate( false ).call(); - - if ( repo.isPushChanges() ) - { - logger.info( "push tag [" + escapedTagName + "] to remote..." ); - JGitUtils.push( git, (GitScmProviderRepository) repo, new RefSpec( Constants.R_TAGS - + escapedTagName ) ); + Ref tagRef = git.tag() + .setName(escapedTagName) + .setMessage(tagMessage) + .setForceUpdate(false) + .call(); + + if (repo.isPushChanges()) { + logger.info("push tag [" + escapedTagName + "] to remote..."); + JGitUtils.push(git, (GitScmProviderRepository) repo, new RefSpec(Constants.R_TAGS + escapedTagName)); } // search for the tagged files - RevWalk revWalk = new RevWalk( git.getRepository() ); - RevCommit commit = revWalk.parseCommit( tagRef.getObjectId() ); + RevWalk revWalk = new RevWalk(git.getRepository()); + RevCommit commit = revWalk.parseCommit(tagRef.getObjectId()); revWalk.close(); - final TreeWalk walk = new TreeWalk( git.getRepository() ); + final TreeWalk walk = new TreeWalk(git.getRepository()); walk.reset(); // drop the first empty tree, which we do not need here - walk.setRecursive( true ); - walk.addTree( commit.getTree() ); + walk.setRecursive(true); + walk.addTree(commit.getTree()); List taggedFiles = new ArrayList<>(); - while ( walk.next() ) - { - taggedFiles.add( new ScmFile( walk.getPathString(), ScmFileStatus.CHECKED_OUT ) ); + while (walk.next()) { + taggedFiles.add(new ScmFile(walk.getPathString(), ScmFileStatus.CHECKED_OUT)); } walk.close(); - return new TagScmResult( "JGit tag", taggedFiles ); - } - catch ( Exception e ) - { - throw new ScmException( "JGit tag failure!", e ); - } - finally - { - JGitUtils.closeRepo( git ); + return new TagScmResult("JGit tag", taggedFiles); + } catch (Exception e) { + throw new ScmException("JGit tag failure!", e); + } finally { + JGitUtils.closeRepo(git); } } - } diff --git a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-jgit/src/main/java/org/apache/maven/scm/provider/git/jgit/command/untag/JGitUntagCommand.java b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-jgit/src/main/java/org/apache/maven/scm/provider/git/jgit/command/untag/JGitUntagCommand.java index 5de923069..f09fcc2ec 100644 --- a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-jgit/src/main/java/org/apache/maven/scm/provider/git/jgit/command/untag/JGitUntagCommand.java +++ b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-jgit/src/main/java/org/apache/maven/scm/provider/git/jgit/command/untag/JGitUntagCommand.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.git.jgit.command.untag; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider.git.jgit.command.untag; import java.util.Collection; @@ -39,65 +38,50 @@ import org.eclipse.jgit.transport.RemoteRefUpdate; /** {@inheritDoc} */ -public class JGitUntagCommand extends AbstractUntagCommand implements GitCommand -{ +public class JGitUntagCommand extends AbstractUntagCommand implements GitCommand { @Override - protected ScmResult executeUntagCommand( ScmProviderRepository repository, ScmFileSet fileSet, - ScmUntagParameters scmUntagParameters ) - throws ScmException - { + protected ScmResult executeUntagCommand( + ScmProviderRepository repository, ScmFileSet fileSet, ScmUntagParameters scmUntagParameters) + throws ScmException { String tagName = scmUntagParameters.getTag(); - if ( tagName == null || StringUtils.isEmpty( tagName.trim() ) ) - { - throw new ScmException( "tag name must be specified" ); + if (tagName == null || StringUtils.isEmpty(tagName.trim())) { + throw new ScmException("tag name must be specified"); } - String escapedTagName = tagName.trim().replace( ' ', '_' ); + String escapedTagName = tagName.trim().replace(' ', '_'); Git git = null; - try - { - git = JGitUtils.openRepo( fileSet.getBasedir() ); + try { + git = JGitUtils.openRepo(fileSet.getBasedir()); // delete the tag - if ( git.tagDelete().setTags( escapedTagName ).call().isEmpty() ) - { - return new UntagScmResult( "JGit tagDelete", "Failed to delete tag", "", false ); + if (git.tagDelete().setTags(escapedTagName).call().isEmpty()) { + return new UntagScmResult("JGit tagDelete", "Failed to delete tag", "", false); } - if ( repository.isPushChanges() ) - { + if (repository.isPushChanges()) { // From https://stackoverflow.com/q/11892766/696632 - RefSpec refSpec = new RefSpec() - .setSource( null ) - .setDestination( Constants.R_TAGS + escapedTagName ); + RefSpec refSpec = new RefSpec().setSource(null).setDestination(Constants.R_TAGS + escapedTagName); - logger.info( "push delete tag [" + escapedTagName + "] to remote..." ); + logger.info("push delete tag [" + escapedTagName + "] to remote..."); - Iterable pushResultList - = JGitUtils.push( git, (GitScmProviderRepository) repository, refSpec ); - if ( logger.isInfoEnabled() ) - { - for ( PushResult pushResult : pushResultList ) - { + Iterable pushResultList = + JGitUtils.push(git, (GitScmProviderRepository) repository, refSpec); + if (logger.isInfoEnabled()) { + for (PushResult pushResult : pushResultList) { Collection ru = pushResult.getRemoteUpdates(); - for ( RemoteRefUpdate remoteRefUpdate : ru ) - { - logger.info( remoteRefUpdate.getStatus() + " - " + remoteRefUpdate ); + for (RemoteRefUpdate remoteRefUpdate : ru) { + logger.info(remoteRefUpdate.getStatus() + " - " + remoteRefUpdate); } } } } - return new UntagScmResult( "JGit tagDelete" ); - } - catch ( Exception e ) - { - throw new ScmException( "JGit tagDelete failure!", e ); - } - finally - { - JGitUtils.closeRepo( git ); + return new UntagScmResult("JGit tagDelete"); + } catch (Exception e) { + throw new ScmException("JGit tagDelete failure!", e); + } finally { + JGitUtils.closeRepo(git); } } } diff --git a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-jgit/src/test/java/org/apache/maven/scm/provider/git/jgit/JGitTestScmProvider.java b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-jgit/src/test/java/org/apache/maven/scm/provider/git/jgit/JGitTestScmProvider.java index befeffb1c..2398123f5 100644 --- a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-jgit/src/test/java/org/apache/maven/scm/provider/git/jgit/JGitTestScmProvider.java +++ b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-jgit/src/test/java/org/apache/maven/scm/provider/git/jgit/JGitTestScmProvider.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.git.jgit; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider.git.jgit; import javax.annotation.Priority; import javax.inject.Inject; @@ -38,67 +37,54 @@ * Allows to register callbacks for all commands leveraging {@link TransportCommand}. */ @Singleton -@Named( "jgit" ) -@Priority( 1 ) // must have higher priority than default JGitScmProvider -public class JGitTestScmProvider - extends JGitScmProvider implements ScmProvider -{ +@Named("jgit") +@Priority(1) // must have higher priority than default JGitScmProvider +public class JGitTestScmProvider extends JGitScmProvider implements ScmProvider { private Consumer checkInCommandCallback; private Consumer checkOutCommandCallback; private Consumer remoteInfoCommandCallback; @Inject - public JGitTestScmProvider( Prompter prompter ) - { - super( prompter ); + public JGitTestScmProvider(Prompter prompter) { + super(prompter); } - public void registerCheckInCommandCallback( Consumer gitCommandConsumer ) - { + public void registerCheckInCommandCallback(Consumer gitCommandConsumer) { checkInCommandCallback = gitCommandConsumer; } - public void registerCheckOutCommandCallback( Consumer gitCommandConsumer ) - { + public void registerCheckOutCommandCallback(Consumer gitCommandConsumer) { checkOutCommandCallback = gitCommandConsumer; } - public void registerRemoteInfoCommandCallback( Consumer gitCommandConsumer ) - { + public void registerRemoteInfoCommandCallback(Consumer gitCommandConsumer) { remoteInfoCommandCallback = gitCommandConsumer; } @Override - protected GitCommand getCheckInCommand() - { + protected GitCommand getCheckInCommand() { JGitCheckInCommand command = (JGitCheckInCommand) super.getCheckInCommand(); - if ( checkInCommandCallback != null ) - { - checkInCommandCallback.accept( command ); + if (checkInCommandCallback != null) { + checkInCommandCallback.accept(command); } return command; } @Override - protected GitCommand getCheckOutCommand() - { + protected GitCommand getCheckOutCommand() { JGitCheckOutCommand command = (JGitCheckOutCommand) super.getCheckOutCommand(); - if ( checkOutCommandCallback != null ) - { - checkOutCommandCallback.accept( command ); + if (checkOutCommandCallback != null) { + checkOutCommandCallback.accept(command); } return command; } @Override - protected GitCommand getRemoteInfoCommand() - { + protected GitCommand getRemoteInfoCommand() { JGitRemoteInfoCommand command = (JGitRemoteInfoCommand) super.getRemoteInfoCommand(); - if ( remoteInfoCommandCallback != null ) - { - remoteInfoCommandCallback.accept( command ); + if (remoteInfoCommandCallback != null) { + remoteInfoCommandCallback.accept(command); } return command; } - } diff --git a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-jgit/src/test/java/org/apache/maven/scm/provider/git/jgit/command/branch/JGitBranchCommandTckTest.java b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-jgit/src/test/java/org/apache/maven/scm/provider/git/jgit/command/branch/JGitBranchCommandTckTest.java index 0ff96e516..312c37461 100644 --- a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-jgit/src/test/java/org/apache/maven/scm/provider/git/jgit/command/branch/JGitBranchCommandTckTest.java +++ b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-jgit/src/test/java/org/apache/maven/scm/provider/git/jgit/command/branch/JGitBranchCommandTckTest.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.git.jgit.command.branch; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider.git.jgit.command.branch; import java.io.File; import java.io.IOException; @@ -29,25 +28,18 @@ /** * @author Dominik Bartholdi (imod) */ -public class JGitBranchCommandTckTest - extends GitBranchCommandTckTest -{ +public class JGitBranchCommandTckTest extends GitBranchCommandTckTest { /** * {@inheritDoc} */ - public String getScmUrl() - throws Exception - { - return GitScmTestUtils.getScmUrl( getRepositoryRoot(), "jgit" ); + public String getScmUrl() throws Exception { + return GitScmTestUtils.getScmUrl(getRepositoryRoot(), "jgit"); } @Override - protected void deleteDirectory( File directory ) - throws IOException - { - if ( directory.exists() ) - { - FileUtils.delete( directory, FileUtils.RECURSIVE | FileUtils.RETRY ); + protected void deleteDirectory(File directory) throws IOException { + if (directory.exists()) { + FileUtils.delete(directory, FileUtils.RECURSIVE | FileUtils.RETRY); } } } diff --git a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-jgit/src/test/java/org/apache/maven/scm/provider/git/jgit/command/changelog/JGitChangeLogCommandTckTest.java b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-jgit/src/test/java/org/apache/maven/scm/provider/git/jgit/command/changelog/JGitChangeLogCommandTckTest.java index f52efed27..d65a2e8aa 100644 --- a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-jgit/src/test/java/org/apache/maven/scm/provider/git/jgit/command/changelog/JGitChangeLogCommandTckTest.java +++ b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-jgit/src/test/java/org/apache/maven/scm/provider/git/jgit/command/changelog/JGitChangeLogCommandTckTest.java @@ -1,12 +1,3 @@ -package org.apache.maven.scm.provider.git.jgit.command.changelog; - -import java.io.File; -import java.io.IOException; - -import org.apache.maven.scm.provider.git.GitScmTestUtils; -import org.apache.maven.scm.provider.git.command.changelog.GitChangeLogCommandTckTest; -import org.eclipse.jgit.util.FileUtils; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -16,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -25,29 +16,30 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider.git.jgit.command.changelog; + +import java.io.File; +import java.io.IOException; + +import org.apache.maven.scm.provider.git.GitScmTestUtils; +import org.apache.maven.scm.provider.git.command.changelog.GitChangeLogCommandTckTest; +import org.eclipse.jgit.util.FileUtils; /** * @author Mark Struberg */ -public class JGitChangeLogCommandTckTest - extends GitChangeLogCommandTckTest -{ +public class JGitChangeLogCommandTckTest extends GitChangeLogCommandTckTest { /** * {@inheritDoc} */ - public String getScmUrl() - throws Exception - { - return GitScmTestUtils.getScmUrl( getRepositoryRoot(), "jgit" ); + public String getScmUrl() throws Exception { + return GitScmTestUtils.getScmUrl(getRepositoryRoot(), "jgit"); } @Override - protected void deleteDirectory( File directory ) - throws IOException - { - if ( directory.exists() ) - { - FileUtils.delete( directory, FileUtils.RECURSIVE | FileUtils.RETRY ); + protected void deleteDirectory(File directory) throws IOException { + if (directory.exists()) { + FileUtils.delete(directory, FileUtils.RECURSIVE | FileUtils.RETRY); } } } diff --git a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-jgit/src/test/java/org/apache/maven/scm/provider/git/jgit/command/checkin/JGitCheckInCommandCommitterAuthorTckTest.java b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-jgit/src/test/java/org/apache/maven/scm/provider/git/jgit/command/checkin/JGitCheckInCommandCommitterAuthorTckTest.java index 5c56c25f8..fb7c1a3e5 100644 --- a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-jgit/src/test/java/org/apache/maven/scm/provider/git/jgit/command/checkin/JGitCheckInCommandCommitterAuthorTckTest.java +++ b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-jgit/src/test/java/org/apache/maven/scm/provider/git/jgit/command/checkin/JGitCheckInCommandCommitterAuthorTckTest.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.git.jgit.command.checkin; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider.git.jgit.command.checkin; import java.io.File; import java.io.FileWriter; @@ -57,316 +56,287 @@ /** * @author Dominik Bartholdi (imod) */ -public class JGitCheckInCommandCommitterAuthorTckTest - extends GitCheckInCommandTckTest -{ +public class JGitCheckInCommandCommitterAuthorTckTest extends GitCheckInCommandTckTest { @Before @Override - public void setUp() - throws Exception - { + public void setUp() throws Exception { super.setUp(); - SystemReader.setInstance( new CustomSystemReader() ); + SystemReader.setInstance(new CustomSystemReader()); } @After @Override - public void tearDown() - throws Exception - { + public void tearDown() throws Exception { super.tearDown(); - + // back to default - SystemReader.setInstance( null ); + SystemReader.setInstance(null); } - + /** * {@inheritDoc} */ - public String getScmUrl() - throws Exception - { - return GitScmTestUtils.getScmUrl( getRepositoryRoot(), "jgit" ); + public String getScmUrl() throws Exception { + return GitScmTestUtils.getScmUrl(getRepositoryRoot(), "jgit"); } @Override - protected void deleteDirectory( File directory ) - throws IOException - { - if ( directory.exists() ) - { - FileUtils.delete( directory, FileUtils.RECURSIVE | FileUtils.RETRY ); + protected void deleteDirectory(File directory) throws IOException { + if (directory.exists()) { + FileUtils.delete(directory, FileUtils.RECURSIVE | FileUtils.RETRY); } } @Override @Test - public void testCheckInCommandTest() - throws Exception - { - File fooJava = new File( getWorkingCopy(), "src/main/java/Foo.java" ); - assertFalse( "check Foo.java doesn't yet exist", fooJava.canRead() ); + public void testCheckInCommandTest() throws Exception { + File fooJava = new File(getWorkingCopy(), "src/main/java/Foo.java"); + assertFalse("check Foo.java doesn't yet exist", fooJava.canRead()); - Git git = Git.open( getWorkingCopy() ); + Git git = Git.open(getWorkingCopy()); - RevCommit head = getHeadCommit( git.getRepository() ); + RevCommit head = getHeadCommit(git.getRepository()); // Mark created the test repo... - assertEquals( "Mark Struberg", head.getCommitterIdent().getName() ); - JGitUtils.closeRepo( git ); + assertEquals("Mark Struberg", head.getCommitterIdent().getName()); + JGitUtils.closeRepo(git); - createAndCommitFile( fooJava, null ); + createAndCommitFile(fooJava, null); // change user in config - git = Git.open( getWorkingCopy() ); + git = Git.open(getWorkingCopy()); StoredConfig config = git.getRepository().getConfig(); - unsetConfig( config ); - config.setString( "user", null, "name", "Dominik" ); - config.setString( "user", null, "email", "domi@mycomp.com" ); + unsetConfig(config); + config.setString("user", null, "name", "Dominik"); + config.setString("user", null, "email", "domi@mycomp.com"); config.save(); // make a commit - createAndCommitFile( fooJava, null ); + createAndCommitFile(fooJava, null); // check new commit is done with new user in config - head = getHeadCommit( git.getRepository() ); - assertEquals( "Dominik", head.getCommitterIdent().getName() ); - assertEquals( "Dominik", head.getAuthorIdent().getName() ); - assertEquals( "domi@mycomp.com", head.getAuthorIdent().getEmailAddress() ); - assertEquals( "domi@mycomp.com", head.getCommitterIdent().getEmailAddress() ); - JGitUtils.closeRepo( git ); + head = getHeadCommit(git.getRepository()); + assertEquals("Dominik", head.getCommitterIdent().getName()); + assertEquals("Dominik", head.getAuthorIdent().getName()); + assertEquals("domi@mycomp.com", head.getAuthorIdent().getEmailAddress()); + assertEquals("domi@mycomp.com", head.getCommitterIdent().getEmailAddress()); + JGitUtils.closeRepo(git); // change user in config - git = Git.open( getWorkingCopy() ); + git = Git.open(getWorkingCopy()); config = git.getRepository().getConfig(); - unsetConfig( config ); - config.setString( "user", null, "name", "dbartholdi" ); + unsetConfig(config); + config.setString("user", null, "name", "dbartholdi"); config.save(); // make a change - createAndCommitFile( fooJava, null ); + createAndCommitFile(fooJava, null); // check new commit is done with new user in config - head = getHeadCommit( git.getRepository() ); - assertEquals( "dbartholdi", head.getCommitterIdent().getName() ); - assertFalse( "no mail domain is configured, git system default should be used", - head.getCommitterIdent().getEmailAddress().contains( "dbartholdi" ) ); - JGitUtils.closeRepo( git ); + head = getHeadCommit(git.getRepository()); + assertEquals("dbartholdi", head.getCommitterIdent().getName()); + assertFalse( + "no mail domain is configured, git system default should be used", + head.getCommitterIdent().getEmailAddress().contains("dbartholdi")); + JGitUtils.closeRepo(git); // unset a user and maven user but set default mail domain - git = Git.open( getWorkingCopy() ); + git = Git.open(getWorkingCopy()); config = git.getRepository().getConfig(); - unsetConfig( config ); - config.setString( JGitCheckInCommand.GIT_MAVEN_SECTION, null, JGitCheckInCommand.GIT_MAILDOMAIN, "comp.com" ); + unsetConfig(config); + config.setString(JGitCheckInCommand.GIT_MAVEN_SECTION, null, JGitCheckInCommand.GIT_MAILDOMAIN, "comp.com"); config.save(); // make a change with an user on the commandline - createAndCommitFile( fooJava, "dude" ); + createAndCommitFile(fooJava, "dude"); // check new commit is done with new maven user in config - head = getHeadCommit( git.getRepository() ); - assertEquals( "dude", head.getCommitterIdent().getName() ); - assertEquals( "dude@comp.com", head.getCommitterIdent().getEmailAddress() ); - assertEquals( "dude", head.getAuthorIdent().getName() ); - assertEquals( "dude@comp.com", head.getAuthorIdent().getEmailAddress() ); - JGitUtils.closeRepo( git ); + head = getHeadCommit(git.getRepository()); + assertEquals("dude", head.getCommitterIdent().getName()); + assertEquals("dude@comp.com", head.getCommitterIdent().getEmailAddress()); + assertEquals("dude", head.getAuthorIdent().getName()); + assertEquals("dude@comp.com", head.getAuthorIdent().getEmailAddress()); + JGitUtils.closeRepo(git); // unset a user and maven user but set default mail domain - git = Git.open( getWorkingCopy() ); + git = Git.open(getWorkingCopy()); config = git.getRepository().getConfig(); - unsetConfig( config ); - config.setString( "user", null, "name", "dbartholdi" ); - config.setBoolean( JGitCheckInCommand.GIT_MAVEN_SECTION, null, JGitCheckInCommand.GIT_FORCE, true ); - config.setString( JGitCheckInCommand.GIT_MAVEN_SECTION, null, JGitCheckInCommand.GIT_MAILDOMAIN, "anycomp.com" ); + unsetConfig(config); + config.setString("user", null, "name", "dbartholdi"); + config.setBoolean(JGitCheckInCommand.GIT_MAVEN_SECTION, null, JGitCheckInCommand.GIT_FORCE, true); + config.setString(JGitCheckInCommand.GIT_MAVEN_SECTION, null, JGitCheckInCommand.GIT_MAILDOMAIN, "anycomp.com"); config.save(); // make a change with an user on the commandline - createAndCommitFile( fooJava, "dude" ); + createAndCommitFile(fooJava, "dude"); // check new commit is done with new maven user in config - head = getHeadCommit( git.getRepository() ); - assertEquals( "dude", head.getCommitterIdent().getName() ); - assertEquals( "dude@anycomp.com", head.getCommitterIdent().getEmailAddress() ); - assertEquals( "dude", head.getAuthorIdent().getName() ); - assertEquals( "dude@anycomp.com", head.getAuthorIdent().getEmailAddress() ); - JGitUtils.closeRepo( git ); + head = getHeadCommit(git.getRepository()); + assertEquals("dude", head.getCommitterIdent().getName()); + assertEquals("dude@anycomp.com", head.getCommitterIdent().getEmailAddress()); + assertEquals("dude", head.getAuthorIdent().getName()); + assertEquals("dude@anycomp.com", head.getAuthorIdent().getEmailAddress()); + JGitUtils.closeRepo(git); // unset a user and maven user but set default mail domain - git = Git.open( getWorkingCopy() ); + git = Git.open(getWorkingCopy()); config = git.getRepository().getConfig(); - unsetConfig( config ); - config.setString( JGitCheckInCommand.GIT_MAVEN_SECTION, null, JGitCheckInCommand.GIT_MAILDOMAIN, "anycomp.com" ); + unsetConfig(config); + config.setString(JGitCheckInCommand.GIT_MAVEN_SECTION, null, JGitCheckInCommand.GIT_MAILDOMAIN, "anycomp.com"); config.save(); // make a change with no username given - createAndCommitFile( fooJava, null ); + createAndCommitFile(fooJava, null); // check new commit does not contain the configured email domain - head = getHeadCommit( git.getRepository() ); - assertFalse( head.getCommitterIdent().getEmailAddress().contains( "anycomp.com" ) ); - assertFalse( head.getAuthorIdent().getEmailAddress().contains( "anycomp.com" ) ); - JGitUtils.closeRepo( git ); + head = getHeadCommit(git.getRepository()); + assertFalse(head.getCommitterIdent().getEmailAddress().contains("anycomp.com")); + assertFalse(head.getAuthorIdent().getEmailAddress().contains("anycomp.com")); + JGitUtils.closeRepo(git); // unset a user and full maven section - git = Git.open( getWorkingCopy() ); + git = Git.open(getWorkingCopy()); config = git.getRepository().getConfig(); - unsetConfig( config ); + unsetConfig(config); config.save(); // make a change with an user on the commandline - createAndCommitFile( fooJava, "dundy" ); + createAndCommitFile(fooJava, "dundy"); // check new commit is done with new maven user in config - head = getHeadCommit( git.getRepository() ); - assertEquals( "dundy", head.getCommitterIdent().getName() ); - assertEquals( "dundy", head.getAuthorIdent().getName() ); - assertTrue( "the maven user (from parameter) name must be in the committer mail when nothing else is configured", - head.getCommitterIdent().getEmailAddress().contains( "dundy" ) ); - assertTrue( "the user name (from parameter) must be in the author mail when nothing else is configured", - head.getAuthorIdent().getEmailAddress().contains( "dundy" ) ); - JGitUtils.closeRepo( git ); + head = getHeadCommit(git.getRepository()); + assertEquals("dundy", head.getCommitterIdent().getName()); + assertEquals("dundy", head.getAuthorIdent().getName()); + assertTrue( + "the maven user (from parameter) name must be in the committer mail when nothing else is configured", + head.getCommitterIdent().getEmailAddress().contains("dundy")); + assertTrue( + "the user name (from parameter) must be in the author mail when nothing else is configured", + head.getAuthorIdent().getEmailAddress().contains("dundy")); + JGitUtils.closeRepo(git); // unset all configs - git = Git.open( getWorkingCopy() ); + git = Git.open(getWorkingCopy()); config = git.getRepository().getConfig(); - unsetConfig( config ); + unsetConfig(config); config.save(); // make a change with no user on the commandline - createAndCommitFile( fooJava, null ); + createAndCommitFile(fooJava, null); // check new commit is has a committer/author with email set - head = getHeadCommit( git.getRepository() ); - assertNotNull( head.getCommitterIdent().getName() ); - assertNotNull( head.getAuthorIdent().getName() ); - assertNotNull( head.getCommitterIdent().getEmailAddress() ); - assertNotNull( head.getAuthorIdent().getEmailAddress() ); - JGitUtils.closeRepo( git ); + head = getHeadCommit(git.getRepository()); + assertNotNull(head.getCommitterIdent().getName()); + assertNotNull(head.getAuthorIdent().getName()); + assertNotNull(head.getCommitterIdent().getEmailAddress()); + assertNotNull(head.getAuthorIdent().getEmailAddress()); + JGitUtils.closeRepo(git); } /** * make sure the local .gitconfig is in a clean state */ - private void unsetConfig( StoredConfig config ) - { - config.unsetSection( "user", null ); - config.unset( "user", null, "name" ); + private void unsetConfig(StoredConfig config) { + config.unsetSection("user", null); + config.unset("user", null, "name"); // somehow unset does not always work on "user" - config.setString( "user", null, "name", null ); - config.setString( "user", null, "email", null ); - config.unsetSection( JGitCheckInCommand.GIT_MAVEN_SECTION, null ); + config.setString("user", null, "name", null); + config.setString("user", null, "email", null); + config.unsetSection(JGitCheckInCommand.GIT_MAVEN_SECTION, null); } - private void createAndCommitFile( File file, String username ) - throws Exception, ScmException, IOException - { - createFooJava( file ); + private void createAndCommitFile(File file, String username) throws Exception, ScmException, IOException { + createFooJava(file); ScmRepository scmRepository = getScmRepository(); - scmRepository.getProviderRepository().setUser( username ); - AddScmResult addResult = getScmManager().add( scmRepository, new ScmFileSet( getWorkingCopy(), "**/*.java" ) ); + scmRepository.getProviderRepository().setUser(username); + AddScmResult addResult = getScmManager().add(scmRepository, new ScmFileSet(getWorkingCopy(), "**/*.java")); - assertResultIsSuccess( addResult ); + assertResultIsSuccess(addResult); - CheckInScmResult result = - getScmManager().checkIn( scmRepository, new ScmFileSet( getWorkingCopy(), "**/Foo.java" ), "Commit message" ); + CheckInScmResult result = getScmManager() + .checkIn(scmRepository, new ScmFileSet(getWorkingCopy(), "**/Foo.java"), "Commit message"); - assertResultIsSuccess( result ); + assertResultIsSuccess(result); } - private RevCommit getHeadCommit( Repository repository ) - throws Exception - { - RevWalk rw = new RevWalk( repository ); - AnyObjectId headId = repository.resolve( Constants.HEAD ); - RevCommit head = rw.parseCommit( headId ); + private RevCommit getHeadCommit(Repository repository) throws Exception { + RevWalk rw = new RevWalk(repository); + AnyObjectId headId = repository.resolve(Constants.HEAD); + RevCommit head = rw.parseCommit(headId); rw.close(); return head; } - private void createFooJava( File fooJava ) - throws Exception - { - FileWriter output = new FileWriter( fooJava ); + private void createFooJava(File fooJava) throws Exception { + FileWriter output = new FileWriter(fooJava); - PrintWriter printer = new PrintWriter( output ); - try - { - printer.println( "public class Foo" ); - printer.println( "{" ); + PrintWriter printer = new PrintWriter(output); + try { + printer.println("public class Foo"); + printer.println("{"); - printer.println( " public void foo()" ); - printer.println( " {" ); - printer.println( " //" + System.currentTimeMillis() ); - printer.println( " int i = 10;" ); - printer.println( " }" ); + printer.println(" public void foo()"); + printer.println(" {"); + printer.println(" //" + System.currentTimeMillis()); + printer.println(" int i = 10;"); + printer.println(" }"); - printer.println( "}" ); - } - finally - { - IOUtil.close( output ); - IOUtil.close( printer ); + printer.println("}"); + } finally { + IOUtil.close(output); + IOUtil.close(printer); } } /** * SystemReader for testing to have full control some imported getters - * + * * @author Robert Scholte */ class CustomSystemReader extends SystemReader { - + private final SystemReader reader = SystemReader.getInstance(); // Ensure environment properties from CI server don't get pulled in - public String getenv( String variable ) - { + public String getenv(String variable) { return null; } @Override - public String getHostname() - { + public String getHostname() { return reader.getHostname(); } @Override - public String getProperty( String key ) - { - return reader.getProperty( key ); + public String getProperty(String key) { + return reader.getProperty(key); } @Override - public FileBasedConfig openSystemConfig( Config parent, FS fs ) - { - return reader.openSystemConfig( parent, fs ); + public FileBasedConfig openSystemConfig(Config parent, FS fs) { + return reader.openSystemConfig(parent, fs); } @Override - public FileBasedConfig openUserConfig( Config parent, FS fs ) - { - return reader.openUserConfig( parent, fs ); + public FileBasedConfig openUserConfig(Config parent, FS fs) { + return reader.openUserConfig(parent, fs); } @Override - public long getCurrentTime() - { + public long getCurrentTime() { return reader.getCurrentTime(); } @Override - public int getTimezone( long when ) - { - return reader.getTimezone( when ); + public int getTimezone(long when) { + return reader.getTimezone(when); } @Override - public FileBasedConfig openJGitConfig( Config config, FS fs ) - { - return reader.openJGitConfig( config, fs ); + public FileBasedConfig openJGitConfig(Config config, FS fs) { + return reader.openJGitConfig(config, fs); } } - } diff --git a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-jgit/src/test/java/org/apache/maven/scm/provider/git/jgit/command/checkin/JGitCheckInCommandTckTest.java b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-jgit/src/test/java/org/apache/maven/scm/provider/git/jgit/command/checkin/JGitCheckInCommandTckTest.java index 442daddec..7582ce448 100644 --- a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-jgit/src/test/java/org/apache/maven/scm/provider/git/jgit/command/checkin/JGitCheckInCommandTckTest.java +++ b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-jgit/src/test/java/org/apache/maven/scm/provider/git/jgit/command/checkin/JGitCheckInCommandTckTest.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.git.jgit.command.checkin; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider.git.jgit.command.checkin; import java.io.File; import java.io.IOException; @@ -29,25 +28,18 @@ /** * @author Mark Struberg */ -public class JGitCheckInCommandTckTest - extends GitCheckInCommandTckTest -{ +public class JGitCheckInCommandTckTest extends GitCheckInCommandTckTest { /** * {@inheritDoc} */ - public String getScmUrl() - throws Exception - { - return GitScmTestUtils.getScmUrl( getRepositoryRoot(), "jgit" ); + public String getScmUrl() throws Exception { + return GitScmTestUtils.getScmUrl(getRepositoryRoot(), "jgit"); } @Override - protected void deleteDirectory( File directory ) - throws IOException - { - if( directory.exists() ) - { - FileUtils.delete( directory, FileUtils.RECURSIVE | FileUtils.RETRY ); + protected void deleteDirectory(File directory) throws IOException { + if (directory.exists()) { + FileUtils.delete(directory, FileUtils.RECURSIVE | FileUtils.RETRY); } } } diff --git a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-jgit/src/test/java/org/apache/maven/scm/provider/git/jgit/command/checkout/JGitCheckOutCommandTckTest.java b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-jgit/src/test/java/org/apache/maven/scm/provider/git/jgit/command/checkout/JGitCheckOutCommandTckTest.java index f5cd2a95e..86c84d37f 100644 --- a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-jgit/src/test/java/org/apache/maven/scm/provider/git/jgit/command/checkout/JGitCheckOutCommandTckTest.java +++ b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-jgit/src/test/java/org/apache/maven/scm/provider/git/jgit/command/checkout/JGitCheckOutCommandTckTest.java @@ -1,6 +1,3 @@ -package org.apache.maven.scm.provider.git.jgit.command.checkout; - - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -10,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -19,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider.git.jgit.command.checkout; import java.io.File; import java.io.IOException; @@ -30,25 +28,18 @@ /** * @author Mark Struberg */ -public class JGitCheckOutCommandTckTest - extends GitCheckOutCommandTckTest -{ +public class JGitCheckOutCommandTckTest extends GitCheckOutCommandTckTest { /** * {@inheritDoc} */ - public String getScmUrl() - throws Exception - { - return GitScmTestUtils.getScmUrl( getRepositoryRoot(), "jgit" ); + public String getScmUrl() throws Exception { + return GitScmTestUtils.getScmUrl(getRepositoryRoot(), "jgit"); } @Override - protected void deleteDirectory( File directory ) - throws IOException - { - if ( directory.exists() ) - { - FileUtils.delete( directory, FileUtils.RECURSIVE | FileUtils.RETRY ); + protected void deleteDirectory(File directory) throws IOException { + if (directory.exists()) { + FileUtils.delete(directory, FileUtils.RECURSIVE | FileUtils.RETRY); } } } diff --git a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-jgit/src/test/java/org/apache/maven/scm/provider/git/jgit/command/checkout/JGitSshCheckOutCommandTckTest.java b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-jgit/src/test/java/org/apache/maven/scm/provider/git/jgit/command/checkout/JGitSshCheckOutCommandTckTest.java index faaea591f..88caaa714 100644 --- a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-jgit/src/test/java/org/apache/maven/scm/provider/git/jgit/command/checkout/JGitSshCheckOutCommandTckTest.java +++ b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-jgit/src/test/java/org/apache/maven/scm/provider/git/jgit/command/checkout/JGitSshCheckOutCommandTckTest.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.git.jgit.command.checkout; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider.git.jgit.command.checkout; import java.io.File; import java.io.IOException; @@ -48,56 +47,46 @@ import org.slf4j.Logger; /** @author Mark Struberg */ -public class JGitSshCheckOutCommandTckTest - extends GitSshCheckOutCommandTckTest -{ +public class JGitSshCheckOutCommandTckTest extends GitSshCheckOutCommandTckTest { - public JGitSshCheckOutCommandTckTest() throws GeneralSecurityException, IOException - { + public JGitSshCheckOutCommandTckTest() throws GeneralSecurityException, IOException { super(); } @Override - protected String getScmProvider() - { + protected String getScmProvider() { return "jgit"; } @Override - public void initRepo() throws Exception - { + public void initRepo() throws Exception { super.initRepo(); - JGitTestScmProvider provider = (JGitTestScmProvider) getScmManager().getProviderByRepository( getScmRepository() ); + JGitTestScmProvider provider = + (JGitTestScmProvider) getScmManager().getProviderByRepository(getScmRepository()); // accept all hosts - provider.registerCheckOutCommandCallback( new Consumer() - { + provider.registerCheckOutCommandCallback(new Consumer() { @Override - public void accept( JGitCheckOutCommand command ) - { - command.setSshSessionFactorySupplier( AcceptAllHostsSshdSessionFactory::new ); + public void accept(JGitCheckOutCommand command) { + command.setSshSessionFactorySupplier(AcceptAllHostsSshdSessionFactory::new); } - - } ); + }); } - private static final class AcceptAllHostsSshdSessionFactory extends ScmProviderAwareSshdSessionFactory - { - public AcceptAllHostsSshdSessionFactory( GitScmProviderRepository repo, Logger logger ) - { - super( repo, logger ); + private static final class AcceptAllHostsSshdSessionFactory extends ScmProviderAwareSshdSessionFactory { + public AcceptAllHostsSshdSessionFactory(GitScmProviderRepository repo, Logger logger) { + super(repo, logger); } @Override - protected ServerKeyDatabase createServerKeyDatabase( File homeDir, File sshDir ) - { - return new OpenSshServerKeyDatabase( false, null ) - { + protected ServerKeyDatabase createServerKeyDatabase(File homeDir, File sshDir) { + return new OpenSshServerKeyDatabase(false, null) { @Override - public boolean accept( @NonNull String connectAddress, + public boolean accept( + @NonNull String connectAddress, @NonNull InetSocketAddress remoteAddress, @NonNull PublicKey serverKey, - @NonNull Configuration config, CredentialsProvider provider ) - { + @NonNull Configuration config, + CredentialsProvider provider) { return true; } }; @@ -105,44 +94,39 @@ public boolean accept( @NonNull String connectAddress, } @Override - protected void deleteDirectory( File directory ) - throws IOException - { - if ( directory.exists() ) - { - FileUtils.delete( directory, FileUtils.RECURSIVE | FileUtils.RETRY ); + protected void deleteDirectory(File directory) throws IOException { + if (directory.exists()) { + FileUtils.delete(directory, FileUtils.RECURSIVE | FileUtils.RETRY); } } @Test - public void testCheckOutCommandWithPregeneratedKeysTest() - throws Exception - { + public void testCheckOutCommandWithPregeneratedKeysTest() throws Exception { // test key pairs being generated with ssh-keygen (they have a slighly different format than the ones tested // in testCheckOutCommandWithPassphraseTest and testCheckOutCommandTest) - configureKeypairFromClasspathResource( getScmRepository(), "sample_rsa", "mySecret"); + configureKeypairFromClasspathResource(getScmRepository(), "sample_rsa", "mySecret"); super.testCheckOutCommandTest(); } - private void configureKeypairFromClasspathResource( ScmRepository repository, String resourceName, String passphrase ) - throws IOException, GeneralSecurityException - { + private void configureKeypairFromClasspathResource(ScmRepository repository, String resourceName, String passphrase) + throws IOException, GeneralSecurityException { // accept public key - try ( InputStream publicKeyInputStream = this.getClass().getResourceAsStream( "/ssh-keypairs/" + resourceName + ".pub" ) ) - { - PublicKey publicKey = PublicKeyEntry.parsePublicKeyEntry( IOUtils.toString( publicKeyInputStream, StandardCharsets.US_ASCII ) ).resolvePublicKey( null, null, null ); - acceptedPublicKeys.add( publicKey ); + try (InputStream publicKeyInputStream = + this.getClass().getResourceAsStream("/ssh-keypairs/" + resourceName + ".pub")) { + PublicKey publicKey = PublicKeyEntry.parsePublicKeyEntry( + IOUtils.toString(publicKeyInputStream, StandardCharsets.US_ASCII)) + .resolvePublicKey(null, null, null); + acceptedPublicKeys.add(publicKey); } - Path privateKeyFile = Files.createTempFile( "privateKey", null ); + Path privateKeyFile = Files.createTempFile("privateKey", null); // private key into tmp file - try ( InputStream privateKeyInputStream = this.getClass().getResourceAsStream( "/ssh-keypairs/" + resourceName ) ) - { - Files.copy( privateKeyInputStream, privateKeyFile, StandardCopyOption.REPLACE_EXISTING ); + try (InputStream privateKeyInputStream = this.getClass().getResourceAsStream("/ssh-keypairs/" + resourceName)) { + Files.copy(privateKeyInputStream, privateKeyFile, StandardCopyOption.REPLACE_EXISTING); } // configure provider repository with private key details ScmProviderRepositoryWithHost providerRepository = - ScmProviderRepositoryWithHost.class.cast( repository.getProviderRepository() ); - providerRepository.setPassphrase( passphrase ); // may be null - providerRepository.setPrivateKey( privateKeyFile.toString() ); + ScmProviderRepositoryWithHost.class.cast(repository.getProviderRepository()); + providerRepository.setPassphrase(passphrase); // may be null + providerRepository.setPrivateKey(privateKeyFile.toString()); } } diff --git a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-jgit/src/test/java/org/apache/maven/scm/provider/git/jgit/command/diff/JGitDiffCommandTckTest.java b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-jgit/src/test/java/org/apache/maven/scm/provider/git/jgit/command/diff/JGitDiffCommandTckTest.java index 2afddfae0..c6f88ccf3 100644 --- a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-jgit/src/test/java/org/apache/maven/scm/provider/git/jgit/command/diff/JGitDiffCommandTckTest.java +++ b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-jgit/src/test/java/org/apache/maven/scm/provider/git/jgit/command/diff/JGitDiffCommandTckTest.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.git.jgit.command.diff; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider.git.jgit.command.diff; import java.io.File; import java.io.IOException; @@ -26,23 +25,16 @@ import org.apache.maven.scm.provider.git.command.diff.GitDiffCommandTckTest; import org.eclipse.jgit.util.FileUtils; -public class JGitDiffCommandTckTest - extends GitDiffCommandTckTest -{ +public class JGitDiffCommandTckTest extends GitDiffCommandTckTest { - public String getScmUrl() - throws Exception - { - return GitScmTestUtils.getScmUrl( getRepositoryRoot(), "jgit" ); + public String getScmUrl() throws Exception { + return GitScmTestUtils.getScmUrl(getRepositoryRoot(), "jgit"); } @Override - protected void deleteDirectory( File directory ) - throws IOException - { - if ( directory.exists() ) - { - FileUtils.delete( directory, FileUtils.RECURSIVE | FileUtils.RETRY ); + protected void deleteDirectory(File directory) throws IOException { + if (directory.exists()) { + FileUtils.delete(directory, FileUtils.RECURSIVE | FileUtils.RETRY); } } } diff --git a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-jgit/src/test/java/org/apache/maven/scm/provider/git/jgit/command/remoteinfo/JGitRemoteInfoCommandTckTest.java b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-jgit/src/test/java/org/apache/maven/scm/provider/git/jgit/command/remoteinfo/JGitRemoteInfoCommandTckTest.java index 48101f5f7..63602a451 100644 --- a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-jgit/src/test/java/org/apache/maven/scm/provider/git/jgit/command/remoteinfo/JGitRemoteInfoCommandTckTest.java +++ b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-jgit/src/test/java/org/apache/maven/scm/provider/git/jgit/command/remoteinfo/JGitRemoteInfoCommandTckTest.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.git.jgit.command.remoteinfo; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider.git.jgit.command.remoteinfo; import java.io.File; import java.io.IOException; @@ -35,41 +34,33 @@ * * @author Dominik Bartholdi (imod) */ -public class JGitRemoteInfoCommandTckTest extends AbstractGitRemoteInfoCommandTckTest -{ +public class JGitRemoteInfoCommandTckTest extends AbstractGitRemoteInfoCommandTckTest { @Override - protected void checkResult( RemoteInfoScmResult result ) - { - assertEquals( 1, result.getBranches().size() ); - assertEquals( "92f139dfec4d1dfb79c3cd2f94e83bf13129668b", result.getBranches().get( "master" ) ); + protected void checkResult(RemoteInfoScmResult result) { + assertEquals(1, result.getBranches().size()); + assertEquals( + "92f139dfec4d1dfb79c3cd2f94e83bf13129668b", result.getBranches().get("master")); - assertEquals( 0, result.getTags().size() ); + assertEquals(0, result.getTags().size()); } /** * {@inheritDoc} */ - public String getScmUrl() - throws Exception - { - String scmUrl = GitScmTestUtils.getScmUrl( getRepositoryRoot(), "jgit" ); + public String getScmUrl() throws Exception { + String scmUrl = GitScmTestUtils.getScmUrl(getRepositoryRoot(), "jgit"); return scmUrl; } @Override - protected ScmProviderRepository getScmProviderRepository() - throws Exception - { - return new GitScmProviderRepository( getScmUrl().substring( "scm:jgit:".length() ) ); + protected ScmProviderRepository getScmProviderRepository() throws Exception { + return new GitScmProviderRepository(getScmUrl().substring("scm:jgit:".length())); } @Override - protected void deleteDirectory( File directory ) - throws IOException - { - if ( directory.exists() ) - { - FileUtils.delete( directory, FileUtils.RECURSIVE | FileUtils.RETRY ); + protected void deleteDirectory(File directory) throws IOException { + if (directory.exists()) { + FileUtils.delete(directory, FileUtils.RECURSIVE | FileUtils.RETRY); } } } diff --git a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-jgit/src/test/java/org/apache/maven/scm/provider/git/jgit/command/remove/JGitRemoveCommandTckTest.java b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-jgit/src/test/java/org/apache/maven/scm/provider/git/jgit/command/remove/JGitRemoveCommandTckTest.java index 0338dd942..d7766de3b 100644 --- a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-jgit/src/test/java/org/apache/maven/scm/provider/git/jgit/command/remove/JGitRemoveCommandTckTest.java +++ b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-jgit/src/test/java/org/apache/maven/scm/provider/git/jgit/command/remove/JGitRemoveCommandTckTest.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.git.jgit.command.remove; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider.git.jgit.command.remove; import java.io.File; import java.io.IOException; @@ -29,25 +28,18 @@ /** * @author Georg Tsakumagos */ -public class JGitRemoveCommandTckTest - extends GitRemoveCommandTckTest -{ +public class JGitRemoveCommandTckTest extends GitRemoveCommandTckTest { /** * {@inheritDoc} */ - public String getScmUrl() - throws Exception - { - return GitScmTestUtils.getScmUrl( getRepositoryRoot(), "jgit" ); + public String getScmUrl() throws Exception { + return GitScmTestUtils.getScmUrl(getRepositoryRoot(), "jgit"); } @Override - protected void deleteDirectory( File directory ) - throws IOException - { - if( directory.exists() ) - { - FileUtils.delete( directory, FileUtils.RECURSIVE | FileUtils.RETRY ); + protected void deleteDirectory(File directory) throws IOException { + if (directory.exists()) { + FileUtils.delete(directory, FileUtils.RECURSIVE | FileUtils.RETRY); } } } diff --git a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-jgit/src/test/java/org/apache/maven/scm/provider/git/jgit/command/status/JGitStatusCommandTckTest.java b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-jgit/src/test/java/org/apache/maven/scm/provider/git/jgit/command/status/JGitStatusCommandTckTest.java index 3f83709ca..c0c46f1ed 100644 --- a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-jgit/src/test/java/org/apache/maven/scm/provider/git/jgit/command/status/JGitStatusCommandTckTest.java +++ b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-jgit/src/test/java/org/apache/maven/scm/provider/git/jgit/command/status/JGitStatusCommandTckTest.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.git.jgit.command.status; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider.git.jgit.command.status; import java.io.File; import java.io.IOException; @@ -29,23 +28,16 @@ /** * @author Mark Strubergr */ -public class JGitStatusCommandTckTest - extends GitStatusCommandTckTest -{ +public class JGitStatusCommandTckTest extends GitStatusCommandTckTest { - public String getScmUrl() - throws Exception - { - return GitScmTestUtils.getScmUrl( getRepositoryRoot(), "jgit" ); + public String getScmUrl() throws Exception { + return GitScmTestUtils.getScmUrl(getRepositoryRoot(), "jgit"); } @Override - protected void deleteDirectory( File directory ) - throws IOException - { - if ( directory.exists() ) - { - FileUtils.delete( directory, FileUtils.RECURSIVE | FileUtils.RETRY ); + protected void deleteDirectory(File directory) throws IOException { + if (directory.exists()) { + FileUtils.delete(directory, FileUtils.RECURSIVE | FileUtils.RETRY); } } } diff --git a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-jgit/src/test/java/org/apache/maven/scm/provider/git/jgit/command/tag/JGitTagCommandTckTest.java b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-jgit/src/test/java/org/apache/maven/scm/provider/git/jgit/command/tag/JGitTagCommandTckTest.java index 7f10305d3..cb63dbb87 100644 --- a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-jgit/src/test/java/org/apache/maven/scm/provider/git/jgit/command/tag/JGitTagCommandTckTest.java +++ b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-jgit/src/test/java/org/apache/maven/scm/provider/git/jgit/command/tag/JGitTagCommandTckTest.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.git.jgit.command.tag; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider.git.jgit.command.tag; import java.io.File; import java.io.IOException; @@ -31,25 +30,18 @@ * * @author Mark Struberg */ -public class JGitTagCommandTckTest - extends GitTagCommandTckTest -{ +public class JGitTagCommandTckTest extends GitTagCommandTckTest { /** * {@inheritDoc} */ - public String getScmUrl() - throws Exception - { - return GitScmTestUtils.getScmUrl( getRepositoryRoot(), "jgit" ); + public String getScmUrl() throws Exception { + return GitScmTestUtils.getScmUrl(getRepositoryRoot(), "jgit"); } @Override - protected void deleteDirectory( File directory ) - throws IOException - { - if ( directory.exists() ) - { - FileUtils.delete( directory, FileUtils.RECURSIVE | FileUtils.RETRY ); + protected void deleteDirectory(File directory) throws IOException { + if (directory.exists()) { + FileUtils.delete(directory, FileUtils.RECURSIVE | FileUtils.RETRY); } } } diff --git a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-jgit/src/test/java/org/apache/maven/scm/provider/git/jgit/command/untag/JGitUntagCommandTckTest.java b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-jgit/src/test/java/org/apache/maven/scm/provider/git/jgit/command/untag/JGitUntagCommandTckTest.java index 268ef41b7..eafcd8fda 100644 --- a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-jgit/src/test/java/org/apache/maven/scm/provider/git/jgit/command/untag/JGitUntagCommandTckTest.java +++ b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-jgit/src/test/java/org/apache/maven/scm/provider/git/jgit/command/untag/JGitUntagCommandTckTest.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.git.jgit.command.untag; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,9 +16,11 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider.git.jgit.command.untag; import java.io.File; import java.io.IOException; + import org.apache.maven.scm.provider.git.GitScmTestUtils; import org.apache.maven.scm.provider.git.command.untag.GitUntagCommandTckTest; import org.eclipse.jgit.util.FileUtils; @@ -28,25 +28,18 @@ /** * This test tests the untag command. */ -public class JGitUntagCommandTckTest - extends GitUntagCommandTckTest -{ +public class JGitUntagCommandTckTest extends GitUntagCommandTckTest { /** * {@inheritDoc} */ - public String getScmUrl() - throws Exception - { - return GitScmTestUtils.getScmUrl( getRepositoryRoot(), "jgit" ); + public String getScmUrl() throws Exception { + return GitScmTestUtils.getScmUrl(getRepositoryRoot(), "jgit"); } @Override - protected void deleteDirectory( File directory ) - throws IOException - { - if ( directory.exists() ) - { - FileUtils.delete( directory, FileUtils.RECURSIVE | FileUtils.RETRY ); + protected void deleteDirectory(File directory) throws IOException { + if (directory.exists()) { + FileUtils.delete(directory, FileUtils.RECURSIVE | FileUtils.RETRY); } } } diff --git a/maven-scm-providers/maven-scm-providers-git/pom.xml b/maven-scm-providers/maven-scm-providers-git/pom.xml index 259ad30cc..53187d4a6 100644 --- a/maven-scm-providers/maven-scm-providers-git/pom.xml +++ b/maven-scm-providers/maven-scm-providers-git/pom.xml @@ -1,5 +1,4 @@ - - 4.0.0 - maven-scm-providers org.apache.maven.scm + maven-scm-providers 2.0.0-M4-SNAPSHOT @@ -40,7 +38,7 @@ maven-scm-provider-gitexe maven-scm-provider-jgit - + tck-git @@ -57,6 +55,6 @@ - + diff --git a/maven-scm-providers/maven-scm-providers-standard/pom.xml b/maven-scm-providers/maven-scm-providers-standard/pom.xml index c622746c7..cda282c56 100644 --- a/maven-scm-providers/maven-scm-providers-standard/pom.xml +++ b/maven-scm-providers/maven-scm-providers-standard/pom.xml @@ -1,5 +1,4 @@ - - 4.0.0 diff --git a/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svn-commons/pom.xml b/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svn-commons/pom.xml index 4e352fbb5..ee4ff4f22 100644 --- a/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svn-commons/pom.xml +++ b/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svn-commons/pom.xml @@ -1,5 +1,4 @@ - - 4.0.0 @@ -60,23 +58,29 @@ org.codehaus.modello modello-maven-plugin + + 1.1.0 + + src/main/mdo/svn-settings.mdo + + generate-xsd-site - pre-site xsd + pre-site ${project.reporting.outputDirectory}/xsd site-docs - pre-site xdoc + pre-site standard @@ -87,12 +91,6 @@ - - 1.1.0 - - src/main/mdo/svn-settings.mdo - - diff --git a/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svn-commons/src/main/java/org/apache/maven/scm/provider/svn/AbstractSvnScmProvider.java b/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svn-commons/src/main/java/org/apache/maven/scm/provider/svn/AbstractSvnScmProvider.java index 1ea133956..8a6c03263 100644 --- a/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svn-commons/src/main/java/org/apache/maven/scm/provider/svn/AbstractSvnScmProvider.java +++ b/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svn-commons/src/main/java/org/apache/maven/scm/provider/svn/AbstractSvnScmProvider.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.svn; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider.svn; import java.io.File; import java.util.ArrayList; @@ -60,15 +59,12 @@ * @author Emmanuel Venisse * */ -public abstract class AbstractSvnScmProvider - extends AbstractScmProvider -{ +public abstract class AbstractSvnScmProvider extends AbstractScmProvider { // ---------------------------------------------------------------------- // // ---------------------------------------------------------------------- - private static class ScmUrlParserResult - { + private static class ScmUrlParserResult { private final List messages = new ArrayList<>(); private ScmProviderRepository repository; @@ -83,116 +79,91 @@ private static class ScmUrlParserResult /** * {@inheritDoc} */ - public String getScmSpecificFilename() - { + public String getScmSpecificFilename() { return ".svn"; } /** * {@inheritDoc} */ - public ScmProviderRepository makeProviderScmRepository( String scmSpecificUrl, char delimiter ) - throws ScmRepositoryException - { - ScmUrlParserResult result = parseScmUrl( scmSpecificUrl ); - - if ( checkCurrentWorkingDirectoryUrl() ) - { - logger.debug( "Checking svn info 'URL:' field matches current sources directory" ); - try - { - String workingDir = System.getProperty( CURRENT_WORKING_DIRECTORY ); + public ScmProviderRepository makeProviderScmRepository(String scmSpecificUrl, char delimiter) + throws ScmRepositoryException { + ScmUrlParserResult result = parseScmUrl(scmSpecificUrl); + + if (checkCurrentWorkingDirectoryUrl()) { + logger.debug("Checking svn info 'URL:' field matches current sources directory"); + try { + String workingDir = System.getProperty(CURRENT_WORKING_DIRECTORY); InfoScmResult info = - info( result.repository, new ScmFileSet( new File( workingDir ) ), new CommandParameters() ); + info(result.repository, new ScmFileSet(new File(workingDir)), new CommandParameters()); - String url = findUrlInfoItem( info ); + String url = findUrlInfoItem(info); String comparison = "'" + url + "' vs. '" + scmSpecificUrl + "'"; - logger.debug( "Comparing : " + comparison ); - if ( url != null && !url.equals( scmSpecificUrl ) ) - { - result.messages.add( "Scm url does not match the value returned by svn info (" + comparison + ")" ); + logger.debug("Comparing : " + comparison); + if (url != null && !url.equals(scmSpecificUrl)) { + result.messages.add("Scm url does not match the value returned by svn info (" + comparison + ")"); } - } - catch ( ScmException e ) - { - throw new ScmRepositoryException( "An error occurred while trying to svn info", e ); + } catch (ScmException e) { + throw new ScmRepositoryException("An error occurred while trying to svn info", e); } } - if ( result.messages.size() > 0 ) - { - throw new ScmRepositoryException( "The scm url is invalid.", result.messages ); + if (result.messages.size() > 0) { + throw new ScmRepositoryException("The scm url is invalid.", result.messages); } - return result.repository; } - private boolean checkCurrentWorkingDirectoryUrl() - { - return StringUtils.isNotEmpty( System.getProperty( CURRENT_WORKING_DIRECTORY ) ); + private boolean checkCurrentWorkingDirectoryUrl() { + return StringUtils.isNotEmpty(System.getProperty(CURRENT_WORKING_DIRECTORY)); } - private String findUrlInfoItem( InfoScmResult infoScmResult ) - { - for ( InfoItem infoItem : infoScmResult.getInfoItems() ) - { - if ( infoItem.getURL() != null ) - { - logger.debug( "URL found: " + infoItem.getURL() ); + private String findUrlInfoItem(InfoScmResult infoScmResult) { + for (InfoItem infoItem : infoScmResult.getInfoItems()) { + if (infoItem.getURL() != null) { + logger.debug("URL found: " + infoItem.getURL()); return infoItem.getURL(); } } - logger.debug( "URL not found (command output=" + infoScmResult.getCommandOutput() + ")" ); + logger.debug("URL not found (command output=" + infoScmResult.getCommandOutput() + ")"); return null; } /** * {@inheritDoc} */ - public ScmProviderRepository makeProviderScmRepository( File path ) - throws ScmRepositoryException, UnknownRepositoryStructure - { - if ( path == null ) - { - throw new NullPointerException( "Path argument is null" ); + public ScmProviderRepository makeProviderScmRepository(File path) + throws ScmRepositoryException, UnknownRepositoryStructure { + if (path == null) { + throw new NullPointerException("Path argument is null"); } - if ( !path.isDirectory() ) - { - throw new ScmRepositoryException( path.getAbsolutePath() + " isn't a valid directory." ); + if (!path.isDirectory()) { + throw new ScmRepositoryException(path.getAbsolutePath() + " isn't a valid directory."); } - if ( !new File( path, ".svn" ).exists() ) - { - throw new ScmRepositoryException( path.getAbsolutePath() + " isn't a svn checkout directory." ); + if (!new File(path, ".svn").exists()) { + throw new ScmRepositoryException(path.getAbsolutePath() + " isn't a svn checkout directory."); } - try - { - return makeProviderScmRepository( getRepositoryURL( path ), ':' ); - } - catch ( ScmException e ) - { + try { + return makeProviderScmRepository(getRepositoryURL(path), ':'); + } catch (ScmException e) { // XXX We should allow throwing of SCMException. - throw new ScmRepositoryException( "Error executing info command", e ); + throw new ScmRepositoryException("Error executing info command", e); } } - protected abstract String getRepositoryURL( File path ) - throws ScmException; + protected abstract String getRepositoryURL(File path) throws ScmException; /** * {@inheritDoc} */ - public List validateScmUrl( String scmSpecificUrl, char delimiter ) - { + public List validateScmUrl(String scmSpecificUrl, char delimiter) { List messages = new ArrayList<>(); - try - { - makeProviderScmRepository( scmSpecificUrl, delimiter ); - } - catch ( ScmRepositoryException e ) - { + try { + makeProviderScmRepository(scmSpecificUrl, delimiter); + } catch (ScmRepositoryException e) { messages = e.getValidationMessages(); } return messages; @@ -201,8 +172,7 @@ public List validateScmUrl( String scmSpecificUrl, char delimiter ) /** * {@inheritDoc} */ - public String getScmType() - { + public String getScmType() { return "svn"; } @@ -210,90 +180,69 @@ public String getScmType() // // ---------------------------------------------------------------------- - private ScmUrlParserResult parseScmUrl( String scmSpecificUrl ) - { + private ScmUrlParserResult parseScmUrl(String scmSpecificUrl) { ScmUrlParserResult result = new ScmUrlParserResult(); // ---------------------------------------------------------------------- // Do some sanity checking of the SVN url // ---------------------------------------------------------------------- - if ( scmSpecificUrl.startsWith( "file" ) ) - { - if ( !scmSpecificUrl.startsWith( "file://" ) ) - { - result.messages.add( "A svn 'file' url must be on the form 'file://[hostname]/'." ); + if (scmSpecificUrl.startsWith("file")) { + if (!scmSpecificUrl.startsWith("file://")) { + result.messages.add("A svn 'file' url must be on the form 'file://[hostname]/'."); return result; } - } - else if ( scmSpecificUrl.startsWith( "https" ) ) - { - if ( !scmSpecificUrl.startsWith( "https://" ) ) - { - result.messages.add( "A svn 'http' url must be on the form 'https://'." ); + } else if (scmSpecificUrl.startsWith("https")) { + if (!scmSpecificUrl.startsWith("https://")) { + result.messages.add("A svn 'http' url must be on the form 'https://'."); return result; } - } - else if ( scmSpecificUrl.startsWith( "http" ) ) - { - if ( !scmSpecificUrl.startsWith( "http://" ) ) - { - result.messages.add( "A svn 'http' url must be on the form 'http://'." ); + } else if (scmSpecificUrl.startsWith("http")) { + if (!scmSpecificUrl.startsWith("http://")) { + result.messages.add("A svn 'http' url must be on the form 'http://'."); return result; } } // Support of tunnels: svn+xxx with xxx defined in subversion conf file - else if ( scmSpecificUrl.startsWith( "svn+" ) ) - { - if ( scmSpecificUrl.indexOf( "://" ) < 0 ) - { - result.messages.add( "A svn 'svn+xxx' url must be on the form 'svn+xxx://'." ); + else if (scmSpecificUrl.startsWith("svn+")) { + if (scmSpecificUrl.indexOf("://") < 0) { + result.messages.add("A svn 'svn+xxx' url must be on the form 'svn+xxx://'."); return result; - } - else - { - String tunnel = scmSpecificUrl.substring( "svn+".length(), scmSpecificUrl.indexOf( "://" ) ); + } else { + String tunnel = scmSpecificUrl.substring("svn+".length(), scmSpecificUrl.indexOf("://")); - //ssh is always an allowed tunnel - if ( !"ssh".equals( tunnel ) ) - { + // ssh is always an allowed tunnel + if (!"ssh".equals(tunnel)) { SvnConfigFileReader reader = new SvnConfigFileReader(); - if ( SvnUtil.getSettings().getConfigDirectory() != null ) - { - reader.setConfigDirectory( new File( SvnUtil.getSettings().getConfigDirectory() ) ); + if (SvnUtil.getSettings().getConfigDirectory() != null) { + reader.setConfigDirectory(new File(SvnUtil.getSettings().getConfigDirectory())); } - if ( StringUtils.isEmpty( reader.getProperty( "tunnels", tunnel ) ) ) - { + if (StringUtils.isEmpty(reader.getProperty("tunnels", tunnel))) { result.messages.add( - "The tunnel '" + tunnel + "' isn't defined in your subversion configuration file." ); + "The tunnel '" + tunnel + "' isn't defined in your subversion configuration file."); return result; } } } - } - else if ( scmSpecificUrl.startsWith( "svn" ) ) - { - if ( !scmSpecificUrl.startsWith( "svn://" ) ) - { - result.messages.add( "A svn 'svn' url must be on the form 'svn://'." ); + } else if (scmSpecificUrl.startsWith("svn")) { + if (!scmSpecificUrl.startsWith("svn://")) { + result.messages.add("A svn 'svn' url must be on the form 'svn://'."); return result; } - } - else - { - result.messages.add( scmSpecificUrl + " url isn't a valid svn URL." ); + } else { + result.messages.add(scmSpecificUrl + " url isn't a valid svn URL."); return result; } - result.repository = new SvnScmProviderRepository( scmSpecificUrl ); + result.repository = new SvnScmProviderRepository(scmSpecificUrl); return result; } @@ -303,10 +252,9 @@ else if ( scmSpecificUrl.startsWith( "svn" ) ) /** * {@inheritDoc} */ - public AddScmResult add( ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters ) - throws ScmException - { - return (AddScmResult) executeCommand( getAddCommand(), repository, fileSet, parameters ); + public AddScmResult add(ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters) + throws ScmException { + return (AddScmResult) executeCommand(getAddCommand(), repository, fileSet, parameters); } protected abstract SvnCommand getBranchCommand(); @@ -314,11 +262,9 @@ public AddScmResult add( ScmProviderRepository repository, ScmFileSet fileSet, C /** * {@inheritDoc} */ - protected BranchScmResult branch( ScmProviderRepository repository, ScmFileSet fileSet, - CommandParameters parameters ) - throws ScmException - { - return (BranchScmResult) executeCommand( getBranchCommand(), repository, fileSet, parameters ); + protected BranchScmResult branch(ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters) + throws ScmException { + return (BranchScmResult) executeCommand(getBranchCommand(), repository, fileSet, parameters); } protected abstract SvnCommand getChangeLogCommand(); @@ -326,11 +272,9 @@ protected BranchScmResult branch( ScmProviderRepository repository, ScmFileSet f /** * {@inheritDoc} */ - public ChangeLogScmResult changelog( ScmProviderRepository repository, ScmFileSet fileSet, - CommandParameters parameters ) - throws ScmException - { - return (ChangeLogScmResult) executeCommand( getChangeLogCommand(), repository, fileSet, parameters ); + public ChangeLogScmResult changelog( + ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters) throws ScmException { + return (ChangeLogScmResult) executeCommand(getChangeLogCommand(), repository, fileSet, parameters); } protected abstract SvnCommand getCheckInCommand(); @@ -338,11 +282,9 @@ public ChangeLogScmResult changelog( ScmProviderRepository repository, ScmFileSe /** * {@inheritDoc} */ - public CheckInScmResult checkin( ScmProviderRepository repository, ScmFileSet fileSet, - CommandParameters parameters ) - throws ScmException - { - return (CheckInScmResult) executeCommand( getCheckInCommand(), repository, fileSet, parameters ); + public CheckInScmResult checkin(ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters) + throws ScmException { + return (CheckInScmResult) executeCommand(getCheckInCommand(), repository, fileSet, parameters); } protected abstract SvnCommand getCheckOutCommand(); @@ -350,11 +292,9 @@ public CheckInScmResult checkin( ScmProviderRepository repository, ScmFileSet fi /** * {@inheritDoc} */ - public CheckOutScmResult checkout( ScmProviderRepository repository, ScmFileSet fileSet, - CommandParameters parameters ) - throws ScmException - { - return (CheckOutScmResult) executeCommand( getCheckOutCommand(), repository, fileSet, parameters ); + public CheckOutScmResult checkout( + ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters) throws ScmException { + return (CheckOutScmResult) executeCommand(getCheckOutCommand(), repository, fileSet, parameters); } protected abstract SvnCommand getDiffCommand(); @@ -362,10 +302,9 @@ public CheckOutScmResult checkout( ScmProviderRepository repository, ScmFileSet /** * {@inheritDoc} */ - public DiffScmResult diff( ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters ) - throws ScmException - { - return (DiffScmResult) executeCommand( getDiffCommand(), repository, fileSet, parameters ); + public DiffScmResult diff(ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters) + throws ScmException { + return (DiffScmResult) executeCommand(getDiffCommand(), repository, fileSet, parameters); } protected abstract SvnCommand getExportCommand(); @@ -373,11 +312,9 @@ public DiffScmResult diff( ScmProviderRepository repository, ScmFileSet fileSet, /** * {@inheritDoc} */ - protected ExportScmResult export( ScmProviderRepository repository, ScmFileSet fileSet, - CommandParameters parameters ) - throws ScmException - { - return (ExportScmResult) executeCommand( getExportCommand(), repository, fileSet, parameters ); + protected ExportScmResult export(ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters) + throws ScmException { + return (ExportScmResult) executeCommand(getExportCommand(), repository, fileSet, parameters); } protected abstract SvnCommand getRemoveCommand(); @@ -385,10 +322,9 @@ protected ExportScmResult export( ScmProviderRepository repository, ScmFileSet f /** * {@inheritDoc} */ - public RemoveScmResult remove( ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters ) - throws ScmException - { - return (RemoveScmResult) executeCommand( getRemoveCommand(), repository, fileSet, parameters ); + public RemoveScmResult remove(ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters) + throws ScmException { + return (RemoveScmResult) executeCommand(getRemoveCommand(), repository, fileSet, parameters); } protected abstract SvnCommand getStatusCommand(); @@ -396,10 +332,9 @@ public RemoveScmResult remove( ScmProviderRepository repository, ScmFileSet file /** * {@inheritDoc} */ - public StatusScmResult status( ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters ) - throws ScmException - { - return (StatusScmResult) executeCommand( getStatusCommand(), repository, fileSet, parameters ); + public StatusScmResult status(ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters) + throws ScmException { + return (StatusScmResult) executeCommand(getStatusCommand(), repository, fileSet, parameters); } protected abstract SvnCommand getTagCommand(); @@ -407,10 +342,9 @@ public StatusScmResult status( ScmProviderRepository repository, ScmFileSet file /** * {@inheritDoc} */ - public TagScmResult tag( ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters ) - throws ScmException - { - return (TagScmResult) executeCommand( getTagCommand(), repository, fileSet, parameters ); + public TagScmResult tag(ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters) + throws ScmException { + return (TagScmResult) executeCommand(getTagCommand(), repository, fileSet, parameters); } protected abstract SvnCommand getUntagCommand(); @@ -419,11 +353,10 @@ public TagScmResult tag( ScmProviderRepository repository, ScmFileSet fileSet, C * {@inheritDoc} */ @Override - public UntagScmResult untag( ScmRepository repository, ScmFileSet fileSet, CommandParameters parameters ) - throws ScmException - { - return (UntagScmResult) executeCommand( getUntagCommand(), repository.getProviderRepository(), - fileSet, parameters ); + public UntagScmResult untag(ScmRepository repository, ScmFileSet fileSet, CommandParameters parameters) + throws ScmException { + return (UntagScmResult) + executeCommand(getUntagCommand(), repository.getProviderRepository(), fileSet, parameters); } protected abstract SvnCommand getUpdateCommand(); @@ -431,17 +364,15 @@ public UntagScmResult untag( ScmRepository repository, ScmFileSet fileSet, Comma /** * {@inheritDoc} */ - public UpdateScmResult update( ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters ) - throws ScmException - { - return (UpdateScmResult) executeCommand( getUpdateCommand(), repository, fileSet, parameters ); + public UpdateScmResult update(ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters) + throws ScmException { + return (UpdateScmResult) executeCommand(getUpdateCommand(), repository, fileSet, parameters); } - protected ScmResult executeCommand( SvnCommand command, ScmProviderRepository repository, ScmFileSet fileSet, - CommandParameters parameters ) - throws ScmException - { - return command.execute( repository, fileSet, parameters ); + protected ScmResult executeCommand( + SvnCommand command, ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters) + throws ScmException { + return command.execute(repository, fileSet, parameters); } protected abstract SvnCommand getListCommand(); @@ -449,33 +380,30 @@ protected ScmResult executeCommand( SvnCommand command, ScmProviderRepository re /** * {@inheritDoc} */ - public ListScmResult list( ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters ) - throws ScmException - { + public ListScmResult list(ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters) + throws ScmException { SvnCommand cmd = getListCommand(); - return (ListScmResult) executeCommand( cmd, repository, fileSet, parameters ); + return (ListScmResult) executeCommand(cmd, repository, fileSet, parameters); } protected abstract SvnCommand getInfoCommand(); - public InfoScmResult info( ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters ) - throws ScmException - { + public InfoScmResult info(ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters) + throws ScmException { SvnCommand cmd = getInfoCommand(); - return (InfoScmResult) executeCommand( cmd, repository, fileSet, parameters ); + return (InfoScmResult) executeCommand(cmd, repository, fileSet, parameters); } /** * {@inheritDoc} */ - protected BlameScmResult blame( ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters ) - throws ScmException - { + protected BlameScmResult blame(ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters) + throws ScmException { SvnCommand cmd = getBlameCommand(); - return (BlameScmResult) executeCommand( cmd, repository, fileSet, parameters ); + return (BlameScmResult) executeCommand(cmd, repository, fileSet, parameters); } protected abstract SvnCommand getBlameCommand(); @@ -483,12 +411,11 @@ protected BlameScmResult blame( ScmProviderRepository repository, ScmFileSet fil /** * {@inheritDoc} */ - public MkdirScmResult mkdir( ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters ) - throws ScmException - { + public MkdirScmResult mkdir(ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters) + throws ScmException { SvnCommand cmd = getMkdirCommand(); - return (MkdirScmResult) executeCommand( cmd, repository, fileSet, parameters ); + return (MkdirScmResult) executeCommand(cmd, repository, fileSet, parameters); } protected abstract SvnCommand getMkdirCommand(); @@ -500,6 +427,6 @@ public MkdirScmResult mkdir( ScmProviderRepository repository, ScmFileSet fileSe * @throws ScmException * @since 1.8 */ - public abstract boolean remoteUrlExist( ScmProviderRepository repository, CommandParameters parameters ) - throws ScmException; + public abstract boolean remoteUrlExist(ScmProviderRepository repository, CommandParameters parameters) + throws ScmException; } diff --git a/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svn-commons/src/main/java/org/apache/maven/scm/provider/svn/SvnChangeSet.java b/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svn-commons/src/main/java/org/apache/maven/scm/provider/svn/SvnChangeSet.java index 8e123b21a..67b5c84ea 100644 --- a/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svn-commons/src/main/java/org/apache/maven/scm/provider/svn/SvnChangeSet.java +++ b/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svn-commons/src/main/java/org/apache/maven/scm/provider/svn/SvnChangeSet.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.svn; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,11 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider.svn; + +import java.util.Date; +import java.util.Iterator; +import java.util.List; import org.apache.maven.scm.ChangeFile; import org.apache.maven.scm.ChangeSet; @@ -25,58 +28,43 @@ import org.apache.maven.scm.provider.svn.repository.SvnScmProviderRepository; import org.codehaus.plexus.util.StringUtils; -import java.util.Date; -import java.util.Iterator; -import java.util.List; - /** * @author Emmanuel Venisse * */ -public class SvnChangeSet - extends ChangeSet -{ +public class SvnChangeSet extends ChangeSet { private static final long serialVersionUID = -4454710577968060741L; - public SvnChangeSet() - { + public SvnChangeSet() { super(); } - public SvnChangeSet( String strDate, String userDatePattern, String comment, String author, - List files ) - { - super( strDate, userDatePattern, comment, author, files ); + public SvnChangeSet(String strDate, String userDatePattern, String comment, String author, List files) { + super(strDate, userDatePattern, comment, author, files); } - public SvnChangeSet( Date date, String comment, String author, List files ) - { - super( date, comment, author, files ); + public SvnChangeSet(Date date, String comment, String author, List files) { + super(date, comment, author, files); } /** {@inheritDoc} */ - public boolean containsFilename( String filename, ScmProviderRepository repository ) - { + public boolean containsFilename(String filename, ScmProviderRepository repository) { SvnScmProviderRepository repo = (SvnScmProviderRepository) repository; String url = repo.getUrl(); - if ( !url.endsWith( "/" ) ) - { + if (!url.endsWith("/")) { url += "/"; } - String currentFile = url + StringUtils.replace( filename, "\\", "/" ); + String currentFile = url + StringUtils.replace(filename, "\\", "/"); - if ( getFiles() != null ) - { - for ( Iterator i = getFiles().iterator(); i.hasNext(); ) - { + if (getFiles() != null) { + for (Iterator i = getFiles().iterator(); i.hasNext(); ) { ChangeFile file = i.next(); - if ( currentFile.endsWith( StringUtils.replace( file.getName(), "\\", "/" ) ) ) - { + if (currentFile.endsWith(StringUtils.replace(file.getName(), "\\", "/"))) { return true; } } diff --git a/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svn-commons/src/main/java/org/apache/maven/scm/provider/svn/SvnCommandUtils.java b/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svn-commons/src/main/java/org/apache/maven/scm/provider/svn/SvnCommandUtils.java index dc5d9a1d9..b0488e3ed 100644 --- a/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svn-commons/src/main/java/org/apache/maven/scm/provider/svn/SvnCommandUtils.java +++ b/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svn-commons/src/main/java/org/apache/maven/scm/provider/svn/SvnCommandUtils.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.svn; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider.svn; import org.codehaus.plexus.util.StringUtils; @@ -27,12 +26,9 @@ * @author Jerome Lacoste * */ -public final class SvnCommandUtils -{ +public final class SvnCommandUtils { - private SvnCommandUtils() - { - } + private SvnCommandUtils() {} /** * Add or overrides the username into a url with a svn+ssh scheme. @@ -47,21 +43,17 @@ private SvnCommandUtils() * @return the fixed url * @throws NullPointerException if url is null */ - public static String fixUrl( String url, String username ) - { - if ( !StringUtils.isEmpty( username ) && url.startsWith( "svn+ssh://" ) ) - { + public static String fixUrl(String url, String username) { + if (!StringUtils.isEmpty(username) && url.startsWith("svn+ssh://")) { // is there a username to override ? If so we cut after - int idx = url.indexOf( '@' ); + int idx = url.indexOf('@'); int cutIdx = idx < 0 ? "svn+ssh://".length() : idx + 1; - url = "svn+ssh://" + username + "@" + url.substring( cutIdx ); + url = "svn+ssh://" + username + "@" + url.substring(cutIdx); + } else if (url.startsWith("file://")) { + // some svn commands does not understand windows path separator in file URL derived from windows file path + url = url.replace('\\', '/'); } - else if ( url.startsWith( "file://" ) ) - { - //some svn commands does not understand windows path separator in file URL derived from windows file path - url = url.replace( '\\', '/' ); - } - + return url; } } diff --git a/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svn-commons/src/main/java/org/apache/maven/scm/provider/svn/SvnConfigFileReader.java b/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svn-commons/src/main/java/org/apache/maven/scm/provider/svn/SvnConfigFileReader.java index 780671aec..9b7176945 100644 --- a/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svn-commons/src/main/java/org/apache/maven/scm/provider/svn/SvnConfigFileReader.java +++ b/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svn-commons/src/main/java/org/apache/maven/scm/provider/svn/SvnConfigFileReader.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.svn; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,10 +16,7 @@ * specific language governing permissions and limitations * under the License. */ - -import org.codehaus.plexus.util.IOUtil; -import org.codehaus.plexus.util.Os; -import org.codehaus.plexus.util.StringUtils; +package org.apache.maven.scm.provider.svn; import java.io.BufferedReader; import java.io.File; @@ -31,77 +26,64 @@ import java.util.Iterator; import java.util.List; +import org.codehaus.plexus.util.IOUtil; +import org.codehaus.plexus.util.Os; +import org.codehaus.plexus.util.StringUtils; + /** * @author Emmanuel Venisse * */ -public class SvnConfigFileReader -{ +public class SvnConfigFileReader { private File configDirectory; - public File getConfigDirectory() - { - if ( configDirectory == null ) - { - if ( Os.isFamily( Os.FAMILY_WINDOWS ) ) - { - configDirectory = new File( System.getenv( "APPDATA" ), "Subversion" ); - } - else - { - configDirectory = new File( System.getProperty( "user.home" ), ".subversion" ); + public File getConfigDirectory() { + if (configDirectory == null) { + if (Os.isFamily(Os.FAMILY_WINDOWS)) { + configDirectory = new File(System.getenv("APPDATA"), "Subversion"); + } else { + configDirectory = new File(System.getProperty("user.home"), ".subversion"); } } return configDirectory; } - public void setConfigDirectory( File configDirectory ) - { + public void setConfigDirectory(File configDirectory) { this.configDirectory = configDirectory; } - public String getProperty( String group, String propertyName ) - { + public String getProperty(String group, String propertyName) { List lines = getConfLines(); boolean inGroup = false; - for ( Iterator i = lines.iterator(); i.hasNext(); ) - { + for (Iterator i = lines.iterator(); i.hasNext(); ) { String line = i.next().trim(); - if ( !inGroup ) - { - if ( ( "[" + group + "]" ).equals( line ) ) - { + if (!inGroup) { + if (("[" + group + "]").equals(line)) { inGroup = true; } - } - else - { - if ( line.startsWith( "[" ) && line.endsWith( "]" ) ) - { - //a new group start + } else { + if (line.startsWith("[") && line.endsWith("]")) { + // a new group start return null; } - if ( line.startsWith( "#" ) ) - { + if (line.startsWith("#")) { continue; } - if ( line.indexOf( '=' ) < 0 ) - { + if (line.indexOf('=') < 0) { continue; } - String property = line.substring( 0, line.indexOf( '=' ) ).trim(); + String property = line.substring(0, line.indexOf('=')).trim(); - if ( !property.equals( propertyName ) ) - { + if (!property.equals(propertyName)) { continue; } - String value = line.substring( line.indexOf( '=' ) + 1 ); + String value = line.substring(line.indexOf('=') + 1); return value.trim(); } } @@ -114,34 +96,25 @@ public String getProperty( String group, String propertyName ) * * @return the list of all lines */ - private List getConfLines() - { + private List getConfLines() { List lines = new ArrayList(); BufferedReader reader = null; - try - { - if ( getConfigDirectory().exists() ) - { - reader = new BufferedReader( new FileReader( new File( getConfigDirectory(), "config" ) ) ); + try { + if (getConfigDirectory().exists()) { + reader = new BufferedReader(new FileReader(new File(getConfigDirectory(), "config"))); String line; - while ( ( line = reader.readLine() ) != null ) - { - if ( !line.startsWith( "#" ) && StringUtils.isNotEmpty( line ) ) - { - lines.add( line ); + while ((line = reader.readLine()) != null) { + if (!line.startsWith("#") && StringUtils.isNotEmpty(line)) { + lines.add(line); } } } - } - catch ( IOException e ) - { + } catch (IOException e) { lines.clear(); - } - finally - { - IOUtil.close( reader ); + } finally { + IOUtil.close(reader); reader = null; } diff --git a/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svn-commons/src/main/java/org/apache/maven/scm/provider/svn/SvnTagBranchUtils.java b/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svn-commons/src/main/java/org/apache/maven/scm/provider/svn/SvnTagBranchUtils.java index 6656eb125..dafcb72ee 100644 --- a/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svn-commons/src/main/java/org/apache/maven/scm/provider/svn/SvnTagBranchUtils.java +++ b/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svn-commons/src/main/java/org/apache/maven/scm/provider/svn/SvnTagBranchUtils.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.svn; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider.svn; import org.apache.maven.scm.ScmBranch; import org.apache.maven.scm.ScmTag; @@ -28,14 +27,11 @@ /** * */ -public final class SvnTagBranchUtils -{ +public final class SvnTagBranchUtils { - private SvnTagBranchUtils() - { - } + private SvnTagBranchUtils() {} - public static final String[] REVISION_SPECIFIERS = new String[]{"HEAD", "BASE", "COMMITTED", "PREV"}; + public static final String[] REVISION_SPECIFIERS = new String[] {"HEAD", "BASE", "COMMITTED", "PREV"}; public static final String SVN_TRUNK = "trunk"; @@ -43,24 +39,20 @@ private SvnTagBranchUtils() public static final String SVN_TAGS = "tags"; - public static final String[] SVN_BASE_DIRS = new String[]{SVN_TRUNK, SVN_BRANCHES, SVN_TAGS}; + public static final String[] SVN_BASE_DIRS = new String[] {SVN_TRUNK, SVN_BRANCHES, SVN_TAGS}; /** * Simple helper function to concatenate two paths together with a "/". * Handles trailing / on basePath. * Returns no trailing "/" if the addlPath is null */ - static String appendPath( String basePath, String addlPath ) - { - basePath = StringUtils.stripEnd( basePath, "/" ); + static String appendPath(String basePath, String addlPath) { + basePath = StringUtils.stripEnd(basePath, "/"); - if ( StringUtils.isEmpty( addlPath ) ) - { + if (StringUtils.isEmpty(addlPath)) { return basePath; - } - else - { - return basePath + "/" + StringUtils.stripStart( addlPath, "/" ); + } else { + return basePath + "/" + StringUtils.stripStart(addlPath, "/"); } } @@ -72,45 +64,36 @@ static String appendPath( String basePath, String addlPath ) * @param repoPath Repository path/url to be searched * @return TODO */ - public static String getProjectRoot( String repoPath ) - { - for ( int i = 0; i < SVN_BASE_DIRS.length; i++ ) - { + public static String getProjectRoot(String repoPath) { + for (int i = 0; i < SVN_BASE_DIRS.length; i++) { String base = "/" + SVN_BASE_DIRS[i]; - int pos = repoPath.lastIndexOf( base + "/" ); - if ( repoPath.endsWith( base ) ) - { - return repoPath.substring( 0, repoPath.length() - base.length() ); - } - else if ( pos >= 0 ) - { - return repoPath.substring( 0, pos ); + int pos = repoPath.lastIndexOf(base + "/"); + if (repoPath.endsWith(base)) { + return repoPath.substring(0, repoPath.length() - base.length()); + } else if (pos >= 0) { + return repoPath.substring(0, pos); } } // At this point we were unable to locate the project root of this url // so assume that the repository url specified is the project root - return appendPath( repoPath, null ); + return appendPath(repoPath, null); } - public static String resolveTagBase( SvnScmProviderRepository repository ) - { - return resolveTagBase( repository.getUrl() ); + public static String resolveTagBase(SvnScmProviderRepository repository) { + return resolveTagBase(repository.getUrl()); } - public static String resolveTagBase( String repositoryUrl ) - { - return appendPath( getProjectRoot( repositoryUrl ), SVN_TAGS ); + public static String resolveTagBase(String repositoryUrl) { + return appendPath(getProjectRoot(repositoryUrl), SVN_TAGS); } - public static String resolveBranchBase( SvnScmProviderRepository repository ) - { - return resolveBranchBase( repository.getUrl() ); + public static String resolveBranchBase(SvnScmProviderRepository repository) { + return resolveBranchBase(repository.getUrl()); } - public static String resolveBranchBase( String repositoryUrl ) - { - return appendPath( getProjectRoot( repositoryUrl ), SVN_BRANCHES ); + public static String resolveBranchBase(String repositoryUrl) { + return appendPath(getProjectRoot(repositoryUrl), SVN_BRANCHES); } /** @@ -123,9 +106,8 @@ public static String resolveBranchBase( String repositoryUrl ) * @return TODO * @see #resolveUrl(String,String,String,ScmBranch) */ - public static String resolveTagUrl( SvnScmProviderRepository repository, ScmTag tag ) - { - return resolveUrl( repository.getUrl(), repository.getTagBase(), SVN_TAGS, tag ); + public static String resolveTagUrl(SvnScmProviderRepository repository, ScmTag tag) { + return resolveUrl(repository.getUrl(), repository.getTagBase(), SVN_TAGS, tag); } /** @@ -137,9 +119,8 @@ public static String resolveTagUrl( SvnScmProviderRepository repository, ScmTag * @return TODO * @see #resolveUrl(String,String,String,ScmBranch) */ - public static String resolveTagUrl( String repositoryUrl, ScmTag tag ) - { - return resolveUrl( repositoryUrl, null, SVN_TAGS, tag ); + public static String resolveTagUrl(String repositoryUrl, ScmTag tag) { + return resolveUrl(repositoryUrl, null, SVN_TAGS, tag); } /** @@ -152,9 +133,8 @@ public static String resolveTagUrl( String repositoryUrl, ScmTag tag ) * @return TODO * @see #resolveUrl(String,String,String,ScmBranch) */ - public static String resolveBranchUrl( SvnScmProviderRepository repository, ScmBranch branch ) - { - return resolveUrl( repository.getUrl(), repository.getBranchBase(), SVN_BRANCHES, branch ); + public static String resolveBranchUrl(SvnScmProviderRepository repository, ScmBranch branch) { + return resolveUrl(repository.getUrl(), repository.getBranchBase(), SVN_BRANCHES, branch); } /** @@ -166,17 +146,14 @@ public static String resolveBranchUrl( SvnScmProviderRepository repository, ScmB * @return TODO * @see #resolveUrl(String,String,String,ScmBranch) */ - public static String resolveBranchUrl( String repositoryUrl, ScmBranch branch ) - { - return resolveUrl( repositoryUrl, resolveBranchBase( repositoryUrl ), SVN_BRANCHES, branch ); + public static String resolveBranchUrl(String repositoryUrl, ScmBranch branch) { + return resolveUrl(repositoryUrl, resolveBranchBase(repositoryUrl), SVN_BRANCHES, branch); } - private static String addSuffix( String baseString, String suffix ) - { - return ( suffix != null ) ? baseString + suffix : baseString; + private static String addSuffix(String baseString, String suffix) { + return (suffix != null) ? baseString + suffix : baseString; } - /** * Resolves a tag or branch name to a repository url.
    * If the branchTagName is an absolute URL, that value is returned. @@ -198,65 +175,55 @@ private static String addSuffix( String baseString, String suffix ) * or even contain a relative path to the root like "branches/my-branch" * @return TODO */ - public static String resolveUrl( String repositoryUrl, String tagBase, String subdir, ScmBranch branchTag ) - { + public static String resolveUrl(String repositoryUrl, String tagBase, String subdir, ScmBranch branchTag) { String branchTagName = branchTag.getName(); - String projectRoot = getProjectRoot( repositoryUrl ); - branchTagName = StringUtils.strip( branchTagName, "/" ); + String projectRoot = getProjectRoot(repositoryUrl); + branchTagName = StringUtils.strip(branchTagName, "/"); - if ( StringUtils.isEmpty( branchTagName ) ) - { + if (StringUtils.isEmpty(branchTagName)) { return null; } // Look for a query string as in ViewSVN urls String queryString = null; - if ( repositoryUrl.indexOf( '?' ) >= 0 ) - { - queryString = repositoryUrl.substring( repositoryUrl.indexOf( '?' ) ); + if (repositoryUrl.indexOf('?') >= 0) { + queryString = repositoryUrl.substring(repositoryUrl.indexOf('?')); // if repositoryUrl contains a query string, remove it from repositoryUrlRoot; will be re-appended later - projectRoot = StringUtils.replace( projectRoot, queryString, "" ); + projectRoot = StringUtils.replace(projectRoot, queryString, ""); } - if ( branchTagName.indexOf( "://" ) >= 0 ) - { + if (branchTagName.indexOf("://") >= 0) { // branch/tag is already an absolute url so just return it. return branchTagName; } // User has a tagBase specified so just return the name appended to the tagBase - if ( StringUtils.isNotEmpty( tagBase ) && !tagBase.equals( resolveTagBase( repositoryUrl ) ) - && !tagBase.equals( resolveBranchBase( repositoryUrl ) ) ) - { - return appendPath( tagBase, branchTagName ); + if (StringUtils.isNotEmpty(tagBase) + && !tagBase.equals(resolveTagBase(repositoryUrl)) + && !tagBase.equals(resolveBranchBase(repositoryUrl))) { + return appendPath(tagBase, branchTagName); } // Look for any "branches/" or "tags/" specifiers in the branchTagName. If one occurs, // don't append the subdir to the projectRoot when appending the name - for ( int i = 0; i < SVN_BASE_DIRS.length; i++ ) - { - if ( branchTagName.startsWith( SVN_BASE_DIRS[i] + "/" ) ) - { - return addSuffix( appendPath( projectRoot, branchTagName ), queryString ); + for (int i = 0; i < SVN_BASE_DIRS.length; i++) { + if (branchTagName.startsWith(SVN_BASE_DIRS[i] + "/")) { + return addSuffix(appendPath(projectRoot, branchTagName), queryString); } } - return addSuffix( appendPath( appendPath( projectRoot, subdir ), branchTagName ), queryString ); + return addSuffix(appendPath(appendPath(projectRoot, subdir), branchTagName), queryString); } /* Helper function that does the checking for {@link #isRevisionSpecifier} */ - private static boolean checkRevisionArg( String arg ) - { - if ( StringUtils.isNumeric( arg ) || ( arg.startsWith( "{" ) && arg.endsWith( "}" ) ) ) - { + private static boolean checkRevisionArg(String arg) { + if (StringUtils.isNumeric(arg) || (arg.startsWith("{") && arg.endsWith("}"))) { return true; } - for ( int i = 0; i < REVISION_SPECIFIERS.length; i++ ) - { - if ( REVISION_SPECIFIERS[i].equalsIgnoreCase( arg ) ) - { + for (int i = 0; i < REVISION_SPECIFIERS.length; i++) { + if (REVISION_SPECIFIERS[i].equalsIgnoreCase(arg)) { return true; } } @@ -278,29 +245,24 @@ private static boolean checkRevisionArg( String arg ) * For command such as diff, the revision argument can be in the format of: * IDENTIFIER:IDENTIFIER where IDENTIFIER is one of the args listed above */ - public static boolean isRevisionSpecifier( ScmVersion version ) - { - if ( version == null ) - { + public static boolean isRevisionSpecifier(ScmVersion version) { + if (version == null) { return false; } String versionName = version.getName(); - if ( StringUtils.isEmpty( versionName ) ) - { + if (StringUtils.isEmpty(versionName)) { return false; } - if ( checkRevisionArg( versionName ) ) - { + if (checkRevisionArg(versionName)) { return true; } - String[] parts = StringUtils.split( versionName, ":" ); - if ( parts.length == 2 && StringUtils.isNotEmpty( parts[0] ) && StringUtils.isNotEmpty( parts[1] ) ) - { - return checkRevisionArg( parts[0] ) && checkRevisionArg( parts[1] ); + String[] parts = StringUtils.split(versionName, ":"); + if (parts.length == 2 && StringUtils.isNotEmpty(parts[0]) && StringUtils.isNotEmpty(parts[1])) { + return checkRevisionArg(parts[0]) && checkRevisionArg(parts[1]); } return false; diff --git a/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svn-commons/src/main/java/org/apache/maven/scm/provider/svn/command/SvnCommand.java b/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svn-commons/src/main/java/org/apache/maven/scm/provider/svn/command/SvnCommand.java index 04d4526e0..ce0283556 100644 --- a/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svn-commons/src/main/java/org/apache/maven/scm/provider/svn/command/SvnCommand.java +++ b/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svn-commons/src/main/java/org/apache/maven/scm/provider/svn/command/SvnCommand.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.svn.command; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider.svn.command; import org.apache.maven.scm.command.Command; @@ -25,8 +24,6 @@ * @author Trygve Laugstøl * */ -public interface SvnCommand - extends Command -{ +public interface SvnCommand extends Command { // no-op } diff --git a/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svn-commons/src/main/java/org/apache/maven/scm/provider/svn/command/diff/SvnDiffConsumer.java b/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svn-commons/src/main/java/org/apache/maven/scm/provider/svn/command/diff/SvnDiffConsumer.java index 81b7b0b85..5846833e9 100644 --- a/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svn-commons/src/main/java/org/apache/maven/scm/provider/svn/command/diff/SvnDiffConsumer.java +++ b/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svn-commons/src/main/java/org/apache/maven/scm/provider/svn/command/diff/SvnDiffConsumer.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.svn.command.diff; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,10 +16,7 @@ * specific language governing permissions and limitations * under the License. */ - -import org.apache.maven.scm.ScmFile; -import org.apache.maven.scm.ScmFileStatus; -import org.apache.maven.scm.util.AbstractConsumer; +package org.apache.maven.scm.provider.svn.command.diff; import java.io.File; import java.util.ArrayList; @@ -29,14 +24,16 @@ import java.util.List; import java.util.Map; +import org.apache.maven.scm.ScmFile; +import org.apache.maven.scm.ScmFileStatus; +import org.apache.maven.scm.util.AbstractConsumer; + /** * @author Brett Porter * @author Olivier Lamy * */ -public class SvnDiffConsumer - extends AbstractConsumer -{ +public class SvnDiffConsumer extends AbstractConsumer { // // Index: plugin.jelly // =================================================================== @@ -76,8 +73,7 @@ public class SvnDiffConsumer // // ---------------------------------------------------------------------- - public SvnDiffConsumer( File workingDirectory ) - { + public SvnDiffConsumer(File workingDirectory) { // empty } @@ -86,85 +82,69 @@ public SvnDiffConsumer( File workingDirectory ) // ---------------------------------------------------------------------- /** {@inheritDoc} */ - public void consumeLine( String line ) - { - if ( line.startsWith( INDEX_TOKEN ) ) - { + public void consumeLine(String line) { + if (line.startsWith(INDEX_TOKEN)) { // start a new file - currentFile = line.substring( INDEX_TOKEN.length() ); + currentFile = line.substring(INDEX_TOKEN.length()); - changedFiles.add( new ScmFile( currentFile, ScmFileStatus.MODIFIED ) ); + changedFiles.add(new ScmFile(currentFile, ScmFileStatus.MODIFIED)); currentDifference = new StringBuilder(); - differences.put( currentFile, currentDifference ); + differences.put(currentFile, currentDifference); - patch.append( line ).append( "\n" ); + patch.append(line).append("\n"); return; } - if ( currentFile == null ) - { - if ( logger.isWarnEnabled() ) - { - logger.warn( "Unparseable line: '" + line + "'" ); + if (currentFile == null) { + if (logger.isWarnEnabled()) { + logger.warn("Unparseable line: '" + line + "'"); } - patch.append( line ).append( "\n" ); + patch.append(line).append("\n"); return; } - if ( line.startsWith( FILE_SEPARATOR_TOKEN ) ) - { + if (line.startsWith(FILE_SEPARATOR_TOKEN)) { // skip - patch.append( line ).append( "\n" ); - } - else if ( line.startsWith( START_REVISION_TOKEN ) ) - { + patch.append(line).append("\n"); + } else if (line.startsWith(START_REVISION_TOKEN)) { // skip, though could parse to verify filename, start revision - patch.append( line ).append( "\n" ); - } - else if ( line.startsWith( END_REVISION_TOKEN ) ) - { + patch.append(line).append("\n"); + } else if (line.startsWith(END_REVISION_TOKEN)) { // skip, though could parse to verify filename, end revision - patch.append( line ).append( "\n" ); - } - else if ( line.startsWith( ADDED_LINE_TOKEN ) || line.startsWith( REMOVED_LINE_TOKEN ) - || line.startsWith( UNCHANGED_LINE_TOKEN ) || line.startsWith( CHANGE_SEPARATOR_TOKEN ) - || line.equals( NO_NEWLINE_TOKEN ) ) - { + patch.append(line).append("\n"); + } else if (line.startsWith(ADDED_LINE_TOKEN) + || line.startsWith(REMOVED_LINE_TOKEN) + || line.startsWith(UNCHANGED_LINE_TOKEN) + || line.startsWith(CHANGE_SEPARATOR_TOKEN) + || line.equals(NO_NEWLINE_TOKEN)) { // add to buffer - currentDifference.append( line ).append( "\n" ); - patch.append( line ).append( "\n" ); - } - else - { + currentDifference.append(line).append("\n"); + patch.append(line).append("\n"); + } else { // TODO: handle property differences - if ( logger.isWarnEnabled() ) - { - logger.warn( "Unparseable line: '" + line + "'" ); + if (logger.isWarnEnabled()) { + logger.warn("Unparseable line: '" + line + "'"); } - patch.append( line ).append( "\n" ); + patch.append(line).append("\n"); // skip to next file currentFile = null; currentDifference = null; } } - public List getChangedFiles() - { + public List getChangedFiles() { return changedFiles; } - public Map getDifferences() - { + public Map getDifferences() { return differences; } - public String getPatch() - { + public String getPatch() { return patch.toString(); } - } diff --git a/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svn-commons/src/main/java/org/apache/maven/scm/provider/svn/command/info/SvnInfoItem.java b/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svn-commons/src/main/java/org/apache/maven/scm/provider/svn/command/info/SvnInfoItem.java index 1e18664b9..79fb782e7 100644 --- a/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svn-commons/src/main/java/org/apache/maven/scm/provider/svn/command/info/SvnInfoItem.java +++ b/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svn-commons/src/main/java/org/apache/maven/scm/provider/svn/command/info/SvnInfoItem.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.svn.command.info; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider.svn.command.info; import org.apache.maven.scm.command.info.InfoItem; @@ -26,8 +25,6 @@ * * @deprecated use {@link InfoItem} */ -public class SvnInfoItem - extends InfoItem -{ +public class SvnInfoItem extends InfoItem { // no op } diff --git a/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svn-commons/src/main/java/org/apache/maven/scm/provider/svn/command/info/SvnInfoScmResult.java b/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svn-commons/src/main/java/org/apache/maven/scm/provider/svn/command/info/SvnInfoScmResult.java index 56f7c6bca..83d129c14 100644 --- a/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svn-commons/src/main/java/org/apache/maven/scm/provider/svn/command/info/SvnInfoScmResult.java +++ b/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svn-commons/src/main/java/org/apache/maven/scm/provider/svn/command/info/SvnInfoScmResult.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.svn.command.info; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider.svn.command.info; import java.util.List; @@ -29,33 +28,26 @@ * * @deprecated use {@link InfoScmResult} */ -public class SvnInfoScmResult - extends InfoScmResult -{ +public class SvnInfoScmResult extends InfoScmResult { private static final long serialVersionUID = 955993340040530451L; - - public SvnInfoScmResult( String commandLine, String providerMessage, String commandOutput, boolean success ) - { - super( commandLine, providerMessage, commandOutput, success ); + + public SvnInfoScmResult(String commandLine, String providerMessage, String commandOutput, boolean success) { + super(commandLine, providerMessage, commandOutput, success); } - public SvnInfoScmResult( String commandLine, List files ) - { - super( commandLine, null, null, true ); - if ( files != null ) - { - getInfoItems().addAll( files ); + public SvnInfoScmResult(String commandLine, List files) { + super(commandLine, null, null, true); + if (files != null) { + getInfoItems().addAll(files); } } - public SvnInfoScmResult( List files, ScmResult result ) - { - super( result ); + public SvnInfoScmResult(List files, ScmResult result) { + super(result); - if ( files != null ) - { - getInfoItems().addAll( files ); + if (files != null) { + getInfoItems().addAll(files); } } } diff --git a/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svn-commons/src/main/java/org/apache/maven/scm/provider/svn/command/update/SvnUpdateScmResult.java b/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svn-commons/src/main/java/org/apache/maven/scm/provider/svn/command/update/SvnUpdateScmResult.java index 77a538d39..011119a81 100644 --- a/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svn-commons/src/main/java/org/apache/maven/scm/provider/svn/command/update/SvnUpdateScmResult.java +++ b/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svn-commons/src/main/java/org/apache/maven/scm/provider/svn/command/update/SvnUpdateScmResult.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.svn.command.update; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider.svn.command.update; import java.util.List; @@ -29,14 +28,11 @@ * * @deprecated */ -public class SvnUpdateScmResult - extends UpdateScmResultWithRevision -{ +public class SvnUpdateScmResult extends UpdateScmResultWithRevision { private static final long serialVersionUID = -3233977852698721693L; - public SvnUpdateScmResult( String commandLine, List updatedFiles, int revision ) - { - super( commandLine, updatedFiles, String.valueOf( revision ) ); + public SvnUpdateScmResult(String commandLine, List updatedFiles, int revision) { + super(commandLine, updatedFiles, String.valueOf(revision)); } } diff --git a/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svn-commons/src/main/java/org/apache/maven/scm/provider/svn/repository/SvnScmProviderRepository.java b/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svn-commons/src/main/java/org/apache/maven/scm/provider/svn/repository/SvnScmProviderRepository.java index 5b12df064..8027aab4b 100644 --- a/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svn-commons/src/main/java/org/apache/maven/scm/provider/svn/repository/SvnScmProviderRepository.java +++ b/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svn-commons/src/main/java/org/apache/maven/scm/provider/svn/repository/SvnScmProviderRepository.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.svn.repository; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider.svn.repository; import org.apache.maven.scm.provider.ScmProviderRepository; import org.apache.maven.scm.provider.ScmProviderRepositoryWithHost; @@ -27,9 +26,7 @@ * @author Emmanuel Venisse * */ -public class SvnScmProviderRepository - extends ScmProviderRepositoryWithHost -{ +public class SvnScmProviderRepository extends ScmProviderRepositoryWithHost { /** */ private String url; @@ -45,34 +42,30 @@ public class SvnScmProviderRepository */ private String branchBase; - public SvnScmProviderRepository( String url ) - { - parseUrl( url ); + public SvnScmProviderRepository(String url) { + parseUrl(url); - tagBase = SvnTagBranchUtils.resolveTagBase( url ); + tagBase = SvnTagBranchUtils.resolveTagBase(url); - branchBase = SvnTagBranchUtils.resolveBranchBase( url ); + branchBase = SvnTagBranchUtils.resolveBranchBase(url); } - public SvnScmProviderRepository( String url, String user, String password ) - { - this( url ); + public SvnScmProviderRepository(String url, String user, String password) { + this(url); - setUser( user ); + setUser(user); - setPassword( password ); + setPassword(password); } - public String getUrl() - { + public String getUrl() { return url; } /** * Returns the url/directory to be used when tagging this repository. */ - public String getTagBase() - { + public String getTagBase() { return tagBase; } @@ -86,16 +79,14 @@ public String getTagBase() * @param tagBase an absolute or relative url to the base directory to create tags in. * URL should be in a format that svn client understands, not the scm url format. */ - public void setTagBase( String tagBase ) - { + public void setTagBase(String tagBase) { this.tagBase = tagBase; } /** * Returns the url/directory to be used when tagging this repository. */ - public String getBranchBase() - { + public String getBranchBase() { return branchBase; } @@ -109,13 +100,11 @@ public String getBranchBase() * @param branchBase an absolute or relative url to the base directory to create branch in. * URL should be in a format that svn client understands, not the scm url format. */ - public void setBranchBase( String branchBase ) - { + public void setBranchBase(String branchBase) { this.branchBase = branchBase; } - private void setProtocol( String protocol ) - { + private void setProtocol(String protocol) { this.protocol = protocol; } @@ -124,129 +113,99 @@ private void setProtocol( String protocol ) * * @return the protocol */ - public String getProtocol() - { + public String getProtocol() { return protocol; } - private void parseUrl( String url ) - { - if ( url.startsWith( "file" ) ) - { - setProtocol( "file://" ); - } - else if ( url.startsWith( "https" ) ) - { - setProtocol( "https://" ); - } - else if ( url.startsWith( "http" ) ) - { - setProtocol( "http://" ); - } - else if ( url.startsWith( "svn+" ) ) - { - setProtocol( url.substring( 0, url.indexOf( "://" ) + 3 ) ); - } - else if ( url.startsWith( "svn" ) ) - { - setProtocol( "svn://" ); + private void parseUrl(String url) { + if (url.startsWith("file")) { + setProtocol("file://"); + } else if (url.startsWith("https")) { + setProtocol("https://"); + } else if (url.startsWith("http")) { + setProtocol("http://"); + } else if (url.startsWith("svn+")) { + setProtocol(url.substring(0, url.indexOf("://") + 3)); + } else if (url.startsWith("svn")) { + setProtocol("svn://"); } - if ( getProtocol() == null ) - { + if (getProtocol() == null) { return; } - String urlPath = url.substring( getProtocol().length() ); + String urlPath = url.substring(getProtocol().length()); - int indexAt = urlPath.indexOf( '@' ); + int indexAt = urlPath.indexOf('@'); // a file:// URL may contain userinfo according to RFC 8089, but our implementation is broken // extract user information, broken see SCM-909 - if ( indexAt > 0 && !getProtocol().startsWith( "svn+" ) && !getProtocol().equals( "file://" ) ) - { - String userPassword = urlPath.substring( 0, indexAt ); - if ( userPassword.indexOf( ':' ) < 0 ) - { - setUser( userPassword ); - } - else - { - setUser( userPassword.substring( 0, userPassword.indexOf( ':' ) ) ); - setPassword( userPassword.substring( userPassword.indexOf( ':' ) + 1 ) ); + if (indexAt > 0 && !getProtocol().startsWith("svn+") && !getProtocol().equals("file://")) { + String userPassword = urlPath.substring(0, indexAt); + if (userPassword.indexOf(':') < 0) { + setUser(userPassword); + } else { + setUser(userPassword.substring(0, userPassword.indexOf(':'))); + setPassword(userPassword.substring(userPassword.indexOf(':') + 1)); } - urlPath = urlPath.substring( indexAt + 1 ); + urlPath = urlPath.substring(indexAt + 1); this.url = getProtocol() + urlPath; - } - else - { + } else { this.url = getProtocol() + urlPath; } - if ( !"file://".equals( getProtocol() ) ) - { - int indexSlash = urlPath.indexOf( '/' ); + if (!"file://".equals(getProtocol())) { + int indexSlash = urlPath.indexOf('/'); String hostPort = urlPath; - if ( indexSlash > 0 ) - { - hostPort = urlPath.substring( 0, indexSlash ); + if (indexSlash > 0) { + hostPort = urlPath.substring(0, indexSlash); } - int indexColon = hostPort.indexOf( ':' ); + int indexColon = hostPort.indexOf(':'); - if ( indexColon > 0 ) - { - setHost( hostPort.substring( 0, indexColon ) ); - setPort( Integer.parseInt( hostPort.substring( indexColon + 1 ) ) ); - } - else - { - setHost( hostPort ); + if (indexColon > 0) { + setHost(hostPort.substring(0, indexColon)); + setPort(Integer.parseInt(hostPort.substring(indexColon + 1))); + } else { + setHost(hostPort); } } } /** {@inheritDoc} */ - public ScmProviderRepository getParent() - { - String newUrl = getUrl().substring( getProtocol().length() ); + public ScmProviderRepository getParent() { + String newUrl = getUrl().substring(getProtocol().length()); - while ( newUrl.endsWith( "/." ) ) - { - newUrl = newUrl.substring( 0, newUrl.length() - 2 ); + while (newUrl.endsWith("/.")) { + newUrl = newUrl.substring(0, newUrl.length() - 2); } - while ( newUrl.endsWith( "/" ) ) - { - newUrl = newUrl.substring( 0, newUrl.length() - 1 ); + while (newUrl.endsWith("/")) { + newUrl = newUrl.substring(0, newUrl.length() - 1); } - int i = newUrl.lastIndexOf( '/' ); + int i = newUrl.lastIndexOf('/'); - if ( i < 0 ) - { + if (i < 0) { return null; } - newUrl = newUrl.substring( 0, i ); + newUrl = newUrl.substring(0, i); - return new SvnScmProviderRepository( getProtocol() + newUrl, getUser(), getPassword() ); + return new SvnScmProviderRepository(getProtocol() + newUrl, getUser(), getPassword()); } /** {@inheritDoc} */ - public String getRelativePath( ScmProviderRepository ancestor ) - { - if ( ancestor instanceof SvnScmProviderRepository ) - { + public String getRelativePath(ScmProviderRepository ancestor) { + if (ancestor instanceof SvnScmProviderRepository) { SvnScmProviderRepository svnAncestor = (SvnScmProviderRepository) ancestor; - String path = getUrl().replaceFirst( svnAncestor.getUrl() + "/", "" ); + String path = getUrl().replaceFirst(svnAncestor.getUrl() + "/", ""); - if ( !path.equals( getUrl() ) ) - { + if (!path.equals(getUrl())) { return path; } } @@ -254,9 +213,7 @@ public String getRelativePath( ScmProviderRepository ancestor ) } /** {@inheritDoc} */ - public String toString() - { + public String toString() { return getUrl(); } - } diff --git a/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svn-commons/src/main/java/org/apache/maven/scm/provider/svn/util/SvnUtil.java b/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svn-commons/src/main/java/org/apache/maven/scm/provider/svn/util/SvnUtil.java index d4d87f565..b24920803 100644 --- a/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svn-commons/src/main/java/org/apache/maven/scm/provider/svn/util/SvnUtil.java +++ b/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svn-commons/src/main/java/org/apache/maven/scm/provider/svn/util/SvnUtil.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.svn.util; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,76 +16,63 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider.svn.util; + +import java.io.File; +import java.io.IOException; import org.apache.maven.scm.providers.svn.settings.Settings; import org.apache.maven.scm.providers.svn.settings.io.xpp3.SvnXpp3Reader; import org.codehaus.plexus.util.ReaderFactory; import org.codehaus.plexus.util.xml.pull.XmlPullParserException; -import java.io.File; -import java.io.IOException; - /** * @author Emmanuel Venisse * */ -public class SvnUtil -{ +public class SvnUtil { protected static final String SVN_SETTINGS_FILENAME = "svn-settings.xml"; - public static final File DEFAULT_SETTINGS_DIRECTORY = new File( System.getProperty( "user.home" ), ".scm" ); + public static final File DEFAULT_SETTINGS_DIRECTORY = new File(System.getProperty("user.home"), ".scm"); private static File settingsDirectory = DEFAULT_SETTINGS_DIRECTORY; private static Settings settings; - private SvnUtil() - { - } + private SvnUtil() {} - public static Settings getSettings() - { - if ( settings == null ) - { + public static Settings getSettings() { + if (settings == null) { settings = readSettings(); } return settings; } - public static Settings readSettings() - { + public static Settings readSettings() { File settingsFile = getSettingsFile(); - if ( settingsFile.exists() ) - { + if (settingsFile.exists()) { SvnXpp3Reader reader = new SvnXpp3Reader(); - try - { - return reader.read( ReaderFactory.newXmlReader( settingsFile ) ); - } - catch ( IOException e ) - { - //Nothing to do - } - catch ( XmlPullParserException e ) - { + try { + return reader.read(ReaderFactory.newXmlReader(settingsFile)); + } catch (IOException e) { + // Nothing to do + } catch (XmlPullParserException e) { String message = settingsFile.getAbsolutePath() + " isn't well formed. SKIPPED." + e.getMessage(); - System.err.println( message ); + System.err.println(message); } } return new Settings(); } - public static void setSettingsDirectory( File directory ) - { + public static void setSettingsDirectory(File directory) { settingsDirectory = directory; settings = readSettings(); } - public static File getSettingsFile() - { - return new File( settingsDirectory, SVN_SETTINGS_FILENAME ); + public static File getSettingsFile() { + return new File(settingsDirectory, SVN_SETTINGS_FILENAME); } } diff --git a/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svn-commons/src/test/java/org/apache/maven/scm/provider/svn/SvnCommandUtilsTest.java b/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svn-commons/src/test/java/org/apache/maven/scm/provider/svn/SvnCommandUtilsTest.java index 005d68fc5..4e9cac122 100644 --- a/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svn-commons/src/test/java/org/apache/maven/scm/provider/svn/SvnCommandUtilsTest.java +++ b/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svn-commons/src/test/java/org/apache/maven/scm/provider/svn/SvnCommandUtilsTest.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.svn; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider.svn; import org.apache.maven.scm.ScmTestCase; import org.junit.Test; @@ -30,59 +29,49 @@ * @author Jerome Lacoste * */ -public class SvnCommandUtilsTest - extends ScmTestCase -{ +public class SvnCommandUtilsTest extends ScmTestCase { // ---------------------------------------------------------------------- // appendPath // ---------------------------------------------------------------------- @Test - public void testFixUrlHttpUrlsAreIgnored() - throws Exception - { + public void testFixUrlHttpUrlsAreIgnored() throws Exception { String unchanged = "http://foo.com/svn/myproject/tags/foo"; - assertEquals( unchanged, SvnCommandUtils.fixUrl( unchanged, null ) ); - assertEquals( unchanged, SvnCommandUtils.fixUrl( unchanged, "" ) ); - assertEquals( unchanged, SvnCommandUtils.fixUrl( unchanged, "user" ) ); + assertEquals(unchanged, SvnCommandUtils.fixUrl(unchanged, null)); + assertEquals(unchanged, SvnCommandUtils.fixUrl(unchanged, "")); + assertEquals(unchanged, SvnCommandUtils.fixUrl(unchanged, "user")); } @Test - public void testFixUrlNPEifNullURL() - throws Exception - { - try - { - SvnCommandUtils.fixUrl( null, "user" ); - fail( "expected NPE" ); - } - catch ( NullPointerException e ) - { - assertTrue( true ); // expected + public void testFixUrlNPEifNullURL() throws Exception { + try { + SvnCommandUtils.fixUrl(null, "user"); + fail("expected NPE"); + } catch (NullPointerException e) { + assertTrue(true); // expected } } @Test - public void testFixUrlSvnSshUrlsUsernameIsAddedWhenUserSpecified() - throws Exception - { - assertEquals( "svn+ssh://foo.com/svn/myproject", - SvnCommandUtils.fixUrl( "svn+ssh://foo.com/svn/myproject", null ) ); - assertEquals( "svn+ssh://foo.com/svn/myproject", - SvnCommandUtils.fixUrl( "svn+ssh://foo.com/svn/myproject", "" ) ); - assertEquals( "svn+ssh://user@foo.com/svn/myproject", - SvnCommandUtils.fixUrl( "svn+ssh://foo.com/svn/myproject", "user" ) ); + public void testFixUrlSvnSshUrlsUsernameIsAddedWhenUserSpecified() throws Exception { + assertEquals( + "svn+ssh://foo.com/svn/myproject", SvnCommandUtils.fixUrl("svn+ssh://foo.com/svn/myproject", null)); + assertEquals("svn+ssh://foo.com/svn/myproject", SvnCommandUtils.fixUrl("svn+ssh://foo.com/svn/myproject", "")); + assertEquals( + "svn+ssh://user@foo.com/svn/myproject", + SvnCommandUtils.fixUrl("svn+ssh://foo.com/svn/myproject", "user")); } @Test - public void testFixUrlSvnSshUrlsUsernameIsOverridenWhenUserSpecified() - throws Exception - { - assertEquals( "svn+ssh://user1@foo.com/svn/myproject", - SvnCommandUtils.fixUrl( "svn+ssh://user1@foo.com/svn/myproject", null ) ); - assertEquals( "svn+ssh://user1@foo.com/svn/myproject", - SvnCommandUtils.fixUrl( "svn+ssh://user1@foo.com/svn/myproject", "" ) ); - assertEquals( "svn+ssh://user2@foo.com/svn/myproject", - SvnCommandUtils.fixUrl( "svn+ssh://user1@foo.com/svn/myproject", "user2" ) ); + public void testFixUrlSvnSshUrlsUsernameIsOverridenWhenUserSpecified() throws Exception { + assertEquals( + "svn+ssh://user1@foo.com/svn/myproject", + SvnCommandUtils.fixUrl("svn+ssh://user1@foo.com/svn/myproject", null)); + assertEquals( + "svn+ssh://user1@foo.com/svn/myproject", + SvnCommandUtils.fixUrl("svn+ssh://user1@foo.com/svn/myproject", "")); + assertEquals( + "svn+ssh://user2@foo.com/svn/myproject", + SvnCommandUtils.fixUrl("svn+ssh://user1@foo.com/svn/myproject", "user2")); } } diff --git a/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svn-commons/src/test/java/org/apache/maven/scm/provider/svn/SvnTagBranchUtilsTest.java b/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svn-commons/src/test/java/org/apache/maven/scm/provider/svn/SvnTagBranchUtilsTest.java index d637f34d9..a1834a97e 100644 --- a/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svn-commons/src/test/java/org/apache/maven/scm/provider/svn/SvnTagBranchUtilsTest.java +++ b/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svn-commons/src/test/java/org/apache/maven/scm/provider/svn/SvnTagBranchUtilsTest.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.svn; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider.svn; import org.apache.maven.scm.ScmBranch; import org.apache.maven.scm.ScmRevision; @@ -35,49 +34,40 @@ * @author Emmanuel Venisse * */ -public class SvnTagBranchUtilsTest - extends ScmTestCase -{ +public class SvnTagBranchUtilsTest extends ScmTestCase { // ---------------------------------------------------------------------- // appendPath // ---------------------------------------------------------------------- @Test - public void testAppendPath() - throws Exception - { - assertEquals( "http://foo.com/svn/myproject/tags/foo", - SvnTagBranchUtils.appendPath( "http://foo.com/svn", "myproject/tags/foo" ) ); + public void testAppendPath() throws Exception { + assertEquals( + "http://foo.com/svn/myproject/tags/foo", + SvnTagBranchUtils.appendPath("http://foo.com/svn", "myproject/tags/foo")); } @Test - public void testAppendPathNullAddlPath() - throws Exception - { - assertEquals( "http://foo.com/svn", SvnTagBranchUtils.appendPath( "http://foo.com/svn", null ) ); + public void testAppendPathNullAddlPath() throws Exception { + assertEquals("http://foo.com/svn", SvnTagBranchUtils.appendPath("http://foo.com/svn", null)); } @Test - public void testAppendPathNullAddlTrailingSlash() - throws Exception - { - assertEquals( "http://foo.com/svn", SvnTagBranchUtils.appendPath( "http://foo.com/svn/", null ) ); + public void testAppendPathNullAddlTrailingSlash() throws Exception { + assertEquals("http://foo.com/svn", SvnTagBranchUtils.appendPath("http://foo.com/svn/", null)); } @Test - public void testAppendPathTrailingSlash() - throws Exception - { - assertEquals( "http://foo.com/svn/myproject/tags/foo", - SvnTagBranchUtils.appendPath( "http://foo.com/svn/", "myproject/tags/foo" ) ); + public void testAppendPathTrailingSlash() throws Exception { + assertEquals( + "http://foo.com/svn/myproject/tags/foo", + SvnTagBranchUtils.appendPath("http://foo.com/svn/", "myproject/tags/foo")); } @Test - public void testAppendPathLeadingAndTrailingSlash() - throws Exception - { - assertEquals( "http://foo.com/svn/myproject/tags/foo", - SvnTagBranchUtils.appendPath( "http://foo.com/svn/", "/myproject/tags/foo" ) ); + public void testAppendPathLeadingAndTrailingSlash() throws Exception { + assertEquals( + "http://foo.com/svn/myproject/tags/foo", + SvnTagBranchUtils.appendPath("http://foo.com/svn/", "/myproject/tags/foo")); } // ---------------------------------------------------------------------- @@ -85,12 +75,13 @@ public void testAppendPathLeadingAndTrailingSlash() // ---------------------------------------------------------------------- @Test - public void testResolveTagBase() - { - assertEquals( "http://foo.com/svn/myproject/tags", - SvnTagBranchUtils.resolveTagBase( "http://foo.com/svn/myproject/trunk" ) ); - assertEquals( "http://foo.com/svn/myproject/tags", - SvnTagBranchUtils.resolveTagBase( "http://foo.com/svn/myproject/trunk/" ) ); + public void testResolveTagBase() { + assertEquals( + "http://foo.com/svn/myproject/tags", + SvnTagBranchUtils.resolveTagBase("http://foo.com/svn/myproject/trunk")); + assertEquals( + "http://foo.com/svn/myproject/tags", + SvnTagBranchUtils.resolveTagBase("http://foo.com/svn/myproject/trunk/")); } // ---------------------------------------------------------------------- @@ -98,53 +89,48 @@ public void testResolveTagBase() // ---------------------------------------------------------------------- @Test - public void testGetProjectRootTagBranchTrunk() - throws Exception - { + public void testGetProjectRootTagBranchTrunk() throws Exception { // All of these should equate to the same project root - String[] paths = new String[]{"scm:svn:http://foo.com/svn/tags/my-tag", "scm:svn:http://foo.com/svn/tags", - "scm:svn:http://foo.com/svn/branches/my-branch", "scm:svn:http://foo.com/svn/branches", - "scm:svn:http://foo.com/svn/trunk", "scm:svn:http://foo.com/svn/trunk/some/path/to/some/file"}; - - for ( int i = 0; i < paths.length; i++ ) - { - testGetProjectRoot( paths[i], "http://foo.com/svn" ); + String[] paths = new String[] { + "scm:svn:http://foo.com/svn/tags/my-tag", + "scm:svn:http://foo.com/svn/tags", + "scm:svn:http://foo.com/svn/branches/my-branch", + "scm:svn:http://foo.com/svn/branches", + "scm:svn:http://foo.com/svn/trunk", + "scm:svn:http://foo.com/svn/trunk/some/path/to/some/file" + }; + + for (int i = 0; i < paths.length; i++) { + testGetProjectRoot(paths[i], "http://foo.com/svn"); } } @Test - public void testGetProjectRootNoRootSpecifier() - throws Exception - { - testGetProjectRoot( "scm:svn:http://foo.com/svn/", "http://foo.com/svn" ); + public void testGetProjectRootNoRootSpecifier() throws Exception { + testGetProjectRoot("scm:svn:http://foo.com/svn/", "http://foo.com/svn"); - testGetProjectRoot( "scm:svn:http://foo.com/svn", "http://foo.com/svn" ); + testGetProjectRoot("scm:svn:http://foo.com/svn", "http://foo.com/svn"); - testGetProjectRoot( "scm:svn:http://foo.com/svn/ntags", "http://foo.com/svn/ntags" ); + testGetProjectRoot("scm:svn:http://foo.com/svn/ntags", "http://foo.com/svn/ntags"); - testGetProjectRoot( "scm:svn:http://foo.com/svn/nbranches", "http://foo.com/svn/nbranches" ); + testGetProjectRoot("scm:svn:http://foo.com/svn/nbranches", "http://foo.com/svn/nbranches"); } @Test - public void testGetProjectRootLooksLikeRootSpecifier() - throws Exception - { - testGetProjectRoot( "scm:svn:http://foo.com/svn/tagst", "http://foo.com/svn/tagst" ); - - testGetProjectRoot( "scm:svn:http://foo.com/svn/tagst/tags", "http://foo.com/svn/tagst" ); + public void testGetProjectRootLooksLikeRootSpecifier() throws Exception { + testGetProjectRoot("scm:svn:http://foo.com/svn/tagst", "http://foo.com/svn/tagst"); - testGetProjectRoot( "scm:svn:http://foo.com/svn/branchess", "http://foo.com/svn/branchess" ); + testGetProjectRoot("scm:svn:http://foo.com/svn/tagst/tags", "http://foo.com/svn/tagst"); + testGetProjectRoot("scm:svn:http://foo.com/svn/branchess", "http://foo.com/svn/branchess"); } @Test - public void testGetProjectRootDoubleProjectRoots() - throws Exception - { - testGetProjectRoot( "scm:svn:http://foo.com/svn/tags/my-tag/tags/another-tag/", - "http://foo.com/svn/tags/my-tag" ); - testGetProjectRoot( "scm:svn:http://foo.com/svn/trunk/a_directory/trunk/", - "http://foo.com/svn/trunk/a_directory" ); + public void testGetProjectRootDoubleProjectRoots() throws Exception { + testGetProjectRoot( + "scm:svn:http://foo.com/svn/tags/my-tag/tags/another-tag/", "http://foo.com/svn/tags/my-tag"); + testGetProjectRoot( + "scm:svn:http://foo.com/svn/trunk/a_directory/trunk/", "http://foo.com/svn/trunk/a_directory"); } // ---------------------------------------------------------------------- @@ -152,113 +138,115 @@ public void testGetProjectRootDoubleProjectRoots() // ---------------------------------------------------------------------- @Test - public void testResolveTagRelative() - throws Exception - { - testResolveTagUrl( "scm:svn:http://foo.com/svn/", "my-tag", "http://foo.com/svn/tags/my-tag" ); + public void testResolveTagRelative() throws Exception { + testResolveTagUrl("scm:svn:http://foo.com/svn/", "my-tag", "http://foo.com/svn/tags/my-tag"); - testResolveTagUrl( "scm:svn:http://foo.com/svn/trunk", "my-tag", "http://foo.com/svn/tags/my-tag" ); + testResolveTagUrl("scm:svn:http://foo.com/svn/trunk", "my-tag", "http://foo.com/svn/tags/my-tag"); - testResolveTagUrl( "scm:svn:http://foo.com/svn/trunk/", "my-tag", "http://foo.com/svn/tags/my-tag" ); + testResolveTagUrl("scm:svn:http://foo.com/svn/trunk/", "my-tag", "http://foo.com/svn/tags/my-tag"); - testResolveTagUrl( "scm:svn:http://foo.com/svn/branches", "my-tag", "http://foo.com/svn/tags/my-tag" ); + testResolveTagUrl("scm:svn:http://foo.com/svn/branches", "my-tag", "http://foo.com/svn/tags/my-tag"); - testResolveTagUrl( "scm:svn:http://foo.com/svn/tags", "my-tag", "http://foo.com/svn/tags/my-tag" ); + testResolveTagUrl("scm:svn:http://foo.com/svn/tags", "my-tag", "http://foo.com/svn/tags/my-tag"); } @Test - public void testResolveTagAbsolute() - throws Exception - { - testResolveTagUrl( "scm:svn:http://foo.com/svn/", "http://foo.com/svn/branches/my-tag", - "http://foo.com/svn/branches/my-tag" ); - - testResolveTagUrl( "scm:svn:http://foo.com/svn/", "file://C://svn/some/crazy/path/my-tag", - "file://C://svn/some/crazy/path/my-tag" ); - + public void testResolveTagAbsolute() throws Exception { + testResolveTagUrl( + "scm:svn:http://foo.com/svn/", + "http://foo.com/svn/branches/my-tag", + "http://foo.com/svn/branches/my-tag"); + + testResolveTagUrl( + "scm:svn:http://foo.com/svn/", + "file://C://svn/some/crazy/path/my-tag", + "file://C://svn/some/crazy/path/my-tag"); } @Test - public void testResolveTagWithSlashes() - throws Exception - { - testResolveTagUrl( "scm:svn:http://foo.com/svn/", "/my-tag/", "http://foo.com/svn/tags/my-tag" ); + public void testResolveTagWithSlashes() throws Exception { + testResolveTagUrl("scm:svn:http://foo.com/svn/", "/my-tag/", "http://foo.com/svn/tags/my-tag"); - testResolveBranchUrl( "scm:svn:http://foo.com/svn/", "/my-branch/", "http://foo.com/svn/branches/my-branch" ); + testResolveBranchUrl("scm:svn:http://foo.com/svn/", "/my-branch/", "http://foo.com/svn/branches/my-branch"); - testResolveBranchUrl( "scm:svn:http://foo.com/svn/", "http://foo.com/svn/myproject/branches/", "/my-branch/", - "http://foo.com/svn/myproject/branches/my-branch" ); + testResolveBranchUrl( + "scm:svn:http://foo.com/svn/", + "http://foo.com/svn/myproject/branches/", + "/my-branch/", + "http://foo.com/svn/myproject/branches/my-branch"); } @Test - public void testResolveTagWithTagOverwritingBase() - throws Exception - { - testResolveTagUrl( "scm:svn:http://foo.com/svn/", "branches/my-tag", "http://foo.com/svn/branches/my-tag" ); + public void testResolveTagWithTagOverwritingBase() throws Exception { + testResolveTagUrl("scm:svn:http://foo.com/svn/", "branches/my-tag", "http://foo.com/svn/branches/my-tag"); - testResolveTagUrl( "scm:svn:http://foo.com/svn/", "tags/my-tag", "http://foo.com/svn/tags/my-tag" ); + testResolveTagUrl("scm:svn:http://foo.com/svn/", "tags/my-tag", "http://foo.com/svn/tags/my-tag"); // Not sure why you would ever specify a tag of /trunk/foo, // but create the test case to assure consistent behavior in the future - testResolveTagUrl( "scm:svn:http://foo.com/svn/", "trunk/my-tag", "http://foo.com/svn/trunk/my-tag" ); - - testResolveTagUrl( "scm:svn:svn+ssh://foo.com/svn/trunk/my_path/to/my_dir", "my-tag", - "svn+ssh://foo.com/svn/tags/my-tag" ); - - testResolveTagUrl( "scm:svn:svn+ssh://foo.com/svn/trunk/my_path/to/my_dir/trunk/mydir", "my-tag", - "svn+ssh://foo.com/svn/trunk/my_path/to/my_dir/tags/my-tag" ); - testResolveTagUrl( "scm:svn:file://localhost/C:/mydir/myproject/trunk/my-module/target/scm-src/trunk", "my-tag", - "file://localhost/C:/mydir/myproject/trunk/my-module/target/scm-src/tags/my-tag" ); + testResolveTagUrl("scm:svn:http://foo.com/svn/", "trunk/my-tag", "http://foo.com/svn/trunk/my-tag"); + + testResolveTagUrl( + "scm:svn:svn+ssh://foo.com/svn/trunk/my_path/to/my_dir", "my-tag", "svn+ssh://foo.com/svn/tags/my-tag"); + + testResolveTagUrl( + "scm:svn:svn+ssh://foo.com/svn/trunk/my_path/to/my_dir/trunk/mydir", + "my-tag", + "svn+ssh://foo.com/svn/trunk/my_path/to/my_dir/tags/my-tag"); + testResolveTagUrl( + "scm:svn:file://localhost/C:/mydir/myproject/trunk/my-module/target/scm-src/trunk", + "my-tag", + "file://localhost/C:/mydir/myproject/trunk/my-module/target/scm-src/tags/my-tag"); } @Test - public void testResolveTagWithTagBaseSpecified() - throws Exception - { - testResolveTagUrl( "scm:svn:http://foo.com/svn/", "../tags", "my-tag", "../tags/my-tag" ); - - testResolveTagUrl( "scm:svn:http://foo.com/svn/", "http://foo.com/svn/non-standard/tag/dir/", "my-tag", - "http://foo.com/svn/non-standard/tag/dir/my-tag" ); + public void testResolveTagWithTagBaseSpecified() throws Exception { + testResolveTagUrl("scm:svn:http://foo.com/svn/", "../tags", "my-tag", "../tags/my-tag"); + + testResolveTagUrl( + "scm:svn:http://foo.com/svn/", + "http://foo.com/svn/non-standard/tag/dir/", + "my-tag", + "http://foo.com/svn/non-standard/tag/dir/my-tag"); } @Test - public void testResolveTagLooksLikeOverwriteTagBase() - throws Exception - { - testResolveTagUrl( "scm:svn:http://foo.com/svn/", "tagst/my-tag", "http://foo.com/svn/tags/tagst/my-tag" ); + public void testResolveTagLooksLikeOverwriteTagBase() throws Exception { + testResolveTagUrl("scm:svn:http://foo.com/svn/", "tagst/my-tag", "http://foo.com/svn/tags/tagst/my-tag"); - testResolveTagUrl( "scm:svn:http://foo.com/svn/", "metatags/my-tag", - "http://foo.com/svn/tags/metatags/my-tag" ); + testResolveTagUrl("scm:svn:http://foo.com/svn/", "metatags/my-tag", "http://foo.com/svn/tags/metatags/my-tag"); } @Test - public void testResolveBranchSimple() - throws Exception - { - testResolveBranchUrl( "scm:svn:http://foo.com/svn/", "my-branch", "http://foo.com/svn/branches/my-branch" ); - - testResolveBranchUrl( "scm:svn:svn+ssh://foo.com/svn/trunk", "my-branch", - "svn+ssh://foo.com/svn/branches/my-branch" ); + public void testResolveBranchSimple() throws Exception { + testResolveBranchUrl("scm:svn:http://foo.com/svn/", "my-branch", "http://foo.com/svn/branches/my-branch"); - testResolveBranchUrl( "scm:svn:svn+ssh://foo.com/svn/trunk/my_path/to/my_dir", "my-branch", - "svn+ssh://foo.com/svn/branches/my-branch" ); + testResolveBranchUrl( + "scm:svn:svn+ssh://foo.com/svn/trunk", "my-branch", "svn+ssh://foo.com/svn/branches/my-branch"); - testResolveBranchUrl( "scm:svn:http://foo.com/svn/trunk", "branches/my-branch", - "http://foo.com/svn/branches/my-branch" ); + testResolveBranchUrl( + "scm:svn:svn+ssh://foo.com/svn/trunk/my_path/to/my_dir", + "my-branch", + "svn+ssh://foo.com/svn/branches/my-branch"); - testResolveBranchUrl( "scm:svn:http://foo.com/svn/", "subbranches/my-branch", - "http://foo.com/svn/branches/subbranches/my-branch" ); + testResolveBranchUrl( + "scm:svn:http://foo.com/svn/trunk", "branches/my-branch", "http://foo.com/svn/branches/my-branch"); + testResolveBranchUrl( + "scm:svn:http://foo.com/svn/", + "subbranches/my-branch", + "http://foo.com/svn/branches/subbranches/my-branch"); } @Test - public void testResolveBranchTagBase() - throws Exception - { - testResolveBranchUrl( "scm:svn:http://foo.com/svn/", "../branches", "my-branch", "../branches/my-branch" ); - - testResolveBranchUrl( "scm:svn:http://foo.com/svn/", "http://foo.com/svn/non-standard/branch/dir", "my-branch", - "http://foo.com/svn/non-standard/branch/dir/my-branch" ); + public void testResolveBranchTagBase() throws Exception { + testResolveBranchUrl("scm:svn:http://foo.com/svn/", "../branches", "my-branch", "../branches/my-branch"); + + testResolveBranchUrl( + "scm:svn:http://foo.com/svn/", + "http://foo.com/svn/non-standard/branch/dir", + "my-branch", + "http://foo.com/svn/non-standard/branch/dir/my-branch"); } // ---------------------------------------------------------------------- @@ -266,111 +254,89 @@ public void testResolveBranchTagBase() // ---------------------------------------------------------------------- @Test - public void testIsRevisionArgumentSimple() - { - assertTrue( SvnTagBranchUtils.isRevisionSpecifier( new ScmRevision( "12345" ) ) ); - - assertTrue( SvnTagBranchUtils.isRevisionSpecifier( new ScmRevision( "hEaD" ) ) ); + public void testIsRevisionArgumentSimple() { + assertTrue(SvnTagBranchUtils.isRevisionSpecifier(new ScmRevision("12345"))); - assertTrue( SvnTagBranchUtils.isRevisionSpecifier( new ScmRevision( "bAsE" ) ) ); + assertTrue(SvnTagBranchUtils.isRevisionSpecifier(new ScmRevision("hEaD"))); - assertTrue( SvnTagBranchUtils.isRevisionSpecifier( new ScmRevision( "cOmMiTtEd" ) ) ); + assertTrue(SvnTagBranchUtils.isRevisionSpecifier(new ScmRevision("bAsE"))); - assertTrue( SvnTagBranchUtils.isRevisionSpecifier( new ScmRevision( "pReV" ) ) ); + assertTrue(SvnTagBranchUtils.isRevisionSpecifier(new ScmRevision("cOmMiTtEd"))); - assertTrue( SvnTagBranchUtils.isRevisionSpecifier( new ScmRevision( "{2005-1-1}" ) ) ); + assertTrue(SvnTagBranchUtils.isRevisionSpecifier(new ScmRevision("pReV"))); + assertTrue(SvnTagBranchUtils.isRevisionSpecifier(new ScmRevision("{2005-1-1}"))); } @Test - public void testIsRevisionArgumentRange() - { - assertTrue( SvnTagBranchUtils.isRevisionSpecifier( new ScmRevision( "12345:12345" ) ) ); + public void testIsRevisionArgumentRange() { + assertTrue(SvnTagBranchUtils.isRevisionSpecifier(new ScmRevision("12345:12345"))); - assertTrue( SvnTagBranchUtils.isRevisionSpecifier( new ScmRevision( "1:2" ) ) ); + assertTrue(SvnTagBranchUtils.isRevisionSpecifier(new ScmRevision("1:2"))); - assertTrue( SvnTagBranchUtils.isRevisionSpecifier( new ScmRevision( "hEaD:bAsE" ) ) ); + assertTrue(SvnTagBranchUtils.isRevisionSpecifier(new ScmRevision("hEaD:bAsE"))); - assertTrue( SvnTagBranchUtils.isRevisionSpecifier( new ScmRevision( "BaSe:CoMmItTeD" ) ) ); + assertTrue(SvnTagBranchUtils.isRevisionSpecifier(new ScmRevision("BaSe:CoMmItTeD"))); - assertTrue( SvnTagBranchUtils.isRevisionSpecifier( new ScmRevision( "{2004-1-1}:{2005-1-1}" ) ) ); - - assertFalse( SvnTagBranchUtils.isRevisionSpecifier( new ScmRevision( "BASE:" ) ) ); - assertFalse( SvnTagBranchUtils.isRevisionSpecifier( new ScmRevision( ":BASE" ) ) ); + assertTrue(SvnTagBranchUtils.isRevisionSpecifier(new ScmRevision("{2004-1-1}:{2005-1-1}"))); + assertFalse(SvnTagBranchUtils.isRevisionSpecifier(new ScmRevision("BASE:"))); + assertFalse(SvnTagBranchUtils.isRevisionSpecifier(new ScmRevision(":BASE"))); } // ---------------------------------------------------------------------- // // ---------------------------------------------------------------------- - private SvnScmProviderRepository getSvnRepository( String scmUrl ) - throws Exception - { - ScmRepository repository = getScmManager().makeScmRepository( scmUrl ); + private SvnScmProviderRepository getSvnRepository(String scmUrl) throws Exception { + ScmRepository repository = getScmManager().makeScmRepository(scmUrl); return (SvnScmProviderRepository) repository.getProviderRepository(); } - private void testGetProjectRoot( String scmUrl, String expected ) - throws Exception - { - assertEquals( expected, SvnTagBranchUtils.getProjectRoot( getSvnRepository( scmUrl ).getUrl() ) ); + private void testGetProjectRoot(String scmUrl, String expected) throws Exception { + assertEquals( + expected, + SvnTagBranchUtils.getProjectRoot(getSvnRepository(scmUrl).getUrl())); } - private void testResolveTagUrl( String scmUrl, String tag, String expected ) - throws Exception - { - testResolveTagUrl( scmUrl, null, tag, expected ); + private void testResolveTagUrl(String scmUrl, String tag, String expected) throws Exception { + testResolveTagUrl(scmUrl, null, tag, expected); } - private void testResolveTagUrl( String scmUrl, String tagBase, String tag, String expected ) - throws Exception - { - SvnScmProviderRepository repository = getSvnRepository( scmUrl ); + private void testResolveTagUrl(String scmUrl, String tagBase, String tag, String expected) throws Exception { + SvnScmProviderRepository repository = getSvnRepository(scmUrl); - if ( tagBase != null ) - { - repository.setTagBase( tagBase ); + if (tagBase != null) { + repository.setTagBase(tagBase); } - if ( tagBase != null ) - { - assertEquals( repository.getTagBase(), tagBase ); - } - else - { - assertEquals( repository.getTagBase(), SvnTagBranchUtils.resolveTagBase( repository.getUrl() ) ); + if (tagBase != null) { + assertEquals(repository.getTagBase(), tagBase); + } else { + assertEquals(repository.getTagBase(), SvnTagBranchUtils.resolveTagBase(repository.getUrl())); } - assertEquals( expected, SvnTagBranchUtils.resolveTagUrl( repository, new ScmTag( tag ) ) ); + assertEquals(expected, SvnTagBranchUtils.resolveTagUrl(repository, new ScmTag(tag))); } - private void testResolveBranchUrl( String scmUrl, String branch, String expected ) - throws Exception - { - testResolveBranchUrl( scmUrl, null, branch, expected ); + private void testResolveBranchUrl(String scmUrl, String branch, String expected) throws Exception { + testResolveBranchUrl(scmUrl, null, branch, expected); } - private void testResolveBranchUrl( String scmUrl, String branchBase, String branch, String expected ) - throws Exception - { - SvnScmProviderRepository repository = getSvnRepository( scmUrl ); - if ( branchBase != null ) - { - repository.setBranchBase( branchBase ); + private void testResolveBranchUrl(String scmUrl, String branchBase, String branch, String expected) + throws Exception { + SvnScmProviderRepository repository = getSvnRepository(scmUrl); + if (branchBase != null) { + repository.setBranchBase(branchBase); } - if ( branchBase != null ) - { - assertEquals( repository.getBranchBase(), branchBase ); - } - else - { - assertEquals( repository.getBranchBase(), SvnTagBranchUtils.resolveBranchBase( repository.getUrl() ) ); + if (branchBase != null) { + assertEquals(repository.getBranchBase(), branchBase); + } else { + assertEquals(repository.getBranchBase(), SvnTagBranchUtils.resolveBranchBase(repository.getUrl())); } - assertEquals( expected, SvnTagBranchUtils.resolveBranchUrl( repository, new ScmBranch( branch ) ) ); + assertEquals(expected, SvnTagBranchUtils.resolveBranchUrl(repository, new ScmBranch(branch))); } - } diff --git a/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svn-commons/src/test/java/org/apache/maven/scm/provider/svn/TestSvnScmProvider.java b/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svn-commons/src/test/java/org/apache/maven/scm/provider/svn/TestSvnScmProvider.java index a582fbbed..5660556eb 100644 --- a/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svn-commons/src/test/java/org/apache/maven/scm/provider/svn/TestSvnScmProvider.java +++ b/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svn-commons/src/test/java/org/apache/maven/scm/provider/svn/TestSvnScmProvider.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.svn; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,111 +16,91 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider.svn; import javax.inject.Named; import javax.inject.Singleton; +import java.io.File; + import org.apache.maven.scm.CommandParameters; import org.apache.maven.scm.ScmException; import org.apache.maven.scm.provider.ScmProviderRepository; import org.apache.maven.scm.provider.svn.command.SvnCommand; -import java.io.File; - @Singleton -@Named( "svn" ) -public class TestSvnScmProvider - extends AbstractSvnScmProvider -{ - protected SvnCommand getAddCommand() - { +@Named("svn") +public class TestSvnScmProvider extends AbstractSvnScmProvider { + protected SvnCommand getAddCommand() { return null; } - protected SvnCommand getBranchCommand() - { + protected SvnCommand getBranchCommand() { return null; } - protected SvnCommand getChangeLogCommand() - { + protected SvnCommand getChangeLogCommand() { return null; } - protected SvnCommand getCheckInCommand() - { + protected SvnCommand getCheckInCommand() { return null; } - protected SvnCommand getCheckOutCommand() - { + protected SvnCommand getCheckOutCommand() { return null; } - protected SvnCommand getDiffCommand() - { + protected SvnCommand getDiffCommand() { return null; } - protected SvnCommand getExportCommand() - { + protected SvnCommand getExportCommand() { return null; } - protected SvnCommand getRemoveCommand() - { + protected SvnCommand getRemoveCommand() { return null; } - protected SvnCommand getStatusCommand() - { + protected SvnCommand getStatusCommand() { return null; } - protected SvnCommand getTagCommand() - { + protected SvnCommand getTagCommand() { return null; } - protected SvnCommand getUntagCommand() - { + protected SvnCommand getUntagCommand() { return null; } - protected SvnCommand getUpdateCommand() - { + protected SvnCommand getUpdateCommand() { return null; } - protected SvnCommand getListCommand() - { + protected SvnCommand getListCommand() { return null; } - protected SvnCommand getInfoCommand() - { + protected SvnCommand getInfoCommand() { return null; } - protected SvnCommand getBlameCommand() - { + protected SvnCommand getBlameCommand() { return null; } - protected SvnCommand getMkdirCommand() - { + protected SvnCommand getMkdirCommand() { return null; } - protected String getRepositoryURL( File path ) - { + protected String getRepositoryURL(File path) { return null; } @Override - public boolean remoteUrlExist( ScmProviderRepository repository, CommandParameters parameters ) - throws ScmException - { + public boolean remoteUrlExist(ScmProviderRepository repository, CommandParameters parameters) throws ScmException { return false; } } diff --git a/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svn-commons/src/test/java/org/apache/maven/scm/provider/svn/repository/SvnScmProviderRepositoryTest.java b/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svn-commons/src/test/java/org/apache/maven/scm/provider/svn/repository/SvnScmProviderRepositoryTest.java index 8c3bd8fcc..690fbe5df 100644 --- a/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svn-commons/src/test/java/org/apache/maven/scm/provider/svn/repository/SvnScmProviderRepositoryTest.java +++ b/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svn-commons/src/test/java/org/apache/maven/scm/provider/svn/repository/SvnScmProviderRepositoryTest.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.svn.repository; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider.svn.repository; import org.apache.maven.scm.ScmTestCase; import org.apache.maven.scm.manager.ScmManager; @@ -35,16 +34,12 @@ * @author Emmanuel Venisse * */ -public class SvnScmProviderRepositoryTest - extends ScmTestCase -{ +public class SvnScmProviderRepositoryTest extends ScmTestCase { private ScmManager scmManager; @Before @Override - public void setUp() - throws Exception - { + public void setUp() throws Exception { super.setUp(); scmManager = getScmManager(); @@ -55,104 +50,118 @@ public void setUp() // ---------------------------------------------------------------------- @Test - public void testLegalFileURL() - throws Exception - { - testUrl( "scm:svn:file:///tmp/repo", "file:///tmp/repo", null, null, null ); + public void testLegalFileURL() throws Exception { + testUrl("scm:svn:file:///tmp/repo", "file:///tmp/repo", null, null, null); } @Test - public void testLegalLocalhostFileURL() - throws Exception - { - testUrl( "scm:svn:file://localhost/tmp/repo", "file://localhost/tmp/repo", null, null, null ); + public void testLegalLocalhostFileURL() throws Exception { + testUrl("scm:svn:file://localhost/tmp/repo", "file://localhost/tmp/repo", null, null, null); } @Test - public void testLegalHistnameFileURL() - throws Exception - { - testUrl( "scm:svn:file://my_server/tmp/repo", "file://my_server/tmp/repo", null, null, null ); + public void testLegalHistnameFileURL() throws Exception { + testUrl("scm:svn:file://my_server/tmp/repo", "file://my_server/tmp/repo", null, null, null); } @Test - public void testLegalHttpURL() - throws Exception - { - testUrl( "scm:svn:http://subversion.tigris.org", "http://subversion.tigris.org", null, null, - "subversion.tigris.org" ); + public void testLegalHttpURL() throws Exception { + testUrl( + "scm:svn:http://subversion.tigris.org", + "http://subversion.tigris.org", + null, + null, + "subversion.tigris.org"); } @Test - public void testLegalHttpURLWithUser() - throws Exception - { - testUrl( "scm:svn:http://user@subversion.tigris.org", "http://subversion.tigris.org", "user", null, - "subversion.tigris.org" ); + public void testLegalHttpURLWithUser() throws Exception { + testUrl( + "scm:svn:http://user@subversion.tigris.org", + "http://subversion.tigris.org", + "user", + null, + "subversion.tigris.org"); } @Test - public void testLegalHttpURLWithUserPassword() - throws Exception - { - testUrl( "scm:svn:http://user:password@subversion.tigris.org", "http://subversion.tigris.org", "user", - "password", "subversion.tigris.org" ); + public void testLegalHttpURLWithUserPassword() throws Exception { + testUrl( + "scm:svn:http://user:password@subversion.tigris.org", + "http://subversion.tigris.org", + "user", + "password", + "subversion.tigris.org"); } @Test - public void testLegalHttpsURL() - throws Exception - { - testUrl( "scm:svn:https://subversion.tigris.org", "https://subversion.tigris.org", null, null, - "subversion.tigris.org" ); + public void testLegalHttpsURL() throws Exception { + testUrl( + "scm:svn:https://subversion.tigris.org", + "https://subversion.tigris.org", + null, + null, + "subversion.tigris.org"); } @Test - public void testLegalHttpsURLWithUser() - throws Exception - { - testUrl( "scm:svn:https://user@subversion.tigris.org", "https://subversion.tigris.org", "user", null, - "subversion.tigris.org" ); + public void testLegalHttpsURLWithUser() throws Exception { + testUrl( + "scm:svn:https://user@subversion.tigris.org", + "https://subversion.tigris.org", + "user", + null, + "subversion.tigris.org"); } @Test - public void testLegalHttpsURLWithUserPassword() - throws Exception - { - testUrl( "scm:svn:https://user:password@subversion.tigris.org", "https://subversion.tigris.org", "user", - "password", "subversion.tigris.org" ); + public void testLegalHttpsURLWithUserPassword() throws Exception { + testUrl( + "scm:svn:https://user:password@subversion.tigris.org", + "https://subversion.tigris.org", + "user", + "password", + "subversion.tigris.org"); } @Test - public void testLegalSvnURL() - throws Exception - { - testUrl( "scm:svn:svn://subversion.tigris.org", "svn://subversion.tigris.org", null, null, - "subversion.tigris.org" ); + public void testLegalSvnURL() throws Exception { + testUrl( + "scm:svn:svn://subversion.tigris.org", + "svn://subversion.tigris.org", + null, + null, + "subversion.tigris.org"); } @Test - public void testLegalSvnPlusUsernameURL() - throws Exception - { - testUrl( "scm:svn:svn://username@subversion.tigris.org", "svn://subversion.tigris.org", "username", null, - "subversion.tigris.org" ); + public void testLegalSvnPlusUsernameURL() throws Exception { + testUrl( + "scm:svn:svn://username@subversion.tigris.org", + "svn://subversion.tigris.org", + "username", + null, + "subversion.tigris.org"); } @Test - public void testLegalSvnPlusUsernamePasswordURL() - throws Exception - { - testUrl( "scm:svn:svn://username:password@subversion.tigris.org", "svn://subversion.tigris.org", "username", - "password", "subversion.tigris.org" ); + public void testLegalSvnPlusUsernamePasswordURL() throws Exception { + testUrl( + "scm:svn:svn://username:password@subversion.tigris.org", + "svn://subversion.tigris.org", + "username", + "password", + "subversion.tigris.org"); } @Test - public void testLegalSvnPlusSshURL() - throws Exception - { - testUrl( "scm:svn:svn+ssh://subversion.tigris.org", "svn+ssh://subversion.tigris.org", null, null, - "subversion.tigris.org" ); + public void testLegalSvnPlusSshURL() throws Exception { + testUrl( + "scm:svn:svn+ssh://subversion.tigris.org", + "svn+ssh://subversion.tigris.org", + null, + null, + "subversion.tigris.org"); } /* This test require a specific subversion config file @@ -164,11 +173,13 @@ public void testLegalSvnPlusXxxURL() }*/ @Test - public void testLegalSvnPlusSshPlusUsernameURL() - throws Exception - { - testUrl( "scm:svn:svn+ssh://username@subversion.tigris.org", "svn+ssh://username@subversion.tigris.org", null, - null, "username@subversion.tigris.org" ); + public void testLegalSvnPlusSshPlusUsernameURL() throws Exception { + testUrl( + "scm:svn:svn+ssh://username@subversion.tigris.org", + "svn+ssh://username@subversion.tigris.org", + null, + null, + "username@subversion.tigris.org"); } /* This test require a specific subversion config file @@ -180,18 +191,31 @@ public void testLegalSvnPlusXxxPlusUsernameURL() }*/ @Test - public void testLegalSvnPortUrl() - throws Exception - { - testUrl( "scm:svn:http://username@subversion.tigris.org:8800/pmgt/trunk", - "http://subversion.tigris.org:8800/pmgt/trunk", "username", "subversion.tigris.org", 8800 ); - testUrl( "scm:svn:https://username@subversion.tigris.org:8080/pmgt/trunk", - "https://subversion.tigris.org:8080/pmgt/trunk", "username", "subversion.tigris.org", 8080 ); - testUrl( "scm:svn:svn://username@subversion.tigris.org:8800/pmgt/trunk", - "svn://subversion.tigris.org:8800/pmgt/trunk", "username", "subversion.tigris.org", 8800 ); - testUrl( "scm:svn:svn+ssh://username@subversion.tigris.org:8080/pmgt/trunk", - "svn+ssh://username@subversion.tigris.org:8080/pmgt/trunk", null, "username@subversion.tigris.org", - 8080 ); + public void testLegalSvnPortUrl() throws Exception { + testUrl( + "scm:svn:http://username@subversion.tigris.org:8800/pmgt/trunk", + "http://subversion.tigris.org:8800/pmgt/trunk", + "username", + "subversion.tigris.org", + 8800); + testUrl( + "scm:svn:https://username@subversion.tigris.org:8080/pmgt/trunk", + "https://subversion.tigris.org:8080/pmgt/trunk", + "username", + "subversion.tigris.org", + 8080); + testUrl( + "scm:svn:svn://username@subversion.tigris.org:8800/pmgt/trunk", + "svn://subversion.tigris.org:8800/pmgt/trunk", + "username", + "subversion.tigris.org", + 8800); + testUrl( + "scm:svn:svn+ssh://username@subversion.tigris.org:8080/pmgt/trunk", + "svn+ssh://username@subversion.tigris.org:8080/pmgt/trunk", + null, + "username@subversion.tigris.org", + 8080); } // ---------------------------------------------------------------------- @@ -199,98 +223,93 @@ public void testLegalSvnPortUrl() // ---------------------------------------------------------------------- @Test - public void testIllegalFileUrl() - throws Exception - { - testIllegalUrl( "file:/tmp/svn" ); + public void testIllegalFileUrl() throws Exception { + testIllegalUrl("file:/tmp/svn"); } // ---------------------------------------------------------------------- // // ---------------------------------------------------------------------- - private void testUrl( String scmUrl, String expectedUrl, String expectedUser, String expectedPassword, - String expectedHost ) - throws Exception - { - ScmRepository repository = scmManager.makeScmRepository( scmUrl ); + private void testUrl( + String scmUrl, String expectedUrl, String expectedUser, String expectedPassword, String expectedHost) + throws Exception { + ScmRepository repository = scmManager.makeScmRepository(scmUrl); - assertNotNull( "ScmManager.makeScmRepository() returned null", repository ); + assertNotNull("ScmManager.makeScmRepository() returned null", repository); - assertNotNull( "The provider repository was null.", repository.getProviderRepository() ); + assertNotNull("The provider repository was null.", repository.getProviderRepository()); - assertTrue( "The SCM Repository isn't a " + SvnScmProviderRepository.class.getName() + ".", - repository.getProviderRepository() instanceof SvnScmProviderRepository ); + assertTrue( + "The SCM Repository isn't a " + SvnScmProviderRepository.class.getName() + ".", + repository.getProviderRepository() instanceof SvnScmProviderRepository); SvnScmProviderRepository providerRepository = (SvnScmProviderRepository) repository.getProviderRepository(); - assertEquals( "url is incorrect", expectedUrl, providerRepository.getUrl() ); + assertEquals("url is incorrect", expectedUrl, providerRepository.getUrl()); - assertEquals( "url string is incorrect", "svn:" + expectedUrl, repository.toString() ); + assertEquals("url string is incorrect", "svn:" + expectedUrl, repository.toString()); - assertEquals( "User is incorrect", expectedUser, providerRepository.getUser() ); + assertEquals("User is incorrect", expectedUser, providerRepository.getUser()); - assertEquals( "Password is incorrect", expectedPassword, providerRepository.getPassword() ); + assertEquals("Password is incorrect", expectedPassword, providerRepository.getPassword()); - assertEquals( "Host is incorrect", expectedHost, - ( (SvnScmProviderRepository) repository.getProviderRepository() ).getHost() ); + assertEquals( + "Host is incorrect", + expectedHost, + ((SvnScmProviderRepository) repository.getProviderRepository()).getHost()); } - private void testUrl( String scmUrl, String expectedUrl, String expectedUser, String expectedHost, - int expectedPort ) - throws Exception - { - testUrl( scmUrl, expectedUrl, expectedUser, null, expectedHost ); + private void testUrl(String scmUrl, String expectedUrl, String expectedUser, String expectedHost, int expectedPort) + throws Exception { + testUrl(scmUrl, expectedUrl, expectedUser, null, expectedHost); } - @SuppressWarnings( "unused" ) - private void testUrl( String scmUrl, String expectedUrl, String expectedUser, String expectedPassword, - String expectedHost, int expectedPort ) - throws Exception - { - testUrl( scmUrl, expectedUrl, expectedUser, expectedPassword, expectedHost ); - - ScmRepository repository = scmManager.makeScmRepository( scmUrl ); - - assertEquals( "Port is incorrect", expectedPort, - ( (SvnScmProviderRepository) repository.getProviderRepository() ).getPort() ); + @SuppressWarnings("unused") + private void testUrl( + String scmUrl, + String expectedUrl, + String expectedUser, + String expectedPassword, + String expectedHost, + int expectedPort) + throws Exception { + testUrl(scmUrl, expectedUrl, expectedUser, expectedPassword, expectedHost); + + ScmRepository repository = scmManager.makeScmRepository(scmUrl); + + assertEquals( + "Port is incorrect", + expectedPort, + ((SvnScmProviderRepository) repository.getProviderRepository()).getPort()); } - private void testIllegalUrl( String url ) - throws Exception - { - try - { - scmManager.makeScmRepository( "scm:svn:" + url ); + private void testIllegalUrl(String url) throws Exception { + try { + scmManager.makeScmRepository("scm:svn:" + url); - fail( "Expected a ScmRepositoryException while testing the url '" + url + "'." ); - } - catch ( ScmRepositoryException e ) - { + fail("Expected a ScmRepositoryException while testing the url '" + url + "'."); + } catch (ScmRepositoryException e) { // expected } } @Test - public void testGetParent() - { - new SvnScmProviderRepository( "http://subversion.tigris.org" ); + public void testGetParent() { + new SvnScmProviderRepository("http://subversion.tigris.org"); } @Test - public void testGetParentDotSlashEndingURL() - { - SvnScmProviderRepository slashDotRepo = new SvnScmProviderRepository( "file://a/b/c/././." ); - assertTrue( slashDotRepo.getParent() instanceof SvnScmProviderRepository ); - assertEquals( "file://a/b", ( (SvnScmProviderRepository) slashDotRepo.getParent() ).getUrl() ); + public void testGetParentDotSlashEndingURL() { + SvnScmProviderRepository slashDotRepo = new SvnScmProviderRepository("file://a/b/c/././."); + assertTrue(slashDotRepo.getParent() instanceof SvnScmProviderRepository); + assertEquals("file://a/b", ((SvnScmProviderRepository) slashDotRepo.getParent()).getUrl()); } @Test - public void testGetParentSlashEndingURL() - { - SvnScmProviderRepository slashRepo = new SvnScmProviderRepository( "file://a/b/c///" ); - assertTrue( slashRepo.getParent() instanceof SvnScmProviderRepository ); - assertEquals( "file://a/b", ( (SvnScmProviderRepository) slashRepo.getParent() ).getUrl() ); + public void testGetParentSlashEndingURL() { + SvnScmProviderRepository slashRepo = new SvnScmProviderRepository("file://a/b/c///"); + assertTrue(slashRepo.getParent() instanceof SvnScmProviderRepository); + assertEquals("file://a/b", ((SvnScmProviderRepository) slashRepo.getParent()).getUrl()); } - -} \ No newline at end of file +} diff --git a/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/pom.xml b/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/pom.xml index 898193ddc..7baa378bb 100644 --- a/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/pom.xml +++ b/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/pom.xml @@ -1,5 +1,4 @@ - - 4.0.0 @@ -72,6 +70,6 @@ org.mockito mockito-core test - + diff --git a/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/main/java/org/apache/maven/scm/provider/svn/svnexe/SvnExeScmProvider.java b/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/main/java/org/apache/maven/scm/provider/svn/svnexe/SvnExeScmProvider.java index 6c83c81b3..f2b6d120e 100644 --- a/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/main/java/org/apache/maven/scm/provider/svn/svnexe/SvnExeScmProvider.java +++ b/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/main/java/org/apache/maven/scm/provider/svn/svnexe/SvnExeScmProvider.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.svn.svnexe; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider.svn.svnexe; import javax.inject.Named; import javax.inject.Singleton; @@ -55,16 +54,13 @@ * @author Emmanuel Venisse */ @Singleton -@Named( "svn" ) -public class SvnExeScmProvider - extends AbstractSvnScmProvider -{ +@Named("svn") +public class SvnExeScmProvider extends AbstractSvnScmProvider { /** * {@inheritDoc} */ @Override - protected SvnCommand getAddCommand() - { + protected SvnCommand getAddCommand() { return new SvnAddCommand(); } @@ -72,8 +68,7 @@ protected SvnCommand getAddCommand() * {@inheritDoc} */ @Override - protected SvnCommand getBranchCommand() - { + protected SvnCommand getBranchCommand() { return new SvnBranchCommand(); } @@ -81,8 +76,7 @@ protected SvnCommand getBranchCommand() * {@inheritDoc} */ @Override - protected SvnCommand getChangeLogCommand() - { + protected SvnCommand getChangeLogCommand() { return new SvnChangeLogCommand(); } @@ -90,8 +84,7 @@ protected SvnCommand getChangeLogCommand() * {@inheritDoc} */ @Override - protected SvnCommand getCheckInCommand() - { + protected SvnCommand getCheckInCommand() { return new SvnCheckInCommand(); } @@ -99,8 +92,7 @@ protected SvnCommand getCheckInCommand() * {@inheritDoc} */ @Override - protected SvnCommand getCheckOutCommand() - { + protected SvnCommand getCheckOutCommand() { return new SvnCheckOutCommand(); } @@ -108,8 +100,7 @@ protected SvnCommand getCheckOutCommand() * {@inheritDoc} */ @Override - protected SvnCommand getDiffCommand() - { + protected SvnCommand getDiffCommand() { return new SvnDiffCommand(); } @@ -117,8 +108,7 @@ protected SvnCommand getDiffCommand() * {@inheritDoc} */ @Override - protected SvnCommand getExportCommand() - { + protected SvnCommand getExportCommand() { return new SvnExeExportCommand(); } @@ -126,8 +116,7 @@ protected SvnCommand getExportCommand() * {@inheritDoc} */ @Override - protected SvnCommand getRemoveCommand() - { + protected SvnCommand getRemoveCommand() { return new SvnRemoveCommand(); } @@ -135,8 +124,7 @@ protected SvnCommand getRemoveCommand() * {@inheritDoc} */ @Override - protected SvnCommand getStatusCommand() - { + protected SvnCommand getStatusCommand() { return new SvnStatusCommand(); } @@ -144,8 +132,7 @@ protected SvnCommand getStatusCommand() * {@inheritDoc} */ @Override - protected SvnCommand getTagCommand() - { + protected SvnCommand getTagCommand() { return new SvnTagCommand(); } @@ -153,8 +140,7 @@ protected SvnCommand getTagCommand() * {@inheritDoc} */ @Override - protected SvnCommand getUntagCommand() - { + protected SvnCommand getUntagCommand() { return new SvnUntagCommand(); } @@ -162,8 +148,7 @@ protected SvnCommand getUntagCommand() * {@inheritDoc} */ @Override - protected SvnCommand getUpdateCommand() - { + protected SvnCommand getUpdateCommand() { return new SvnUpdateCommand(); } @@ -171,14 +156,12 @@ protected SvnCommand getUpdateCommand() * {@inheritDoc} */ @Override - protected SvnCommand getListCommand() - { + protected SvnCommand getListCommand() { return new SvnListCommand(); } @Override - public SvnCommand getInfoCommand() - { + public SvnCommand getInfoCommand() { return new SvnInfoCommand(); } @@ -186,8 +169,7 @@ public SvnCommand getInfoCommand() * {@inheritDoc} */ @Override - protected SvnCommand getBlameCommand() - { + protected SvnCommand getBlameCommand() { return new SvnBlameCommand(); } @@ -195,8 +177,7 @@ protected SvnCommand getBlameCommand() * {@inheritDoc} */ @Override - protected SvnCommand getMkdirCommand() - { + protected SvnCommand getMkdirCommand() { return new SvnMkdirCommand(); } @@ -204,40 +185,31 @@ protected SvnCommand getMkdirCommand() * {@inheritDoc} */ @Override - protected String getRepositoryURL( File path ) - throws ScmException - { + protected String getRepositoryURL(File path) throws ScmException { // Note: I need to supply just 1 absolute path, but ScmFileSet won't let me without // a basedir (which isn't used here anyway), so use a dummy file. SvnInfoCommand infoCmd = (SvnInfoCommand) getInfoCommand(); - InfoScmResult result = - infoCmd.executeInfoCommand( null, new ScmFileSet( new File( "" ), path ), null, false, null ); + InfoScmResult result = infoCmd.executeInfoCommand(null, new ScmFileSet(new File(""), path), null, false, null); - if ( result.getInfoItems().size() != 1 ) - { - throw new ScmRepositoryException( - "Cannot find URL: " + ( result.getInfoItems().size() == 0 ? "no" : "multiple" ) - + " items returned by the info command" ); + if (result.getInfoItems().size() != 1) { + throw new ScmRepositoryException("Cannot find URL: " + + (result.getInfoItems().size() == 0 ? "no" : "multiple") + " items returned by the info command"); } - return result.getInfoItems().get( 0 ).getURL(); + return result.getInfoItems().get(0).getURL(); } @Override - public RemoteInfoScmResult remoteInfo( ScmProviderRepository repository, ScmFileSet fileSet, - CommandParameters parameters ) - throws ScmException - { + public RemoteInfoScmResult remoteInfo( + ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters) throws ScmException { SvnRemoteInfoCommand svnRemoteInfoCommand = new SvnRemoteInfoCommand(); - return svnRemoteInfoCommand.executeRemoteInfoCommand( repository, fileSet, parameters ); + return svnRemoteInfoCommand.executeRemoteInfoCommand(repository, fileSet, parameters); } @Override - public boolean remoteUrlExist( ScmProviderRepository repository, CommandParameters parameters ) - throws ScmException - { + public boolean remoteUrlExist(ScmProviderRepository repository, CommandParameters parameters) throws ScmException { SvnRemoteInfoCommand svnRemoteInfoCommand = new SvnRemoteInfoCommand(); - return svnRemoteInfoCommand.remoteUrlExist( repository, parameters ); + return svnRemoteInfoCommand.remoteUrlExist(repository, parameters); } } diff --git a/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/main/java/org/apache/maven/scm/provider/svn/svnexe/command/AbstractFileCheckingConsumer.java b/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/main/java/org/apache/maven/scm/provider/svn/svnexe/command/AbstractFileCheckingConsumer.java index 71aabfb70..2a9e78bfd 100644 --- a/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/main/java/org/apache/maven/scm/provider/svn/svnexe/command/AbstractFileCheckingConsumer.java +++ b/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/main/java/org/apache/maven/scm/provider/svn/svnexe/command/AbstractFileCheckingConsumer.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.svn.svnexe.command; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider.svn.svnexe.command; import java.io.File; import java.util.ArrayList; @@ -32,9 +31,7 @@ * @author Kenney Westerhof * */ -public abstract class AbstractFileCheckingConsumer - extends AbstractConsumer -{ +public abstract class AbstractFileCheckingConsumer extends AbstractConsumer { protected File workingDirectory; private final List files = new ArrayList<>(); @@ -43,48 +40,37 @@ public abstract class AbstractFileCheckingConsumer private boolean filtered; - public AbstractFileCheckingConsumer( File workingDirectory ) - { + public AbstractFileCheckingConsumer(File workingDirectory) { this.workingDirectory = workingDirectory; } /** {@inheritDoc} */ - public final void consumeLine( String line ) - { - if ( line.length() <= 3 ) - { + public final void consumeLine(String line) { + if (line.length() <= 3) { return; } - if ( logger.isDebugEnabled() ) - { - logger.debug( line ); + if (logger.isDebugEnabled()) { + logger.debug(line); } - try - { - parseLine( line ); - } - catch ( RuntimeException re ) - { - logger.warn( "RuntimeException while parsing: " + line , re ); + try { + parseLine(line); + } catch (RuntimeException re) { + logger.warn("RuntimeException while parsing: " + line, re); throw re; } } - protected abstract void parseLine( String line ); + protected abstract void parseLine(String line); - protected List getFiles() - { - - if ( !filtered ) - { - for ( Iterator ite = files.iterator(); ite.hasNext(); ) - { + protected List getFiles() { + + if (!filtered) { + for (Iterator ite = files.iterator(); ite.hasNext(); ) { ScmFile file = ite.next(); - if ( !file.getStatus().equals( ScmFileStatus.DELETED ) - && !new File( workingDirectory, file.getPath() ).isFile() ) - { + if (!file.getStatus().equals(ScmFileStatus.DELETED) + && !new File(workingDirectory, file.getPath()).isFile()) { ite.remove(); } } @@ -95,31 +81,23 @@ protected List getFiles() return files; } - protected final int parseInt( String revisionString ) - { - try - { - return Integer.parseInt( revisionString ); - } - catch ( NumberFormatException ex ) - { + protected final int parseInt(String revisionString) { + try { + return Integer.parseInt(revisionString); + } catch (NumberFormatException ex) { return 0; } } - protected void addFile( ScmFile file ) - { - files.add( file ); + protected void addFile(ScmFile file) { + files.add(file); } - public final int getRevision() - { + public final int getRevision() { return revision; } - public File getWorkingDirectory() - { + public File getWorkingDirectory() { return workingDirectory; } - } diff --git a/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/main/java/org/apache/maven/scm/provider/svn/svnexe/command/SvnCommandLineUtils.java b/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/main/java/org/apache/maven/scm/provider/svn/svnexe/command/SvnCommandLineUtils.java index d85d8f80b..f4c054492 100644 --- a/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/main/java/org/apache/maven/scm/provider/svn/svnexe/command/SvnCommandLineUtils.java +++ b/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/main/java/org/apache/maven/scm/provider/svn/svnexe/command/SvnCommandLineUtils.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.svn.svnexe.command; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider.svn.svnexe.command; import java.io.File; import java.io.FileOutputStream; @@ -43,175 +42,147 @@ * @author Olivier Lamy * */ -public final class SvnCommandLineUtils -{ - private static final Logger LOGGER = LoggerFactory.getLogger( SvnCommandLineUtils.class ); +public final class SvnCommandLineUtils { + private static final Logger LOGGER = LoggerFactory.getLogger(SvnCommandLineUtils.class); - private SvnCommandLineUtils() - { - } + private SvnCommandLineUtils() {} - public static void addTarget( Commandline cl, List files ) - throws IOException - { - if ( files == null || files.isEmpty() ) - { + public static void addTarget(Commandline cl, List files) throws IOException { + if (files == null || files.isEmpty()) { return; } StringBuilder sb = new StringBuilder(); - String ls = System.getProperty( "line.separator" ); - for ( File f : files ) - { - sb.append( f.getPath().replace( '\\', '/' ) ); - sb.append( ls ); + String ls = System.getProperty("line.separator"); + for (File f : files) { + sb.append(f.getPath().replace('\\', '/')); + sb.append(ls); } - File targets = File.createTempFile( "maven-scm-", "-targets" ); - PrintStream out = new PrintStream( new FileOutputStream( targets ) ); - out.print( sb ); + File targets = File.createTempFile("maven-scm-", "-targets"); + PrintStream out = new PrintStream(new FileOutputStream(targets)); + out.print(sb); out.flush(); out.close(); - cl.createArg().setValue( "--targets" ); - cl.createArg().setValue( targets.getAbsolutePath() ); + cl.createArg().setValue("--targets"); + cl.createArg().setValue(targets.getAbsolutePath()); targets.deleteOnExit(); } - public static Commandline getBaseSvnCommandLine( File workingDirectory, SvnScmProviderRepository repository ) - { + public static Commandline getBaseSvnCommandLine(File workingDirectory, SvnScmProviderRepository repository) { Commandline cl = new Commandline(); - cl.setExecutable( "svn" ); - try - { + cl.setExecutable("svn"); + try { cl.addSystemEnvironment(); - cl.addEnvironment( "LC_MESSAGES", "C" ); - } - catch ( Exception e ) - { - //Do nothing + cl.addEnvironment("LC_MESSAGES", "C"); + } catch (Exception e) { + // Do nothing } - if ( workingDirectory != null ) - { - cl.setWorkingDirectory( workingDirectory.getAbsolutePath() ); + if (workingDirectory != null) { + cl.setWorkingDirectory(workingDirectory.getAbsolutePath()); } - if ( !StringUtils.isEmpty( System.getProperty( "maven.scm.svn.config_directory" ) ) ) - { - cl.createArg().setValue( "--config-dir" ); - cl.createArg().setValue( System.getProperty( "maven.scm.svn.config_directory" ) ); - } - else if ( !StringUtils.isEmpty( SvnUtil.getSettings().getConfigDirectory() ) ) - { - cl.createArg().setValue( "--config-dir" ); - cl.createArg().setValue( SvnUtil.getSettings().getConfigDirectory() ); + if (!StringUtils.isEmpty(System.getProperty("maven.scm.svn.config_directory"))) { + cl.createArg().setValue("--config-dir"); + cl.createArg().setValue(System.getProperty("maven.scm.svn.config_directory")); + } else if (!StringUtils.isEmpty(SvnUtil.getSettings().getConfigDirectory())) { + cl.createArg().setValue("--config-dir"); + cl.createArg().setValue(SvnUtil.getSettings().getConfigDirectory()); } boolean hasAuthInfo = false; - if ( repository != null && !StringUtils.isEmpty( repository.getUser() ) ) - { + if (repository != null && !StringUtils.isEmpty(repository.getUser())) { hasAuthInfo = true; - cl.createArg().setValue( "--username" ); - cl.createArg().setValue( repository.getUser() ); + cl.createArg().setValue("--username"); + cl.createArg().setValue(repository.getUser()); } - if ( repository != null && !StringUtils.isEmpty( repository.getPassword() ) ) - { + if (repository != null && !StringUtils.isEmpty(repository.getPassword())) { hasAuthInfo = true; - cl.createArg().setValue( "--password" ); - cl.createArg().setValue( repository.getPassword() ); + cl.createArg().setValue("--password"); + cl.createArg().setValue(repository.getPassword()); } // [by Lenik] don't overwrite existing auth cache by default. - if ( hasAuthInfo && !SvnUtil.getSettings().isUseAuthCache() ) - { - cl.createArg().setValue( "--no-auth-cache" ); + if (hasAuthInfo && !SvnUtil.getSettings().isUseAuthCache()) { + cl.createArg().setValue("--no-auth-cache"); } - if ( SvnUtil.getSettings().isUseNonInteractive() ) - { - cl.createArg().setValue( "--non-interactive" ); + if (SvnUtil.getSettings().isUseNonInteractive()) { + cl.createArg().setValue("--non-interactive"); } - if ( SvnUtil.getSettings().isTrustServerCert() ) - { - cl.createArg().setValue( "--trust-server-cert" ); + if (SvnUtil.getSettings().isTrustServerCert()) { + cl.createArg().setValue("--trust-server-cert"); } return cl; } - public static int execute( Commandline cl, StreamConsumer consumer, CommandLineUtils.StringStreamConsumer stderr ) - throws CommandLineException - { + public static int execute(Commandline cl, StreamConsumer consumer, CommandLineUtils.StringStreamConsumer stderr) + throws CommandLineException { // SCM-482: force English resource bundle - cl.addEnvironment( "LC_MESSAGES", "en" ); + cl.addEnvironment("LC_MESSAGES", "en"); - int exitCode = CommandLineUtils.executeCommandLine( cl, consumer, stderr ); + int exitCode = CommandLineUtils.executeCommandLine(cl, consumer, stderr); - exitCode = checkIfCleanUpIsNeeded( exitCode, cl, consumer, stderr ); + exitCode = checkIfCleanUpIsNeeded(exitCode, cl, consumer, stderr); return exitCode; } - public static int execute( Commandline cl, CommandLineUtils.StringStreamConsumer stdout, - CommandLineUtils.StringStreamConsumer stderr ) - throws CommandLineException - { - int exitCode = CommandLineUtils.executeCommandLine( cl, stdout, stderr ); + public static int execute( + Commandline cl, CommandLineUtils.StringStreamConsumer stdout, CommandLineUtils.StringStreamConsumer stderr) + throws CommandLineException { + int exitCode = CommandLineUtils.executeCommandLine(cl, stdout, stderr); - exitCode = checkIfCleanUpIsNeeded( exitCode, cl, stdout, stderr ); + exitCode = checkIfCleanUpIsNeeded(exitCode, cl, stdout, stderr); return exitCode; } - private static int checkIfCleanUpIsNeeded( int exitCode, Commandline cl, StreamConsumer consumer, - CommandLineUtils.StringStreamConsumer stderr ) - throws CommandLineException - { - if ( exitCode != 0 && stderr.getOutput() != null && stderr.getOutput().indexOf( "'svn cleanup'" ) > 0 - && stderr.getOutput().indexOf( "'svn help cleanup'" ) > 0 ) - { - if ( LOGGER.isInfoEnabled() ) - { - LOGGER.info( "Svn command failed due to some locks in working copy. We try to run a 'svn cleanup'." ); + private static int checkIfCleanUpIsNeeded( + int exitCode, Commandline cl, StreamConsumer consumer, CommandLineUtils.StringStreamConsumer stderr) + throws CommandLineException { + if (exitCode != 0 + && stderr.getOutput() != null + && stderr.getOutput().indexOf("'svn cleanup'") > 0 + && stderr.getOutput().indexOf("'svn help cleanup'") > 0) { + if (LOGGER.isInfoEnabled()) { + LOGGER.info("Svn command failed due to some locks in working copy. We try to run a 'svn cleanup'."); } - if ( executeCleanUp( cl.getWorkingDirectory(), consumer, stderr ) == 0 ) - { - exitCode = CommandLineUtils.executeCommandLine( cl, consumer, stderr ); + if (executeCleanUp(cl.getWorkingDirectory(), consumer, stderr) == 0) { + exitCode = CommandLineUtils.executeCommandLine(cl, consumer, stderr); } } return exitCode; } - public static int executeCleanUp( File workinDirectory, StreamConsumer stdout, StreamConsumer stderr ) - throws CommandLineException - { + public static int executeCleanUp(File workinDirectory, StreamConsumer stdout, StreamConsumer stderr) + throws CommandLineException { Commandline cl = new Commandline(); - cl.setExecutable( "svn" ); + cl.setExecutable("svn"); - cl.setWorkingDirectory( workinDirectory.getAbsolutePath() ); + cl.setWorkingDirectory(workinDirectory.getAbsolutePath()); - if ( LOGGER.isInfoEnabled() ) - { - LOGGER.info( "Executing: " + SvnCommandLineUtils.cryptPassword( cl ) ); + if (LOGGER.isInfoEnabled()) { + LOGGER.info("Executing: " + SvnCommandLineUtils.cryptPassword(cl)); - if ( Os.isFamily( Os.FAMILY_WINDOWS ) ) - { - LOGGER.info( "Working directory: " + cl.getWorkingDirectory().getAbsolutePath() ); + if (Os.isFamily(Os.FAMILY_WINDOWS)) { + LOGGER.info("Working directory: " + cl.getWorkingDirectory().getAbsolutePath()); } } - return CommandLineUtils.executeCommandLine( cl, stdout, stderr ); + return CommandLineUtils.executeCommandLine(cl, stdout, stderr); } - public static String cryptPassword( Commandline cl ) - { + public static String cryptPassword(Commandline cl) { String clString = cl.toString(); final String passwordOpt = "--password"; @@ -219,56 +190,45 @@ public static String cryptPassword( Commandline cl ) String escapedQuoteChar; String cryptedPassword; - int pos = clString.indexOf( passwordOpt ); + int pos = clString.indexOf(passwordOpt); - if ( pos > 0 ) - { - if ( Os.isFamily( Os.FAMILY_WINDOWS ) ) - { + if (pos > 0) { + if (Os.isFamily(Os.FAMILY_WINDOWS)) { quoteChar = "\""; escapedQuoteChar = "\"\""; cryptedPassword = "*****"; - } - else - { - quoteChar = "'"; - escapedQuoteChar = "'\"'\"'"; - cryptedPassword = "'*****'"; - } - - // Move pointer after password option - pos += passwordOpt.length(); - - // Skip quote after password option - if ( clString.substring( pos, pos + 1 ).equals( quoteChar ) ) - { - pos++; - } - - // Skip space after password option - pos++; - - String beforePassword = clString.substring( 0, pos ); - String afterPassword = clString.substring( pos ); - - if ( afterPassword.startsWith( quoteChar ) ) - { + } else { + quoteChar = "'"; + escapedQuoteChar = "'\"'\"'"; + cryptedPassword = "'*****'"; + } + + // Move pointer after password option + pos += passwordOpt.length(); + + // Skip quote after password option + if (clString.substring(pos, pos + 1).equals(quoteChar)) { + pos++; + } + + // Skip space after password option + pos++; + + String beforePassword = clString.substring(0, pos); + String afterPassword = clString.substring(pos); + + if (afterPassword.startsWith(quoteChar)) { pos = 1; - while ( afterPassword.indexOf( escapedQuoteChar, pos ) != -1 ) - { - pos = afterPassword.indexOf( escapedQuoteChar, pos ) + escapedQuoteChar.length(); + while (afterPassword.indexOf(escapedQuoteChar, pos) != -1) { + pos = afterPassword.indexOf(escapedQuoteChar, pos) + escapedQuoteChar.length(); } - afterPassword = afterPassword.substring ( afterPassword.indexOf( quoteChar, pos ) - + quoteChar.length() ); - } - else - { + afterPassword = afterPassword.substring(afterPassword.indexOf(quoteChar, pos) + quoteChar.length()); + } else { // We assume that the password arg ist not the last one on the arg list - afterPassword = afterPassword.substring( afterPassword.indexOf( ' ' ) ); + afterPassword = afterPassword.substring(afterPassword.indexOf(' ')); } clString = beforePassword + cryptedPassword + afterPassword; - } return clString; diff --git a/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/main/java/org/apache/maven/scm/provider/svn/svnexe/command/add/SvnAddCommand.java b/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/main/java/org/apache/maven/scm/provider/svn/svnexe/command/add/SvnAddCommand.java index 227f95ea2..a8660fc12 100644 --- a/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/main/java/org/apache/maven/scm/provider/svn/svnexe/command/add/SvnAddCommand.java +++ b/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/main/java/org/apache/maven/scm/provider/svn/svnexe/command/add/SvnAddCommand.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.svn.svnexe.command.add; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,11 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider.svn.svnexe.command.add; + +import java.io.File; +import java.io.IOException; +import java.util.List; import org.apache.maven.scm.ScmException; import org.apache.maven.scm.ScmFileSet; @@ -32,96 +35,73 @@ import org.codehaus.plexus.util.cli.CommandLineUtils; import org.codehaus.plexus.util.cli.Commandline; -import java.io.File; -import java.io.IOException; -import java.util.List; - /** * @author Brett Porter * */ -public class SvnAddCommand - extends AbstractAddCommand - implements SvnCommand -{ +public class SvnAddCommand extends AbstractAddCommand implements SvnCommand { /** {@inheritDoc} */ - protected ScmResult executeAddCommand( ScmProviderRepository repository, ScmFileSet fileSet, String message, - boolean binary ) - throws ScmException - { - if ( fileSet.getFileList().isEmpty() ) - { - throw new ScmException( "You must provide at least one file/directory to add" ); + protected ScmResult executeAddCommand( + ScmProviderRepository repository, ScmFileSet fileSet, String message, boolean binary) throws ScmException { + if (fileSet.getFileList().isEmpty()) { + throw new ScmException("You must provide at least one file/directory to add"); } - Commandline cl = createCommandLine( fileSet.getBasedir(), fileSet.getFileList() ); + Commandline cl = createCommandLine(fileSet.getBasedir(), fileSet.getFileList()); - if ( binary ) - { - cl.createArg().setValue( "--config-option" ); - cl.createArg().setValue( "config:miscellany:enable-auto-props=no" ); + if (binary) { + cl.createArg().setValue("--config-option"); + cl.createArg().setValue("config:miscellany:enable-auto-props=no"); } SvnAddConsumer consumer = new SvnAddConsumer(); CommandLineUtils.StringStreamConsumer stderr = new CommandLineUtils.StringStreamConsumer(); - if ( logger.isInfoEnabled() ) - { - logger.info( "Executing: " + SvnCommandLineUtils.cryptPassword( cl ) ); + if (logger.isInfoEnabled()) { + logger.info("Executing: " + SvnCommandLineUtils.cryptPassword(cl)); - if ( Os.isFamily( Os.FAMILY_WINDOWS ) ) - { - logger.info( "Working directory: " + cl.getWorkingDirectory().getAbsolutePath() ); + if (Os.isFamily(Os.FAMILY_WINDOWS)) { + logger.info("Working directory: " + cl.getWorkingDirectory().getAbsolutePath()); } } int exitCode; - try - { - exitCode = SvnCommandLineUtils.execute( cl, consumer, stderr ); - } - catch ( CommandLineException ex ) - { - throw new ScmException( "Error while executing command.", ex ); + try { + exitCode = SvnCommandLineUtils.execute(cl, consumer, stderr); + } catch (CommandLineException ex) { + throw new ScmException("Error while executing command.", ex); } - if ( exitCode != 0 ) - { - return new AddScmResult( cl.toString(), "The svn command failed.", stderr.getOutput(), false ); + if (exitCode != 0) { + return new AddScmResult(cl.toString(), "The svn command failed.", stderr.getOutput(), false); } - return new AddScmResult( cl.toString(), consumer.getAddedFiles() ); + return new AddScmResult(cl.toString(), consumer.getAddedFiles()); } - private static Commandline createCommandLine( File workingDirectory, List files ) - throws ScmException - { + private static Commandline createCommandLine(File workingDirectory, List files) throws ScmException { // Base command line doesn't make sense here - username/password not needed, and non-interactive is not valid Commandline cl = new Commandline(); - cl.setExecutable( "svn" ); + cl.setExecutable("svn"); - cl.setWorkingDirectory( workingDirectory.getAbsolutePath() ); + cl.setWorkingDirectory(workingDirectory.getAbsolutePath()); - cl.createArg().setValue( "add" ); + cl.createArg().setValue("add"); - cl.createArg().setValue( "--parents" ); + cl.createArg().setValue("--parents"); - cl.createArg().setValue( "--non-recursive" ); + cl.createArg().setValue("--non-recursive"); - try - { - SvnCommandLineUtils.addTarget( cl, files ); - } - catch ( IOException e ) - { - throw new ScmException( "Can't create the targets file", e ); + try { + SvnCommandLineUtils.addTarget(cl, files); + } catch (IOException e) { + throw new ScmException("Can't create the targets file", e); } return cl; } - } diff --git a/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/main/java/org/apache/maven/scm/provider/svn/svnexe/command/add/SvnAddConsumer.java b/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/main/java/org/apache/maven/scm/provider/svn/svnexe/command/add/SvnAddConsumer.java index 97d67e814..d9695c32f 100644 --- a/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/main/java/org/apache/maven/scm/provider/svn/svnexe/command/add/SvnAddConsumer.java +++ b/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/main/java/org/apache/maven/scm/provider/svn/svnexe/command/add/SvnAddConsumer.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.svn.svnexe.command.add; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,21 +16,20 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider.svn.svnexe.command.add; + +import java.util.ArrayList; +import java.util.List; import org.apache.maven.scm.ScmFile; import org.apache.maven.scm.ScmFileStatus; import org.apache.maven.scm.util.AbstractConsumer; -import java.util.ArrayList; -import java.util.List; - /** * @author Brett Porter * */ -public class SvnAddConsumer - extends AbstractConsumer -{ +public class SvnAddConsumer extends AbstractConsumer { private final List addedFiles = new ArrayList<>(); // ---------------------------------------------------------------------- @@ -40,45 +37,35 @@ public class SvnAddConsumer // ---------------------------------------------------------------------- /** {@inheritDoc} */ - public void consumeLine( String line ) - { - if ( line.length() <= 3 ) - { - if ( logger.isWarnEnabled() ) - { - logger.warn( "Unexpected input, the line must be at least three characters long. Line: '" - + line + "'." ); + public void consumeLine(String line) { + if (line.length() <= 3) { + if (logger.isWarnEnabled()) { + logger.warn("Unexpected input, the line must be at least three characters long. Line: '" + line + "'."); } return; } - String statusString = line.substring( 0, 1 ); + String statusString = line.substring(0, 1); - String file = line.substring( 3 ).trim(); + String file = line.substring(3).trim(); ScmFileStatus status; - if ( statusString.equals( "A" ) ) - { + if (statusString.equals("A")) { status = ScmFileStatus.ADDED; - } - else - { - if ( logger.isInfoEnabled() ) - { - logger.info( "Unknown file status: '" + statusString + "'." ); + } else { + if (logger.isInfoEnabled()) { + logger.info("Unknown file status: '" + statusString + "'."); } return; } - addedFiles.add( new ScmFile( file, status ) ); + addedFiles.add(new ScmFile(file, status)); } - public List getAddedFiles() - { + public List getAddedFiles() { return addedFiles; } - } diff --git a/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/main/java/org/apache/maven/scm/provider/svn/svnexe/command/blame/SvnBlameCommand.java b/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/main/java/org/apache/maven/scm/provider/svn/svnexe/command/blame/SvnBlameCommand.java index 61778ed5f..ceef18619 100644 --- a/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/main/java/org/apache/maven/scm/provider/svn/svnexe/command/blame/SvnBlameCommand.java +++ b/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/main/java/org/apache/maven/scm/provider/svn/svnexe/command/blame/SvnBlameCommand.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.svn.svnexe.command.blame; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,9 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider.svn.svnexe.command.blame; + +import java.io.File; import org.apache.maven.scm.ScmException; import org.apache.maven.scm.ScmFileSet; @@ -32,66 +33,52 @@ import org.codehaus.plexus.util.cli.CommandLineUtils; import org.codehaus.plexus.util.cli.Commandline; -import java.io.File; - /** * @author Evgeny Mandrikov * @author Olivier Lamy * @since 1.4 */ -public class SvnBlameCommand - extends AbstractBlameCommand - implements SvnCommand -{ +public class SvnBlameCommand extends AbstractBlameCommand implements SvnCommand { /** * {@inheritDoc} */ - public BlameScmResult executeBlameCommand( ScmProviderRepository repo, ScmFileSet workingDirectory, - String filename ) - throws ScmException - { - Commandline cl = createCommandLine( (SvnScmProviderRepository) repo, workingDirectory.getBasedir(), filename ); + public BlameScmResult executeBlameCommand(ScmProviderRepository repo, ScmFileSet workingDirectory, String filename) + throws ScmException { + Commandline cl = createCommandLine((SvnScmProviderRepository) repo, workingDirectory.getBasedir(), filename); SvnBlameConsumer consumer = new SvnBlameConsumer(); CommandLineUtils.StringStreamConsumer stderr = new CommandLineUtils.StringStreamConsumer(); - if ( logger.isInfoEnabled() ) - { - logger.info( "Executing: " + SvnCommandLineUtils.cryptPassword( cl ) ); + if (logger.isInfoEnabled()) { + logger.info("Executing: " + SvnCommandLineUtils.cryptPassword(cl)); - if ( Os.isFamily( Os.FAMILY_WINDOWS ) ) - { - logger.info( "Working directory: " + cl.getWorkingDirectory().getAbsolutePath() ); + if (Os.isFamily(Os.FAMILY_WINDOWS)) { + logger.info("Working directory: " + cl.getWorkingDirectory().getAbsolutePath()); } } int exitCode; - try - { - exitCode = SvnCommandLineUtils.execute( cl, consumer, stderr ); - } - catch ( CommandLineException ex ) - { - throw new ScmException( "Error while executing command.", ex ); + try { + exitCode = SvnCommandLineUtils.execute(cl, consumer, stderr); + } catch (CommandLineException ex) { + throw new ScmException("Error while executing command.", ex); } - if ( exitCode != 0 ) - { - return new BlameScmResult( cl.toString(), "The svn command failed.", stderr.getOutput(), false ); + if (exitCode != 0) { + return new BlameScmResult(cl.toString(), "The svn command failed.", stderr.getOutput(), false); } - return new BlameScmResult( cl.toString(), consumer.getLines() ); + return new BlameScmResult(cl.toString(), consumer.getLines()); } - public static Commandline createCommandLine( SvnScmProviderRepository repository, File workingDirectory, - String filename ) - { - Commandline cl = SvnCommandLineUtils.getBaseSvnCommandLine( workingDirectory, repository ); - cl.createArg().setValue( "blame" ); - cl.createArg().setValue( "--xml" ); - cl.createArg().setValue( filename ); + public static Commandline createCommandLine( + SvnScmProviderRepository repository, File workingDirectory, String filename) { + Commandline cl = SvnCommandLineUtils.getBaseSvnCommandLine(workingDirectory, repository); + cl.createArg().setValue("blame"); + cl.createArg().setValue("--xml"); + cl.createArg().setValue(filename); return cl; } } diff --git a/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/main/java/org/apache/maven/scm/provider/svn/svnexe/command/blame/SvnBlameConsumer.java b/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/main/java/org/apache/maven/scm/provider/svn/svnexe/command/blame/SvnBlameConsumer.java index 7aa40d42a..96a4d69fe 100644 --- a/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/main/java/org/apache/maven/scm/provider/svn/svnexe/command/blame/SvnBlameConsumer.java +++ b/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/main/java/org/apache/maven/scm/provider/svn/svnexe/command/blame/SvnBlameConsumer.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.svn.svnexe.command.blame; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,9 +16,7 @@ * specific language governing permissions and limitations * under the License. */ - -import org.apache.maven.scm.command.blame.BlameLine; -import org.apache.maven.scm.util.AbstractConsumer; +package org.apache.maven.scm.provider.svn.svnexe.command.blame; import java.text.ParseException; import java.text.SimpleDateFormat; @@ -31,33 +27,32 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; +import org.apache.maven.scm.command.blame.BlameLine; +import org.apache.maven.scm.util.AbstractConsumer; + /** * @author Evgeny Mandrikov * @author Olivier Lamy * @since 1.4 */ -public class SvnBlameConsumer - extends AbstractConsumer -{ +public class SvnBlameConsumer extends AbstractConsumer { private static final String SVN_TIMESTAMP_PATTERN = "yyyy-MM-dd HH:mm:ss"; - private static final Pattern LINE_PATTERN = Pattern.compile( "line-number=\"(.*)\"" ); + private static final Pattern LINE_PATTERN = Pattern.compile("line-number=\"(.*)\""); - private static final Pattern REVISION_PATTERN = Pattern.compile( "revision=\"(.*)\"" ); + private static final Pattern REVISION_PATTERN = Pattern.compile("revision=\"(.*)\""); - private static final Pattern AUTHOR_PATTERN = Pattern.compile( "(.*)" ); - - private static final Pattern DATE_PATTERN = Pattern.compile( "(.*)T(.*)\\.(.*)Z" ); + private static final Pattern AUTHOR_PATTERN = Pattern.compile("(.*)"); + private static final Pattern DATE_PATTERN = Pattern.compile("(.*)T(.*)\\.(.*)Z"); private final SimpleDateFormat dateFormat; private final List lines = new ArrayList<>(); - public SvnBlameConsumer() - { - dateFormat = new SimpleDateFormat( SVN_TIMESTAMP_PATTERN ); - dateFormat.setTimeZone( TimeZone.getTimeZone( "UTC" ) ); + public SvnBlameConsumer() { + dateFormat = new SimpleDateFormat(SVN_TIMESTAMP_PATTERN); + dateFormat.setTimeZone(TimeZone.getTimeZone("UTC")); } private int lineNumber; @@ -66,50 +61,36 @@ public SvnBlameConsumer() private String author; - public void consumeLine( String line ) - { + public void consumeLine(String line) { Matcher matcher; - if ( ( matcher = LINE_PATTERN.matcher( line ) ).find() ) - { - String lineNumberStr = matcher.group( 1 ); - lineNumber = Integer.parseInt( lineNumberStr ); - } - else if ( ( matcher = REVISION_PATTERN.matcher( line ) ).find() ) - { - revision = matcher.group( 1 ); - } - else if ( ( matcher = AUTHOR_PATTERN.matcher( line ) ).find() ) - { - author = matcher.group( 1 ); - } - else if ( ( matcher = DATE_PATTERN.matcher( line ) ).find() ) - { - String date = matcher.group( 1 ); - String time = matcher.group( 2 ); - Date dateTime = parseDateTime( date + " " + time ); - lines.add( new BlameLine( dateTime, revision, author ) ); - if ( logger.isDebugEnabled() ) - { - logger.debug( "Author of line " + lineNumber + ": " + author + " (" + date + ")" ); + if ((matcher = LINE_PATTERN.matcher(line)).find()) { + String lineNumberStr = matcher.group(1); + lineNumber = Integer.parseInt(lineNumberStr); + } else if ((matcher = REVISION_PATTERN.matcher(line)).find()) { + revision = matcher.group(1); + } else if ((matcher = AUTHOR_PATTERN.matcher(line)).find()) { + author = matcher.group(1); + } else if ((matcher = DATE_PATTERN.matcher(line)).find()) { + String date = matcher.group(1); + String time = matcher.group(2); + Date dateTime = parseDateTime(date + " " + time); + lines.add(new BlameLine(dateTime, revision, author)); + if (logger.isDebugEnabled()) { + logger.debug("Author of line " + lineNumber + ": " + author + " (" + date + ")"); } } } - protected Date parseDateTime( String dateTimeStr ) - { - try - { - return dateFormat.parse( dateTimeStr ); - } - catch ( ParseException e ) - { - logger.error( "skip ParseException: " + e.getMessage() + " during parsing date " + dateTimeStr, e ); + protected Date parseDateTime(String dateTimeStr) { + try { + return dateFormat.parse(dateTimeStr); + } catch (ParseException e) { + logger.error("skip ParseException: " + e.getMessage() + " during parsing date " + dateTimeStr, e); return null; } } - public List getLines() - { + public List getLines() { return lines; } } diff --git a/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/main/java/org/apache/maven/scm/provider/svn/svnexe/command/branch/SvnBranchCommand.java b/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/main/java/org/apache/maven/scm/provider/svn/svnexe/command/branch/SvnBranchCommand.java index 78e61b235..99060c640 100644 --- a/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/main/java/org/apache/maven/scm/provider/svn/svnexe/command/branch/SvnBranchCommand.java +++ b/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/main/java/org/apache/maven/scm/provider/svn/svnexe/command/branch/SvnBranchCommand.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.svn.svnexe.command.branch; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider.svn.svnexe.command.branch; import java.io.File; import java.io.IOException; @@ -52,167 +51,139 @@ * * TODO since this is just a copy, use that instead. */ -public class SvnBranchCommand - extends AbstractBranchCommand - implements SvnCommand -{ - - public ScmResult executeBranchCommand( ScmProviderRepository repo, ScmFileSet fileSet, String branch, - ScmBranchParameters scmBranchParameters ) - throws ScmException - { - if ( branch == null || StringUtils.isEmpty( branch.trim() ) ) - { - throw new ScmException( "branch name must be specified" ); +public class SvnBranchCommand extends AbstractBranchCommand implements SvnCommand { + + public ScmResult executeBranchCommand( + ScmProviderRepository repo, ScmFileSet fileSet, String branch, ScmBranchParameters scmBranchParameters) + throws ScmException { + if (branch == null || StringUtils.isEmpty(branch.trim())) { + throw new ScmException("branch name must be specified"); } - if ( !fileSet.getFileList().isEmpty() ) - { - throw new ScmException( "This provider doesn't support branching subsets of a directory" ); + if (!fileSet.getFileList().isEmpty()) { + throw new ScmException("This provider doesn't support branching subsets of a directory"); } SvnScmProviderRepository repository = (SvnScmProviderRepository) repo; - File messageFile = FileUtils.createTempFile( "maven-scm-", ".commit", null ); + File messageFile = FileUtils.createTempFile("maven-scm-", ".commit", null); - try - { - FileUtils.fileWrite( messageFile.getAbsolutePath(), "UTF-8", scmBranchParameters.getMessage() ); - } - catch ( IOException ex ) - { - return new BranchScmResult( null, "Error while making a temporary file for the commit message: " - + ex.getMessage(), null, false ); + try { + FileUtils.fileWrite(messageFile.getAbsolutePath(), "UTF-8", scmBranchParameters.getMessage()); + } catch (IOException ex) { + return new BranchScmResult( + null, + "Error while making a temporary file for the commit message: " + ex.getMessage(), + null, + false); } - Commandline cl = createCommandLine( repository, fileSet.getBasedir(), branch, messageFile, - scmBranchParameters ); + Commandline cl = createCommandLine(repository, fileSet.getBasedir(), branch, messageFile, scmBranchParameters); CommandLineUtils.StringStreamConsumer stdout = new CommandLineUtils.StringStreamConsumer(); CommandLineUtils.StringStreamConsumer stderr = new CommandLineUtils.StringStreamConsumer(); - if ( logger.isInfoEnabled() ) - { - logger.info( "Executing: " + SvnCommandLineUtils.cryptPassword( cl ) ); + if (logger.isInfoEnabled()) { + logger.info("Executing: " + SvnCommandLineUtils.cryptPassword(cl)); - if ( Os.isFamily( Os.FAMILY_WINDOWS ) ) - { - logger.info( "Working directory: " + cl.getWorkingDirectory().getAbsolutePath() ); + if (Os.isFamily(Os.FAMILY_WINDOWS)) { + logger.info("Working directory: " + cl.getWorkingDirectory().getAbsolutePath()); } } int exitCode; - try - { - exitCode = SvnCommandLineUtils.execute( cl, stdout, stderr ); - } - catch ( CommandLineException ex ) - { - throw new ScmException( "Error while executing command.", ex ); - } - finally - { - try - { - FileUtils.forceDelete( messageFile ); - } - catch ( IOException ex ) - { + try { + exitCode = SvnCommandLineUtils.execute(cl, stdout, stderr); + } catch (CommandLineException ex) { + throw new ScmException("Error while executing command.", ex); + } finally { + try { + FileUtils.forceDelete(messageFile); + } catch (IOException ex) { // ignore } } - if ( exitCode != 0 ) - { - return new BranchScmResult( cl.toString(), "The svn branch command failed.", stderr.getOutput(), false ); + if (exitCode != 0) { + return new BranchScmResult(cl.toString(), "The svn branch command failed.", stderr.getOutput(), false); } List fileList = new ArrayList<>(); List files = null; - try - { - files = FileUtils.getFiles( fileSet.getBasedir(), "**", "**/.svn/**", false ); - } - catch ( IOException e ) - { - throw new ScmException( "Error while executing command.", e ); + try { + files = FileUtils.getFiles(fileSet.getBasedir(), "**", "**/.svn/**", false); + } catch (IOException e) { + throw new ScmException("Error while executing command.", e); } - for ( File f : files ) - { - fileList.add( new ScmFile( f.getPath(), ScmFileStatus.TAGGED ) ); + for (File f : files) { + fileList.add(new ScmFile(f.getPath(), ScmFileStatus.TAGGED)); } - return new BranchScmResult( cl.toString(), fileList ); + return new BranchScmResult(cl.toString(), fileList); } /** {@inheritDoc} */ - public ScmResult executeBranchCommand( ScmProviderRepository repo, ScmFileSet fileSet, String branch, - String message ) - throws ScmException - { - ScmBranchParameters scmBranchParameters = new ScmBranchParameters( message ); - return executeBranchCommand( repo, fileSet, branch, scmBranchParameters ); + public ScmResult executeBranchCommand(ScmProviderRepository repo, ScmFileSet fileSet, String branch, String message) + throws ScmException { + ScmBranchParameters scmBranchParameters = new ScmBranchParameters(message); + return executeBranchCommand(repo, fileSet, branch, scmBranchParameters); } // ---------------------------------------------------------------------- // // ---------------------------------------------------------------------- - public static Commandline createCommandLine( SvnScmProviderRepository repository, File workingDirectory, - String branch, File messageFile ) - { + public static Commandline createCommandLine( + SvnScmProviderRepository repository, File workingDirectory, String branch, File messageFile) { ScmBranchParameters scmBranchParameters = new ScmBranchParameters(); - scmBranchParameters.setRemoteBranching( false ); - scmBranchParameters.setPinExternals( false ); - return createCommandLine( repository, workingDirectory, branch, messageFile, scmBranchParameters ); + scmBranchParameters.setRemoteBranching(false); + scmBranchParameters.setPinExternals(false); + return createCommandLine(repository, workingDirectory, branch, messageFile, scmBranchParameters); } - public static Commandline createCommandLine( SvnScmProviderRepository repository, File workingDirectory, - String branch, File messageFile, - ScmBranchParameters scmBranchParameters ) - { - Commandline cl = SvnCommandLineUtils.getBaseSvnCommandLine( workingDirectory, repository ); + public static Commandline createCommandLine( + SvnScmProviderRepository repository, + File workingDirectory, + String branch, + File messageFile, + ScmBranchParameters scmBranchParameters) { + Commandline cl = SvnCommandLineUtils.getBaseSvnCommandLine(workingDirectory, repository); - cl.createArg().setValue( "copy" ); + cl.createArg().setValue("copy"); - cl.createArg().setValue( "--parents" ); + cl.createArg().setValue("--parents"); - cl.createArg().setValue( "--file" ); + cl.createArg().setValue("--file"); - cl.createArg().setValue( messageFile.getAbsolutePath() ); + cl.createArg().setValue(messageFile.getAbsolutePath()); - cl.createArg().setValue( "--encoding" ); + cl.createArg().setValue("--encoding"); - cl.createArg().setValue( "UTF-8" ); + cl.createArg().setValue("UTF-8"); - if ( scmBranchParameters != null && scmBranchParameters.isPinExternals() ) - { - cl.createArg().setValue( "--pin-externals" ); + if (scmBranchParameters != null && scmBranchParameters.isPinExternals()) { + cl.createArg().setValue("--pin-externals"); } - if ( scmBranchParameters != null && scmBranchParameters.isRemoteBranching() ) - { - if ( StringUtils.isNotBlank( scmBranchParameters.getScmRevision() ) ) - { - cl.createArg().setValue( "--revision" ); - cl.createArg().setValue( scmBranchParameters.getScmRevision() ); + if (scmBranchParameters != null && scmBranchParameters.isRemoteBranching()) { + if (StringUtils.isNotBlank(scmBranchParameters.getScmRevision())) { + cl.createArg().setValue("--revision"); + cl.createArg().setValue(scmBranchParameters.getScmRevision()); } - String url = SvnCommandUtils.fixUrl( repository.getUrl(), repository.getUser() ); - cl.createArg().setValue( url + "@" ); - } - else - { - cl.createArg().setValue( "." ); + String url = SvnCommandUtils.fixUrl(repository.getUrl(), repository.getUser()); + cl.createArg().setValue(url + "@"); + } else { + cl.createArg().setValue("."); } // Note: this currently assumes you have the branch base checked out too - String branchUrl = SvnTagBranchUtils.resolveBranchUrl( repository, new ScmBranch( branch ) ); - branchUrl = SvnCommandUtils.fixUrl( branchUrl, repository.getUser() ); - cl.createArg().setValue( branchUrl + "@" ); + String branchUrl = SvnTagBranchUtils.resolveBranchUrl(repository, new ScmBranch(branch)); + branchUrl = SvnCommandUtils.fixUrl(branchUrl, repository.getUser()); + cl.createArg().setValue(branchUrl + "@"); return cl; } diff --git a/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/main/java/org/apache/maven/scm/provider/svn/svnexe/command/changelog/IllegalOutputException.java b/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/main/java/org/apache/maven/scm/provider/svn/svnexe/command/changelog/IllegalOutputException.java index e980472af..4be83950f 100644 --- a/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/main/java/org/apache/maven/scm/provider/svn/svnexe/command/changelog/IllegalOutputException.java +++ b/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/main/java/org/apache/maven/scm/provider/svn/svnexe/command/changelog/IllegalOutputException.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.svn.svnexe.command.changelog; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,23 +16,21 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider.svn.svnexe.command.changelog; /** * Thrown when the output of an svn log command isn't recognized. * @since 1.3 */ -@SuppressWarnings( "serial" ) -public class IllegalOutputException - extends RuntimeException -{ +@SuppressWarnings("serial") +public class IllegalOutputException extends RuntimeException { /** * Create the exception with a message. - * + * * @param message the message. */ - public IllegalOutputException( final String message ) - { - super( message ); + public IllegalOutputException(final String message) { + super(message); } } diff --git a/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/main/java/org/apache/maven/scm/provider/svn/svnexe/command/changelog/SvnChangeLogCommand.java b/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/main/java/org/apache/maven/scm/provider/svn/svnexe/command/changelog/SvnChangeLogCommand.java index cdeb42693..d3e6c7792 100644 --- a/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/main/java/org/apache/maven/scm/provider/svn/svnexe/command/changelog/SvnChangeLogCommand.java +++ b/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/main/java/org/apache/maven/scm/provider/svn/svnexe/command/changelog/SvnChangeLogCommand.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.svn.svnexe.command.changelog; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,10 +16,20 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider.svn.svnexe.command.changelog; + +import java.io.File; +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.Objects; +import java.util.TimeZone; +import org.apache.maven.scm.CommandParameter; +import org.apache.maven.scm.CommandParameters; import org.apache.maven.scm.ScmBranch; import org.apache.maven.scm.ScmException; import org.apache.maven.scm.ScmFileSet; +import org.apache.maven.scm.ScmResult; import org.apache.maven.scm.ScmTag; import org.apache.maven.scm.ScmVersion; import org.apache.maven.scm.command.changelog.AbstractChangeLogCommand; @@ -39,210 +47,207 @@ import org.codehaus.plexus.util.cli.CommandLineUtils; import org.codehaus.plexus.util.cli.Commandline; -import java.io.File; -import java.text.SimpleDateFormat; -import java.util.Date; -import java.util.Objects; -import java.util.TimeZone; -import org.apache.maven.scm.CommandParameter; -import org.apache.maven.scm.CommandParameters; -import org.apache.maven.scm.ScmResult; - /** * @author Emmanuel Venisse * @author Olivier Lamy * */ -public class SvnChangeLogCommand - extends AbstractChangeLogCommand - implements SvnCommand -{ +public class SvnChangeLogCommand extends AbstractChangeLogCommand implements SvnCommand { private static final String DATE_FORMAT = "yyyy-MM-dd HH:mm:ss Z"; @Override - public ScmResult executeCommand( ScmProviderRepository repository, ScmFileSet fileSet, - CommandParameters parameters ) - throws ScmException - { - return executeChangeLogCommand( repository, fileSet, - parameters.getDate( CommandParameter.START_DATE, null ), - parameters.getDate( CommandParameter.END_DATE, null ), - (ScmBranch) parameters.getScmVersion( CommandParameter.BRANCH, null ), - parameters.getString( CommandParameter.CHANGELOG_DATE_PATTERN, null ), - parameters.getScmVersion( CommandParameter.START_SCM_VERSION, null ), - parameters.getScmVersion( CommandParameter.END_SCM_VERSION, null ), - parameters.getInt( CommandParameter.LIMIT, -1 ) ); + public ScmResult executeCommand(ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters) + throws ScmException { + return executeChangeLogCommand( + repository, + fileSet, + parameters.getDate(CommandParameter.START_DATE, null), + parameters.getDate(CommandParameter.END_DATE, null), + (ScmBranch) parameters.getScmVersion(CommandParameter.BRANCH, null), + parameters.getString(CommandParameter.CHANGELOG_DATE_PATTERN, null), + parameters.getScmVersion(CommandParameter.START_SCM_VERSION, null), + parameters.getScmVersion(CommandParameter.END_SCM_VERSION, null), + parameters.getInt(CommandParameter.LIMIT, -1)); } /** {@inheritDoc} */ @Deprecated @Override - protected ChangeLogScmResult executeChangeLogCommand( ScmProviderRepository repo, ScmFileSet fileSet, - ScmVersion startVersion, ScmVersion endVersion, - String datePattern ) - throws ScmException - { - return executeChangeLogCommand( repo, fileSet, null, null, null, datePattern, startVersion, endVersion, null ); + protected ChangeLogScmResult executeChangeLogCommand( + ScmProviderRepository repo, + ScmFileSet fileSet, + ScmVersion startVersion, + ScmVersion endVersion, + String datePattern) + throws ScmException { + return executeChangeLogCommand(repo, fileSet, null, null, null, datePattern, startVersion, endVersion, null); } /** {@inheritDoc} */ @Deprecated @Override - protected ChangeLogScmResult executeChangeLogCommand( ScmProviderRepository repo, ScmFileSet fileSet, - Date startDate, Date endDate, ScmBranch branch, - String datePattern ) - throws ScmException - { - return executeChangeLogCommand( repo, fileSet, startDate, endDate, branch, datePattern, null, null, null ); + protected ChangeLogScmResult executeChangeLogCommand( + ScmProviderRepository repo, + ScmFileSet fileSet, + Date startDate, + Date endDate, + ScmBranch branch, + String datePattern) + throws ScmException { + return executeChangeLogCommand(repo, fileSet, startDate, endDate, branch, datePattern, null, null, null); } @Override - protected ChangeLogScmResult executeChangeLogCommand( ChangeLogScmRequest request ) - throws ScmException - { + protected ChangeLogScmResult executeChangeLogCommand(ChangeLogScmRequest request) throws ScmException { final ScmVersion startVersion = request.getStartRevision(); final ScmVersion endVersion = request.getEndRevision(); final ScmFileSet fileSet = request.getScmFileSet(); final String datePattern = request.getDatePattern(); - return executeChangeLogCommand( request.getScmRepository().getProviderRepository(), fileSet, - request.getStartDate(), request.getEndDate(), request.getScmBranch(), datePattern, startVersion, - endVersion, request.getLimit() ); + return executeChangeLogCommand( + request.getScmRepository().getProviderRepository(), + fileSet, + request.getStartDate(), + request.getEndDate(), + request.getScmBranch(), + datePattern, + startVersion, + endVersion, + request.getLimit()); } - private ChangeLogScmResult executeChangeLogCommand( ScmProviderRepository repo, ScmFileSet fileSet, - Date startDate, Date endDate, ScmBranch branch, - String datePattern, ScmVersion startVersion, - ScmVersion endVersion, Integer limit ) - throws ScmException - { - Commandline cl = createCommandLine( (SvnScmProviderRepository) repo, fileSet.getBasedir(), branch, startDate, - endDate, startVersion, endVersion, limit ); - - SvnChangeLogConsumer consumer = new SvnChangeLogConsumer( datePattern ); + private ChangeLogScmResult executeChangeLogCommand( + ScmProviderRepository repo, + ScmFileSet fileSet, + Date startDate, + Date endDate, + ScmBranch branch, + String datePattern, + ScmVersion startVersion, + ScmVersion endVersion, + Integer limit) + throws ScmException { + Commandline cl = createCommandLine( + (SvnScmProviderRepository) repo, + fileSet.getBasedir(), + branch, + startDate, + endDate, + startVersion, + endVersion, + limit); + + SvnChangeLogConsumer consumer = new SvnChangeLogConsumer(datePattern); CommandLineUtils.StringStreamConsumer stderr = new CommandLineUtils.StringStreamConsumer(); - if ( logger.isInfoEnabled() ) - { - logger.info( "Executing: " + SvnCommandLineUtils.cryptPassword( cl ) ); + if (logger.isInfoEnabled()) { + logger.info("Executing: " + SvnCommandLineUtils.cryptPassword(cl)); - if ( Os.isFamily( Os.FAMILY_WINDOWS ) ) - { - logger.info( "Working directory: " + cl.getWorkingDirectory().getAbsolutePath() ); + if (Os.isFamily(Os.FAMILY_WINDOWS)) { + logger.info("Working directory: " + cl.getWorkingDirectory().getAbsolutePath()); } } int exitCode; - try - { - exitCode = SvnCommandLineUtils.execute( cl, consumer, stderr ); - } - catch ( CommandLineException ex ) - { - throw new ScmException( "Error while executing svn command.", ex ); + try { + exitCode = SvnCommandLineUtils.execute(cl, consumer, stderr); + } catch (CommandLineException ex) { + throw new ScmException("Error while executing svn command.", ex); } - if ( exitCode != 0 ) - { - return new ChangeLogScmResult( cl.toString(), "The svn command failed.", stderr.getOutput(), false ); + if (exitCode != 0) { + return new ChangeLogScmResult(cl.toString(), "The svn command failed.", stderr.getOutput(), false); } - ChangeLogSet changeLogSet = new ChangeLogSet( consumer.getModifications(), startDate, endDate ); - changeLogSet.setStartVersion( startVersion ); - changeLogSet.setEndVersion( endVersion ); + ChangeLogSet changeLogSet = new ChangeLogSet(consumer.getModifications(), startDate, endDate); + changeLogSet.setStartVersion(startVersion); + changeLogSet.setEndVersion(endVersion); - return new ChangeLogScmResult( cl.toString(), changeLogSet ); + return new ChangeLogScmResult(cl.toString(), changeLogSet); } // ---------------------------------------------------------------------- // // ---------------------------------------------------------------------- - public static Commandline createCommandLine( SvnScmProviderRepository repository, File workingDirectory, - ScmBranch branch, Date startDate, Date endDate, - ScmVersion startVersion, ScmVersion endVersion ) - { - return createCommandLine( repository, workingDirectory, branch, startDate, endDate, startVersion, endVersion, - null ); + public static Commandline createCommandLine( + SvnScmProviderRepository repository, + File workingDirectory, + ScmBranch branch, + Date startDate, + Date endDate, + ScmVersion startVersion, + ScmVersion endVersion) { + return createCommandLine( + repository, workingDirectory, branch, startDate, endDate, startVersion, endVersion, null); } - public static Commandline createCommandLine( SvnScmProviderRepository repository, File workingDirectory, - ScmBranch branch, Date startDate, Date endDate, - ScmVersion startVersion, ScmVersion endVersion, Integer limit ) - { - SimpleDateFormat dateFormat = new SimpleDateFormat( DATE_FORMAT ); + public static Commandline createCommandLine( + SvnScmProviderRepository repository, + File workingDirectory, + ScmBranch branch, + Date startDate, + Date endDate, + ScmVersion startVersion, + ScmVersion endVersion, + Integer limit) { + SimpleDateFormat dateFormat = new SimpleDateFormat(DATE_FORMAT); - dateFormat.setTimeZone( TimeZone.getTimeZone( "GMT" ) ); + dateFormat.setTimeZone(TimeZone.getTimeZone("GMT")); - Commandline cl = SvnCommandLineUtils.getBaseSvnCommandLine( workingDirectory, repository ); + Commandline cl = SvnCommandLineUtils.getBaseSvnCommandLine(workingDirectory, repository); - cl.createArg().setValue( "log" ); + cl.createArg().setValue("log"); - cl.createArg().setValue( "-v" ); + cl.createArg().setValue("-v"); // TODO: May want to add some kind of support for --stop-on-copy and --limit NUM - if ( limit != null && limit > 0 ) - { - cl.createArg().setValue( "--limit" ); - cl.createArg().setValue( Integer.toString( limit ) ); + if (limit != null && limit > 0) { + cl.createArg().setValue("--limit"); + cl.createArg().setValue(Integer.toString(limit)); } - if ( startDate != null ) - { - cl.createArg().setValue( "-r" ); + if (startDate != null) { + cl.createArg().setValue("-r"); - if ( endDate != null ) - { - cl.createArg().setValue( - "{" + dateFormat.format( startDate ) + "}" + ":" + "{" + dateFormat.format( endDate ) + "}" ); - } - else - { - cl.createArg().setValue( "{" + dateFormat.format( startDate ) + "}:HEAD" ); + if (endDate != null) { + cl.createArg() + .setValue("{" + dateFormat.format(startDate) + "}" + ":" + "{" + dateFormat.format(endDate) + + "}"); + } else { + cl.createArg().setValue("{" + dateFormat.format(startDate) + "}:HEAD"); } } - if ( startVersion != null ) - { - cl.createArg().setValue( "-r" ); + if (startVersion != null) { + cl.createArg().setValue("-r"); - if ( endVersion != null ) - { - if ( startVersion.getName().equals( endVersion.getName() ) ) - { - cl.createArg().setValue( startVersion.getName() ); + if (endVersion != null) { + if (startVersion.getName().equals(endVersion.getName())) { + cl.createArg().setValue(startVersion.getName()); + } else { + cl.createArg().setValue(startVersion.getName() + ":" + endVersion.getName()); } - else - { - cl.createArg().setValue( startVersion.getName() + ":" + endVersion.getName() ); - } - } - else - { - cl.createArg().setValue( startVersion.getName() + ":HEAD" ); + } else { + cl.createArg().setValue(startVersion.getName() + ":HEAD"); } } - if ( branch != null && StringUtils.isNotEmpty( branch.getName() ) ) - { + if (branch != null && StringUtils.isNotEmpty(branch.getName())) { // By specifying a branch and this repository url below, subversion should show // the changelog of that branch, but limit it to paths that also occur in this repository. - if ( branch instanceof ScmTag ) - { - String tagUrl = SvnTagBranchUtils.resolveTagUrl( repository, (ScmTag) branch ); - cl.createArg().setValue( tagUrl + "@" ); - } - else - { - String branchUrl = SvnTagBranchUtils.resolveBranchUrl( repository, branch ); - cl.createArg().setValue( branchUrl + "@" ); + if (branch instanceof ScmTag) { + String tagUrl = SvnTagBranchUtils.resolveTagUrl(repository, (ScmTag) branch); + cl.createArg().setValue(tagUrl + "@"); + } else { + String branchUrl = SvnTagBranchUtils.resolveBranchUrl(repository, branch); + cl.createArg().setValue(branchUrl + "@"); } } - if ( endVersion == null || !Objects.equals( "BASE", endVersion.getName() ) ) - { - cl.createArg().setValue( repository.getUrl() + "@" ); + if (endVersion == null || !Objects.equals("BASE", endVersion.getName())) { + cl.createArg().setValue(repository.getUrl() + "@"); } return cl; diff --git a/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/main/java/org/apache/maven/scm/provider/svn/svnexe/command/changelog/SvnChangeLogConsumer.java b/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/main/java/org/apache/maven/scm/provider/svn/svnexe/command/changelog/SvnChangeLogConsumer.java index b5de55650..33fc999da 100644 --- a/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/main/java/org/apache/maven/scm/provider/svn/svnexe/command/changelog/SvnChangeLogConsumer.java +++ b/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/main/java/org/apache/maven/scm/provider/svn/svnexe/command/changelog/SvnChangeLogConsumer.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.svn.svnexe.command.changelog; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,12 +16,7 @@ * specific language governing permissions and limitations * under the License. */ - -import org.apache.maven.scm.ChangeFile; -import org.apache.maven.scm.ChangeSet; -import org.apache.maven.scm.ScmFileStatus; -import org.apache.maven.scm.provider.svn.SvnChangeSet; -import org.apache.maven.scm.util.AbstractConsumer; +package org.apache.maven.scm.provider.svn.svnexe.command.changelog; import java.util.ArrayList; import java.util.Date; @@ -31,13 +24,17 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; +import org.apache.maven.scm.ChangeFile; +import org.apache.maven.scm.ChangeSet; +import org.apache.maven.scm.ScmFileStatus; +import org.apache.maven.scm.provider.svn.SvnChangeSet; +import org.apache.maven.scm.util.AbstractConsumer; + /** * @author Emmanuel Venisse * */ -public class SvnChangeLogConsumer - extends AbstractConsumer -{ +public class SvnChangeLogConsumer extends AbstractConsumer { /** * Date formatter for svn timestamp (after a little massaging) */ @@ -61,13 +58,13 @@ public class SvnChangeLogConsumer /** * There is always action and affected path; when copying/moving, recognize also original path and revision */ - private static final Pattern FILE_PATTERN = Pattern.compile( "^\\s\\s\\s([A-Z])\\s(.+)$" ); + private static final Pattern FILE_PATTERN = Pattern.compile("^\\s\\s\\s([A-Z])\\s(.+)$"); /** * This matches the 'original file info' part of the complete file line. * Note the use of [:alpha:] instead of literal 'from' - this is meant to allow non-English localizations. */ - private static final Pattern ORIG_FILE_PATTERN = Pattern.compile( "\\([A-Za-z]+ (.+):(\\d+)\\)" ); + private static final Pattern ORIG_FILE_PATTERN = Pattern.compile("\\([A-Za-z]+ (.+):(\\d+)\\)"); /** * The file section ends with a blank line @@ -78,7 +75,7 @@ public class SvnChangeLogConsumer * The comment section ends with a dashed line */ private static final String COMMENT_END_TOKEN = - "------------------------------------" + "------------------------------------"; + "------------------------------------" + "------------------------------------"; /** * Current status of the parser @@ -108,7 +105,7 @@ public class SvnChangeLogConsumer /** * The regular expression used to match header lines */ - private static final Pattern HEADER_REG_EXP = Pattern.compile( "^(.+) \\| (.+) \\| (.+) \\|.*$" ); + private static final Pattern HEADER_REG_EXP = Pattern.compile("^(.+) \\| (.+) \\| (.+) \\|.*$"); private static final int REVISION_GROUP = 1; @@ -116,26 +113,25 @@ public class SvnChangeLogConsumer private static final int DATE_GROUP = 3; - private static final Pattern REVISION_REG_EXP1 = Pattern.compile( "rev (\\d+):" ); + private static final Pattern REVISION_REG_EXP1 = Pattern.compile("rev (\\d+):"); - private static final Pattern REVISION_REG_EXP2 = Pattern.compile( "r(\\d+)" ); + private static final Pattern REVISION_REG_EXP2 = Pattern.compile("r(\\d+)"); - private static final Pattern DATE_REG_EXP = Pattern.compile( "(\\d+-\\d+-\\d+ " + // date 2002-08-24 - "\\d+:\\d+:\\d+) " + // time 16:01:00 - "([\\-+])(\\d\\d)(\\d\\d)" ); // gmt offset -0400);) + private static final Pattern DATE_REG_EXP = Pattern.compile("(\\d+-\\d+-\\d+ " + // date 2002-08-24 + "\\d+:\\d+:\\d+) " + + // time 16:01:00 + "([\\-+])(\\d\\d)(\\d\\d)"); // gmt offset -0400);) private final String userDateFormat; /** * Default constructor. */ - public SvnChangeLogConsumer( String userDateFormat ) - { + public SvnChangeLogConsumer(String userDateFormat) { this.userDateFormat = userDateFormat; } - public List getModifications() - { + public List getModifications() { return entries; } @@ -146,25 +142,22 @@ public List getModifications() /** * {@inheritDoc} */ - public void consumeLine( String line ) - { - if ( logger.isDebugEnabled() ) - { - logger.debug( line ); + public void consumeLine(String line) { + if (logger.isDebugEnabled()) { + logger.debug(line); } - switch ( status ) - { + switch (status) { case GET_HEADER: - processGetHeader( line ); + processGetHeader(line); break; case GET_FILE: - processGetFile( line ); + processGetFile(line); break; case GET_COMMENT: - processGetComment( line ); + processGetComment(line); break; default: - throw new IllegalStateException( "Unknown state: " + status ); + throw new IllegalStateException("Unknown state: " + status); } } @@ -181,24 +174,22 @@ public void consumeLine( String line ) * * @param line A line of text from the svn log output */ - private void processGetHeader( String line ) - { - Matcher matcher = HEADER_REG_EXP.matcher( line ); - if ( !matcher.matches() ) - { + private void processGetHeader(String line) { + Matcher matcher = HEADER_REG_EXP.matcher(line); + if (!matcher.matches()) { // The header line is not found. Intentionally do nothing. return; } - currentRevision = getRevision( matcher.group( REVISION_GROUP ) ); + currentRevision = getRevision(matcher.group(REVISION_GROUP)); currentChange = new SvnChangeSet(); - currentChange.setAuthor( matcher.group( AUTHOR_GROUP ) ); + currentChange.setAuthor(matcher.group(AUTHOR_GROUP)); - currentChange.setDate( getDate( matcher.group( DATE_GROUP ) ) ); + currentChange.setDate(getDate(matcher.group(DATE_GROUP))); - currentChange.setRevision( currentRevision ); + currentChange.setRevision(currentRevision); status = GET_FILE; } @@ -209,20 +200,14 @@ private void processGetHeader( String line ) * @param revisionOutput * @return the svn revision */ - private String getRevision( final String revisionOutput ) - { + private String getRevision(final String revisionOutput) { Matcher matcher; - if ( ( matcher = REVISION_REG_EXP1.matcher( revisionOutput ) ).matches() ) - { - return matcher.group( 1 ); - } - else if ( ( matcher = REVISION_REG_EXP2.matcher( revisionOutput ) ).matches() ) - { - return matcher.group( 1 ); - } - else - { - throw new IllegalOutputException( revisionOutput ); + if ((matcher = REVISION_REG_EXP1.matcher(revisionOutput)).matches()) { + return matcher.group(1); + } else if ((matcher = REVISION_REG_EXP2.matcher(revisionOutput)).matches()) { + return matcher.group(1); + } else { + throw new IllegalOutputException(revisionOutput); } } @@ -234,65 +219,49 @@ else if ( ( matcher = REVISION_REG_EXP2.matcher( revisionOutput ) ).matches() ) * * @param line A line of text from the svn log output */ - private void processGetFile( String line ) - { - Matcher matcher = FILE_PATTERN.matcher( line ); - if ( matcher.matches() ) - { - final String fileinfo = matcher.group( 2 ); + private void processGetFile(String line) { + Matcher matcher = FILE_PATTERN.matcher(line); + if (matcher.matches()) { + final String fileinfo = matcher.group(2); String name = fileinfo; String originalName = null; String originalRev = null; - final int n = fileinfo.indexOf( " (" ); - if ( n > 1 && fileinfo.endsWith( ")" ) ) - { - final String origFileInfo = fileinfo.substring( n ); - Matcher matcher2 = ORIG_FILE_PATTERN.matcher( origFileInfo ); - if ( matcher2.find() ) - { + final int n = fileinfo.indexOf(" ("); + if (n > 1 && fileinfo.endsWith(")")) { + final String origFileInfo = fileinfo.substring(n); + Matcher matcher2 = ORIG_FILE_PATTERN.matcher(origFileInfo); + if (matcher2.find()) { // if original file is present, we must extract the affected one from the beginning - name = fileinfo.substring( 0, n ); - originalName = matcher2.group( 1 ); - originalRev = matcher2.group( 2 ); + name = fileinfo.substring(0, n); + originalName = matcher2.group(1); + originalRev = matcher2.group(2); } } - final String actionStr = matcher.group( 1 ); + final String actionStr = matcher.group(1); final ScmFileStatus action; - if ( "A".equals( actionStr ) ) - { - //TODO: this may even change to MOVED if we later explore whole changeset and find matching DELETED + if ("A".equals(actionStr)) { + // TODO: this may even change to MOVED if we later explore whole changeset and find matching DELETED action = originalRev == null ? ScmFileStatus.ADDED : ScmFileStatus.COPIED; - } - else if ( "D".equals( actionStr ) ) - { + } else if ("D".equals(actionStr)) { action = ScmFileStatus.DELETED; - } - else if ( "M".equals( actionStr ) ) - { + } else if ("M".equals(actionStr)) { action = ScmFileStatus.MODIFIED; - } - else if ( "R".equals( actionStr ) ) - { - action = ScmFileStatus.UPDATED; //== REPLACED in svn terms - } - else - { + } else if ("R".equals(actionStr)) { + action = ScmFileStatus.UPDATED; // == REPLACED in svn terms + } else { action = ScmFileStatus.UNKNOWN; } - if ( logger.isDebugEnabled() ) - { - logger.debug( actionStr + " : " + name ); + if (logger.isDebugEnabled()) { + logger.debug(actionStr + " : " + name); } - final ChangeFile changeFile = new ChangeFile( name, currentRevision ); - changeFile.setAction( action ); - changeFile.setOriginalName( originalName ); - changeFile.setOriginalRevision( originalRev ); - currentChange.addFile( changeFile ); + final ChangeFile changeFile = new ChangeFile(name, currentRevision); + changeFile.setAction(action); + changeFile.setOriginalName(originalName); + changeFile.setOriginalRevision(originalRev); + currentChange.addFile(changeFile); status = GET_FILE; - } - else if ( line.equals( FILE_END_TOKEN ) ) - { + } else if (line.equals(FILE_END_TOKEN)) { // Create a buffer for the collection of the comment now // that we are leaving the GET_FILE state. currentComment = new StringBuilder(); @@ -307,19 +276,15 @@ else if ( line.equals( FILE_END_TOKEN ) ) * * @param line a line of text from the svn log output */ - private void processGetComment( String line ) - { - if ( line.equals( COMMENT_END_TOKEN ) ) - { - currentChange.setComment( currentComment.toString() ); + private void processGetComment(String line) { + if (line.equals(COMMENT_END_TOKEN)) { + currentChange.setComment(currentComment.toString()); - entries.add( currentChange ); + entries.add(currentChange); status = GET_HEADER; - } - else - { - currentComment.append( line ).append( '\n' ); + } else { + currentComment.append(line).append('\n'); } } @@ -330,22 +295,20 @@ private void processGetComment( String line ) * @param dateOutput The date output from an svn log command. * @return A date representing the time stamp of the log entry. */ - private Date getDate( final String dateOutput ) - { - Matcher matcher = DATE_REG_EXP.matcher( dateOutput ); - if ( !matcher.find() ) - { - throw new IllegalOutputException( dateOutput ); + private Date getDate(final String dateOutput) { + Matcher matcher = DATE_REG_EXP.matcher(dateOutput); + if (!matcher.find()) { + throw new IllegalOutputException(dateOutput); } final StringBuilder date = new StringBuilder(); - date.append( matcher.group( 1 ) ); - date.append( " GMT" ); - date.append( matcher.group( 2 ) ); - date.append( matcher.group( 3 ) ); - date.append( ':' ); - date.append( matcher.group( 4 ) ); - - return parseDate( date.toString(), userDateFormat, SVN_TIMESTAMP_PATTERN ); + date.append(matcher.group(1)); + date.append(" GMT"); + date.append(matcher.group(2)); + date.append(matcher.group(3)); + date.append(':'); + date.append(matcher.group(4)); + + return parseDate(date.toString(), userDateFormat, SVN_TIMESTAMP_PATTERN); } } diff --git a/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/main/java/org/apache/maven/scm/provider/svn/svnexe/command/checkin/SvnCheckInCommand.java b/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/main/java/org/apache/maven/scm/provider/svn/svnexe/command/checkin/SvnCheckInCommand.java index e2607a38e..324dfcb43 100644 --- a/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/main/java/org/apache/maven/scm/provider/svn/svnexe/command/checkin/SvnCheckInCommand.java +++ b/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/main/java/org/apache/maven/scm/provider/svn/svnexe/command/checkin/SvnCheckInCommand.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.svn.svnexe.command.checkin; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,10 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider.svn.svnexe.command.checkin; + +import java.io.File; +import java.io.IOException; import org.apache.maven.scm.ScmException; import org.apache.maven.scm.ScmFileSet; @@ -35,114 +37,89 @@ import org.codehaus.plexus.util.cli.CommandLineUtils; import org.codehaus.plexus.util.cli.Commandline; -import java.io.File; -import java.io.IOException; - /** * @author Trygve Laugstøl * @author Olivier Lamy * */ -public class SvnCheckInCommand - extends AbstractCheckInCommand - implements SvnCommand -{ +public class SvnCheckInCommand extends AbstractCheckInCommand implements SvnCommand { /** {@inheritDoc} */ - protected CheckInScmResult executeCheckInCommand( ScmProviderRepository repo, ScmFileSet fileSet, String message, - ScmVersion version ) - throws ScmException - { - if ( version != null && StringUtils.isNotEmpty( version.getName() ) ) - { - throw new ScmException( "This provider command can't handle tags." ); + protected CheckInScmResult executeCheckInCommand( + ScmProviderRepository repo, ScmFileSet fileSet, String message, ScmVersion version) throws ScmException { + if (version != null && StringUtils.isNotEmpty(version.getName())) { + throw new ScmException("This provider command can't handle tags."); } - File messageFile = FileUtils.createTempFile( "maven-scm-", ".commit", null ); + File messageFile = FileUtils.createTempFile("maven-scm-", ".commit", null); - try - { - FileUtils.fileWrite( messageFile.getAbsolutePath(), "UTF-8", message ); - } - catch ( IOException ex ) - { - return new CheckInScmResult( null, "Error while making a temporary file for the commit message: " - + ex.getMessage(), null, false ); + try { + FileUtils.fileWrite(messageFile.getAbsolutePath(), "UTF-8", message); + } catch (IOException ex) { + return new CheckInScmResult( + null, + "Error while making a temporary file for the commit message: " + ex.getMessage(), + null, + false); } - Commandline cl = createCommandLine( (SvnScmProviderRepository) repo, fileSet, messageFile ); + Commandline cl = createCommandLine((SvnScmProviderRepository) repo, fileSet, messageFile); - SvnCheckInConsumer consumer = new SvnCheckInConsumer( fileSet.getBasedir() ); + SvnCheckInConsumer consumer = new SvnCheckInConsumer(fileSet.getBasedir()); CommandLineUtils.StringStreamConsumer stderr = new CommandLineUtils.StringStreamConsumer(); - if ( logger.isInfoEnabled() ) - { - logger.info( "Executing: " + SvnCommandLineUtils.cryptPassword( cl ) ); + if (logger.isInfoEnabled()) { + logger.info("Executing: " + SvnCommandLineUtils.cryptPassword(cl)); - if ( Os.isFamily( Os.FAMILY_WINDOWS ) ) - { - logger.info( "Working directory: " + cl.getWorkingDirectory().getAbsolutePath() ); + if (Os.isFamily(Os.FAMILY_WINDOWS)) { + logger.info("Working directory: " + cl.getWorkingDirectory().getAbsolutePath()); } } int exitCode; - try - { - exitCode = SvnCommandLineUtils.execute( cl, consumer, stderr ); - } - catch ( CommandLineException ex ) - { - throw new ScmException( "Error while executing command.", ex ); - } - finally - { - try - { - FileUtils.forceDelete( messageFile ); - } - catch ( IOException ex ) - { + try { + exitCode = SvnCommandLineUtils.execute(cl, consumer, stderr); + } catch (CommandLineException ex) { + throw new ScmException("Error while executing command.", ex); + } finally { + try { + FileUtils.forceDelete(messageFile); + } catch (IOException ex) { // ignore } } - if ( exitCode != 0 ) - { - return new CheckInScmResult( cl.toString(), "The svn command failed.", stderr.getOutput(), false ); + if (exitCode != 0) { + return new CheckInScmResult(cl.toString(), "The svn command failed.", stderr.getOutput(), false); } - return new CheckInScmResult( cl.toString(), consumer.getCheckedInFiles(), - Integer.toString( consumer.getRevision() ) ); + return new CheckInScmResult( + cl.toString(), consumer.getCheckedInFiles(), Integer.toString(consumer.getRevision())); } // ---------------------------------------------------------------------- // // ---------------------------------------------------------------------- - public static Commandline createCommandLine( SvnScmProviderRepository repository, ScmFileSet fileSet, - File messageFile ) - throws ScmException - { - Commandline cl = SvnCommandLineUtils.getBaseSvnCommandLine( fileSet.getBasedir(), repository ); + public static Commandline createCommandLine( + SvnScmProviderRepository repository, ScmFileSet fileSet, File messageFile) throws ScmException { + Commandline cl = SvnCommandLineUtils.getBaseSvnCommandLine(fileSet.getBasedir(), repository); - cl.createArg().setValue( "commit" ); + cl.createArg().setValue("commit"); - cl.createArg().setValue( "--file" ); + cl.createArg().setValue("--file"); - cl.createArg().setValue( messageFile.getAbsolutePath() ); + cl.createArg().setValue(messageFile.getAbsolutePath()); - cl.createArg().setValue( "--encoding" ); + cl.createArg().setValue("--encoding"); - cl.createArg().setValue( "UTF-8" ); + cl.createArg().setValue("UTF-8"); - try - { - SvnCommandLineUtils.addTarget( cl, fileSet.getFileList() ); - } - catch ( IOException e ) - { - throw new ScmException( "Can't create the targets file", e ); + try { + SvnCommandLineUtils.addTarget(cl, fileSet.getFileList()); + } catch (IOException e) { + throw new ScmException("Can't create the targets file", e); } return cl; diff --git a/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/main/java/org/apache/maven/scm/provider/svn/svnexe/command/checkin/SvnCheckInConsumer.java b/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/main/java/org/apache/maven/scm/provider/svn/svnexe/command/checkin/SvnCheckInConsumer.java index f7b8cc236..0743037b1 100644 --- a/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/main/java/org/apache/maven/scm/provider/svn/svnexe/command/checkin/SvnCheckInConsumer.java +++ b/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/main/java/org/apache/maven/scm/provider/svn/svnexe/command/checkin/SvnCheckInConsumer.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.svn.svnexe.command.checkin; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,22 +16,21 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider.svn.svnexe.command.checkin; + +import java.io.File; +import java.util.List; import org.apache.maven.scm.ScmFile; import org.apache.maven.scm.ScmFileStatus; import org.apache.maven.scm.provider.svn.svnexe.command.AbstractFileCheckingConsumer; -import java.io.File; -import java.util.List; - /** * @author Trygve Laugstøl * @author Olivier Lamy * */ -public class SvnCheckInConsumer - extends AbstractFileCheckingConsumer -{ +public class SvnCheckInConsumer extends AbstractFileCheckingConsumer { private static final String SENDING_TOKEN = "Sending "; private static final String ADDING_TOKEN = "Adding "; @@ -50,9 +47,8 @@ public class SvnCheckInConsumer // // ---------------------------------------------------------------------- - public SvnCheckInConsumer( File workingDirectory ) - { - super( workingDirectory ); + public SvnCheckInConsumer(File workingDirectory) { + super(workingDirectory); } // ---------------------------------------------------------------------- @@ -60,54 +56,38 @@ public SvnCheckInConsumer( File workingDirectory ) // ---------------------------------------------------------------------- /** {@inheritDoc} */ - protected void parseLine( String line ) - { + protected void parseLine(String line) { String file; - if ( line.startsWith( COMMITTED_REVISION_TOKEN ) ) - { - String revisionString = line.substring( COMMITTED_REVISION_TOKEN.length() + 1, line.length() - 1 ); + if (line.startsWith(COMMITTED_REVISION_TOKEN)) { + String revisionString = line.substring(COMMITTED_REVISION_TOKEN.length() + 1, line.length() - 1); - revision = parseInt( revisionString ); + revision = parseInt(revisionString); return; - } - else if ( line.startsWith( SENDING_TOKEN ) ) - { - file = line.substring( SENDING_TOKEN.length() ); - } - else if ( line.startsWith( ADDING_TOKEN ) ) - { - file = line.substring( ADDING_TOKEN.length() ); - } - else if ( line.startsWith( ADDING_BIN_TOKEN ) ) - { - file = line.substring( ADDING_BIN_TOKEN.length() ); - } - else if ( line.startsWith( DELETING_TOKEN ) ) - { - file = line.substring( DELETING_TOKEN.length() ); - } - else if ( line.startsWith( TRANSMITTING_TOKEN ) ) - { + } else if (line.startsWith(SENDING_TOKEN)) { + file = line.substring(SENDING_TOKEN.length()); + } else if (line.startsWith(ADDING_TOKEN)) { + file = line.substring(ADDING_TOKEN.length()); + } else if (line.startsWith(ADDING_BIN_TOKEN)) { + file = line.substring(ADDING_BIN_TOKEN.length()); + } else if (line.startsWith(DELETING_TOKEN)) { + file = line.substring(DELETING_TOKEN.length()); + } else if (line.startsWith(TRANSMITTING_TOKEN)) { // ignore return; - } - else - { - if ( logger.isInfoEnabled() ) - { - logger.info( "Unknown line: '" + line + "'" ); + } else { + if (logger.isInfoEnabled()) { + logger.info("Unknown line: '" + line + "'"); } return; } - addFile( new ScmFile( file, ScmFileStatus.CHECKED_IN ) ); + addFile(new ScmFile(file, ScmFileStatus.CHECKED_IN)); } - public List getCheckedInFiles() - { + public List getCheckedInFiles() { return getFiles(); } } diff --git a/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/main/java/org/apache/maven/scm/provider/svn/svnexe/command/checkout/SvnCheckOutCommand.java b/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/main/java/org/apache/maven/scm/provider/svn/svnexe/command/checkout/SvnCheckOutCommand.java index 919ee5902..2d5eb69ea 100644 --- a/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/main/java/org/apache/maven/scm/provider/svn/svnexe/command/checkout/SvnCheckOutCommand.java +++ b/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/main/java/org/apache/maven/scm/provider/svn/svnexe/command/checkout/SvnCheckOutCommand.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.svn.svnexe.command.checkout; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,9 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider.svn.svnexe.command.checkout; + +import java.io.File; import org.apache.maven.scm.ScmBranch; import org.apache.maven.scm.ScmException; @@ -39,76 +40,60 @@ import org.codehaus.plexus.util.cli.CommandLineUtils; import org.codehaus.plexus.util.cli.Commandline; -import java.io.File; - /** * @author Emmanuel Venisse * @author Olivier Lamy * */ -public class SvnCheckOutCommand - extends AbstractCheckOutCommand - implements SvnCommand -{ +public class SvnCheckOutCommand extends AbstractCheckOutCommand implements SvnCommand { /** * {@inheritDoc} */ - protected CheckOutScmResult executeCheckOutCommand( ScmProviderRepository repo, ScmFileSet fileSet, - ScmVersion version, boolean recursive, boolean shallow ) - throws ScmException - { + protected CheckOutScmResult executeCheckOutCommand( + ScmProviderRepository repo, ScmFileSet fileSet, ScmVersion version, boolean recursive, boolean shallow) + throws ScmException { SvnScmProviderRepository repository = (SvnScmProviderRepository) repo; String url = repository.getUrl(); - if ( version != null && StringUtils.isNotEmpty( version.getName() ) ) - { - if ( version instanceof ScmTag ) - { - url = SvnTagBranchUtils.resolveTagUrl( repository, (ScmTag) version ); - } - else if ( version instanceof ScmBranch ) - { - url = SvnTagBranchUtils.resolveBranchUrl( repository, (ScmBranch) version ); + if (version != null && StringUtils.isNotEmpty(version.getName())) { + if (version instanceof ScmTag) { + url = SvnTagBranchUtils.resolveTagUrl(repository, (ScmTag) version); + } else if (version instanceof ScmBranch) { + url = SvnTagBranchUtils.resolveBranchUrl(repository, (ScmBranch) version); } } - url = SvnCommandUtils.fixUrl( url, repository.getUser() ); + url = SvnCommandUtils.fixUrl(url, repository.getUser()); - Commandline cl = createCommandLine( repository, fileSet.getBasedir(), version, url, recursive ); + Commandline cl = createCommandLine(repository, fileSet.getBasedir(), version, url, recursive); - SvnCheckOutConsumer consumer = new SvnCheckOutConsumer( fileSet.getBasedir() ); + SvnCheckOutConsumer consumer = new SvnCheckOutConsumer(fileSet.getBasedir()); CommandLineUtils.StringStreamConsumer stderr = new CommandLineUtils.StringStreamConsumer(); int exitCode; - if ( logger.isInfoEnabled() ) - { - logger.info( "Executing: " + SvnCommandLineUtils.cryptPassword( cl ) ); + if (logger.isInfoEnabled()) { + logger.info("Executing: " + SvnCommandLineUtils.cryptPassword(cl)); - if ( Os.isFamily( Os.FAMILY_WINDOWS ) ) - { - logger.info( "Working directory: " + cl.getWorkingDirectory().getAbsolutePath() ); + if (Os.isFamily(Os.FAMILY_WINDOWS)) { + logger.info("Working directory: " + cl.getWorkingDirectory().getAbsolutePath()); } } - try - { - exitCode = SvnCommandLineUtils.execute( cl, consumer, stderr ); - } - catch ( CommandLineException ex ) - { - throw new ScmException( "Error while executing command.", ex ); + try { + exitCode = SvnCommandLineUtils.execute(cl, consumer, stderr); + } catch (CommandLineException ex) { + throw new ScmException("Error while executing command.", ex); } - if ( exitCode != 0 ) - { - return new CheckOutScmResult( cl.toString(), "The svn command failed.", stderr.getOutput(), false ); + if (exitCode != 0) { + return new CheckOutScmResult(cl.toString(), "The svn command failed.", stderr.getOutput(), false); } - return new CheckOutScmResult( cl.toString(), Integer.toString( consumer.getRevision() ), - consumer.getCheckedOutFiles() ); + return new CheckOutScmResult( + cl.toString(), Integer.toString(consumer.getRevision()), consumer.getCheckedOutFiles()); } // ---------------------------------------------------------------------- @@ -125,10 +110,9 @@ else if ( version instanceof ScmBranch ) * @return the SVN command line for the SVN check out. * @see #createCommandLine(SvnScmProviderRepository, File, ScmVersion, String, boolean) */ - public static Commandline createCommandLine( SvnScmProviderRepository repository, File workingDirectory, - ScmVersion version, String url ) - { - return createCommandLine( repository, workingDirectory, version, url, true ); + public static Commandline createCommandLine( + SvnScmProviderRepository repository, File workingDirectory, ScmVersion version, String url) { + return createCommandLine(repository, workingDirectory, version, url, true); } /** @@ -142,32 +126,32 @@ public static Commandline createCommandLine( SvnScmProviderRepository repository * @return the SVN command line for the SVN check out. * @since 1.1.1 */ - public static Commandline createCommandLine( SvnScmProviderRepository repository, File workingDirectory, - ScmVersion version, String url, boolean recursive ) - { - Commandline cl = SvnCommandLineUtils.getBaseSvnCommandLine( workingDirectory.getParentFile(), repository ); + public static Commandline createCommandLine( + SvnScmProviderRepository repository, + File workingDirectory, + ScmVersion version, + String url, + boolean recursive) { + Commandline cl = SvnCommandLineUtils.getBaseSvnCommandLine(workingDirectory.getParentFile(), repository); - cl.createArg().setValue( "checkout" ); + cl.createArg().setValue("checkout"); // add non recursive option - if ( !recursive ) - { - cl.createArg().setValue( "-N" ); + if (!recursive) { + cl.createArg().setValue("-N"); } - if ( version != null && StringUtils.isNotEmpty( version.getName() ) ) - { - if ( version instanceof ScmRevision ) - { - cl.createArg().setValue( "-r" ); + if (version != null && StringUtils.isNotEmpty(version.getName())) { + if (version instanceof ScmRevision) { + cl.createArg().setValue("-r"); - cl.createArg().setValue( version.getName() ); + cl.createArg().setValue(version.getName()); } } - cl.createArg().setValue( url + "@" ); + cl.createArg().setValue(url + "@"); - cl.createArg().setValue( workingDirectory.getAbsolutePath() ); + cl.createArg().setValue(workingDirectory.getAbsolutePath()); return cl; } diff --git a/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/main/java/org/apache/maven/scm/provider/svn/svnexe/command/checkout/SvnCheckOutConsumer.java b/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/main/java/org/apache/maven/scm/provider/svn/svnexe/command/checkout/SvnCheckOutConsumer.java index cea907645..7181e78db 100644 --- a/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/main/java/org/apache/maven/scm/provider/svn/svnexe/command/checkout/SvnCheckOutConsumer.java +++ b/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/main/java/org/apache/maven/scm/provider/svn/svnexe/command/checkout/SvnCheckOutConsumer.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.svn.svnexe.command.checkout; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,105 +16,89 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider.svn.svnexe.command.checkout; + +import java.io.File; +import java.util.ArrayList; +import java.util.List; import org.apache.maven.scm.ScmFile; import org.apache.maven.scm.ScmFileStatus; import org.apache.maven.scm.provider.svn.svnexe.command.AbstractFileCheckingConsumer; import org.codehaus.plexus.util.StringUtils; -import java.io.File; -import java.util.ArrayList; -import java.util.List; - /** * @author Trygve Laugstøl * @author Olivier Lamy * */ -public class SvnCheckOutConsumer - extends AbstractFileCheckingConsumer -{ +public class SvnCheckOutConsumer extends AbstractFileCheckingConsumer { private static final String CHECKED_OUT_REVISION_TOKEN = "Checked out revision"; private final List files = new ArrayList<>(); - public SvnCheckOutConsumer( File workingDirectory ) - { - super( workingDirectory ); + public SvnCheckOutConsumer(File workingDirectory) { + super(workingDirectory); } /** * {@inheritDoc} */ - protected void parseLine( String line ) - { - String statusString = line.substring( 0, 1 ); - - String file = line.substring( 3 ).trim(); - //[SCM-368] - if ( file.startsWith( getWorkingDirectory().getAbsolutePath() ) ) - { - file = StringUtils.substring( file, getWorkingDirectory().getAbsolutePath().length() + 1 ); + protected void parseLine(String line) { + String statusString = line.substring(0, 1); + + String file = line.substring(3).trim(); + // [SCM-368] + if (file.startsWith(getWorkingDirectory().getAbsolutePath())) { + file = StringUtils.substring( + file, getWorkingDirectory().getAbsolutePath().length() + 1); } ScmFileStatus status; - if ( line.startsWith( CHECKED_OUT_REVISION_TOKEN ) ) - { - String revisionString = line.substring( CHECKED_OUT_REVISION_TOKEN.length() + 1, line.length() - 1 ); + if (line.startsWith(CHECKED_OUT_REVISION_TOKEN)) { + String revisionString = line.substring(CHECKED_OUT_REVISION_TOKEN.length() + 1, line.length() - 1); - revision = parseInt( revisionString ); + revision = parseInt(revisionString); return; - } - else if ( statusString.equals( "A" ) ) - { + } else if (statusString.equals("A")) { status = ScmFileStatus.ADDED; - } - else if ( statusString.equals( "U" ) ) - { + } else if (statusString.equals("U")) { status = ScmFileStatus.UPDATED; - } - else - { - //Do nothing + } else { + // Do nothing return; } - addFile( new ScmFile( file, status ) ); + addFile(new ScmFile(file, status)); } // ---------------------------------------------------------------------- // // ---------------------------------------------------------------------- - public List getCheckedOutFiles() - { + public List getCheckedOutFiles() { return getFiles(); } - protected void addFile( ScmFile file ) - { - files.add( file ); + protected void addFile(ScmFile file) { + files.add(file); } - protected List getFiles() - { + protected List getFiles() { List onlyFiles = new ArrayList<>(); - for ( ScmFile file : files ) - { + for (ScmFile file : files) { // second part is for svn 1.7 as the co output is now relative not a full path as for svn 1.7- - if ( !( !file.getStatus().equals( ScmFileStatus.DELETED ) && !new File( getWorkingDirectory(), - file.getPath() ).isFile() ) || !( - !file.getStatus().equals( ScmFileStatus.DELETED ) && !new File( getWorkingDirectory().getParent(), - file.getPath() ).isFile() ) ) - { - onlyFiles.add( file ); + if (!(!file.getStatus().equals(ScmFileStatus.DELETED) + && !new File(getWorkingDirectory(), file.getPath()).isFile()) + || !(!file.getStatus().equals(ScmFileStatus.DELETED) + && !new File(getWorkingDirectory().getParent(), file.getPath()).isFile())) { + onlyFiles.add(file); } } return onlyFiles; } - } diff --git a/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/main/java/org/apache/maven/scm/provider/svn/svnexe/command/diff/SvnDiffCommand.java b/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/main/java/org/apache/maven/scm/provider/svn/svnexe/command/diff/SvnDiffCommand.java index 8c1bdd722..d39d3fd20 100644 --- a/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/main/java/org/apache/maven/scm/provider/svn/svnexe/command/diff/SvnDiffCommand.java +++ b/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/main/java/org/apache/maven/scm/provider/svn/svnexe/command/diff/SvnDiffCommand.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.svn.svnexe.command.diff; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,9 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider.svn.svnexe.command.diff; + +import java.io.File; import org.apache.maven.scm.ScmException; import org.apache.maven.scm.ScmFileSet; @@ -35,83 +36,69 @@ import org.codehaus.plexus.util.cli.CommandLineUtils; import org.codehaus.plexus.util.cli.Commandline; -import java.io.File; - /** * @author Brett Porter * @author Olivier Lamy * */ -public class SvnDiffCommand - extends AbstractDiffCommand - implements SvnCommand -{ +public class SvnDiffCommand extends AbstractDiffCommand implements SvnCommand { /** {@inheritDoc} */ - protected DiffScmResult executeDiffCommand( ScmProviderRepository repo, ScmFileSet fileSet, ScmVersion startVersion, - ScmVersion endVersion ) - throws ScmException - { + protected DiffScmResult executeDiffCommand( + ScmProviderRepository repo, ScmFileSet fileSet, ScmVersion startVersion, ScmVersion endVersion) + throws ScmException { Commandline cl = - createCommandLine( (SvnScmProviderRepository) repo, fileSet.getBasedir(), startVersion, endVersion ); + createCommandLine((SvnScmProviderRepository) repo, fileSet.getBasedir(), startVersion, endVersion); - SvnDiffConsumer consumer = new SvnDiffConsumer( fileSet.getBasedir() ); + SvnDiffConsumer consumer = new SvnDiffConsumer(fileSet.getBasedir()); CommandLineUtils.StringStreamConsumer stderr = new CommandLineUtils.StringStreamConsumer(); - if ( logger.isInfoEnabled() ) - { - logger.info( "Executing: " + SvnCommandLineUtils.cryptPassword( cl ) ); + if (logger.isInfoEnabled()) { + logger.info("Executing: " + SvnCommandLineUtils.cryptPassword(cl)); - if ( Os.isFamily( Os.FAMILY_WINDOWS ) ) - { - logger.info( "Working directory: " + cl.getWorkingDirectory().getAbsolutePath() ); + if (Os.isFamily(Os.FAMILY_WINDOWS)) { + logger.info("Working directory: " + cl.getWorkingDirectory().getAbsolutePath()); } } int exitCode; - try - { - exitCode = SvnCommandLineUtils.execute( cl, consumer, stderr ); - } - catch ( CommandLineException ex ) - { - throw new ScmException( "Error while executing command.", ex ); + try { + exitCode = SvnCommandLineUtils.execute(cl, consumer, stderr); + } catch (CommandLineException ex) { + throw new ScmException("Error while executing command.", ex); } - if ( exitCode != 0 ) - { - return new DiffScmResult( cl.toString(), "The svn command failed.", stderr.getOutput(), false ); + if (exitCode != 0) { + return new DiffScmResult(cl.toString(), "The svn command failed.", stderr.getOutput(), false); } - return new DiffScmResult( cl.toString(), consumer.getChangedFiles(), consumer.getDifferences(), - consumer.getPatch() ); + return new DiffScmResult( + cl.toString(), consumer.getChangedFiles(), consumer.getDifferences(), consumer.getPatch()); } // ---------------------------------------------------------------------- // // ---------------------------------------------------------------------- - public static Commandline createCommandLine( SvnScmProviderRepository repository, File workingDirectory, - ScmVersion startVersion, ScmVersion endVersion ) - { - Commandline cl = SvnCommandLineUtils.getBaseSvnCommandLine( workingDirectory, repository ); + public static Commandline createCommandLine( + SvnScmProviderRepository repository, + File workingDirectory, + ScmVersion startVersion, + ScmVersion endVersion) { + Commandline cl = SvnCommandLineUtils.getBaseSvnCommandLine(workingDirectory, repository); - cl.createArg().setValue( "diff" ); + cl.createArg().setValue("diff"); - cl.createArg().setValue( "--internal-diff" ); + cl.createArg().setValue("--internal-diff"); - if ( startVersion != null && StringUtils.isNotEmpty( startVersion.getName() ) ) - { - cl.createArg().setValue( "-r" ); + if (startVersion != null && StringUtils.isNotEmpty(startVersion.getName())) { + cl.createArg().setValue("-r"); - if ( endVersion != null && StringUtils.isNotEmpty( endVersion.getName() ) ) - { - cl.createArg().setValue( startVersion.getName() + ":" + endVersion.getName() ); - } - else - { - cl.createArg().setValue( startVersion.getName() ); + if (endVersion != null && StringUtils.isNotEmpty(endVersion.getName())) { + cl.createArg().setValue(startVersion.getName() + ":" + endVersion.getName()); + } else { + cl.createArg().setValue(startVersion.getName()); } } diff --git a/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/main/java/org/apache/maven/scm/provider/svn/svnexe/command/export/SvnExeExportCommand.java b/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/main/java/org/apache/maven/scm/provider/svn/svnexe/command/export/SvnExeExportCommand.java index 263bbc509..6ffda54c2 100644 --- a/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/main/java/org/apache/maven/scm/provider/svn/svnexe/command/export/SvnExeExportCommand.java +++ b/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/main/java/org/apache/maven/scm/provider/svn/svnexe/command/export/SvnExeExportCommand.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.svn.svnexe.command.export; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider.svn.svnexe.command.export; import java.io.File; @@ -47,18 +46,13 @@ * @author Emmanuel Venisse * */ -public class SvnExeExportCommand - extends AbstractExportCommand - implements SvnCommand -{ +public class SvnExeExportCommand extends AbstractExportCommand implements SvnCommand { /** {@inheritDoc} */ - protected ExportScmResult executeExportCommand( ScmProviderRepository repo, ScmFileSet fileSet, ScmVersion version, - String outputDirectory ) - throws ScmException - { + protected ExportScmResult executeExportCommand( + ScmProviderRepository repo, ScmFileSet fileSet, ScmVersion version, String outputDirectory) + throws ScmException { - if ( outputDirectory == null ) - { + if (outputDirectory == null) { outputDirectory = fileSet.getBasedir().getAbsolutePath(); } @@ -66,91 +60,80 @@ protected ExportScmResult executeExportCommand( ScmProviderRepository repo, ScmF String url = repository.getUrl(); - if ( version != null && StringUtils.isNotEmpty( version.getName() ) ) - { - if ( version instanceof ScmTag ) - { - url = SvnTagBranchUtils.resolveTagUrl( repository, (ScmTag) version ); - } - else if ( version instanceof ScmBranch ) - { - url = SvnTagBranchUtils.resolveBranchUrl( repository, (ScmBranch) version ); + if (version != null && StringUtils.isNotEmpty(version.getName())) { + if (version instanceof ScmTag) { + url = SvnTagBranchUtils.resolveTagUrl(repository, (ScmTag) version); + } else if (version instanceof ScmBranch) { + url = SvnTagBranchUtils.resolveBranchUrl(repository, (ScmBranch) version); } } - url = SvnCommandUtils.fixUrl( url, repository.getUser() ); + url = SvnCommandUtils.fixUrl(url, repository.getUser()); Commandline cl = - createCommandLine( (SvnScmProviderRepository) repo, fileSet.getBasedir(), version, url, outputDirectory ); + createCommandLine((SvnScmProviderRepository) repo, fileSet.getBasedir(), version, url, outputDirectory); - SvnUpdateConsumer consumer = new SvnUpdateConsumer( fileSet.getBasedir() ); + SvnUpdateConsumer consumer = new SvnUpdateConsumer(fileSet.getBasedir()); CommandLineUtils.StringStreamConsumer stderr = new CommandLineUtils.StringStreamConsumer(); - if ( logger.isInfoEnabled() ) - { - logger.info( "Executing: " + SvnCommandLineUtils.cryptPassword( cl ) ); + if (logger.isInfoEnabled()) { + logger.info("Executing: " + SvnCommandLineUtils.cryptPassword(cl)); - if ( cl.getWorkingDirectory() != null && Os.isFamily( Os.FAMILY_WINDOWS ) ) - { - logger.info( "Working directory: " + cl.getWorkingDirectory().getAbsolutePath() ); + if (cl.getWorkingDirectory() != null && Os.isFamily(Os.FAMILY_WINDOWS)) { + logger.info("Working directory: " + cl.getWorkingDirectory().getAbsolutePath()); } } int exitCode; - try - { - exitCode = SvnCommandLineUtils.execute( cl, consumer, stderr ); - } - catch ( CommandLineException ex ) - { - throw new ScmException( "Error while executing command.", ex ); + try { + exitCode = SvnCommandLineUtils.execute(cl, consumer, stderr); + } catch (CommandLineException ex) { + throw new ScmException("Error while executing command.", ex); } - if ( exitCode != 0 ) - { - return new ExportScmResult( cl.toString(), "The svn command failed.", stderr.getOutput(), false ); + if (exitCode != 0) { + return new ExportScmResult(cl.toString(), "The svn command failed.", stderr.getOutput(), false); } - return new ExportScmResultWithRevision( cl.toString(), consumer.getUpdatedFiles(), - String.valueOf( consumer.getRevision() ) ); + return new ExportScmResultWithRevision( + cl.toString(), consumer.getUpdatedFiles(), String.valueOf(consumer.getRevision())); } // ---------------------------------------------------------------------- // // ---------------------------------------------------------------------- - public static Commandline createCommandLine( SvnScmProviderRepository repository, File workingDirectory, - ScmVersion version, String url, String outputSirectory ) - { - if ( version != null && StringUtils.isEmpty( version.getName() ) ) - { + public static Commandline createCommandLine( + SvnScmProviderRepository repository, + File workingDirectory, + ScmVersion version, + String url, + String outputSirectory) { + if (version != null && StringUtils.isEmpty(version.getName())) { version = null; } - Commandline cl = SvnCommandLineUtils.getBaseSvnCommandLine( workingDirectory, repository ); + Commandline cl = SvnCommandLineUtils.getBaseSvnCommandLine(workingDirectory, repository); - cl.createArg().setValue( "export" ); + cl.createArg().setValue("export"); - if ( version != null && StringUtils.isNotEmpty( version.getName() ) ) - { - if ( version instanceof ScmRevision ) - { - cl.createArg().setValue( "-r" ); + if (version != null && StringUtils.isNotEmpty(version.getName())) { + if (version instanceof ScmRevision) { + cl.createArg().setValue("-r"); - cl.createArg().setValue( version.getName() ); + cl.createArg().setValue(version.getName()); } } - //support exporting to an existing directory - cl.createArg().setValue( "--force" ); + // support exporting to an existing directory + cl.createArg().setValue("--force"); - cl.createArg().setValue( url + "@" ); + cl.createArg().setValue(url + "@"); - if ( StringUtils.isNotEmpty( outputSirectory ) ) - { - cl.createArg().setValue( outputSirectory + "@" ); + if (StringUtils.isNotEmpty(outputSirectory)) { + cl.createArg().setValue(outputSirectory + "@"); } return cl; diff --git a/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/main/java/org/apache/maven/scm/provider/svn/svnexe/command/info/SvnInfoCommand.java b/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/main/java/org/apache/maven/scm/provider/svn/svnexe/command/info/SvnInfoCommand.java index 4f6318a88..58fabc7f6 100644 --- a/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/main/java/org/apache/maven/scm/provider/svn/svnexe/command/info/SvnInfoCommand.java +++ b/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/main/java/org/apache/maven/scm/provider/svn/svnexe/command/info/SvnInfoCommand.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.svn.svnexe.command.info; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider.svn.svnexe.command.info; import java.io.File; import java.util.Iterator; @@ -42,95 +41,80 @@ * @author Kenney Westerhof * */ -public class SvnInfoCommand - extends AbstractCommand - implements SvnCommand -{ +public class SvnInfoCommand extends AbstractCommand implements SvnCommand { /** {@inheritDoc} */ - protected ScmResult executeCommand( ScmProviderRepository repository, ScmFileSet fileSet, - CommandParameters parameters ) - throws ScmException - { - return executeInfoCommand( (SvnScmProviderRepository) repository, fileSet, parameters, false, null ); + protected ScmResult executeCommand( + ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters) throws ScmException { + return executeInfoCommand((SvnScmProviderRepository) repository, fileSet, parameters, false, null); } - public InfoScmResult executeInfoCommand( SvnScmProviderRepository repository, ScmFileSet fileSet, - CommandParameters parameters, boolean recursive, String revision ) - throws ScmException - { - Commandline cl = createCommandLine( repository, fileSet, recursive, revision ); + public InfoScmResult executeInfoCommand( + SvnScmProviderRepository repository, + ScmFileSet fileSet, + CommandParameters parameters, + boolean recursive, + String revision) + throws ScmException { + Commandline cl = createCommandLine(repository, fileSet, recursive, revision); SvnInfoConsumer consumer = new SvnInfoConsumer(); CommandLineUtils.StringStreamConsumer stderr = new CommandLineUtils.StringStreamConsumer(); - if ( logger.isInfoEnabled() ) - { - logger.info( "Executing: " + SvnCommandLineUtils.cryptPassword( cl ) ); + if (logger.isInfoEnabled()) { + logger.info("Executing: " + SvnCommandLineUtils.cryptPassword(cl)); - if ( Os.isFamily( Os.FAMILY_WINDOWS ) ) - { - logger.info( "Working directory: " + cl.getWorkingDirectory().getAbsolutePath() ); + if (Os.isFamily(Os.FAMILY_WINDOWS)) { + logger.info("Working directory: " + cl.getWorkingDirectory().getAbsolutePath()); } } int exitCode; - try - { - exitCode = SvnCommandLineUtils.execute( cl, consumer, stderr ); - } - catch ( CommandLineException ex ) - { - throw new ScmException( "Error while executing command.", ex ); + try { + exitCode = SvnCommandLineUtils.execute(cl, consumer, stderr); + } catch (CommandLineException ex) { + throw new ScmException("Error while executing command.", ex); } - if ( exitCode != 0 ) - { - return new InfoScmResult( cl.toString(), "The svn command failed.", stderr.getOutput(), false ); + if (exitCode != 0) { + return new InfoScmResult(cl.toString(), "The svn command failed.", stderr.getOutput(), false); } - return new InfoScmResult( cl.toString(), consumer.getInfoItems() ); + return new InfoScmResult(cl.toString(), consumer.getInfoItems()); } - //set scope to protected to allow test to call it directly - protected static Commandline createCommandLine( SvnScmProviderRepository repository, ScmFileSet fileSet, - boolean recursive, String revision ) - { - Commandline cl = SvnCommandLineUtils.getBaseSvnCommandLine( fileSet.getBasedir(), repository ); + // set scope to protected to allow test to call it directly + protected static Commandline createCommandLine( + SvnScmProviderRepository repository, ScmFileSet fileSet, boolean recursive, String revision) { + Commandline cl = SvnCommandLineUtils.getBaseSvnCommandLine(fileSet.getBasedir(), repository); - cl.createArg().setValue( "info" ); + cl.createArg().setValue("info"); - if ( recursive ) - { - cl.createArg().setValue( "--recursive" ); + if (recursive) { + cl.createArg().setValue("--recursive"); } - if ( StringUtils.isNotEmpty( revision ) ) - { - cl.createArg().setValue( "-r" ); + if (StringUtils.isNotEmpty(revision)) { + cl.createArg().setValue("-r"); - cl.createArg().setValue( revision ); + cl.createArg().setValue(revision); } Iterator it = fileSet.getFileList().iterator(); - while ( it.hasNext() ) - { + while (it.hasNext()) { File file = (File) it.next(); - if ( repository == null ) - { - cl.createArg().setValue( file.getPath() ); - } - else - { - cl.createArg().setValue( repository.getUrl() + "/" + file.getPath().replace( '\\', '/' ) + "@" ); + if (repository == null) { + cl.createArg().setValue(file.getPath()); + } else { + cl.createArg() + .setValue(repository.getUrl() + "/" + file.getPath().replace('\\', '/') + "@"); } } return cl; } - } diff --git a/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/main/java/org/apache/maven/scm/provider/svn/svnexe/command/info/SvnInfoConsumer.java b/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/main/java/org/apache/maven/scm/provider/svn/svnexe/command/info/SvnInfoConsumer.java index 1dc9cc3a6..0a4a71680 100644 --- a/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/main/java/org/apache/maven/scm/provider/svn/svnexe/command/info/SvnInfoConsumer.java +++ b/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/main/java/org/apache/maven/scm/provider/svn/svnexe/command/info/SvnInfoConsumer.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.svn.svnexe.command.info; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider.svn.svnexe.command.info; import java.util.ArrayList; import java.util.List; @@ -29,84 +28,54 @@ * @author Kenney Westerhof * */ -public class SvnInfoConsumer - extends AbstractConsumer -{ +public class SvnInfoConsumer extends AbstractConsumer { private final List infoItems = new ArrayList<>(); private InfoItem currentItem = new InfoItem(); /** {@inheritDoc} */ - public void consumeLine( String s ) - { - if ( s.equals( "" ) ) - { - if ( currentItem != null ) - { - infoItems.add( currentItem ); + public void consumeLine(String s) { + if (s.equals("")) { + if (currentItem != null) { + infoItems.add(currentItem); } currentItem = new InfoItem(); - } - else if ( s.startsWith( "Path: " ) ) - { - currentItem.setPath( getValue( s ) ); - } - else if ( s.startsWith( "URL: " ) ) - { - currentItem.setURL( getValue( s ) ); - } - else if ( s.startsWith( "Repository Root: " ) ) - { - currentItem.setRepositoryRoot( getValue( s ) ); - } - else if ( s.startsWith( "Repository UUID: " ) ) - { - currentItem.setRepositoryUUID( getValue( s ) ); - } - else if ( s.startsWith( "Revision: " ) ) - { - currentItem.setRevision( getValue( s ) ); - } - else if ( s.startsWith( "Node Kind: " ) ) - { - currentItem.setNodeKind( getValue( s ) ); - } - else if ( s.startsWith( "Schedule: " ) ) - { - currentItem.setSchedule( getValue( s ) ); - } - else if ( s.startsWith( "Last Changed Author: " ) ) - { - currentItem.setLastChangedAuthor( getValue( s ) ); - } - else if ( s.startsWith( "Last Changed Rev: " ) ) - { - currentItem.setLastChangedRevision( getValue( s ) ); - } - else if ( s.startsWith( "Last Changed Date: " ) ) - { - currentItem.setLastChangedDate( getValue( s ) ); + } else if (s.startsWith("Path: ")) { + currentItem.setPath(getValue(s)); + } else if (s.startsWith("URL: ")) { + currentItem.setURL(getValue(s)); + } else if (s.startsWith("Repository Root: ")) { + currentItem.setRepositoryRoot(getValue(s)); + } else if (s.startsWith("Repository UUID: ")) { + currentItem.setRepositoryUUID(getValue(s)); + } else if (s.startsWith("Revision: ")) { + currentItem.setRevision(getValue(s)); + } else if (s.startsWith("Node Kind: ")) { + currentItem.setNodeKind(getValue(s)); + } else if (s.startsWith("Schedule: ")) { + currentItem.setSchedule(getValue(s)); + } else if (s.startsWith("Last Changed Author: ")) { + currentItem.setLastChangedAuthor(getValue(s)); + } else if (s.startsWith("Last Changed Rev: ")) { + currentItem.setLastChangedRevision(getValue(s)); + } else if (s.startsWith("Last Changed Date: ")) { + currentItem.setLastChangedDate(getValue(s)); } } - private static String getValue( String s ) - { - int idx = s.indexOf( ": " ); + private static String getValue(String s) { + int idx = s.indexOf(": "); - if ( idx < 0 ) - { + if (idx < 0) { // FIXME: Can't throw any exceptions in consumeLine.. return null; - } - else - { - return s.substring( idx + 2 ); + } else { + return s.substring(idx + 2); } } - public List getInfoItems() - { + public List getInfoItems() { return infoItems; } } diff --git a/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/main/java/org/apache/maven/scm/provider/svn/svnexe/command/list/SvnListCommand.java b/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/main/java/org/apache/maven/scm/provider/svn/svnexe/command/list/SvnListCommand.java index 32ad0a1fc..685979678 100644 --- a/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/main/java/org/apache/maven/scm/provider/svn/svnexe/command/list/SvnListCommand.java +++ b/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/main/java/org/apache/maven/scm/provider/svn/svnexe/command/list/SvnListCommand.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.svn.svnexe.command.list; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,10 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider.svn.svnexe.command.list; + +import java.io.File; +import java.util.Iterator; import org.apache.maven.scm.ScmException; import org.apache.maven.scm.ScmFileSet; @@ -35,93 +37,74 @@ import org.codehaus.plexus.util.cli.CommandLineUtils; import org.codehaus.plexus.util.cli.Commandline; -import java.io.File; -import java.util.Iterator; - /** * Command to list files in SVN ( svn list command ) * * @author Carlos Sanchez * */ -public class SvnListCommand - extends AbstractListCommand - implements SvnCommand -{ - private static final File TMP_DIR = new File( System.getProperty( "java.io.tmpdir" ) ); +public class SvnListCommand extends AbstractListCommand implements SvnCommand { + private static final File TMP_DIR = new File(System.getProperty("java.io.tmpdir")); /** {@inheritDoc} */ - protected ListScmResult executeListCommand( ScmProviderRepository repository, ScmFileSet fileSet, boolean recursive, - ScmVersion version ) - throws ScmException - { - Commandline cl = createCommandLine( (SvnScmProviderRepository) repository, fileSet, recursive, version ); + protected ListScmResult executeListCommand( + ScmProviderRepository repository, ScmFileSet fileSet, boolean recursive, ScmVersion version) + throws ScmException { + Commandline cl = createCommandLine((SvnScmProviderRepository) repository, fileSet, recursive, version); SvnListConsumer consumer = new SvnListConsumer(); CommandLineUtils.StringStreamConsumer stderr = new CommandLineUtils.StringStreamConsumer(); - if ( logger.isInfoEnabled() ) - { - logger.info( "Executing: " + SvnCommandLineUtils.cryptPassword( cl ) ); + if (logger.isInfoEnabled()) { + logger.info("Executing: " + SvnCommandLineUtils.cryptPassword(cl)); - if ( Os.isFamily( Os.FAMILY_WINDOWS ) ) - { - logger.info( "Working directory: " + cl.getWorkingDirectory().getAbsolutePath() ); + if (Os.isFamily(Os.FAMILY_WINDOWS)) { + logger.info("Working directory: " + cl.getWorkingDirectory().getAbsolutePath()); } } int exitCode; - try - { - exitCode = SvnCommandLineUtils.execute( cl, consumer, stderr ); - } - catch ( CommandLineException ex ) - { - throw new ScmException( "Error while executing command.", ex ); + try { + exitCode = SvnCommandLineUtils.execute(cl, consumer, stderr); + } catch (CommandLineException ex) { + throw new ScmException("Error while executing command.", ex); } - if ( exitCode != 0 ) - { - return new ListScmResult( cl.toString(), "The svn command failed.", stderr.getOutput(), false ); + if (exitCode != 0) { + return new ListScmResult(cl.toString(), "The svn command failed.", stderr.getOutput(), false); } - return new ListScmResult( cl.toString(), consumer.getFiles() ); + return new ListScmResult(cl.toString(), consumer.getFiles()); } - static Commandline createCommandLine( SvnScmProviderRepository repository, ScmFileSet fileSet, boolean recursive, - ScmVersion version ) - { - Commandline cl = SvnCommandLineUtils.getBaseSvnCommandLine( TMP_DIR, repository ); + static Commandline createCommandLine( + SvnScmProviderRepository repository, ScmFileSet fileSet, boolean recursive, ScmVersion version) { + Commandline cl = SvnCommandLineUtils.getBaseSvnCommandLine(TMP_DIR, repository); - cl.createArg().setValue( "list" ); + cl.createArg().setValue("list"); - if ( recursive ) - { - cl.createArg().setValue( "--recursive" ); + if (recursive) { + cl.createArg().setValue("--recursive"); } - if ( version != null && StringUtils.isNotEmpty( version.getName() ) ) - { - if ( version instanceof ScmRevision ) - { - cl.createArg().setValue( "-r" ); + if (version != null && StringUtils.isNotEmpty(version.getName())) { + if (version instanceof ScmRevision) { + cl.createArg().setValue("-r"); - cl.createArg().setValue( version.getName() ); + cl.createArg().setValue(version.getName()); } } Iterator it = fileSet.getFileList().iterator(); - while ( it.hasNext() ) - { + while (it.hasNext()) { File file = it.next(); - cl.createArg().setValue( repository.getUrl() + "/" + file.getPath().replace( '\\', '/' ) + "@" ); + cl.createArg().setValue(repository.getUrl() + "/" + file.getPath().replace('\\', '/') + "@"); } return cl; } - } diff --git a/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/main/java/org/apache/maven/scm/provider/svn/svnexe/command/list/SvnListConsumer.java b/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/main/java/org/apache/maven/scm/provider/svn/svnexe/command/list/SvnListConsumer.java index 813ca6421..7536110ab 100644 --- a/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/main/java/org/apache/maven/scm/provider/svn/svnexe/command/list/SvnListConsumer.java +++ b/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/main/java/org/apache/maven/scm/provider/svn/svnexe/command/list/SvnListConsumer.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.svn.svnexe.command.list; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,21 +16,20 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider.svn.svnexe.command.list; + +import java.util.ArrayList; +import java.util.List; import org.apache.maven.scm.ScmFile; import org.apache.maven.scm.ScmFileStatus; import org.apache.maven.scm.util.AbstractConsumer; -import java.util.ArrayList; -import java.util.List; - /** * @author Carlos Sanchez * */ -public class SvnListConsumer - extends AbstractConsumer -{ +public class SvnListConsumer extends AbstractConsumer { private final List files = new ArrayList<>(); // ---------------------------------------------------------------------- @@ -40,14 +37,11 @@ public class SvnListConsumer // ---------------------------------------------------------------------- /** {@inheritDoc} */ - public void consumeLine( String line ) - { - files.add( new ScmFile( line, ScmFileStatus.CHECKED_IN ) ); + public void consumeLine(String line) { + files.add(new ScmFile(line, ScmFileStatus.CHECKED_IN)); } - public List getFiles() - { + public List getFiles() { return files; } - } diff --git a/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/main/java/org/apache/maven/scm/provider/svn/svnexe/command/mkdir/SvnMkdirCommand.java b/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/main/java/org/apache/maven/scm/provider/svn/svnexe/command/mkdir/SvnMkdirCommand.java index 9e339d7a8..d55d43605 100644 --- a/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/main/java/org/apache/maven/scm/provider/svn/svnexe/command/mkdir/SvnMkdirCommand.java +++ b/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/main/java/org/apache/maven/scm/provider/svn/svnexe/command/mkdir/SvnMkdirCommand.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.svn.svnexe.command.mkdir; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,11 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider.svn.svnexe.command.mkdir; + +import java.io.File; +import java.io.IOException; +import java.util.Iterator; import org.apache.maven.scm.ScmException; import org.apache.maven.scm.ScmFileSet; @@ -34,131 +37,97 @@ import org.codehaus.plexus.util.cli.CommandLineUtils; import org.codehaus.plexus.util.cli.Commandline; -import java.io.File; -import java.io.IOException; -import java.util.Iterator; - /** * @author Maria Odea Ching * */ -public class SvnMkdirCommand - extends AbstractMkdirCommand - implements SvnCommand -{ +public class SvnMkdirCommand extends AbstractMkdirCommand implements SvnCommand { /** * {@inheritDoc} */ - protected MkdirScmResult executeMkdirCommand( ScmProviderRepository repository, ScmFileSet fileSet, String message, - boolean createInLocal ) - throws ScmException - { - File messageFile = FileUtils.createTempFile( "maven-scm-", ".commit", null ); - - try - { - FileUtils.fileWrite( messageFile.getAbsolutePath(), "UTF-8", message ); - } - catch ( IOException ex ) - { - return new MkdirScmResult( null, - "Error while making a temporary file for the mkdir message: " + ex.getMessage(), - null, false ); + protected MkdirScmResult executeMkdirCommand( + ScmProviderRepository repository, ScmFileSet fileSet, String message, boolean createInLocal) + throws ScmException { + File messageFile = FileUtils.createTempFile("maven-scm-", ".commit", null); + + try { + FileUtils.fileWrite(messageFile.getAbsolutePath(), "UTF-8", message); + } catch (IOException ex) { + return new MkdirScmResult( + null, "Error while making a temporary file for the mkdir message: " + ex.getMessage(), null, false); } - Commandline cl = - createCommandLine( (SvnScmProviderRepository) repository, fileSet, messageFile, createInLocal ); + Commandline cl = createCommandLine((SvnScmProviderRepository) repository, fileSet, messageFile, createInLocal); SvnMkdirConsumer consumer = new SvnMkdirConsumer(); CommandLineUtils.StringStreamConsumer stderr = new CommandLineUtils.StringStreamConsumer(); - if ( logger.isInfoEnabled() ) - { - logger.info( "Executing: " + SvnCommandLineUtils.cryptPassword( cl ) ); + if (logger.isInfoEnabled()) { + logger.info("Executing: " + SvnCommandLineUtils.cryptPassword(cl)); - if ( Os.isFamily( Os.FAMILY_WINDOWS ) ) - { - logger.info( "Working directory: " + cl.getWorkingDirectory().getAbsolutePath() ); + if (Os.isFamily(Os.FAMILY_WINDOWS)) { + logger.info("Working directory: " + cl.getWorkingDirectory().getAbsolutePath()); } } int exitCode; - try - { - exitCode = SvnCommandLineUtils.execute( cl, consumer, stderr ); - } - catch ( CommandLineException ex ) - { - throw new ScmException( "Error while executing command.", ex ); - } - finally - { - try - { - FileUtils.forceDelete( messageFile ); - } - catch ( IOException ex ) - { + try { + exitCode = SvnCommandLineUtils.execute(cl, consumer, stderr); + } catch (CommandLineException ex) { + throw new ScmException("Error while executing command.", ex); + } finally { + try { + FileUtils.forceDelete(messageFile); + } catch (IOException ex) { // ignore } } - if ( exitCode != 0 ) - { - return new MkdirScmResult( cl.toString(), "The svn command failed.", stderr.getOutput(), false ); + if (exitCode != 0) { + return new MkdirScmResult(cl.toString(), "The svn command failed.", stderr.getOutput(), false); } - if ( createInLocal ) - { - return new MkdirScmResult( cl.toString(), consumer.getCreatedDirs() ); - } - else - { - return new MkdirScmResult( cl.toString(), Integer.toString( consumer.getRevision() ) ); + if (createInLocal) { + return new MkdirScmResult(cl.toString(), consumer.getCreatedDirs()); + } else { + return new MkdirScmResult(cl.toString(), Integer.toString(consumer.getRevision())); } } - protected static Commandline createCommandLine( SvnScmProviderRepository repository, ScmFileSet fileSet, - File messageFile, boolean createInLocal ) - { + protected static Commandline createCommandLine( + SvnScmProviderRepository repository, ScmFileSet fileSet, File messageFile, boolean createInLocal) { // as we want to be able to create path remote only create this directory if not here - if ( !fileSet.getBasedir().exists() && !createInLocal ) - { + if (!fileSet.getBasedir().exists() && !createInLocal) { fileSet.getBasedir().mkdirs(); } - Commandline cl = SvnCommandLineUtils.getBaseSvnCommandLine( fileSet.getBasedir(), repository ); + Commandline cl = SvnCommandLineUtils.getBaseSvnCommandLine(fileSet.getBasedir(), repository); - cl.createArg().setValue( "mkdir" ); + cl.createArg().setValue("mkdir"); - cl.createArg().setValue( "--parents" ); + cl.createArg().setValue("--parents"); Iterator it = fileSet.getFileList().iterator(); String dirPath = it.next().getPath(); // replacing \ with / for windauze - if ( dirPath != null && Os.isFamily( Os.FAMILY_WINDOWS ) ) - { - dirPath = StringUtils.replace( dirPath, "\\", "/" ); + if (dirPath != null && Os.isFamily(Os.FAMILY_WINDOWS)) { + dirPath = StringUtils.replace(dirPath, "\\", "/"); } - if ( !createInLocal ) - { - cl.createArg().setValue( repository.getUrl() + "/" + dirPath + "@" ); + if (!createInLocal) { + cl.createArg().setValue(repository.getUrl() + "/" + dirPath + "@"); - if ( messageFile != null ) - { - cl.createArg().setValue( "--file" ); - cl.createArg().setValue( messageFile.getAbsolutePath() ); + if (messageFile != null) { + cl.createArg().setValue("--file"); + cl.createArg().setValue(messageFile.getAbsolutePath()); - cl.createArg().setValue( "--encoding" ); - cl.createArg().setValue( "UTF-8" ); + cl.createArg().setValue("--encoding"); + cl.createArg().setValue("UTF-8"); } - } - else - { - cl.createArg().setValue( dirPath ); + } else { + cl.createArg().setValue(dirPath); } return cl; diff --git a/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/main/java/org/apache/maven/scm/provider/svn/svnexe/command/mkdir/SvnMkdirConsumer.java b/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/main/java/org/apache/maven/scm/provider/svn/svnexe/command/mkdir/SvnMkdirConsumer.java index 3c52c0888..1fd8315ce 100644 --- a/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/main/java/org/apache/maven/scm/provider/svn/svnexe/command/mkdir/SvnMkdirConsumer.java +++ b/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/main/java/org/apache/maven/scm/provider/svn/svnexe/command/mkdir/SvnMkdirConsumer.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.svn.svnexe.command.mkdir; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider.svn.svnexe.command.mkdir; import java.util.ArrayList; import java.util.List; @@ -31,60 +30,48 @@ * @author Maria Odea Ching * */ -public class SvnMkdirConsumer - extends AbstractConsumer -{ +public class SvnMkdirConsumer extends AbstractConsumer { private static final String COMMITTED_REVISION_TOKEN = "Committed revision"; private int revision; - + private final List createdDirs = new ArrayList<>(); /** {@inheritDoc} */ - public void consumeLine( String line ) - { - if ( StringUtils.isBlank( line ) ) - { + public void consumeLine(String line) { + if (StringUtils.isBlank(line)) { return; } - - String statusString = line.substring( 0, 1 ); + + String statusString = line.substring(0, 1); ScmFileStatus status; - - if ( line.startsWith( COMMITTED_REVISION_TOKEN ) ) - { - String revisionString = line.substring( COMMITTED_REVISION_TOKEN.length() + 1, line.length() - 1 ); - revision = Integer.parseInt( revisionString ); - + if (line.startsWith(COMMITTED_REVISION_TOKEN)) { + String revisionString = line.substring(COMMITTED_REVISION_TOKEN.length() + 1, line.length() - 1); + + revision = Integer.parseInt(revisionString); + return; - } - else if ( statusString.equals( "A" ) ) - { - String file = line.substring( 3 ); - + } else if (statusString.equals("A")) { + String file = line.substring(3); + status = ScmFileStatus.ADDED; - - createdDirs.add( new ScmFile( file, status ) ); - } - else - { - if ( logger.isInfoEnabled() ) - { - logger.info( "Unknown line: '" + line + "'" ); + + createdDirs.add(new ScmFile(file, status)); + } else { + if (logger.isInfoEnabled()) { + logger.info("Unknown line: '" + line + "'"); } return; } } - public int getRevision() - { + public int getRevision() { return revision; } - - public List getCreatedDirs() - { + + public List getCreatedDirs() { return createdDirs; } } diff --git a/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/main/java/org/apache/maven/scm/provider/svn/svnexe/command/remoteinfo/SvnRemoteInfoCommand.java b/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/main/java/org/apache/maven/scm/provider/svn/svnexe/command/remoteinfo/SvnRemoteInfoCommand.java index ccc083213..95b8f2c99 100644 --- a/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/main/java/org/apache/maven/scm/provider/svn/svnexe/command/remoteinfo/SvnRemoteInfoCommand.java +++ b/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/main/java/org/apache/maven/scm/provider/svn/svnexe/command/remoteinfo/SvnRemoteInfoCommand.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.svn.svnexe.command.remoteinfo; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -18,6 +16,10 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider.svn.svnexe.command.remoteinfo; + +import java.util.HashMap; +import java.util.Map; import org.apache.maven.scm.CommandParameters; import org.apache.maven.scm.ScmException; @@ -34,153 +36,125 @@ import org.codehaus.plexus.util.cli.CommandLineUtils; import org.codehaus.plexus.util.cli.Commandline; -import java.util.HashMap; -import java.util.Map; - /** * @author Olivier Lamy * @since 1.6 */ -public class SvnRemoteInfoCommand - extends AbstractRemoteInfoCommand - implements SvnCommand -{ +public class SvnRemoteInfoCommand extends AbstractRemoteInfoCommand implements SvnCommand { @Override - public RemoteInfoScmResult executeRemoteInfoCommand( ScmProviderRepository repository, ScmFileSet fileSet, - CommandParameters parameters ) - throws ScmException - { + public RemoteInfoScmResult executeRemoteInfoCommand( + ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters) throws ScmException { - String url = ( (SvnScmProviderRepository) repository ).getUrl(); + String url = ((SvnScmProviderRepository) repository).getUrl(); // use a default svn layout, url is here http://svn.apache.org/repos/asf/maven/maven-3/trunk // so as we presume we have good users using standard svn layout, we calculate tags and branches url - url = StringUtils.stripEnd( url, "/" ); - int idx = url.lastIndexOf( "/" ); - String baseUrl = url.substring( 0, idx ); + url = StringUtils.stripEnd(url, "/"); + int idx = url.lastIndexOf("/"); + String baseUrl = url.substring(0, idx); - Commandline cl = SvnCommandLineUtils.getBaseSvnCommandLine( fileSet == null ? null : fileSet.getBasedir(), - (SvnScmProviderRepository) repository ); + Commandline cl = SvnCommandLineUtils.getBaseSvnCommandLine( + fileSet == null ? null : fileSet.getBasedir(), (SvnScmProviderRepository) repository); - cl.createArg().setValue( "ls" ); + cl.createArg().setValue("ls"); - cl.createArg().setValue( baseUrl + "/tags" + "@" ); + cl.createArg().setValue(baseUrl + "/tags" + "@"); CommandLineUtils.StringStreamConsumer stderr = new CommandLineUtils.StringStreamConsumer(); - LsConsumer consumer = new LsConsumer( baseUrl + "/tags" ); + LsConsumer consumer = new LsConsumer(baseUrl + "/tags"); int exitCode = 0; Map tagsInfos = null; - try - { - exitCode = SvnCommandLineUtils.execute( cl, consumer, stderr ); + try { + exitCode = SvnCommandLineUtils.execute(cl, consumer, stderr); tagsInfos = consumer.infos; - } - catch ( CommandLineException ex ) - { - throw new ScmException( "Error while executing svn command.", ex ); + } catch (CommandLineException ex) { + throw new ScmException("Error while executing svn command.", ex); } - if ( exitCode != 0 ) - { - return new RemoteInfoScmResult( cl.toString(), "The svn command failed.", stderr.getOutput(), false ); + if (exitCode != 0) { + return new RemoteInfoScmResult(cl.toString(), "The svn command failed.", stderr.getOutput(), false); } - cl = SvnCommandLineUtils.getBaseSvnCommandLine( fileSet == null ? null : fileSet.getBasedir(), - (SvnScmProviderRepository) repository ); + cl = SvnCommandLineUtils.getBaseSvnCommandLine( + fileSet == null ? null : fileSet.getBasedir(), (SvnScmProviderRepository) repository); - cl.createArg().setValue( "ls" ); + cl.createArg().setValue("ls"); - cl.createArg().setValue( baseUrl + "/branches" + "@" ); + cl.createArg().setValue(baseUrl + "/branches" + "@"); stderr = new CommandLineUtils.StringStreamConsumer(); - consumer = new LsConsumer( baseUrl + "/branches" ); + consumer = new LsConsumer(baseUrl + "/branches"); Map branchesInfos = null; - try - { - exitCode = SvnCommandLineUtils.execute( cl, consumer, stderr ); + try { + exitCode = SvnCommandLineUtils.execute(cl, consumer, stderr); branchesInfos = consumer.infos; - } - catch ( CommandLineException ex ) - { - throw new ScmException( "Error while executing svn command.", ex ); + } catch (CommandLineException ex) { + throw new ScmException("Error while executing svn command.", ex); } - if ( exitCode != 0 ) - { - return new RemoteInfoScmResult( cl.toString(), "The svn command failed.", stderr.getOutput(), false ); + if (exitCode != 0) { + return new RemoteInfoScmResult(cl.toString(), "The svn command failed.", stderr.getOutput(), false); } - return new RemoteInfoScmResult( cl.toString(), branchesInfos, tagsInfos ); + return new RemoteInfoScmResult(cl.toString(), branchesInfos, tagsInfos); } - public boolean remoteUrlExist( ScmProviderRepository repository, CommandParameters parameters ) - throws ScmException - { - String url = ( (SvnScmProviderRepository) repository ).getUrl(); + public boolean remoteUrlExist(ScmProviderRepository repository, CommandParameters parameters) throws ScmException { + String url = ((SvnScmProviderRepository) repository).getUrl(); - Commandline cl = SvnCommandLineUtils.getBaseSvnCommandLine( null, (SvnScmProviderRepository) repository ); + Commandline cl = SvnCommandLineUtils.getBaseSvnCommandLine(null, (SvnScmProviderRepository) repository); - cl.createArg().setValue( "ls" ); + cl.createArg().setValue("ls"); - cl.createArg().setValue( url + "@" ); + cl.createArg().setValue(url + "@"); CommandLineUtils.StringStreamConsumer stderr = new CommandLineUtils.StringStreamConsumer(); - LsConsumer consumer = new LsConsumer( url ); + LsConsumer consumer = new LsConsumer(url); int exitCode = 0; - try - { - exitCode = SvnCommandLineUtils.execute( cl, consumer, stderr ); - } - catch ( CommandLineException ex ) - { - throw new ScmException( "Error while executing svn command.", ex ); + try { + exitCode = SvnCommandLineUtils.execute(cl, consumer, stderr); + } catch (CommandLineException ex) { + throw new ScmException("Error while executing svn command.", ex); } - if ( exitCode != 0 ) - { + if (exitCode != 0) { String output = stderr.getOutput(); - //olamy: a bit ugly but.... + // olamy: a bit ugly but.... // trying to parse error from svn cli which indicate no remote path - if ( output.contains( "W160013" ) || output.contains( "svn: URL" ) ) - { + if (output.contains("W160013") || output.contains("svn: URL")) { return false; } - throw new ScmException( cl + ".The svn command failed:" + stderr.getOutput() ); + throw new ScmException(cl + ".The svn command failed:" + stderr.getOutput()); } return true; } - private static class LsConsumer - extends AbstractConsumer - { + private static class LsConsumer extends AbstractConsumer { Map infos = new HashMap<>(); String url; - LsConsumer( String url ) - { + LsConsumer(String url) { this.url = url; } - public void consumeLine( String s ) - { - infos.put( StringUtils.stripEnd( s, "/" ), url + "/" + s ); + public void consumeLine(String s) { + infos.put(StringUtils.stripEnd(s, "/"), url + "/" + s); } - Map getInfos() - { + Map getInfos() { return infos; } } diff --git a/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/main/java/org/apache/maven/scm/provider/svn/svnexe/command/remove/SvnRemoveCommand.java b/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/main/java/org/apache/maven/scm/provider/svn/svnexe/command/remove/SvnRemoveCommand.java index 11e329938..369931fd6 100644 --- a/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/main/java/org/apache/maven/scm/provider/svn/svnexe/command/remove/SvnRemoveCommand.java +++ b/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/main/java/org/apache/maven/scm/provider/svn/svnexe/command/remove/SvnRemoveCommand.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.svn.svnexe.command.remove; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,11 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider.svn.svnexe.command.remove; + +import java.io.File; +import java.io.IOException; +import java.util.List; import org.apache.maven.scm.ScmException; import org.apache.maven.scm.ScmFileSet; @@ -32,87 +35,66 @@ import org.codehaus.plexus.util.cli.CommandLineUtils; import org.codehaus.plexus.util.cli.Commandline; -import java.io.File; -import java.io.IOException; -import java.util.List; - /** * @author Brett Porter * @author Olivier Lamy * */ -public class SvnRemoveCommand - extends AbstractRemoveCommand - implements SvnCommand -{ +public class SvnRemoveCommand extends AbstractRemoveCommand implements SvnCommand { /** {@inheritDoc} */ - protected ScmResult executeRemoveCommand( ScmProviderRepository repository, ScmFileSet fileSet, String message ) - throws ScmException - { - if ( fileSet.getFileList().isEmpty() ) - { - throw new ScmException( "You must provide at least one file/directory to remove" ); + protected ScmResult executeRemoveCommand(ScmProviderRepository repository, ScmFileSet fileSet, String message) + throws ScmException { + if (fileSet.getFileList().isEmpty()) { + throw new ScmException("You must provide at least one file/directory to remove"); } - Commandline cl = createCommandLine( fileSet.getBasedir(), fileSet.getFileList() ); + Commandline cl = createCommandLine(fileSet.getBasedir(), fileSet.getFileList()); SvnRemoveConsumer consumer = new SvnRemoveConsumer(); CommandLineUtils.StringStreamConsumer stderr = new CommandLineUtils.StringStreamConsumer(); - if ( logger.isInfoEnabled() ) - { - logger.info( "Executing: " + SvnCommandLineUtils.cryptPassword( cl ) ); + if (logger.isInfoEnabled()) { + logger.info("Executing: " + SvnCommandLineUtils.cryptPassword(cl)); - if ( Os.isFamily( Os.FAMILY_WINDOWS ) ) - { - logger.info( "Working directory: " + cl.getWorkingDirectory().getAbsolutePath() ); + if (Os.isFamily(Os.FAMILY_WINDOWS)) { + logger.info("Working directory: " + cl.getWorkingDirectory().getAbsolutePath()); } } int exitCode; - try - { - exitCode = SvnCommandLineUtils.execute( cl, consumer, stderr ); - } - catch ( CommandLineException ex ) - { - throw new ScmException( "Error while executing command.", ex ); + try { + exitCode = SvnCommandLineUtils.execute(cl, consumer, stderr); + } catch (CommandLineException ex) { + throw new ScmException("Error while executing command.", ex); } - if ( exitCode != 0 ) - { - return new RemoveScmResult( cl.toString(), "The svn command failed.", stderr.getOutput(), false ); + if (exitCode != 0) { + return new RemoveScmResult(cl.toString(), "The svn command failed.", stderr.getOutput(), false); } - return new RemoveScmResult( cl.toString(), consumer.getRemovedFiles() ); + return new RemoveScmResult(cl.toString(), consumer.getRemovedFiles()); } - private static Commandline createCommandLine( File workingDirectory, List files ) - throws ScmException - { + private static Commandline createCommandLine(File workingDirectory, List files) throws ScmException { // Base command line doesn't make sense here - username/password not needed, and non-interactive/non-recusive is // not valid Commandline cl = new Commandline(); - cl.setExecutable( "svn" ); + cl.setExecutable("svn"); - cl.setWorkingDirectory( workingDirectory.getAbsolutePath() ); + cl.setWorkingDirectory(workingDirectory.getAbsolutePath()); - cl.createArg().setValue( "remove" ); + cl.createArg().setValue("remove"); - try - { - SvnCommandLineUtils.addTarget( cl, files ); - } - catch ( IOException e ) - { - throw new ScmException( "Can't create the targets file", e ); + try { + SvnCommandLineUtils.addTarget(cl, files); + } catch (IOException e) { + throw new ScmException("Can't create the targets file", e); } return cl; } - } diff --git a/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/main/java/org/apache/maven/scm/provider/svn/svnexe/command/remove/SvnRemoveConsumer.java b/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/main/java/org/apache/maven/scm/provider/svn/svnexe/command/remove/SvnRemoveConsumer.java index c5e63491e..8e3c28484 100644 --- a/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/main/java/org/apache/maven/scm/provider/svn/svnexe/command/remove/SvnRemoveConsumer.java +++ b/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/main/java/org/apache/maven/scm/provider/svn/svnexe/command/remove/SvnRemoveConsumer.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.svn.svnexe.command.remove; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,22 +16,21 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider.svn.svnexe.command.remove; + +import java.util.ArrayList; +import java.util.List; import org.apache.maven.scm.ScmFile; import org.apache.maven.scm.ScmFileStatus; import org.apache.maven.scm.util.AbstractConsumer; -import java.util.ArrayList; -import java.util.List; - /** * @author Brett Porter * @author Olivier Lamy * */ -public class SvnRemoveConsumer - extends AbstractConsumer -{ +public class SvnRemoveConsumer extends AbstractConsumer { private final List removedFiles = new ArrayList<>(); // ---------------------------------------------------------------------- @@ -41,45 +38,35 @@ public class SvnRemoveConsumer // ---------------------------------------------------------------------- /** {@inheritDoc} */ - public void consumeLine( String line ) - { - if ( line.length() <= 3 ) - { - if ( logger.isWarnEnabled() ) - { - logger.warn( "Unexpected input, the line must be at least three characters long. Line: '" - + line + "'." ); + public void consumeLine(String line) { + if (line.length() <= 3) { + if (logger.isWarnEnabled()) { + logger.warn("Unexpected input, the line must be at least three characters long. Line: '" + line + "'."); } return; } - String statusString = line.substring( 0, 1 ); + String statusString = line.substring(0, 1); - String file = line.substring( 3 ).trim(); + String file = line.substring(3).trim(); ScmFileStatus status; - if ( statusString.equals( "D" ) ) - { + if (statusString.equals("D")) { status = ScmFileStatus.DELETED; - } - else - { - if ( logger.isInfoEnabled() ) - { - logger.info( "Unknown file status: '" + statusString + "'." ); + } else { + if (logger.isInfoEnabled()) { + logger.info("Unknown file status: '" + statusString + "'."); } return; } - removedFiles.add( new ScmFile( file, status ) ); + removedFiles.add(new ScmFile(file, status)); } - public List getRemovedFiles() - { + public List getRemovedFiles() { return removedFiles; } - } diff --git a/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/main/java/org/apache/maven/scm/provider/svn/svnexe/command/status/SvnStatusCommand.java b/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/main/java/org/apache/maven/scm/provider/svn/svnexe/command/status/SvnStatusCommand.java index 29364b269..2ca6b8b71 100644 --- a/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/main/java/org/apache/maven/scm/provider/svn/svnexe/command/status/SvnStatusCommand.java +++ b/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/main/java/org/apache/maven/scm/provider/svn/svnexe/command/status/SvnStatusCommand.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.svn.svnexe.command.status; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider.svn.svnexe.command.status; import org.apache.maven.scm.ScmException; import org.apache.maven.scm.ScmFileSet; @@ -36,58 +35,46 @@ * @author Brett Porter * */ -public class SvnStatusCommand - extends AbstractStatusCommand - implements SvnCommand -{ +public class SvnStatusCommand extends AbstractStatusCommand implements SvnCommand { /** {@inheritDoc} */ - protected StatusScmResult executeStatusCommand( ScmProviderRepository repo, ScmFileSet fileSet ) - throws ScmException - { - Commandline cl = createCommandLine( (SvnScmProviderRepository) repo, fileSet ); + protected StatusScmResult executeStatusCommand(ScmProviderRepository repo, ScmFileSet fileSet) throws ScmException { + Commandline cl = createCommandLine((SvnScmProviderRepository) repo, fileSet); - SvnStatusConsumer consumer = new SvnStatusConsumer( fileSet.getBasedir() ); + SvnStatusConsumer consumer = new SvnStatusConsumer(fileSet.getBasedir()); CommandLineUtils.StringStreamConsumer stderr = new CommandLineUtils.StringStreamConsumer(); - if ( logger.isInfoEnabled() ) - { - logger.info( "Executing: " + SvnCommandLineUtils.cryptPassword( cl ) ); + if (logger.isInfoEnabled()) { + logger.info("Executing: " + SvnCommandLineUtils.cryptPassword(cl)); - if ( Os.isFamily( Os.FAMILY_WINDOWS ) ) - { - logger.info( "Working directory: " + cl.getWorkingDirectory().getAbsolutePath() ); + if (Os.isFamily(Os.FAMILY_WINDOWS)) { + logger.info("Working directory: " + cl.getWorkingDirectory().getAbsolutePath()); } } int exitCode; - try - { - exitCode = SvnCommandLineUtils.execute( cl, consumer, stderr ); - } - catch ( CommandLineException ex ) - { - throw new ScmException( "Error while executing command.", ex ); + try { + exitCode = SvnCommandLineUtils.execute(cl, consumer, stderr); + } catch (CommandLineException ex) { + throw new ScmException("Error while executing command.", ex); } - if ( exitCode != 0 ) - { - return new StatusScmResult( cl.toString(), "The svn command failed.", stderr.getOutput(), false ); + if (exitCode != 0) { + return new StatusScmResult(cl.toString(), "The svn command failed.", stderr.getOutput(), false); } - return new StatusScmResult( cl.toString(), consumer.getChangedFiles() ); + return new StatusScmResult(cl.toString(), consumer.getChangedFiles()); } // ---------------------------------------------------------------------- // // ---------------------------------------------------------------------- - public static Commandline createCommandLine( SvnScmProviderRepository repository, ScmFileSet fileSet ) - { - Commandline cl = SvnCommandLineUtils.getBaseSvnCommandLine( fileSet.getBasedir(), repository ); + public static Commandline createCommandLine(SvnScmProviderRepository repository, ScmFileSet fileSet) { + Commandline cl = SvnCommandLineUtils.getBaseSvnCommandLine(fileSet.getBasedir(), repository); - cl.createArg().setValue( "status" ); + cl.createArg().setValue("status"); return cl; } diff --git a/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/main/java/org/apache/maven/scm/provider/svn/svnexe/command/status/SvnStatusConsumer.java b/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/main/java/org/apache/maven/scm/provider/svn/svnexe/command/status/SvnStatusConsumer.java index 13ceb3123..9de72ab24 100644 --- a/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/main/java/org/apache/maven/scm/provider/svn/svnexe/command/status/SvnStatusConsumer.java +++ b/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/main/java/org/apache/maven/scm/provider/svn/svnexe/command/status/SvnStatusConsumer.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.svn.svnexe.command.status; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,23 +16,22 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider.svn.svnexe.command.status; + +import java.io.File; +import java.util.ArrayList; +import java.util.List; import org.apache.maven.scm.ScmFile; import org.apache.maven.scm.ScmFileStatus; import org.apache.maven.scm.util.AbstractConsumer; import org.codehaus.plexus.util.StringUtils; -import java.io.File; -import java.util.ArrayList; -import java.util.List; - /** * @author Trygve Laugstøl * */ -public class SvnStatusConsumer - extends AbstractConsumer -{ +public class SvnStatusConsumer extends AbstractConsumer { private final File workingDirectory; private final List changedFiles = new ArrayList<>(); @@ -43,8 +40,7 @@ public class SvnStatusConsumer // // ---------------------------------------------------------------------- - public SvnStatusConsumer( File workingDirectory ) - { + public SvnStatusConsumer(File workingDirectory) { this.workingDirectory = workingDirectory; } @@ -53,31 +49,25 @@ public SvnStatusConsumer( File workingDirectory ) // ---------------------------------------------------------------------- /** {@inheritDoc} */ - public void consumeLine( String line ) - { - if ( logger.isDebugEnabled() ) - { - logger.debug( line ); + public void consumeLine(String line) { + if (logger.isDebugEnabled()) { + logger.debug(line); } - if ( StringUtils.isEmpty( line.trim() ) ) - { + if (StringUtils.isEmpty(line.trim())) { return; } - if ( line.length() <= 7 ) - { - if ( logger.isWarnEnabled() ) - { - logger.warn( "Unexpected input, the line must be at least seven characters long. Line: '" - + line + "'." ); + if (line.length() <= 7) { + if (logger.isWarnEnabled()) { + logger.warn("Unexpected input, the line must be at least seven characters long. Line: '" + line + "'."); } return; } - String statusString = line.substring( 0, 1 ); + String statusString = line.substring(0, 1); - String file = line.substring( 7 ).trim(); + String file = line.substring(7).trim(); ScmFileStatus status; @@ -121,65 +111,44 @@ public void consumeLine( String line ) // The out-of-date information appears in the eighth column (with -u): // '*' a newer revision exists on the server // ' ' the working copy is up to date - if ( statusString.equals( "A" ) ) - { + if (statusString.equals("A")) { status = ScmFileStatus.ADDED; - } - else if ( statusString.equals( "M" ) || statusString.equals( "R" ) || statusString.equals( "~" ) ) - { + } else if (statusString.equals("M") || statusString.equals("R") || statusString.equals("~")) { status = ScmFileStatus.MODIFIED; - } - else if ( statusString.equals( "D" ) ) - { + } else if (statusString.equals("D")) { status = ScmFileStatus.DELETED; - } - else if ( statusString.equals( "?" ) ) - { + } else if (statusString.equals("?")) { status = ScmFileStatus.UNKNOWN; - } - else if ( statusString.equals( "!" ) ) - { + } else if (statusString.equals("!")) { status = ScmFileStatus.MISSING; - } - else if ( statusString.equals( "C" ) ) - { + } else if (statusString.equals("C")) { status = ScmFileStatus.CONFLICT; - } - else if ( statusString.equals( "L" ) ) - { + } else if (statusString.equals("L")) { status = ScmFileStatus.LOCKED; - } - else if ( statusString.equals( "X" ) ) - { - //skip svn:external entries + } else if (statusString.equals("X")) { + // skip svn:external entries return; - } - else if ( statusString.equals( "I" ) ) - { - //skip svn:external entries + } else if (statusString.equals("I")) { + // skip svn:external entries return; - } - else - { - //Parse the second column - statusString = line.substring( 1, 1 ); + } else { + // Parse the second column + statusString = line.substring(1, 1); - //The line isn't a status line, ie something like 'Performing status on external item at...' - //or a status defined in next columns + // The line isn't a status line, ie something like 'Performing status on external item at...' + // or a status defined in next columns return; } // If the file isn't a file; don't add it. - if ( !status.equals( ScmFileStatus.DELETED ) && !new File( workingDirectory, file ).isFile() ) - { + if (!status.equals(ScmFileStatus.DELETED) && !new File(workingDirectory, file).isFile()) { return; } - changedFiles.add( new ScmFile( file, status ) ); + changedFiles.add(new ScmFile(file, status)); } - public List getChangedFiles() - { + public List getChangedFiles() { return changedFiles; } } diff --git a/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/main/java/org/apache/maven/scm/provider/svn/svnexe/command/tag/SvnTagCommand.java b/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/main/java/org/apache/maven/scm/provider/svn/svnexe/command/tag/SvnTagCommand.java index 673918251..b3110eebc 100644 --- a/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/main/java/org/apache/maven/scm/provider/svn/svnexe/command/tag/SvnTagCommand.java +++ b/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/main/java/org/apache/maven/scm/provider/svn/svnexe/command/tag/SvnTagCommand.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.svn.svnexe.command.tag; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider.svn.svnexe.command.tag; import java.io.File; import java.io.IOException; @@ -53,141 +52,114 @@ * * TODO since this is just a copy, use that instead. */ -public class SvnTagCommand - extends AbstractTagCommand - implements SvnCommand -{ - - public ScmResult executeTagCommand( ScmProviderRepository repo, ScmFileSet fileSet, String tag, String message ) - throws ScmException - { - ScmTagParameters scmTagParameters = new ScmTagParameters( message ); +public class SvnTagCommand extends AbstractTagCommand implements SvnCommand { + + public ScmResult executeTagCommand(ScmProviderRepository repo, ScmFileSet fileSet, String tag, String message) + throws ScmException { + ScmTagParameters scmTagParameters = new ScmTagParameters(message); // force false to preserve backward comp - scmTagParameters.setRemoteTagging( false ); - scmTagParameters.setPinExternals( false ); - return executeTagCommand( repo, fileSet, tag, scmTagParameters ); + scmTagParameters.setRemoteTagging(false); + scmTagParameters.setPinExternals(false); + return executeTagCommand(repo, fileSet, tag, scmTagParameters); } /** {@inheritDoc} */ - public ScmResult executeTagCommand( ScmProviderRepository repo, ScmFileSet fileSet, String tag, - ScmTagParameters scmTagParameters ) - throws ScmException - { + public ScmResult executeTagCommand( + ScmProviderRepository repo, ScmFileSet fileSet, String tag, ScmTagParameters scmTagParameters) + throws ScmException { // NPE free - if ( scmTagParameters == null ) - { - logger.debug( "SvnTagCommand :: scmTagParameters is null create an empty one" ); + if (scmTagParameters == null) { + logger.debug("SvnTagCommand :: scmTagParameters is null create an empty one"); scmTagParameters = new ScmTagParameters(); - scmTagParameters.setRemoteTagging( false ); - scmTagParameters.setPinExternals( false ); + scmTagParameters.setRemoteTagging(false); + scmTagParameters.setPinExternals(false); + } else { + logger.debug("SvnTagCommand :: scmTagParameters.remoteTagging : " + scmTagParameters.isRemoteTagging()); } - else - { - logger.debug( - "SvnTagCommand :: scmTagParameters.remoteTagging : " - + scmTagParameters.isRemoteTagging() ); - } - if ( tag == null || StringUtils.isEmpty( tag.trim() ) ) - { - throw new ScmException( "tag must be specified" ); + if (tag == null || StringUtils.isEmpty(tag.trim())) { + throw new ScmException("tag must be specified"); } - if ( !fileSet.getFileList().isEmpty() ) - { - throw new ScmException( "This provider doesn't support tagging subsets of a directory" ); + if (!fileSet.getFileList().isEmpty()) { + throw new ScmException("This provider doesn't support tagging subsets of a directory"); } SvnScmProviderRepository repository = (SvnScmProviderRepository) repo; - File messageFile = FileUtils.createTempFile( "maven-scm-", ".commit", null ); + File messageFile = FileUtils.createTempFile("maven-scm-", ".commit", null); - try - { - FileUtils.fileWrite( messageFile.getAbsolutePath(), "UTF-8", scmTagParameters.getMessage() ); - } - catch ( IOException ex ) - { - return new TagScmResult( null, "Error while making a temporary file for the commit message: " - + ex.getMessage(), null, false ); + try { + FileUtils.fileWrite(messageFile.getAbsolutePath(), "UTF-8", scmTagParameters.getMessage()); + } catch (IOException ex) { + return new TagScmResult( + null, + "Error while making a temporary file for the commit message: " + ex.getMessage(), + null, + false); } - Commandline cl = createCommandLine( repository, fileSet.getBasedir(), tag, messageFile, scmTagParameters ); + Commandline cl = createCommandLine(repository, fileSet.getBasedir(), tag, messageFile, scmTagParameters); CommandLineUtils.StringStreamConsumer stdout = new CommandLineUtils.StringStreamConsumer(); CommandLineUtils.StringStreamConsumer stderr = new CommandLineUtils.StringStreamConsumer(); - if ( logger.isInfoEnabled() ) - { - logger.info( "Executing: " + SvnCommandLineUtils.cryptPassword( cl ) ); + if (logger.isInfoEnabled()) { + logger.info("Executing: " + SvnCommandLineUtils.cryptPassword(cl)); - if ( Os.isFamily( Os.FAMILY_WINDOWS ) ) - { - logger.info( "Working directory: " + cl.getWorkingDirectory().getAbsolutePath() ); + if (Os.isFamily(Os.FAMILY_WINDOWS)) { + logger.info("Working directory: " + cl.getWorkingDirectory().getAbsolutePath()); } } int exitCode; - try - { - exitCode = SvnCommandLineUtils.execute( cl, stdout, stderr ); - } - catch ( CommandLineException ex ) - { - throw new ScmException( "Error while executing command.", ex ); - } - finally - { - try - { - FileUtils.forceDelete( messageFile ); - } - catch ( IOException ex ) - { + try { + exitCode = SvnCommandLineUtils.execute(cl, stdout, stderr); + } catch (CommandLineException ex) { + throw new ScmException("Error while executing command.", ex); + } finally { + try { + FileUtils.forceDelete(messageFile); + } catch (IOException ex) { // ignore } } - if ( exitCode != 0 ) - { + if (exitCode != 0) { // TODO: Improve this error message - return new TagScmResult( cl.toString(), "The svn tag command failed.", stderr.getOutput(), false ); + return new TagScmResult(cl.toString(), "The svn tag command failed.", stderr.getOutput(), false); } List fileList = new ArrayList<>(); List files = null; - try - { - if ( StringUtils.isNotEmpty( fileSet.getExcludes() ) ) - { - files = FileUtils.getFiles( fileSet.getBasedir(), - ( StringUtils.isEmpty( fileSet.getIncludes() ) ? "**" - : fileSet.getIncludes() ), fileSet.getExcludes() - + ",**/.svn/**", false ); + try { + if (StringUtils.isNotEmpty(fileSet.getExcludes())) { + files = FileUtils.getFiles( + fileSet.getBasedir(), + (StringUtils.isEmpty(fileSet.getIncludes()) ? "**" : fileSet.getIncludes()), + fileSet.getExcludes() + ",**/.svn/**", + false); + } else { + files = FileUtils.getFiles( + fileSet.getBasedir(), + (StringUtils.isEmpty(fileSet.getIncludes()) ? "**" : fileSet.getIncludes()), + "**/.svn/**", + false); } - else - { - files = FileUtils.getFiles( fileSet.getBasedir(), - ( StringUtils.isEmpty( fileSet.getIncludes() ) ? "**" - : fileSet.getIncludes() ), "**/.svn/**", false ); - } - } - catch ( IOException e ) - { - throw new ScmException( "Error while executing command.", e ); + } catch (IOException e) { + throw new ScmException("Error while executing command.", e); } - for ( Iterator i = files.iterator(); i.hasNext(); ) - { + for (Iterator i = files.iterator(); i.hasNext(); ) { File f = i.next(); - fileList.add( new ScmFile( f.getPath(), ScmFileStatus.TAGGED ) ); + fileList.add(new ScmFile(f.getPath(), ScmFileStatus.TAGGED)); } - return new TagScmResult( cl.toString(), fileList ); + return new TagScmResult(cl.toString(), fileList); } // ---------------------------------------------------------------------- @@ -202,74 +174,69 @@ public ScmResult executeTagCommand( ScmProviderRepository repo, ScmFileSet fileS * @param messageFile * @return TODO */ - public static Commandline createCommandLine( SvnScmProviderRepository repository, File workingDirectory, String tag, - File messageFile ) - { - Commandline cl = SvnCommandLineUtils.getBaseSvnCommandLine( workingDirectory, repository ); + public static Commandline createCommandLine( + SvnScmProviderRepository repository, File workingDirectory, String tag, File messageFile) { + Commandline cl = SvnCommandLineUtils.getBaseSvnCommandLine(workingDirectory, repository); - cl.createArg().setValue( "copy" ); + cl.createArg().setValue("copy"); - cl.createArg().setValue( "--parents" ); + cl.createArg().setValue("--parents"); - cl.createArg().setValue( "--file" ); + cl.createArg().setValue("--file"); - cl.createArg().setValue( messageFile.getAbsolutePath() ); + cl.createArg().setValue(messageFile.getAbsolutePath()); - cl.createArg().setValue( "." ); + cl.createArg().setValue("."); // Note: this currently assumes you have the tag base checked out too - String tagUrl = SvnTagBranchUtils.resolveTagUrl( repository, new ScmTag( tag ) ); - tagUrl = SvnCommandUtils.fixUrl( tagUrl, repository.getUser() ); - cl.createArg().setValue( tagUrl + "@" ); + String tagUrl = SvnTagBranchUtils.resolveTagUrl(repository, new ScmTag(tag)); + tagUrl = SvnCommandUtils.fixUrl(tagUrl, repository.getUser()); + cl.createArg().setValue(tagUrl + "@"); return cl; } + public static Commandline createCommandLine( + SvnScmProviderRepository repository, + File workingDirectory, + String tag, + File messageFile, + ScmTagParameters scmTagParameters) { + Commandline cl = SvnCommandLineUtils.getBaseSvnCommandLine(workingDirectory, repository); - public static Commandline createCommandLine( SvnScmProviderRepository repository, File workingDirectory, - String tag, File messageFile, ScmTagParameters scmTagParameters ) - { - Commandline cl = SvnCommandLineUtils.getBaseSvnCommandLine( workingDirectory, repository ); + cl.createArg().setValue("copy"); - cl.createArg().setValue( "copy" ); + cl.createArg().setValue("--file"); - cl.createArg().setValue( "--file" ); + cl.createArg().setValue(messageFile.getAbsolutePath()); - cl.createArg().setValue( messageFile.getAbsolutePath() ); + cl.createArg().setValue("--encoding"); - cl.createArg().setValue( "--encoding" ); + cl.createArg().setValue("UTF-8"); - cl.createArg().setValue( "UTF-8" ); + cl.createArg().setValue("--parents"); - cl.createArg().setValue( "--parents" ); - - if ( scmTagParameters != null && scmTagParameters.getScmRevision() != null ) - { - cl.createArg().setValue( "--revision" ); - - cl.createArg().setValue( scmTagParameters.getScmRevision() ); + if (scmTagParameters != null && scmTagParameters.getScmRevision() != null) { + cl.createArg().setValue("--revision"); + cl.createArg().setValue(scmTagParameters.getScmRevision()); } - if ( scmTagParameters != null && scmTagParameters.isPinExternals() ) - { - cl.createArg().setValue( "--pin-externals" ); + if (scmTagParameters != null && scmTagParameters.isPinExternals()) { + cl.createArg().setValue("--pin-externals"); } - if ( scmTagParameters != null && scmTagParameters.isRemoteTagging() ) - { - String url = SvnCommandUtils.fixUrl( repository.getUrl(), repository.getUser() ); - cl.createArg().setValue( url + "@" ); - } - else - { - cl.createArg().setValue( "." ); + if (scmTagParameters != null && scmTagParameters.isRemoteTagging()) { + String url = SvnCommandUtils.fixUrl(repository.getUrl(), repository.getUser()); + cl.createArg().setValue(url + "@"); + } else { + cl.createArg().setValue("."); } // Note: this currently assumes you have the tag base checked out too - String tagUrl = SvnTagBranchUtils.resolveTagUrl( repository, new ScmTag( tag ) ); - tagUrl = SvnCommandUtils.fixUrl( tagUrl, repository.getUser() ); - cl.createArg().setValue( tagUrl + "@" ); + String tagUrl = SvnTagBranchUtils.resolveTagUrl(repository, new ScmTag(tag)); + tagUrl = SvnCommandUtils.fixUrl(tagUrl, repository.getUser()); + cl.createArg().setValue(tagUrl + "@"); return cl; } diff --git a/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/main/java/org/apache/maven/scm/provider/svn/svnexe/command/untag/SvnUntagCommand.java b/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/main/java/org/apache/maven/scm/provider/svn/svnexe/command/untag/SvnUntagCommand.java index 927756794..a830ae7b3 100644 --- a/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/main/java/org/apache/maven/scm/provider/svn/svnexe/command/untag/SvnUntagCommand.java +++ b/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/main/java/org/apache/maven/scm/provider/svn/svnexe/command/untag/SvnUntagCommand.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.svn.svnexe.command.untag; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,9 +16,11 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider.svn.svnexe.command.untag; import java.io.File; import java.io.IOException; + import org.apache.maven.scm.ScmException; import org.apache.maven.scm.ScmFileSet; import org.apache.maven.scm.ScmResult; @@ -45,83 +45,66 @@ * * @since 1.11.2 */ -public class SvnUntagCommand extends AbstractUntagCommand implements SvnCommand -{ +public class SvnUntagCommand extends AbstractUntagCommand implements SvnCommand { /** {@inheritDoc} */ @Override - public ScmResult executeUntagCommand( ScmProviderRepository repo, ScmFileSet fileSet, - ScmUntagParameters scmUntagParameters ) throws ScmException - { + public ScmResult executeUntagCommand( + ScmProviderRepository repo, ScmFileSet fileSet, ScmUntagParameters scmUntagParameters) throws ScmException { String tag = scmUntagParameters.getTag(); - if ( tag == null || tag.trim().isEmpty() ) - { - throw new ScmException( "tag must be specified" ); + if (tag == null || tag.trim().isEmpty()) { + throw new ScmException("tag must be specified"); } SvnScmProviderRepository repository = (SvnScmProviderRepository) repo; - File messageFile = FileUtils.createTempFile( "maven-scm-", ".commit", null ); + File messageFile = FileUtils.createTempFile("maven-scm-", ".commit", null); String message = scmUntagParameters.getMessage(); - try - { - FileUtils.fileWrite( messageFile.getAbsolutePath(), "UTF-8", message ); - } - catch ( IOException ex ) - { - return new UntagScmResult( null, "Error while making a temporary file for the commit message: " - + ex.getMessage(), null, false ); + try { + FileUtils.fileWrite(messageFile.getAbsolutePath(), "UTF-8", message); + } catch (IOException ex) { + return new UntagScmResult( + null, + "Error while making a temporary file for the commit message: " + ex.getMessage(), + null, + false); } - Commandline cl = createCommandline( repository, fileSet, tag, messageFile ); + Commandline cl = createCommandline(repository, fileSet, tag, messageFile); CommandLineUtils.StringStreamConsumer stdout = new CommandLineUtils.StringStreamConsumer(); CommandLineUtils.StringStreamConsumer stderr = new CommandLineUtils.StringStreamConsumer(); - if ( logger.isInfoEnabled() ) - { - logger.info( "Executing: " + SvnCommandLineUtils.cryptPassword( cl ) ); + if (logger.isInfoEnabled()) { + logger.info("Executing: " + SvnCommandLineUtils.cryptPassword(cl)); - if ( Os.isFamily( Os.FAMILY_WINDOWS ) ) - { - logger.info( "Working directory: " + cl.getWorkingDirectory().getAbsolutePath() ); + if (Os.isFamily(Os.FAMILY_WINDOWS)) { + logger.info("Working directory: " + cl.getWorkingDirectory().getAbsolutePath()); } } int exitCode; - try - { - exitCode = SvnCommandLineUtils.execute( cl, stdout, stderr ); - } - catch ( CommandLineException ex ) - { - throw new ScmException( "Error while executing svn remove command.", ex ); - } - finally - { - try - { - FileUtils.forceDelete( messageFile ); - } - catch ( IOException ex ) - { + try { + exitCode = SvnCommandLineUtils.execute(cl, stdout, stderr); + } catch (CommandLineException ex) { + throw new ScmException("Error while executing svn remove command.", ex); + } finally { + try { + FileUtils.forceDelete(messageFile); + } catch (IOException ex) { // ignore } } - if ( exitCode == 0 ) - { - return new UntagScmResult( cl.toString(), "The svn remove command was successful.", - stderr.getOutput(), true ); - } - else - { - return new UntagScmResult( cl.toString(), "The svn remove command failed.", stderr.getOutput(), false ); + if (exitCode == 0) { + return new UntagScmResult( + cl.toString(), "The svn remove command was successful.", stderr.getOutput(), true); + } else { + return new UntagScmResult(cl.toString(), "The svn remove command failed.", stderr.getOutput(), false); } - } /** @@ -133,21 +116,19 @@ public ScmResult executeUntagCommand( ScmProviderRepository repo, ScmFileSet fil * @param messageFile file containing commit message * @return command line instance */ - Commandline createCommandline( SvnScmProviderRepository repo, ScmFileSet fileSet, String tag, File messageFile ) - { - Commandline cl = SvnCommandLineUtils.getBaseSvnCommandLine( fileSet.getBasedir(), repo ); + Commandline createCommandline(SvnScmProviderRepository repo, ScmFileSet fileSet, String tag, File messageFile) { + Commandline cl = SvnCommandLineUtils.getBaseSvnCommandLine(fileSet.getBasedir(), repo); - cl.createArg().setValue( "--file" ); + cl.createArg().setValue("--file"); - cl.createArg().setValue( messageFile.getAbsolutePath() ); + cl.createArg().setValue(messageFile.getAbsolutePath()); - cl.createArg().setValue( "remove" ); + cl.createArg().setValue("remove"); - String tagUrl = SvnTagBranchUtils.resolveTagUrl( repo, new ScmTag( tag ) ); - tagUrl = SvnCommandUtils.fixUrl( tagUrl, repo.getUser() ); - cl.createArg().setValue( tagUrl + "@" ); + String tagUrl = SvnTagBranchUtils.resolveTagUrl(repo, new ScmTag(tag)); + tagUrl = SvnCommandUtils.fixUrl(tagUrl, repo.getUser()); + cl.createArg().setValue(tagUrl + "@"); return cl; } - } diff --git a/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/main/java/org/apache/maven/scm/provider/svn/svnexe/command/update/SvnUpdateCommand.java b/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/main/java/org/apache/maven/scm/provider/svn/svnexe/command/update/SvnUpdateCommand.java index 7c4dd3457..ef3738122 100644 --- a/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/main/java/org/apache/maven/scm/provider/svn/svnexe/command/update/SvnUpdateCommand.java +++ b/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/main/java/org/apache/maven/scm/provider/svn/svnexe/command/update/SvnUpdateCommand.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.svn.svnexe.command.update; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider.svn.svnexe.command.update; import java.io.File; @@ -48,54 +47,43 @@ * @author Emmanuel Venisse * */ -public class SvnUpdateCommand - extends AbstractUpdateCommand - implements SvnCommand -{ +public class SvnUpdateCommand extends AbstractUpdateCommand implements SvnCommand { /** {@inheritDoc} */ - protected UpdateScmResult executeUpdateCommand( ScmProviderRepository repo, ScmFileSet fileSet, ScmVersion version ) - throws ScmException - { - Commandline cl = createCommandLine( (SvnScmProviderRepository) repo, fileSet.getBasedir(), version ); + protected UpdateScmResult executeUpdateCommand(ScmProviderRepository repo, ScmFileSet fileSet, ScmVersion version) + throws ScmException { + Commandline cl = createCommandLine((SvnScmProviderRepository) repo, fileSet.getBasedir(), version); - SvnUpdateConsumer consumer = new SvnUpdateConsumer( fileSet.getBasedir() ); + SvnUpdateConsumer consumer = new SvnUpdateConsumer(fileSet.getBasedir()); CommandLineUtils.StringStreamConsumer stderr = new CommandLineUtils.StringStreamConsumer(); - if ( logger.isInfoEnabled() ) - { - logger.info( "Executing: " + SvnCommandLineUtils.cryptPassword( cl ) ); + if (logger.isInfoEnabled()) { + logger.info("Executing: " + SvnCommandLineUtils.cryptPassword(cl)); - if ( Os.isFamily( Os.FAMILY_WINDOWS ) ) - { - logger.info( "Working directory: " + cl.getWorkingDirectory().getAbsolutePath() ); + if (Os.isFamily(Os.FAMILY_WINDOWS)) { + logger.info("Working directory: " + cl.getWorkingDirectory().getAbsolutePath()); } } int exitCode; - try - { - exitCode = SvnCommandLineUtils.execute( cl, consumer, stderr ); - } - catch ( CommandLineException ex ) - { - throw new ScmException( "Error while executing command.", ex ); + try { + exitCode = SvnCommandLineUtils.execute(cl, consumer, stderr); + } catch (CommandLineException ex) { + throw new ScmException("Error while executing command.", ex); } - if ( exitCode != 0 ) - { - return new UpdateScmResult( cl.toString(), "The svn command failed.", stderr.getOutput(), false ); + if (exitCode != 0) { + return new UpdateScmResult(cl.toString(), "The svn command failed.", stderr.getOutput(), false); } - UpdateScmResultWithRevision result = new UpdateScmResultWithRevision( cl.toString(), consumer.getUpdatedFiles(), - String.valueOf( consumer.getRevision() ) ); + UpdateScmResultWithRevision result = new UpdateScmResultWithRevision( + cl.toString(), consumer.getUpdatedFiles(), String.valueOf(consumer.getRevision())); - result.setChanges( consumer.getChangeSets() ); + result.setChanges(consumer.getChangeSets()); - if ( logger.isDebugEnabled() ) - { - logger.debug( "changeSets " + consumer.getChangeSets() ); + if (logger.isDebugEnabled()) { + logger.debug("changeSets " + consumer.getChangeSets()); } return result; @@ -105,57 +93,46 @@ protected UpdateScmResult executeUpdateCommand( ScmProviderRepository repo, ScmF // // ---------------------------------------------------------------------- - public static Commandline createCommandLine( SvnScmProviderRepository repository, File workingDirectory, - ScmVersion version ) - { + public static Commandline createCommandLine( + SvnScmProviderRepository repository, File workingDirectory, ScmVersion version) { Settings settings = SvnUtil.getSettings(); String workingDir = workingDirectory.getAbsolutePath(); - if ( settings.isUseCygwinPath() ) - { + if (settings.isUseCygwinPath()) { workingDir = settings.getCygwinMountPath() + "/" + workingDir; - workingDir = StringUtils.replace( workingDir, ":", "" ); - workingDir = StringUtils.replace( workingDir, "\\", "/" ); + workingDir = StringUtils.replace(workingDir, ":", ""); + workingDir = StringUtils.replace(workingDir, "\\", "/"); } - if ( version != null && StringUtils.isEmpty( version.getName() ) ) - { + if (version != null && StringUtils.isEmpty(version.getName())) { version = null; } - Commandline cl = SvnCommandLineUtils.getBaseSvnCommandLine( workingDirectory, repository ); + Commandline cl = SvnCommandLineUtils.getBaseSvnCommandLine(workingDirectory, repository); - if ( version == null || SvnTagBranchUtils.isRevisionSpecifier( version ) ) - { - cl.createArg().setValue( "update" ); + if (version == null || SvnTagBranchUtils.isRevisionSpecifier(version)) { + cl.createArg().setValue("update"); - if ( version != null && StringUtils.isNotEmpty( version.getName() ) ) - { - cl.createArg().setValue( "-r" ); - cl.createArg().setValue( version.getName() ); + if (version != null && StringUtils.isNotEmpty(version.getName())) { + cl.createArg().setValue("-r"); + cl.createArg().setValue(version.getName()); } - cl.createArg().setValue( workingDir + "@" ); - } - else - { - if ( version instanceof ScmBranch ) - { + cl.createArg().setValue(workingDir + "@"); + } else { + if (version instanceof ScmBranch) { // The tag specified does not appear to be numeric, so assume it refers // to a branch/tag url and perform a switch operation rather than update - cl.createArg().setValue( "switch" ); - if ( version instanceof ScmTag ) - { - String tagUrl = SvnTagBranchUtils.resolveTagUrl( repository, (ScmTag) version ); - cl.createArg().setValue( tagUrl + "@" ); - } - else - { - String branchUrl = SvnTagBranchUtils.resolveBranchUrl( repository, (ScmBranch) version ); - cl.createArg().setValue( branchUrl + "@" ); + cl.createArg().setValue("switch"); + if (version instanceof ScmTag) { + String tagUrl = SvnTagBranchUtils.resolveTagUrl(repository, (ScmTag) version); + cl.createArg().setValue(tagUrl + "@"); + } else { + String branchUrl = SvnTagBranchUtils.resolveBranchUrl(repository, (ScmBranch) version); + cl.createArg().setValue(branchUrl + "@"); } - cl.createArg().setValue( workingDir + "@" ); + cl.createArg().setValue(workingDir + "@"); } } @@ -163,10 +140,7 @@ public static Commandline createCommandLine( SvnScmProviderRepository repository } /** {@inheritDoc} */ - protected ChangeLogCommand getChangeLogCommand() - { + protected ChangeLogCommand getChangeLogCommand() { return new SvnChangeLogCommand(); } - - } diff --git a/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/main/java/org/apache/maven/scm/provider/svn/svnexe/command/update/SvnUpdateConsumer.java b/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/main/java/org/apache/maven/scm/provider/svn/svnexe/command/update/SvnUpdateConsumer.java index efadc9b05..c7bac86da 100644 --- a/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/main/java/org/apache/maven/scm/provider/svn/svnexe/command/update/SvnUpdateConsumer.java +++ b/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/main/java/org/apache/maven/scm/provider/svn/svnexe/command/update/SvnUpdateConsumer.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.svn.svnexe.command.update; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider.svn.svnexe.command.update; import java.io.File; import java.util.ArrayList; @@ -34,9 +33,7 @@ * @author Trygve Laugstøl * */ -public class SvnUpdateConsumer - extends AbstractFileCheckingConsumer -{ +public class SvnUpdateConsumer extends AbstractFileCheckingConsumer { private static final String UPDATED_TO_REVISION_TOKEN = "Updated to revision"; private static final String AT_REVISION_TOKEN = "At revision"; @@ -44,16 +41,15 @@ public class SvnUpdateConsumer private static final String EXPORTED_REVISION_TOKEN = "Exported revision"; private static final String RESTORED_TOKEN = "Restored"; - + private List changeSets = new ArrayList<>(); // ---------------------------------------------------------------------- // // ---------------------------------------------------------------------- - public SvnUpdateConsumer( File workingDirectory ) - { - super( workingDirectory ); + public SvnUpdateConsumer(File workingDirectory) { + super(workingDirectory); } // ---------------------------------------------------------------------- @@ -61,97 +57,73 @@ public SvnUpdateConsumer( File workingDirectory ) // ---------------------------------------------------------------------- /** {@inheritDoc} */ - protected void parseLine( String line ) - { + protected void parseLine(String line) { line = line.trim(); - String statusString = line.substring( 0, 1 ); + String statusString = line.substring(0, 1); - String file = line.substring( 3 ).trim(); - //[SCM-368] - if ( file.startsWith( workingDirectory.getAbsolutePath() ) ) - { - if ( file.length() == workingDirectory.getAbsolutePath().length() ) - { + String file = line.substring(3).trim(); + // [SCM-368] + if (file.startsWith(workingDirectory.getAbsolutePath())) { + if (file.length() == workingDirectory.getAbsolutePath().length()) { file = "."; - } - else - { - file = file.substring( this.workingDirectory.getAbsolutePath().length() + 1 ); + } else { + file = file.substring(this.workingDirectory.getAbsolutePath().length() + 1); } } ScmFileStatus status; - if ( line.startsWith( UPDATED_TO_REVISION_TOKEN ) ) - { - String revisionString = line.substring( UPDATED_TO_REVISION_TOKEN.length() + 1, line.length() - 1 ); + if (line.startsWith(UPDATED_TO_REVISION_TOKEN)) { + String revisionString = line.substring(UPDATED_TO_REVISION_TOKEN.length() + 1, line.length() - 1); - revision = parseInt( revisionString ); + revision = parseInt(revisionString); return; - } - else if ( line.startsWith( AT_REVISION_TOKEN ) ) - { - String revisionString = line.substring( AT_REVISION_TOKEN.length() + 1, line.length() - 1 ); + } else if (line.startsWith(AT_REVISION_TOKEN)) { + String revisionString = line.substring(AT_REVISION_TOKEN.length() + 1, line.length() - 1); - revision = parseInt( revisionString ); + revision = parseInt(revisionString); return; - } - else if ( line.startsWith( EXPORTED_REVISION_TOKEN ) ) - { - String revisionString = line.substring( EXPORTED_REVISION_TOKEN.length() + 1, line.length() - 1 ); + } else if (line.startsWith(EXPORTED_REVISION_TOKEN)) { + String revisionString = line.substring(EXPORTED_REVISION_TOKEN.length() + 1, line.length() - 1); - revision = parseInt( revisionString ); + revision = parseInt(revisionString); return; - } - else if ( line.startsWith( RESTORED_TOKEN ) ) - { + } else if (line.startsWith(RESTORED_TOKEN)) { return; - } - else if ( statusString.equals( "A" ) ) - { + } else if (statusString.equals("A")) { status = ScmFileStatus.ADDED; - } - else if ( statusString.equals( "U" ) || statusString.equals( "M" ) ) - { + } else if (statusString.equals("U") || statusString.equals("M")) { status = ScmFileStatus.UPDATED; - } - else if ( statusString.equals( "D" ) ) - { + } else if (statusString.equals("D")) { status = ScmFileStatus.DELETED; - } - else - { - //Do nothing + } else { + // Do nothing return; } - addFile( new ScmFile( file, status ) ); - - List - changeFiles = - Arrays.asList( new ChangeFile[] { new ChangeFile( line, Integer.valueOf( revision ).toString() ) } ); + addFile(new ScmFile(file, status)); + + List changeFiles = Arrays.asList( + new ChangeFile[] {new ChangeFile(line, Integer.valueOf(revision).toString())}); - ChangeSet changeSet = new ChangeSet( null, null, null, changeFiles ); - changeSets.add( changeSet ); + ChangeSet changeSet = new ChangeSet(null, null, null, changeFiles); + changeSets.add(changeSet); } - public List getUpdatedFiles() - { + public List getUpdatedFiles() { return getFiles(); } - public List getChangeSets() - { + public List getChangeSets() { return changeSets; } - public void setChangeSets( List changeSets ) - { + public void setChangeSets(List changeSets) { this.changeSets = changeSets; } } diff --git a/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/test/java/org/apache/maven/scm/provider/svn/svnexe/SvnExeScmProviderTest.java b/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/test/java/org/apache/maven/scm/provider/svn/svnexe/SvnExeScmProviderTest.java index f01d76114..e2b16172d 100644 --- a/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/test/java/org/apache/maven/scm/provider/svn/svnexe/SvnExeScmProviderTest.java +++ b/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/test/java/org/apache/maven/scm/provider/svn/svnexe/SvnExeScmProviderTest.java @@ -1,20 +1,3 @@ -package org.apache.maven.scm.provider.svn.svnexe; - -import static org.junit.Assert.assertFalse; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - -import java.io.File; - -import org.apache.maven.scm.ScmException; -import org.codehaus.plexus.util.Os; -import org.junit.Assume; -import org.junit.Before; -import org.junit.Ignore; -import org.junit.Test; -import org.slf4j.Logger; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -24,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -33,48 +16,56 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider.svn.svnexe; -public class SvnExeScmProviderTest -{ +import java.io.File; + +import org.apache.maven.scm.ScmException; +import org.codehaus.plexus.util.Os; +import org.junit.Assume; +import org.junit.Before; +import org.junit.Ignore; +import org.junit.Test; +import org.slf4j.Logger; + +import static org.junit.Assert.assertFalse; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; + +public class SvnExeScmProviderTest { private SvnExeScmProvider scmProvider; - + @Before - public void onSetup() - { + public void onSetup() { scmProvider = new SvnExeScmProvider(); } - + // SCM-435 @Test - @Ignore( "This test is for now ignore: it mock Logger and then asserts against it" ) - public void testGetRepositoryURL_Windows() - throws Exception - { - Assume.assumeTrue( Os.isFamily( Os.FAMILY_WINDOWS ) ); - + @Ignore("This test is for now ignore: it mock Logger and then asserts against it") + public void testGetRepositoryURL_Windows() throws Exception { + Assume.assumeTrue(Os.isFamily(Os.FAMILY_WINDOWS)); + // prepare - Logger logger = mock( Logger.class ); - when( logger.isInfoEnabled() ).thenReturn( Boolean.TRUE ); + Logger logger = mock(Logger.class); + when(logger.isInfoEnabled()).thenReturn(Boolean.TRUE); // scmProvider.addListener( logger ); - File workingDirectory = new File( "." ); - + File workingDirectory = new File("."); + // test - // Since SCM-project has moved from svn to GIT, we can't verify the URL of this project + // Since SCM-project has moved from svn to GIT, we can't verify the URL of this project String url; - try - { - url = scmProvider.getRepositoryURL( workingDirectory ); - + try { + url = scmProvider.getRepositoryURL(workingDirectory); + // verify - assertFalse( url.startsWith( "file://" ) ); - } - catch ( ScmException e ) - { + assertFalse(url.startsWith("file://")); + } catch (ScmException e) { } - + // verify - verify( logger ).info( "Executing: cmd.exe /X /C \"svn --non-interactive info .\"" ); - verify( logger ).info( "Working directory: " + workingDirectory.getCanonicalPath() ); + verify(logger).info("Executing: cmd.exe /X /C \"svn --non-interactive info .\""); + verify(logger).info("Working directory: " + workingDirectory.getCanonicalPath()); } } - diff --git a/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/test/java/org/apache/maven/scm/provider/svn/svnexe/command/SvnCommandLineUtilsTest.java b/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/test/java/org/apache/maven/scm/provider/svn/svnexe/command/SvnCommandLineUtilsTest.java index 873aabd57..1d0272597 100644 --- a/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/test/java/org/apache/maven/scm/provider/svn/svnexe/command/SvnCommandLineUtilsTest.java +++ b/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/test/java/org/apache/maven/scm/provider/svn/svnexe/command/SvnCommandLineUtilsTest.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.svn.svnexe.command; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,9 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider.svn.svnexe.command; + +import java.io.File; import org.apache.maven.scm.ScmTestCase; import org.apache.maven.scm.provider.svn.repository.SvnScmProviderRepository; @@ -28,101 +29,103 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotEquals; -import java.io.File; - /** * @author Emmanuel Venisse * */ -public class SvnCommandLineUtilsTest - extends ScmTestCase -{ +public class SvnCommandLineUtilsTest extends ScmTestCase { @Test - public void testCryptPassword() - throws Exception - { + public void testCryptPassword() throws Exception { /* FIXME Plexus does not quote the crypted password on Windows which is actually incorrect at the moment * it would cause wildcard expansion with cmd: https://github.com/codehaus-plexus/plexus-utils/issues/37. */ - SvnScmProviderRepository repo = - new SvnScmProviderRepository( "https://svn.apache.org/repos/asf/maven/scm/trunk", "username", "password" ); + SvnScmProviderRepository repo = new SvnScmProviderRepository( + "https://svn.apache.org/repos/asf/maven/scm/trunk", "username", "password"); String clString = - SvnCommandLineUtils.cryptPassword( SvnCommandLineUtils.getBaseSvnCommandLine( new File( "." ), repo ) ); - Commandline expectedCmd = new Commandline( "svn --username username --password ***** --no-auth-cache --non-interactive" ); - expectedCmd.setWorkingDirectory( new File( "." ).getAbsolutePath() ); - assertEquals( expectedCmd.toString(), clString ); + SvnCommandLineUtils.cryptPassword(SvnCommandLineUtils.getBaseSvnCommandLine(new File("."), repo)); + Commandline expectedCmd = + new Commandline("svn --username username --password ***** --no-auth-cache --non-interactive"); + expectedCmd.setWorkingDirectory(new File(".").getAbsolutePath()); + assertEquals(expectedCmd.toString(), clString); - repo = new SvnScmProviderRepository( "https://svn.apache.org/repos/asf/maven/scm/trunk", "username", null ); - clString = - SvnCommandLineUtils.cryptPassword( SvnCommandLineUtils.getBaseSvnCommandLine( new File( "." ), repo ) ); - assertCommandLine( "svn --username username --no-auth-cache --non-interactive", new File( "." ), - SvnCommandLineUtils.getBaseSvnCommandLine( new File( "." ), repo ) ); + repo = new SvnScmProviderRepository("https://svn.apache.org/repos/asf/maven/scm/trunk", "username", null); + clString = SvnCommandLineUtils.cryptPassword(SvnCommandLineUtils.getBaseSvnCommandLine(new File("."), repo)); + assertCommandLine( + "svn --username username --no-auth-cache --non-interactive", + new File("."), + SvnCommandLineUtils.getBaseSvnCommandLine(new File("."), repo)); - repo = new SvnScmProviderRepository( "https://svn.apache.org/repos/asf/maven/scm/trunk", "username", "password with spaces" ); - clString = - SvnCommandLineUtils.cryptPassword( SvnCommandLineUtils.getBaseSvnCommandLine( new File( "." ), repo ) ); - expectedCmd = new Commandline( "svn --username username --password ***** --no-auth-cache --non-interactive" ); - expectedCmd.setWorkingDirectory( new File( "." ).getAbsolutePath() ); - assertEquals( expectedCmd.toString(), clString ); + repo = new SvnScmProviderRepository( + "https://svn.apache.org/repos/asf/maven/scm/trunk", "username", "password with spaces"); + clString = SvnCommandLineUtils.cryptPassword(SvnCommandLineUtils.getBaseSvnCommandLine(new File("."), repo)); + expectedCmd = new Commandline("svn --username username --password ***** --no-auth-cache --non-interactive"); + expectedCmd.setWorkingDirectory(new File(".").getAbsolutePath()); + assertEquals(expectedCmd.toString(), clString); - repo = new SvnScmProviderRepository( "https://svn.apache.org/repos/asf/maven/scm/trunk", "username", "password'with'single'quotes" ); - clString = - SvnCommandLineUtils.cryptPassword( SvnCommandLineUtils.getBaseSvnCommandLine( new File( "." ), repo ) ); - expectedCmd = new Commandline( "svn --username username --password ***** --no-auth-cache --non-interactive" ); - expectedCmd.setWorkingDirectory( new File( "." ).getAbsolutePath() ); - assertEquals( expectedCmd.toString(), clString ); + repo = new SvnScmProviderRepository( + "https://svn.apache.org/repos/asf/maven/scm/trunk", "username", "password'with'single'quotes"); + clString = SvnCommandLineUtils.cryptPassword(SvnCommandLineUtils.getBaseSvnCommandLine(new File("."), repo)); + expectedCmd = new Commandline("svn --username username --password ***** --no-auth-cache --non-interactive"); + expectedCmd.setWorkingDirectory(new File(".").getAbsolutePath()); + assertEquals(expectedCmd.toString(), clString); - repo = new SvnScmProviderRepository( "https://svn.apache.org/repos/asf/maven/scm/trunk", "username", "password'with'single'quotes and spaces" ); - clString = - SvnCommandLineUtils.cryptPassword( SvnCommandLineUtils.getBaseSvnCommandLine( new File( "." ), repo ) ); - expectedCmd = new Commandline( "svn --username username --password ***** --no-auth-cache --non-interactive" ); - expectedCmd.setWorkingDirectory( new File( "." ).getAbsolutePath() ); - assertEquals( expectedCmd.toString(), clString ); + repo = new SvnScmProviderRepository( + "https://svn.apache.org/repos/asf/maven/scm/trunk", + "username", + "password'with'single'quotes and spaces"); + clString = SvnCommandLineUtils.cryptPassword(SvnCommandLineUtils.getBaseSvnCommandLine(new File("."), repo)); + expectedCmd = new Commandline("svn --username username --password ***** --no-auth-cache --non-interactive"); + expectedCmd.setWorkingDirectory(new File(".").getAbsolutePath()); + assertEquals(expectedCmd.toString(), clString); - repo = new SvnScmProviderRepository( "https://svn.apache.org/repos/asf/maven/scm/trunk", "username", "password\"with\"double\"quotes" ); - clString = - SvnCommandLineUtils.cryptPassword( SvnCommandLineUtils.getBaseSvnCommandLine( new File( "." ), repo ) ); - expectedCmd = new Commandline( "svn --username username --password ***** --no-auth-cache --non-interactive" ); - expectedCmd.setWorkingDirectory( new File( "." ).getAbsolutePath() ); - assertEquals( expectedCmd.toString(), clString ); + repo = new SvnScmProviderRepository( + "https://svn.apache.org/repos/asf/maven/scm/trunk", "username", "password\"with\"double\"quotes"); + clString = SvnCommandLineUtils.cryptPassword(SvnCommandLineUtils.getBaseSvnCommandLine(new File("."), repo)); + expectedCmd = new Commandline("svn --username username --password ***** --no-auth-cache --non-interactive"); + expectedCmd.setWorkingDirectory(new File(".").getAbsolutePath()); + assertEquals(expectedCmd.toString(), clString); - repo = new SvnScmProviderRepository( "https://svn.apache.org/repos/asf/maven/scm/trunk", "username", "password\"with\"double\"quotes and spaces" ); - clString = - SvnCommandLineUtils.cryptPassword( SvnCommandLineUtils.getBaseSvnCommandLine( new File( "." ), repo ) ); - expectedCmd = new Commandline( "svn --username username --password ***** --no-auth-cache --non-interactive" ); - expectedCmd.setWorkingDirectory( new File( "." ).getAbsolutePath() ); + repo = new SvnScmProviderRepository( + "https://svn.apache.org/repos/asf/maven/scm/trunk", + "username", + "password\"with\"double\"quotes and spaces"); + clString = SvnCommandLineUtils.cryptPassword(SvnCommandLineUtils.getBaseSvnCommandLine(new File("."), repo)); + expectedCmd = new Commandline("svn --username username --password ***** --no-auth-cache --non-interactive"); + expectedCmd.setWorkingDirectory(new File(".").getAbsolutePath()); // FIXME https://github.com/codehaus-plexus/plexus-utils/issues/36 - if ( Os.isFamily( Os.FAMILY_WINDOWS ) ) - { - assertNotEquals( expectedCmd.toString(), clString ); - } - else { - assertEquals( expectedCmd.toString(), clString ); + if (Os.isFamily(Os.FAMILY_WINDOWS)) { + assertNotEquals(expectedCmd.toString(), clString); + } else { + assertEquals(expectedCmd.toString(), clString); } - repo = new SvnScmProviderRepository( "https://svn.apache.org/repos/asf/maven/scm/trunk", "username", "password\"with\"double\"quotes'and'single'quotes" ); - clString = - SvnCommandLineUtils.cryptPassword( SvnCommandLineUtils.getBaseSvnCommandLine( new File( "." ), repo ) ); - expectedCmd = new Commandline( "svn --username username --password ***** --no-auth-cache --non-interactive" ); - expectedCmd.setWorkingDirectory( new File( "." ).getAbsolutePath() ); - assertEquals( expectedCmd.toString(), clString ); + repo = new SvnScmProviderRepository( + "https://svn.apache.org/repos/asf/maven/scm/trunk", + "username", + "password\"with\"double\"quotes'and'single'quotes"); + clString = SvnCommandLineUtils.cryptPassword(SvnCommandLineUtils.getBaseSvnCommandLine(new File("."), repo)); + expectedCmd = new Commandline("svn --username username --password ***** --no-auth-cache --non-interactive"); + expectedCmd.setWorkingDirectory(new File(".").getAbsolutePath()); + assertEquals(expectedCmd.toString(), clString); - repo = new SvnScmProviderRepository( "https://svn.apache.org/repos/asf/maven/scm/trunk", "username", "password\"with\"double\"quotes'and'single'quotes and spaces" ); - clString = - SvnCommandLineUtils.cryptPassword( SvnCommandLineUtils.getBaseSvnCommandLine( new File( "." ), repo ) ); - expectedCmd = new Commandline( "svn --username username --password ***** --no-auth-cache --non-interactive" ); - expectedCmd.setWorkingDirectory( new File( "." ).getAbsolutePath() ); + repo = new SvnScmProviderRepository( + "https://svn.apache.org/repos/asf/maven/scm/trunk", + "username", + "password\"with\"double\"quotes'and'single'quotes and spaces"); + clString = SvnCommandLineUtils.cryptPassword(SvnCommandLineUtils.getBaseSvnCommandLine(new File("."), repo)); + expectedCmd = new Commandline("svn --username username --password ***** --no-auth-cache --non-interactive"); + expectedCmd.setWorkingDirectory(new File(".").getAbsolutePath()); // FIXME https://github.com/codehaus-plexus/plexus-utils/issues/36 - if ( Os.isFamily( Os.FAMILY_WINDOWS ) ) - { - assertNotEquals( expectedCmd.toString(), clString ); - } - else { - assertEquals( expectedCmd.toString(), clString ); + if (Os.isFamily(Os.FAMILY_WINDOWS)) { + assertNotEquals(expectedCmd.toString(), clString); + } else { + assertEquals(expectedCmd.toString(), clString); } - repo = new SvnScmProviderRepository( "https://svn.apache.org/repos/asf/maven/scm/trunk", "username", null ); - assertCommandLine( "svn --username username --no-auth-cache --non-interactive", new File( "." ), - SvnCommandLineUtils.getBaseSvnCommandLine( new File( "." ), repo ) ); + repo = new SvnScmProviderRepository("https://svn.apache.org/repos/asf/maven/scm/trunk", "username", null); + assertCommandLine( + "svn --username username --no-auth-cache --non-interactive", + new File("."), + SvnCommandLineUtils.getBaseSvnCommandLine(new File("."), repo)); } } diff --git a/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/test/java/org/apache/maven/scm/provider/svn/svnexe/command/blame/SvnExeBlameCommandTckTest.java b/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/test/java/org/apache/maven/scm/provider/svn/svnexe/command/blame/SvnExeBlameCommandTckTest.java index 3c1cd09f5..de13e0370 100644 --- a/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/test/java/org/apache/maven/scm/provider/svn/svnexe/command/blame/SvnExeBlameCommandTckTest.java +++ b/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/test/java/org/apache/maven/scm/provider/svn/svnexe/command/blame/SvnExeBlameCommandTckTest.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.svn.svnexe.command.blame; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider.svn.svnexe.command.blame; import org.apache.maven.scm.provider.svn.command.blame.SvnBlameCommandTckTest; import org.junit.Test; @@ -27,18 +26,13 @@ /** * @author Evgeny Mandrikov */ -public class SvnExeBlameCommandTckTest - extends SvnBlameCommandTckTest -{ - public String getScmProviderCommand() - { +public class SvnExeBlameCommandTckTest extends SvnBlameCommandTckTest { + public String getScmProviderCommand() { return SVN_COMMAND_LINE; } @Test - public void testBlameCommand() - throws Exception - { + public void testBlameCommand() throws Exception { super.testBlameCommand(); } } diff --git a/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/test/java/org/apache/maven/scm/provider/svn/svnexe/command/branch/SvnExeBranchCommandTckTest.java b/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/test/java/org/apache/maven/scm/provider/svn/svnexe/command/branch/SvnExeBranchCommandTckTest.java index f716d812b..d661def2c 100644 --- a/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/test/java/org/apache/maven/scm/provider/svn/svnexe/command/branch/SvnExeBranchCommandTckTest.java +++ b/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/test/java/org/apache/maven/scm/provider/svn/svnexe/command/branch/SvnExeBranchCommandTckTest.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.svn.svnexe.command.branch; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,9 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider.svn.svnexe.command.branch; + +import java.io.File; import org.apache.maven.scm.ScmBranchParameters; import org.apache.maven.scm.provider.svn.command.branch.SvnBranchCommandTckTest; @@ -26,8 +27,6 @@ import org.codehaus.plexus.util.cli.Commandline; import org.junit.Test; -import java.io.File; - import static org.apache.maven.scm.provider.svn.SvnScmTestUtils.SVN_COMMAND_LINE; /** @@ -36,136 +35,153 @@ * @author Emmanuel Venisse * */ -public class SvnExeBranchCommandTckTest - extends SvnBranchCommandTckTest -{ - public String getScmProviderCommand() - { +public class SvnExeBranchCommandTckTest extends SvnBranchCommandTckTest { + public String getScmProviderCommand() { return SVN_COMMAND_LINE; } - //--no-auth-cache + // --no-auth-cache @Test - public void testBranchUserNameSvnHttpsRemoteBranchingWithRev() - throws Exception - { - File messageFile = File.createTempFile( "maven-scm", "commit" ); + public void testBranchUserNameSvnHttpsRemoteBranchingWithRev() throws Exception { + File messageFile = File.createTempFile("maven-scm", "commit"); messageFile.deleteOnExit(); ScmBranchParameters scmBranchParameters = new ScmBranchParameters(); - scmBranchParameters.setRemoteBranching( true ); - scmBranchParameters.setPinExternals( false ); - scmBranchParameters.setScmRevision( "2" ); - - testCommandLine( "scm:svn:https://foo.com/svn/trunk", "svnbranch", messageFile, "user", - "svn --username user --no-auth-cache --non-interactive copy --parents --file " + messageFile.getAbsolutePath() - + " --encoding UTF-8 --revision 2 https://foo.com/svn/trunk@ https://foo.com/svn/branches/svnbranch@", - scmBranchParameters ); + scmBranchParameters.setRemoteBranching(true); + scmBranchParameters.setPinExternals(false); + scmBranchParameters.setScmRevision("2"); + + testCommandLine( + "scm:svn:https://foo.com/svn/trunk", + "svnbranch", + messageFile, + "user", + "svn --username user --no-auth-cache --non-interactive copy --parents --file " + + messageFile.getAbsolutePath() + + " --encoding UTF-8 --revision 2 https://foo.com/svn/trunk@ https://foo.com/svn/branches/svnbranch@", + scmBranchParameters); } @Test - public void testBranchUserNameSvnHttpsRemoteBranchingWithRevWithPinExternals() - throws Exception - { - File messageFile = File.createTempFile( "maven-scm", "commit" ); + public void testBranchUserNameSvnHttpsRemoteBranchingWithRevWithPinExternals() throws Exception { + File messageFile = File.createTempFile("maven-scm", "commit"); messageFile.deleteOnExit(); ScmBranchParameters scmBranchParameters = new ScmBranchParameters(); - scmBranchParameters.setRemoteBranching( true ); - scmBranchParameters.setPinExternals( true ); - scmBranchParameters.setScmRevision( "2" ); - - testCommandLine( "scm:svn:https://foo.com/svn/trunk", "svnbranch", messageFile, "user", - "svn --username user --no-auth-cache --non-interactive copy --parents --file " + messageFile.getAbsolutePath() - + " --encoding UTF-8 --pin-externals --revision 2 https://foo.com/svn/trunk@ https://foo.com/svn/branches/svnbranch@", - scmBranchParameters ); + scmBranchParameters.setRemoteBranching(true); + scmBranchParameters.setPinExternals(true); + scmBranchParameters.setScmRevision("2"); + + testCommandLine( + "scm:svn:https://foo.com/svn/trunk", + "svnbranch", + messageFile, + "user", + "svn --username user --no-auth-cache --non-interactive copy --parents --file " + + messageFile.getAbsolutePath() + + " --encoding UTF-8 --pin-externals --revision 2 https://foo.com/svn/trunk@ https://foo.com/svn/branches/svnbranch@", + scmBranchParameters); } @Test - public void testBranchUserNameSvnHttpsRemoteBranchingNoRev() - throws Exception - { - File messageFile = File.createTempFile( "maven-scm", "commit" ); + public void testBranchUserNameSvnHttpsRemoteBranchingNoRev() throws Exception { + File messageFile = File.createTempFile("maven-scm", "commit"); messageFile.deleteOnExit(); ScmBranchParameters scmBranchParameters = new ScmBranchParameters(); - scmBranchParameters.setRemoteBranching( true ); - scmBranchParameters.setPinExternals( false ); - - testCommandLine( "scm:svn:https://foo.com/svn/trunk", "svnbranch", messageFile, "user", - "svn --username user --no-auth-cache --non-interactive copy --parents --file " + messageFile.getAbsolutePath() - + " --encoding UTF-8 https://foo.com/svn/trunk@ https://foo.com/svn/branches/svnbranch@", scmBranchParameters ); + scmBranchParameters.setRemoteBranching(true); + scmBranchParameters.setPinExternals(false); + + testCommandLine( + "scm:svn:https://foo.com/svn/trunk", + "svnbranch", + messageFile, + "user", + "svn --username user --no-auth-cache --non-interactive copy --parents --file " + + messageFile.getAbsolutePath() + + " --encoding UTF-8 https://foo.com/svn/trunk@ https://foo.com/svn/branches/svnbranch@", + scmBranchParameters); } @Test - public void testBranchUserNameSvnHttpsRemoteBranchingNoRevWithPinExternals() - throws Exception - { - File messageFile = File.createTempFile( "maven-scm", "commit" ); + public void testBranchUserNameSvnHttpsRemoteBranchingNoRevWithPinExternals() throws Exception { + File messageFile = File.createTempFile("maven-scm", "commit"); messageFile.deleteOnExit(); ScmBranchParameters scmBranchParameters = new ScmBranchParameters(); - scmBranchParameters.setRemoteBranching( true ); - scmBranchParameters.setPinExternals( true ); - - testCommandLine( "scm:svn:https://foo.com/svn/trunk", "svnbranch", messageFile, "user", - "svn --username user --no-auth-cache --non-interactive copy --parents --file " + messageFile.getAbsolutePath() - + " --encoding UTF-8 --pin-externals https://foo.com/svn/trunk@ https://foo.com/svn/branches/svnbranch@", scmBranchParameters ); + scmBranchParameters.setRemoteBranching(true); + scmBranchParameters.setPinExternals(true); + + testCommandLine( + "scm:svn:https://foo.com/svn/trunk", + "svnbranch", + messageFile, + "user", + "svn --username user --no-auth-cache --non-interactive copy --parents --file " + + messageFile.getAbsolutePath() + + " --encoding UTF-8 --pin-externals https://foo.com/svn/trunk@ https://foo.com/svn/branches/svnbranch@", + scmBranchParameters); } @Test - public void testBranchUserNameSvnHttps() - throws Exception - { - File messageFile = File.createTempFile( "maven-scm", "commit" ); + public void testBranchUserNameSvnHttps() throws Exception { + File messageFile = File.createTempFile("maven-scm", "commit"); messageFile.deleteOnExit(); - testCommandLine( "scm:svn:https://foo.com/svn/trunk", "svnbranch", messageFile, "user", - "svn --username user --no-auth-cache --non-interactive copy --parents --file " + messageFile.getAbsolutePath() - + " --encoding UTF-8 . https://foo.com/svn/branches/svnbranch@", null ); + testCommandLine( + "scm:svn:https://foo.com/svn/trunk", + "svnbranch", + messageFile, + "user", + "svn --username user --no-auth-cache --non-interactive copy --parents --file " + + messageFile.getAbsolutePath() + " --encoding UTF-8 . https://foo.com/svn/branches/svnbranch@", + null); } @Test - public void testBranchUserNameSvnSsh() - throws Exception - { - File messageFile = File.createTempFile( "maven-scm", "commit" ); + public void testBranchUserNameSvnSsh() throws Exception { + File messageFile = File.createTempFile("maven-scm", "commit"); messageFile.deleteOnExit(); - testCommandLine( "scm:svn:svn+ssh://foo.com/svn/trunk", "svnbranch", messageFile, "user", - "svn --username user --no-auth-cache --non-interactive copy --parents --file " + messageFile.getAbsolutePath() - + " --encoding UTF-8 . svn+ssh://user@foo.com/svn/branches/svnbranch@" ); + testCommandLine( + "scm:svn:svn+ssh://foo.com/svn/trunk", + "svnbranch", + messageFile, + "user", + "svn --username user --no-auth-cache --non-interactive copy --parents --file " + + messageFile.getAbsolutePath() + + " --encoding UTF-8 . svn+ssh://user@foo.com/svn/branches/svnbranch@"); } - private void testCommandLine( String scmUrl, String branch, File messageFile, String user, String commandLine, - ScmBranchParameters scmBranchParameters ) - throws Exception - { - File workingDirectory = getTestFile( "target/svn-update-command-test" ); + private void testCommandLine( + String scmUrl, + String branch, + File messageFile, + String user, + String commandLine, + ScmBranchParameters scmBranchParameters) + throws Exception { + File workingDirectory = getTestFile("target/svn-update-command-test"); - ScmRepository repository = getScmManager().makeScmRepository( scmUrl ); + ScmRepository repository = getScmManager().makeScmRepository(scmUrl); SvnScmProviderRepository svnRepository = (SvnScmProviderRepository) repository.getProviderRepository(); - svnRepository.setUser( user ); + svnRepository.setUser(user); Commandline cl = null; - if ( scmBranchParameters == null ) - { - cl = SvnBranchCommand.createCommandLine( svnRepository, workingDirectory, branch, messageFile ); - } - else - { - cl = SvnBranchCommand.createCommandLine( svnRepository, workingDirectory, branch, messageFile, - scmBranchParameters ); + if (scmBranchParameters == null) { + cl = SvnBranchCommand.createCommandLine(svnRepository, workingDirectory, branch, messageFile); + } else { + cl = SvnBranchCommand.createCommandLine( + svnRepository, workingDirectory, branch, messageFile, scmBranchParameters); } - assertCommandLine( commandLine, workingDirectory, cl ); + assertCommandLine(commandLine, workingDirectory, cl); } - private void testCommandLine( String scmUrl, String branch, File messageFile, String user, String commandLine ) - throws Exception - { - testCommandLine( scmUrl, branch, messageFile, user, commandLine, null ); + private void testCommandLine(String scmUrl, String branch, File messageFile, String user, String commandLine) + throws Exception { + testCommandLine(scmUrl, branch, messageFile, user, commandLine, null); } } diff --git a/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/test/java/org/apache/maven/scm/provider/svn/svnexe/command/changelog/SvnChangeLogCommandTest.java b/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/test/java/org/apache/maven/scm/provider/svn/svnexe/command/changelog/SvnChangeLogCommandTest.java index 332320fda..56a81b929 100644 --- a/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/test/java/org/apache/maven/scm/provider/svn/svnexe/command/changelog/SvnChangeLogCommandTest.java +++ b/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/test/java/org/apache/maven/scm/provider/svn/svnexe/command/changelog/SvnChangeLogCommandTest.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.svn.svnexe.command.changelog; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,194 +16,216 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider.svn.svnexe.command.changelog; + +import java.io.File; +import java.util.Calendar; +import java.util.Date; import org.apache.maven.scm.ScmBranch; +import org.apache.maven.scm.ScmRevision; import org.apache.maven.scm.ScmTestCase; import org.apache.maven.scm.ScmVersion; -import org.apache.maven.scm.ScmRevision; import org.apache.maven.scm.provider.svn.repository.SvnScmProviderRepository; import org.apache.maven.scm.repository.ScmRepository; import org.codehaus.plexus.util.cli.Commandline; import org.junit.Test; -import java.io.File; -import java.util.Calendar; -import java.util.Date; - /** * @author Emmanuel Venisse * */ -public class SvnChangeLogCommandTest - extends ScmTestCase -{ +public class SvnChangeLogCommandTest extends ScmTestCase { @Test - public void testCommandLineNoDates() - throws Exception - { - testCommandLine( "scm:svn:http://foo.com/svn/trunk", null, null, null, - "svn --non-interactive log -v http://foo.com/svn/trunk@" ); + public void testCommandLineNoDates() throws Exception { + testCommandLine( + "scm:svn:http://foo.com/svn/trunk", + null, + null, + null, + "svn --non-interactive log -v http://foo.com/svn/trunk@"); } @Test - public void testCommandLineNoDatesLimitedCount() - throws Exception - { - testCommandLine( "scm:svn:http://foo.com/svn/trunk", null, null, null, 40, - "svn --non-interactive log -v --limit 40 http://foo.com/svn/trunk@" ); + public void testCommandLineNoDatesLimitedCount() throws Exception { + testCommandLine( + "scm:svn:http://foo.com/svn/trunk", + null, + null, + null, + 40, + "svn --non-interactive log -v --limit 40 http://foo.com/svn/trunk@"); } @Test - public void testCommandLineWithDates() - throws Exception - { - Date startDate = getDate( 2003, Calendar.SEPTEMBER, 10, GMT_TIME_ZONE ); - Date endDate = getDate( 2003, Calendar.OCTOBER, 10, GMT_TIME_ZONE ); + public void testCommandLineWithDates() throws Exception { + Date startDate = getDate(2003, Calendar.SEPTEMBER, 10, GMT_TIME_ZONE); + Date endDate = getDate(2003, Calendar.OCTOBER, 10, GMT_TIME_ZONE); - testCommandLine( "scm:svn:http://foo.com/svn/trunk", null, startDate, endDate, - "svn --non-interactive log -v -r \"{2003-09-10 00:00:00 +0000}:{2003-10-10 00:00:00 +0000}\" http://foo.com/svn/trunk@" ); + testCommandLine( + "scm:svn:http://foo.com/svn/trunk", + null, + startDate, + endDate, + "svn --non-interactive log -v -r \"{2003-09-10 00:00:00 +0000}:{2003-10-10 00:00:00 +0000}\" http://foo.com/svn/trunk@"); } @Test - public void testCommandLineStartDateOnly() - throws Exception - { - Date startDate = getDate( 2003, Calendar.SEPTEMBER, 10, 1, 1, 1, GMT_TIME_ZONE ); + public void testCommandLineStartDateOnly() throws Exception { + Date startDate = getDate(2003, Calendar.SEPTEMBER, 10, 1, 1, 1, GMT_TIME_ZONE); - testCommandLine( "scm:svn:http://foo.com/svn/trunk", null, startDate, null, - "svn --non-interactive log -v -r \"{2003-09-10 01:01:01 +0000}:HEAD\" http://foo.com/svn/trunk@" ); + testCommandLine( + "scm:svn:http://foo.com/svn/trunk", + null, + startDate, + null, + "svn --non-interactive log -v -r \"{2003-09-10 01:01:01 +0000}:HEAD\" http://foo.com/svn/trunk@"); } @Test - public void testCommandLineDateFormat() - throws Exception - { - Date startDate = getDate( 2003, Calendar.SEPTEMBER, 10, 1, 1, 1, GMT_TIME_ZONE ); - Date endDate = getDate( 2005, Calendar.NOVEMBER, 13, 23, 23, 23, GMT_TIME_ZONE ); + public void testCommandLineDateFormat() throws Exception { + Date startDate = getDate(2003, Calendar.SEPTEMBER, 10, 1, 1, 1, GMT_TIME_ZONE); + Date endDate = getDate(2005, Calendar.NOVEMBER, 13, 23, 23, 23, GMT_TIME_ZONE); - testCommandLine( "scm:svn:http://foo.com/svn/trunk", null, startDate, endDate, - "svn --non-interactive log -v -r \"{2003-09-10 01:01:01 +0000}:{2005-11-13 23:23:23 +0000}\" http://foo.com/svn/trunk@" ); + testCommandLine( + "scm:svn:http://foo.com/svn/trunk", + null, + startDate, + endDate, + "svn --non-interactive log -v -r \"{2003-09-10 01:01:01 +0000}:{2005-11-13 23:23:23 +0000}\" http://foo.com/svn/trunk@"); } @Test - public void testCommandLineEndDateOnly() - throws Exception - { - Date endDate = getDate( 2003, Calendar.NOVEMBER, 10, GMT_TIME_ZONE ); + public void testCommandLineEndDateOnly() throws Exception { + Date endDate = getDate(2003, Calendar.NOVEMBER, 10, GMT_TIME_ZONE); // Only specifying end date should print no dates at all - testCommandLine( "scm:svn:http://foo.com/svn/trunk", null, null, endDate, - "svn --non-interactive log -v http://foo.com/svn/trunk@" ); + testCommandLine( + "scm:svn:http://foo.com/svn/trunk", + null, + null, + endDate, + "svn --non-interactive log -v http://foo.com/svn/trunk@"); } @Test - public void testCommandLineWithBranchNoDates() - throws Exception - { - testCommandLine( "scm:svn:http://foo.com/svn/trunk", new ScmBranch( "my-test-branch" ), null, null, - "svn --non-interactive log -v http://foo.com/svn/branches/my-test-branch@ http://foo.com/svn/trunk@" ); + public void testCommandLineWithBranchNoDates() throws Exception { + testCommandLine( + "scm:svn:http://foo.com/svn/trunk", + new ScmBranch("my-test-branch"), + null, + null, + "svn --non-interactive log -v http://foo.com/svn/branches/my-test-branch@ http://foo.com/svn/trunk@"); } @Test - public void testCommandLineWithBranchStartDateOnly() - throws Exception - { - Date startDate = getDate( 2003, Calendar.SEPTEMBER, 10, 1, 1, 1, GMT_TIME_ZONE ); + public void testCommandLineWithBranchStartDateOnly() throws Exception { + Date startDate = getDate(2003, Calendar.SEPTEMBER, 10, 1, 1, 1, GMT_TIME_ZONE); - testCommandLine( "scm:svn:http://foo.com/svn/trunk", new ScmBranch( "my-test-branch" ), startDate, null, - "svn --non-interactive log -v -r \"{2003-09-10 01:01:01 +0000}:HEAD\" http://foo.com/svn/branches/my-test-branch@ http://foo.com/svn/trunk@" ); + testCommandLine( + "scm:svn:http://foo.com/svn/trunk", + new ScmBranch("my-test-branch"), + startDate, + null, + "svn --non-interactive log -v -r \"{2003-09-10 01:01:01 +0000}:HEAD\" http://foo.com/svn/branches/my-test-branch@ http://foo.com/svn/trunk@"); } @Test - public void testCommandLineWithBranchEndDateOnly() - throws Exception - { - Date endDate = getDate( 2003, Calendar.OCTOBER, 10, 1, 1, 1, GMT_TIME_ZONE ); + public void testCommandLineWithBranchEndDateOnly() throws Exception { + Date endDate = getDate(2003, Calendar.OCTOBER, 10, 1, 1, 1, GMT_TIME_ZONE); // Only specifying end date should print no dates at all - testCommandLine( "scm:svn:http://foo.com/svn/trunk", new ScmBranch( "my-test-branch" ), null, endDate, - "svn --non-interactive log -v http://foo.com/svn/branches/my-test-branch@ http://foo.com/svn/trunk@" ); + testCommandLine( + "scm:svn:http://foo.com/svn/trunk", + new ScmBranch("my-test-branch"), + null, + endDate, + "svn --non-interactive log -v http://foo.com/svn/branches/my-test-branch@ http://foo.com/svn/trunk@"); } @Test - public void testCommandLineWithBranchBothDates() - throws Exception - { - Date startDate = getDate( 2003, Calendar.SEPTEMBER, 10, GMT_TIME_ZONE ); - Date endDate = getDate( 2003, Calendar.OCTOBER, 10, GMT_TIME_ZONE ); + public void testCommandLineWithBranchBothDates() throws Exception { + Date startDate = getDate(2003, Calendar.SEPTEMBER, 10, GMT_TIME_ZONE); + Date endDate = getDate(2003, Calendar.OCTOBER, 10, GMT_TIME_ZONE); - testCommandLine( "scm:svn:http://foo.com/svn/trunk", new ScmBranch( "my-test-branch" ), startDate, endDate, - "svn --non-interactive log -v -r \"{2003-09-10 00:00:00 +0000}:{2003-10-10 00:00:00 +0000}\" http://foo.com/svn/branches/my-test-branch@ http://foo.com/svn/trunk@" ); + testCommandLine( + "scm:svn:http://foo.com/svn/trunk", + new ScmBranch("my-test-branch"), + startDate, + endDate, + "svn --non-interactive log -v -r \"{2003-09-10 00:00:00 +0000}:{2003-10-10 00:00:00 +0000}\" http://foo.com/svn/branches/my-test-branch@ http://foo.com/svn/trunk@"); } @Test - public void testCommandLineWithStartVersion() - throws Exception - { - testCommandLine( "scm:svn:http://foo.com/svn/trunk", new ScmRevision( "1" ), null, - "svn --non-interactive log -v -r 1:HEAD http://foo.com/svn/trunk@" ); + public void testCommandLineWithStartVersion() throws Exception { + testCommandLine( + "scm:svn:http://foo.com/svn/trunk", + new ScmRevision("1"), + null, + "svn --non-interactive log -v -r 1:HEAD http://foo.com/svn/trunk@"); } @Test - public void testCommandLineWithStartVersionAndEndVersion() - throws Exception - { - testCommandLine( "scm:svn:http://foo.com/svn/trunk", new ScmRevision( "1" ), new ScmRevision( "10" ), - "svn --non-interactive log -v -r 1:10 http://foo.com/svn/trunk@" ); + public void testCommandLineWithStartVersionAndEndVersion() throws Exception { + testCommandLine( + "scm:svn:http://foo.com/svn/trunk", + new ScmRevision("1"), + new ScmRevision("10"), + "svn --non-interactive log -v -r 1:10 http://foo.com/svn/trunk@"); } @Test - public void testCommandLineWithStartVersionAndEndVersionEquals() - throws Exception - { - testCommandLine( "scm:svn:http://foo.com/svn/trunk", new ScmRevision( "1" ), new ScmRevision( "1" ), - "svn --non-interactive log -v -r 1 http://foo.com/svn/trunk@" ); + public void testCommandLineWithStartVersionAndEndVersionEquals() throws Exception { + testCommandLine( + "scm:svn:http://foo.com/svn/trunk", + new ScmRevision("1"), + new ScmRevision("1"), + "svn --non-interactive log -v -r 1 http://foo.com/svn/trunk@"); } @Test - public void testCommandLineWithBaseVersion() - throws Exception - { - testCommandLine( "scm:svn:http://foo.com/svn/trunk", new ScmRevision( "1" ), new ScmRevision( "BASE" ), - "svn --non-interactive log -v -r 1:BASE" ); + public void testCommandLineWithBaseVersion() throws Exception { + testCommandLine( + "scm:svn:http://foo.com/svn/trunk", + new ScmRevision("1"), + new ScmRevision("BASE"), + "svn --non-interactive log -v -r 1:BASE"); } // ---------------------------------------------------------------------- // // ---------------------------------------------------------------------- - private void testCommandLine( String scmUrl, ScmBranch branch, Date startDate, Date endDate, String commandLine ) - throws Exception - { - testCommandLine( scmUrl, branch, startDate, endDate, null, commandLine ); + private void testCommandLine(String scmUrl, ScmBranch branch, Date startDate, Date endDate, String commandLine) + throws Exception { + testCommandLine(scmUrl, branch, startDate, endDate, null, commandLine); } - private void testCommandLine( String scmUrl, ScmBranch branch, Date startDate, Date endDate, Integer limit, String commandLine ) - throws Exception - { - File workingDirectory = getTestFile( "target/svn-update-command-test" ); + private void testCommandLine( + String scmUrl, ScmBranch branch, Date startDate, Date endDate, Integer limit, String commandLine) + throws Exception { + File workingDirectory = getTestFile("target/svn-update-command-test"); - ScmRepository repository = getScmManager().makeScmRepository( scmUrl ); + ScmRepository repository = getScmManager().makeScmRepository(scmUrl); SvnScmProviderRepository svnRepository = (SvnScmProviderRepository) repository.getProviderRepository(); - Commandline cl = SvnChangeLogCommand.createCommandLine( svnRepository, workingDirectory, branch, startDate, - endDate, null, null, limit ); + Commandline cl = SvnChangeLogCommand.createCommandLine( + svnRepository, workingDirectory, branch, startDate, endDate, null, null, limit); - assertCommandLine( commandLine, workingDirectory, cl ); + assertCommandLine(commandLine, workingDirectory, cl); } - private void testCommandLine( String scmUrl, ScmVersion startVersion, ScmVersion endVersion, String commandLine ) - throws Exception - { - File workingDirectory = getTestFile( "target/svn-update-command-test" ); + private void testCommandLine(String scmUrl, ScmVersion startVersion, ScmVersion endVersion, String commandLine) + throws Exception { + File workingDirectory = getTestFile("target/svn-update-command-test"); - ScmRepository repository = getScmManager().makeScmRepository( scmUrl ); + ScmRepository repository = getScmManager().makeScmRepository(scmUrl); SvnScmProviderRepository svnRepository = (SvnScmProviderRepository) repository.getProviderRepository(); - Commandline cl = SvnChangeLogCommand.createCommandLine( svnRepository, workingDirectory, null, null, null, - startVersion, endVersion ); - assertCommandLine( commandLine, workingDirectory, cl ); + Commandline cl = SvnChangeLogCommand.createCommandLine( + svnRepository, workingDirectory, null, null, null, startVersion, endVersion); + assertCommandLine(commandLine, workingDirectory, cl); } } diff --git a/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/test/java/org/apache/maven/scm/provider/svn/svnexe/command/changelog/SvnChangeLogConsumerTest.java b/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/test/java/org/apache/maven/scm/provider/svn/svnexe/command/changelog/SvnChangeLogConsumerTest.java index ce847692a..30bfd05d7 100644 --- a/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/test/java/org/apache/maven/scm/provider/svn/svnexe/command/changelog/SvnChangeLogConsumerTest.java +++ b/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/test/java/org/apache/maven/scm/provider/svn/svnexe/command/changelog/SvnChangeLogConsumerTest.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.svn.svnexe.command.changelog; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,16 +16,7 @@ * specific language governing permissions and limitations * under the License. */ - -import org.apache.maven.scm.ChangeFile; -import org.apache.maven.scm.ChangeSet; -import org.apache.maven.scm.ScmFileStatus; -import org.apache.maven.scm.ScmTestCase; -import org.apache.maven.scm.util.ConsumerUtils; -import org.junit.Before; -import org.junit.Test; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +package org.apache.maven.scm.provider.svn.svnexe.command.changelog; import java.io.File; import java.io.IOException; @@ -40,6 +29,16 @@ import java.util.TimeZone; import java.util.concurrent.atomic.AtomicInteger; +import org.apache.maven.scm.ChangeFile; +import org.apache.maven.scm.ChangeSet; +import org.apache.maven.scm.ScmFileStatus; +import org.apache.maven.scm.ScmTestCase; +import org.apache.maven.scm.util.ConsumerUtils; +import org.junit.Before; +import org.junit.Test; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; @@ -48,29 +47,26 @@ * @author Emmanuel Venisse * */ -public class SvnChangeLogConsumerTest - extends ScmTestCase -{ - Logger logger = LoggerFactory.getLogger( getClass() ); +public class SvnChangeLogConsumerTest extends ScmTestCase { + Logger logger = LoggerFactory.getLogger(getClass()); SvnChangeLogConsumer consumer; @Before @Override - public void setUp() - throws Exception - { + public void setUp() throws Exception { super.setUp(); - consumer = new SvnChangeLogConsumer( null ); + consumer = new SvnChangeLogConsumer(null); } /** * Initial modifications should be empty. */ @Test - public void testGetModifications_Initial() - { - assertTrue( "Initial modifications should be empty", consumer.getModifications().isEmpty() ); + public void testGetModifications_Initial() { + assertTrue( + "Initial modifications should be empty", + consumer.getModifications().isEmpty()); } /** @@ -79,34 +75,30 @@ public void testGetModifications_Initial() * @throws Exception if any problem occurs. */ @Test - public void testConsumeLine_ValidOutput() - throws Exception - { - final File svnLog = getTestFile( "/src/test/resources/svn/changelog/svnLogValidOutput.txt" ); + public void testConsumeLine_ValidOutput() throws Exception { + final File svnLog = getTestFile("/src/test/resources/svn/changelog/svnLogValidOutput.txt"); - consumeLog( svnLog ); + consumeLog(svnLog); - final ChangeSet entry = consumer.getModifications().get( 0 ); + final ChangeSet entry = consumer.getModifications().get(0); final List changedFiles = entry.getFiles(); - final String revision = changedFiles.get( 0 ).getRevision(); - - assertEquals( "Valid revision expected", "15", revision ); - assertEquals( "Valid num changed files expected", 2, changedFiles.size() ); - assertEquals( "Valid name expected", "unconventional author output (somedata)", entry.getAuthor() ); - String expectedDate = getLocalizedDate( "2002-08-26 14:33:26", TimeZone.getTimeZone( "GMT-4" ) ); - assertEquals( "Valid date expected", expectedDate, entry.getDateFormatted() ); - assertEquals( "Valid comment expected", "Minor formatting changes.\n", entry.getComment() ); + final String revision = changedFiles.get(0).getRevision(); + + assertEquals("Valid revision expected", "15", revision); + assertEquals("Valid num changed files expected", 2, changedFiles.size()); + assertEquals("Valid name expected", "unconventional author output (somedata)", entry.getAuthor()); + String expectedDate = getLocalizedDate("2002-08-26 14:33:26", TimeZone.getTimeZone("GMT-4")); + assertEquals("Valid date expected", expectedDate, entry.getDateFormatted()); + assertEquals("Valid comment expected", "Minor formatting changes.\n", entry.getComment()); } - private static String getLocalizedDate( String date, TimeZone timeZone ) - throws Exception - { - DateFormat fmt = new SimpleDateFormat( "yyyy-MM-dd HH:mm:ss" ); - fmt.setTimeZone( timeZone ); - Date parsed = fmt.parse( date ); - fmt = new SimpleDateFormat( "yyyy-MM-dd" ); - return fmt.format( parsed ); + private static String getLocalizedDate(String date, TimeZone timeZone) throws Exception { + DateFormat fmt = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + fmt.setTimeZone(timeZone); + Date parsed = fmt.parse(date); + fmt = new SimpleDateFormat("yyyy-MM-dd"); + return fmt.format(parsed); } /** @@ -115,19 +107,14 @@ private static String getLocalizedDate( String date, TimeZone timeZone ) * @throws Exception */ @Test - public void testConsumeLine_InvalidReason() - throws Exception - { - final File svnLog = getTestFile( "/src/test/resources/svn/changelog/svnLogInvalidReason.txt" ); - - try - { - consumeLog( svnLog ); - fail( "Svn log output with an invalid reason should throw IllegalOutputException" ); - } - catch ( final IllegalOutputException e ) - { - assertTrue( true ); + public void testConsumeLine_InvalidReason() throws Exception { + final File svnLog = getTestFile("/src/test/resources/svn/changelog/svnLogInvalidReason.txt"); + + try { + consumeLog(svnLog); + fail("Svn log output with an invalid reason should throw IllegalOutputException"); + } catch (final IllegalOutputException e) { + assertTrue(true); } } @@ -137,18 +124,13 @@ public void testConsumeLine_InvalidReason() * @throws Exception */ @Test - public void testConsumeLine_InvalidDate() - throws Exception - { - final File svnLog = getTestFile( "/src/test/resources/svn/changelog/svnLogInvalidDate.txt" ); - try - { - consumeLog( svnLog ); - fail( "Svn log output with an invalid date should throw IllegalOutputException" ); - } - catch ( final IllegalOutputException e ) - { - assertTrue( true ); + public void testConsumeLine_InvalidDate() throws Exception { + final File svnLog = getTestFile("/src/test/resources/svn/changelog/svnLogInvalidDate.txt"); + try { + consumeLog(svnLog); + fail("Svn log output with an invalid date should throw IllegalOutputException"); + } catch (final IllegalOutputException e) { + assertTrue(true); } } @@ -158,126 +140,113 @@ public void testConsumeLine_InvalidDate() * @param logFile the file. * @throws IOException if a problem occurs. */ - private void consumeLog( final File logFile ) - throws IOException - { - ConsumerUtils.consumeFile( logFile, consumer ); + private void consumeLog(final File logFile) throws IOException { + ConsumerUtils.consumeFile(logFile, consumer); } @Test - public void testConsumerWithPattern1() - throws Exception - { + public void testConsumerWithPattern1() throws Exception { StringBuilder out = new StringBuilder(); - File f = getTestFile( "/src/test/resources/svn/changelog/svnlog.txt" ); + File f = getTestFile("/src/test/resources/svn/changelog/svnlog.txt"); - ConsumerUtils.consumeFile( f, consumer ); + ConsumerUtils.consumeFile(f, consumer); List modifications = consumer.getModifications(); - out.append( "Text format:" ); + out.append("Text format:"); - out.append( "nb modifications : " + modifications.size() ); + out.append("nb modifications : " + modifications.size()); - for ( ChangeSet entry : modifications ) - { + for (ChangeSet entry : modifications) { - out.append( "Author:" + entry.getAuthor() ); + out.append("Author:" + entry.getAuthor()); - out.append( "Date:" + entry.getDate() ); + out.append("Date:" + entry.getDate()); - out.append( "Comment:" + entry.getComment() ); + out.append("Comment:" + entry.getComment()); - for ( ChangeFile file : entry.getFiles() ) - { + for (ChangeFile file : entry.getFiles()) { - out.append( "File:" + file.getName() ); + out.append("File:" + file.getName()); } - out.append( "==============================" ); + out.append("=============================="); } - out.append( "XML format:" ); + out.append("XML format:"); - out.append( "nb modifications : " + modifications.size() ); + out.append("nb modifications : " + modifications.size()); - for ( ChangeSet entry : modifications ) - { - out.append( entry.toXML() ); + for (ChangeSet entry : modifications) { + out.append(entry.toXML()); - out.append( "==============================" ); + out.append("=============================="); } - if ( logger.isDebugEnabled() ) - { - logger.debug( out.toString() ); + if (logger.isDebugEnabled()) { + logger.debug(out.toString()); } } @Test - public void testConsumerWithPattern2() - throws Exception - { + public void testConsumerWithPattern2() throws Exception { StringBuilder out = new StringBuilder(); - File f = getTestFile( "/src/test/resources/svn/changelog/svnlog2.txt" ); + File f = getTestFile("/src/test/resources/svn/changelog/svnlog2.txt"); - ConsumerUtils.consumeFile( f, consumer ); + ConsumerUtils.consumeFile(f, consumer); List modifications = consumer.getModifications(); - out.append( "nb modifications : " + modifications.size() ); + out.append("nb modifications : " + modifications.size()); int origFileCounter = 0; // must use *Linked* HashMap to have predictable toString final Map summary = new LinkedHashMap(); - for ( ChangeSet entry : consumer.getModifications() ) - { + for (ChangeSet entry : consumer.getModifications()) { - out.append( "Author:" + entry.getAuthor() ); + out.append("Author:" + entry.getAuthor()); - out.append( "Date:" + entry.getDate() ); + out.append("Date:" + entry.getDate()); - out.append( "Comment:" + entry.getComment() ); + out.append("Comment:" + entry.getComment()); - for ( ChangeFile file : entry.getFiles() ) - { + for (ChangeFile file : entry.getFiles()) { final ScmFileStatus action = file.getAction(); - if ( !summary.containsKey( action ) ) - { - summary.put( action, new AtomicInteger() ); + if (!summary.containsKey(action)) { + summary.put(action, new AtomicInteger()); } - summary.get( action ).incrementAndGet(); + summary.get(action).incrementAndGet(); final String fileName = file.getName(); - out.append( "File:" + fileName ); + out.append("File:" + fileName); // files in this log are known to be from one subtree - assertTrue( "Unexpected file name: " + fileName, fileName.startsWith( "/maven/scm/trunk" ) ); + assertTrue("Unexpected file name: " + fileName, fileName.startsWith("/maven/scm/trunk")); // files in this log are known not to contain space - assertEquals( "Unexpected space found in filename: " + fileName, -1, fileName.indexOf( " " ) ); + assertEquals("Unexpected space found in filename: " + fileName, -1, fileName.indexOf(" ")); - if ( file.getOriginalName() != null ) - { + if (file.getOriginalName() != null) { origFileCounter++; } } - out.append( "==============================" ); + out.append("=============================="); } - assertEquals( "Unexpected number of file copy records", 1, origFileCounter ); + assertEquals("Unexpected number of file copy records", 1, origFileCounter); - assertEquals( "Action summary differs from expectations", - "{modified=626, deleted=56, added=310, copied=1}", summary.toString() ); + assertEquals( + "Action summary differs from expectations", + "{modified=626, deleted=56, added=310, copied=1}", + summary.toString()); - if ( logger.isDebugEnabled() ) - { - logger.debug( out.toString() ); + if (logger.isDebugEnabled()) { + logger.debug(out.toString()); } } } diff --git a/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/test/java/org/apache/maven/scm/provider/svn/svnexe/command/checkin/SvnCheckInCommandTest.java b/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/test/java/org/apache/maven/scm/provider/svn/svnexe/command/checkin/SvnCheckInCommandTest.java index 91cb399bd..7e8b02e6a 100644 --- a/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/test/java/org/apache/maven/scm/provider/svn/svnexe/command/checkin/SvnCheckInCommandTest.java +++ b/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/test/java/org/apache/maven/scm/provider/svn/svnexe/command/checkin/SvnCheckInCommandTest.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.svn.svnexe.command.checkin; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,9 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider.svn.svnexe.command.checkin; + +import java.io.File; import org.apache.maven.scm.ScmFileSet; import org.apache.maven.scm.ScmTestCase; @@ -28,80 +29,63 @@ import org.junit.Before; import org.junit.Test; -import java.io.File; - /** * @author Trygve Laugstøl * */ -public class SvnCheckInCommandTest - extends ScmTestCase -{ +public class SvnCheckInCommandTest extends ScmTestCase { private File messageFile; private String messageFileString; @Before @Override - public void setUp() - throws Exception - { + public void setUp() throws Exception { super.setUp(); - messageFile = new File( "commit-message" ); + messageFile = new File("commit-message"); String path = messageFile.getAbsolutePath(); - if ( path.indexOf( ' ' ) >= 0 ) - { + if (path.indexOf(' ') >= 0) { path = "\"" + path + "\""; } messageFileString = "--file " + path + " --encoding UTF-8"; } @Test - public void testCommandLineWithEmptyTag() - throws Exception - { - testCommandLine( "scm:svn:http://foo.com/svn/trunk", "svn --non-interactive commit " + messageFileString ); + public void testCommandLineWithEmptyTag() throws Exception { + testCommandLine("scm:svn:http://foo.com/svn/trunk", "svn --non-interactive commit " + messageFileString); } @Test - public void testCommandLineWithoutTag() - throws Exception - { - testCommandLine( "scm:svn:http://foo.com/svn/trunk", "svn --non-interactive commit " + messageFileString ); + public void testCommandLineWithoutTag() throws Exception { + testCommandLine("scm:svn:http://foo.com/svn/trunk", "svn --non-interactive commit " + messageFileString); } @Test - public void testCommandLineTag() - throws Exception - { - testCommandLine( "scm:svn:http://anonymous@foo.com/svn/trunk", - "svn --username anonymous --no-auth-cache --non-interactive commit " + messageFileString ); + public void testCommandLineTag() throws Exception { + testCommandLine( + "scm:svn:http://anonymous@foo.com/svn/trunk", + "svn --username anonymous --no-auth-cache --non-interactive commit " + messageFileString); } @Test - public void testCommandLineWithUsernameAndTag() - throws Exception - { - testCommandLine( "scm:svn:http://anonymous@foo.com/svn/trunk", - "svn --username anonymous --no-auth-cache --non-interactive commit " + messageFileString ); + public void testCommandLineWithUsernameAndTag() throws Exception { + testCommandLine( + "scm:svn:http://anonymous@foo.com/svn/trunk", + "svn --username anonymous --no-auth-cache --non-interactive commit " + messageFileString); } @Test - public void testCommandLineWithUsernameWithoutNonInteractive() - throws Exception - { - try - { - SvnUtil.setSettingsDirectory( getTestFile( "src/test/resources/svn/checkin/macos" ) ); - testCommandLine( "scm:svn:http://anonymous@foo.com/svn/trunk", "svn --username anonymous --no-auth-cache commit " - + messageFileString ); - } - finally - { - - SvnUtil.setSettingsDirectory( SvnUtil.DEFAULT_SETTINGS_DIRECTORY ); + public void testCommandLineWithUsernameWithoutNonInteractive() throws Exception { + try { + SvnUtil.setSettingsDirectory(getTestFile("src/test/resources/svn/checkin/macos")); + testCommandLine( + "scm:svn:http://anonymous@foo.com/svn/trunk", + "svn --username anonymous --no-auth-cache commit " + messageFileString); + } finally { + + SvnUtil.setSettingsDirectory(SvnUtil.DEFAULT_SETTINGS_DIRECTORY); } } @@ -109,18 +93,16 @@ public void testCommandLineWithUsernameWithoutNonInteractive() // // ---------------------------------------------------------------------- - private void testCommandLine( String scmUrl, String commandLine ) - throws Exception - { - File workingDirectory = getTestFile( "target/svn-checkin-command-test" ); + private void testCommandLine(String scmUrl, String commandLine) throws Exception { + File workingDirectory = getTestFile("target/svn-checkin-command-test"); - ScmRepository repository = getScmManager().makeScmRepository( scmUrl ); + ScmRepository repository = getScmManager().makeScmRepository(scmUrl); SvnScmProviderRepository svnRepository = (SvnScmProviderRepository) repository.getProviderRepository(); Commandline cl = - SvnCheckInCommand.createCommandLine( svnRepository, new ScmFileSet( workingDirectory ), messageFile ); + SvnCheckInCommand.createCommandLine(svnRepository, new ScmFileSet(workingDirectory), messageFile); - assertCommandLine( commandLine, workingDirectory, cl ); + assertCommandLine(commandLine, workingDirectory, cl); } } diff --git a/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/test/java/org/apache/maven/scm/provider/svn/svnexe/command/checkin/SvnExeCheckInCommandTckTest.java b/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/test/java/org/apache/maven/scm/provider/svn/svnexe/command/checkin/SvnExeCheckInCommandTckTest.java index 7ffd2f099..fb53e82b9 100644 --- a/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/test/java/org/apache/maven/scm/provider/svn/svnexe/command/checkin/SvnExeCheckInCommandTckTest.java +++ b/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/test/java/org/apache/maven/scm/provider/svn/svnexe/command/checkin/SvnExeCheckInCommandTckTest.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.svn.svnexe.command.checkin; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider.svn.svnexe.command.checkin; import org.apache.maven.scm.provider.svn.command.checkin.SvnCheckInCommandTckTest; @@ -27,12 +26,9 @@ * @author Brett Porter * */ -public class SvnExeCheckInCommandTckTest - extends SvnCheckInCommandTckTest -{ +public class SvnExeCheckInCommandTckTest extends SvnCheckInCommandTckTest { @Override - public String getScmProviderCommand() - { + public String getScmProviderCommand() { return SVN_COMMAND_LINE; } } diff --git a/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/test/java/org/apache/maven/scm/provider/svn/svnexe/command/checkout/SvnCheckOutCommandTest.java b/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/test/java/org/apache/maven/scm/provider/svn/svnexe/command/checkout/SvnCheckOutCommandTest.java index c49f8f435..8b9d1d176 100644 --- a/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/test/java/org/apache/maven/scm/provider/svn/svnexe/command/checkout/SvnCheckOutCommandTest.java +++ b/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/test/java/org/apache/maven/scm/provider/svn/svnexe/command/checkout/SvnCheckOutCommandTest.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.svn.svnexe.command.checkout; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,9 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider.svn.svnexe.command.checkout; + +import java.io.File; import org.apache.maven.scm.ScmRevision; import org.apache.maven.scm.ScmTestCase; @@ -29,15 +30,11 @@ import org.junit.Before; import org.junit.Test; -import java.io.File; - /** * @author Emmanuel Venisse * */ -public class SvnCheckOutCommandTest - extends ScmTestCase -{ +public class SvnCheckOutCommandTest extends ScmTestCase { private File workingDirectory; private boolean recursive; @@ -48,16 +45,13 @@ public class SvnCheckOutCommandTest @Before @Override - public void setUp() - throws Exception - { + public void setUp() throws Exception { super.setUp(); recursive = true; - workingDirectory = getTestFile( "target/svn-checkout-command-test" ); - if ( workingDirectory != null && workingDirectory.isDirectory() ) - { - FileUtils.deleteDirectory( workingDirectory ); + workingDirectory = getTestFile("target/svn-checkout-command-test"); + if (workingDirectory != null && workingDirectory.isDirectory()) { + FileUtils.deleteDirectory(workingDirectory); } } @@ -66,58 +60,56 @@ public void setUp() // ---------------------------------------------------------------------- @Test - public void testCommandLineWithoutRevision() - throws Exception - { - testCommandLine( getScmManager(), "scm:svn:http://foo.com/svn/trunk", null, - "svn --non-interactive checkout http://foo.com/svn/trunk@ " - + workingDirectory.getAbsolutePath() ); + public void testCommandLineWithoutRevision() throws Exception { + testCommandLine( + getScmManager(), + "scm:svn:http://foo.com/svn/trunk", + null, + "svn --non-interactive checkout http://foo.com/svn/trunk@ " + workingDirectory.getAbsolutePath()); } @Test - public void testCommandLineWithEmptyRevision() - throws Exception - { - testCommandLine( getScmManager(), "scm:svn:http://foo.com/svn/trunk", "", - "svn --non-interactive checkout http://foo.com/svn/trunk@ " - + workingDirectory.getAbsolutePath() ); + public void testCommandLineWithEmptyRevision() throws Exception { + testCommandLine( + getScmManager(), + "scm:svn:http://foo.com/svn/trunk", + "", + "svn --non-interactive checkout http://foo.com/svn/trunk@ " + workingDirectory.getAbsolutePath()); } @Test - public void testCommandLineWithRevision() - throws Exception - { - testCommandLine( getScmManager(), "scm:svn:http://foo.com/svn/trunk", "10", - "svn --non-interactive checkout -r 10 http://foo.com/svn/trunk@ " - + workingDirectory.getAbsolutePath() ); + public void testCommandLineWithRevision() throws Exception { + testCommandLine( + getScmManager(), + "scm:svn:http://foo.com/svn/trunk", + "10", + "svn --non-interactive checkout -r 10 http://foo.com/svn/trunk@ " + workingDirectory.getAbsolutePath()); } @Test - public void testRecursiveCheckOutCommandLine() - throws Exception - { + public void testRecursiveCheckOutCommandLine() throws Exception { recursive = false; - testCommandLine( getScmManager(), "scm:svn:http://foo.com/svn/trunk", "10", - "svn --non-interactive checkout -N -r 10 http://foo.com/svn/trunk@ " - + workingDirectory.getAbsolutePath() ); + testCommandLine( + getScmManager(), + "scm:svn:http://foo.com/svn/trunk", + "10", + "svn --non-interactive checkout -N -r 10 http://foo.com/svn/trunk@ " + + workingDirectory.getAbsolutePath()); } // ---------------------------------------------------------------------- // // ---------------------------------------------------------------------- - private void testCommandLine( ScmManager scmManager, String scmUrl, String revision, String commandLine ) - throws Exception - { - ScmRepository repository = scmManager.makeScmRepository( scmUrl ); + private void testCommandLine(ScmManager scmManager, String scmUrl, String revision, String commandLine) + throws Exception { + ScmRepository repository = scmManager.makeScmRepository(scmUrl); SvnScmProviderRepository svnRepository = (SvnScmProviderRepository) repository.getProviderRepository(); - Commandline cl = - SvnCheckOutCommand.createCommandLine( svnRepository, workingDirectory, - new ScmRevision( revision ), svnRepository.getUrl(), - recursive ); + Commandline cl = SvnCheckOutCommand.createCommandLine( + svnRepository, workingDirectory, new ScmRevision(revision), svnRepository.getUrl(), recursive); - assertCommandLine( commandLine, workingDirectory.getParentFile(), cl ); + assertCommandLine(commandLine, workingDirectory.getParentFile(), cl); } } diff --git a/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/test/java/org/apache/maven/scm/provider/svn/svnexe/command/checkout/SvnCheckOutConsumerTest.java b/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/test/java/org/apache/maven/scm/provider/svn/svnexe/command/checkout/SvnCheckOutConsumerTest.java index 6c2576d68..42b53c649 100644 --- a/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/test/java/org/apache/maven/scm/provider/svn/svnexe/command/checkout/SvnCheckOutConsumerTest.java +++ b/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/test/java/org/apache/maven/scm/provider/svn/svnexe/command/checkout/SvnCheckOutConsumerTest.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.svn.svnexe.command.checkout; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,27 +16,26 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider.svn.svnexe.command.checkout; import java.io.File; import org.junit.Assert; import org.junit.Test; -public class SvnCheckOutConsumerTest -{ +public class SvnCheckOutConsumerTest { SvnCheckOutConsumer consumer; - + @Test - public void testParseLine() - { - File file = new File( "mine/a" ); - consumer = new SvnCheckOutConsumer( file ); - + public void testParseLine() { + File file = new File("mine/a"); + consumer = new SvnCheckOutConsumer(file); + // SCM-618 StringIndexOutOfBoundsException - consumer.parseLine( "A " + file.getAbsolutePath() ); + consumer.parseLine("A " + file.getAbsolutePath()); - consumer.parseLine( "Checked out revision 1345915." ); + consumer.parseLine("Checked out revision 1345915."); - Assert.assertEquals( 1345915, consumer.getRevision()); + Assert.assertEquals(1345915, consumer.getRevision()); } -} \ No newline at end of file +} diff --git a/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/test/java/org/apache/maven/scm/provider/svn/svnexe/command/checkout/SvnExeCheckOutCommandTckTest.java b/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/test/java/org/apache/maven/scm/provider/svn/svnexe/command/checkout/SvnExeCheckOutCommandTckTest.java index eef23e86e..60a50b6b4 100644 --- a/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/test/java/org/apache/maven/scm/provider/svn/svnexe/command/checkout/SvnExeCheckOutCommandTckTest.java +++ b/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/test/java/org/apache/maven/scm/provider/svn/svnexe/command/checkout/SvnExeCheckOutCommandTckTest.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.svn.svnexe.command.checkout; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider.svn.svnexe.command.checkout; import org.apache.maven.scm.provider.svn.command.checkout.SvnCheckOutCommandTckTest; @@ -27,12 +26,9 @@ * @author Emmanuel Venisse * */ -public class SvnExeCheckOutCommandTckTest - extends SvnCheckOutCommandTckTest -{ +public class SvnExeCheckOutCommandTckTest extends SvnCheckOutCommandTckTest { @Override - public String getScmProviderCommand() - { + public String getScmProviderCommand() { return SVN_COMMAND_LINE; } } diff --git a/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/test/java/org/apache/maven/scm/provider/svn/svnexe/command/diff/SvnExeDiffCommandTckTest.java b/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/test/java/org/apache/maven/scm/provider/svn/svnexe/command/diff/SvnExeDiffCommandTckTest.java index 242dcf85e..d7353df86 100644 --- a/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/test/java/org/apache/maven/scm/provider/svn/svnexe/command/diff/SvnExeDiffCommandTckTest.java +++ b/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/test/java/org/apache/maven/scm/provider/svn/svnexe/command/diff/SvnExeDiffCommandTckTest.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.svn.svnexe.command.diff; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider.svn.svnexe.command.diff; import org.apache.maven.scm.provider.svn.command.diff.SvnDiffCommandTckTest; @@ -27,12 +26,9 @@ * @author Brett Porter * */ -public class SvnExeDiffCommandTckTest - extends SvnDiffCommandTckTest -{ +public class SvnExeDiffCommandTckTest extends SvnDiffCommandTckTest { @Override - public String getScmProviderCommand() - { + public String getScmProviderCommand() { return SVN_COMMAND_LINE; } } diff --git a/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/test/java/org/apache/maven/scm/provider/svn/svnexe/command/export/SvnExportCommandTest.java b/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/test/java/org/apache/maven/scm/provider/svn/svnexe/command/export/SvnExportCommandTest.java index 307fa1d6c..b27b8c8d6 100644 --- a/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/test/java/org/apache/maven/scm/provider/svn/svnexe/command/export/SvnExportCommandTest.java +++ b/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/test/java/org/apache/maven/scm/provider/svn/svnexe/command/export/SvnExportCommandTest.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.svn.svnexe.command.export; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider.svn.svnexe.command.export; import java.io.File; @@ -27,40 +26,43 @@ import org.codehaus.plexus.util.cli.Commandline; import org.junit.Test; -public class SvnExportCommandTest - extends ScmTestCase -{ +public class SvnExportCommandTest extends ScmTestCase { @Test - public void testGetExportCommandLineWithImplicitExportDirectory() - throws Exception - { - File exportDirectory = new File( getBasedir() ); + public void testGetExportCommandLineWithImplicitExportDirectory() throws Exception { + File exportDirectory = new File(getBasedir()); - testCommandLine( "scm:svn:http://foo.com/svn/trunk", exportDirectory, null, - "svn --non-interactive export --force http://foo.com/svn/trunk@" ); + testCommandLine( + "scm:svn:http://foo.com/svn/trunk", + exportDirectory, + null, + "svn --non-interactive export --force http://foo.com/svn/trunk@"); } @Test - public void testGetExportCommandLineWithExplicitExportDirectory() - throws Exception - { - File exportDirectory = new File( getBasedir() ); + public void testGetExportCommandLineWithExplicitExportDirectory() throws Exception { + File exportDirectory = new File(getBasedir()); - testCommandLine( "scm:svn:http://foo.com/svn/trunk", exportDirectory, exportDirectory, - "svn --non-interactive export --force http://foo.com/svn/trunk@ " + exportDirectory + "@" ); + testCommandLine( + "scm:svn:http://foo.com/svn/trunk", + exportDirectory, + exportDirectory, + "svn --non-interactive export --force http://foo.com/svn/trunk@ " + exportDirectory + "@"); } - private void testCommandLine( String scmUrl, File workingDirectory, File exportDirectory, String commandLine ) - throws Exception - { - ScmRepository repository = getScmManager().makeScmRepository( scmUrl ); + private void testCommandLine(String scmUrl, File workingDirectory, File exportDirectory, String commandLine) + throws Exception { + ScmRepository repository = getScmManager().makeScmRepository(scmUrl); SvnScmProviderRepository svnRepository = (SvnScmProviderRepository) repository.getProviderRepository(); - Commandline cl = SvnExeExportCommand.createCommandLine( svnRepository, exportDirectory, null, svnRepository.getUrl(), - exportDirectory != null?exportDirectory.getAbsolutePath():null ); + Commandline cl = SvnExeExportCommand.createCommandLine( + svnRepository, + exportDirectory, + null, + svnRepository.getUrl(), + exportDirectory != null ? exportDirectory.getAbsolutePath() : null); - assertCommandLine( commandLine, exportDirectory, cl ); + assertCommandLine(commandLine, exportDirectory, cl); } } diff --git a/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/test/java/org/apache/maven/scm/provider/svn/svnexe/command/info/SvnInfoCommandTest.java b/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/test/java/org/apache/maven/scm/provider/svn/svnexe/command/info/SvnInfoCommandTest.java index 137c5cb30..2e0f11b4f 100644 --- a/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/test/java/org/apache/maven/scm/provider/svn/svnexe/command/info/SvnInfoCommandTest.java +++ b/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/test/java/org/apache/maven/scm/provider/svn/svnexe/command/info/SvnInfoCommandTest.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.svn.svnexe.command.info; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider.svn.svnexe.command.info; import java.io.File; @@ -28,28 +27,22 @@ import org.codehaus.plexus.util.cli.Commandline; import org.junit.Test; -public class SvnInfoCommandTest - extends ScmTestCase -{ +public class SvnInfoCommandTest extends ScmTestCase { @Test - public void testGetInfoOnEmptyFileSet() - throws Exception - { - ScmFileSet fileSet = new ScmFileSet( new File( getBasedir() ) ); - - testCommandLine( "scm:svn:http://foo.com/svn/trunk", fileSet, "svn --non-interactive info" ); + public void testGetInfoOnEmptyFileSet() throws Exception { + ScmFileSet fileSet = new ScmFileSet(new File(getBasedir())); + + testCommandLine("scm:svn:http://foo.com/svn/trunk", fileSet, "svn --non-interactive info"); } - - private void testCommandLine( String scmUrl, ScmFileSet fileSet, String commandLine ) - throws Exception - { - ScmRepository repository = getScmManager().makeScmRepository( scmUrl ); + + private void testCommandLine(String scmUrl, ScmFileSet fileSet, String commandLine) throws Exception { + ScmRepository repository = getScmManager().makeScmRepository(scmUrl); SvnScmProviderRepository svnRepository = (SvnScmProviderRepository) repository.getProviderRepository(); - Commandline cl = SvnInfoCommand.createCommandLine( svnRepository, fileSet, false, null ); - - assertCommandLine( commandLine, fileSet.getBasedir(), cl ); + Commandline cl = SvnInfoCommand.createCommandLine(svnRepository, fileSet, false, null); + + assertCommandLine(commandLine, fileSet.getBasedir(), cl); } } diff --git a/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/test/java/org/apache/maven/scm/provider/svn/svnexe/command/list/SvnExeListCommandTckTest.java b/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/test/java/org/apache/maven/scm/provider/svn/svnexe/command/list/SvnExeListCommandTckTest.java index add8b813b..7a8dfc4f5 100644 --- a/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/test/java/org/apache/maven/scm/provider/svn/svnexe/command/list/SvnExeListCommandTckTest.java +++ b/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/test/java/org/apache/maven/scm/provider/svn/svnexe/command/list/SvnExeListCommandTckTest.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.svn.svnexe.command.list; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider.svn.svnexe.command.list; import org.apache.maven.scm.provider.svn.command.list.SvnListCommandTckTest; @@ -27,12 +26,9 @@ * @author Carlos Sanchez * */ -public class SvnExeListCommandTckTest - extends SvnListCommandTckTest -{ +public class SvnExeListCommandTckTest extends SvnListCommandTckTest { @Override - public String getScmProviderCommand() - { + public String getScmProviderCommand() { return SVN_COMMAND_LINE; } } diff --git a/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/test/java/org/apache/maven/scm/provider/svn/svnexe/command/list/SvnListCommandTest.java b/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/test/java/org/apache/maven/scm/provider/svn/svnexe/command/list/SvnListCommandTest.java index 5d50c84ae..7ab87e26a 100644 --- a/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/test/java/org/apache/maven/scm/provider/svn/svnexe/command/list/SvnListCommandTest.java +++ b/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/test/java/org/apache/maven/scm/provider/svn/svnexe/command/list/SvnListCommandTest.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.svn.svnexe.command.list; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,9 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider.svn.svnexe.command.list; + +import java.io.File; import org.apache.maven.scm.ScmFileSet; import org.apache.maven.scm.ScmRevision; @@ -27,79 +28,66 @@ import org.codehaus.plexus.util.cli.Commandline; import org.junit.Test; -import java.io.File; - /** * @author Carlos Sanchez * */ -public class SvnListCommandTest - extends ScmTestCase -{ +public class SvnListCommandTest extends ScmTestCase { @Test - public void testCommandLineWithEmptyTag() - throws Exception - { - testCommandLine( "scm:svn:http://foo.com/svn/trunk", true, "svn --non-interactive list --recursive" ); + public void testCommandLineWithEmptyTag() throws Exception { + testCommandLine("scm:svn:http://foo.com/svn/trunk", true, "svn --non-interactive list --recursive"); } @Test - public void testCommandLineWithWhitespaceTag() - throws Exception - { - testCommandLine( "scm:svn:http://foo.com/svn/trunk", false, "svn --non-interactive list" ); + public void testCommandLineWithWhitespaceTag() throws Exception { + testCommandLine("scm:svn:http://foo.com/svn/trunk", false, "svn --non-interactive list"); } @Test - public void testCommandLineWithoutTag() - throws Exception - { - testCommandLine( "scm:svn:http://foo.com/svn/trunk", false, "svn --non-interactive list" ); + public void testCommandLineWithoutTag() throws Exception { + testCommandLine("scm:svn:http://foo.com/svn/trunk", false, "svn --non-interactive list"); } @Test - public void testCommandLineTag() - throws Exception - { - testCommandLine( "scm:svn:http://anonymous@foo.com/svn/trunk", false, "10", - "svn --username anonymous --no-auth-cache --non-interactive list -r 10" ); + public void testCommandLineTag() throws Exception { + testCommandLine( + "scm:svn:http://anonymous@foo.com/svn/trunk", + false, + "10", + "svn --username anonymous --no-auth-cache --non-interactive list -r 10"); } @Test - public void testCommandLineWithUsernameAndTag() - throws Exception - { - testCommandLine( "scm:svn:http://anonymous@foo.com/svn/trunk", false, "10", - "svn --username anonymous --no-auth-cache --non-interactive list -r 10" ); + public void testCommandLineWithUsernameAndTag() throws Exception { + testCommandLine( + "scm:svn:http://anonymous@foo.com/svn/trunk", + false, + "10", + "svn --username anonymous --no-auth-cache --non-interactive list -r 10"); } // ---------------------------------------------------------------------- // // ---------------------------------------------------------------------- - private SvnScmProviderRepository getSvnRepository( String scmUrl ) - throws Exception - { - ScmRepository repository = getScmManager().makeScmRepository( scmUrl ); + private SvnScmProviderRepository getSvnRepository(String scmUrl) throws Exception { + ScmRepository repository = getScmManager().makeScmRepository(scmUrl); return (SvnScmProviderRepository) repository.getProviderRepository(); } - private void testCommandLine( String scmUrl, boolean recursive, String commandLine ) - throws Exception - { - testCommandLine( scmUrl, recursive, null, commandLine ); + private void testCommandLine(String scmUrl, boolean recursive, String commandLine) throws Exception { + testCommandLine(scmUrl, recursive, null, commandLine); } - private void testCommandLine( String scmUrl, boolean recursive, String revision, String commandLine ) - throws Exception - { - ScmFileSet fileSet = new ScmFileSet( new File( "." ), new File( "." ) ); + private void testCommandLine(String scmUrl, boolean recursive, String revision, String commandLine) + throws Exception { + ScmFileSet fileSet = new ScmFileSet(new File("."), new File(".")); - Commandline cl = SvnListCommand.createCommandLine( getSvnRepository( scmUrl ), fileSet, recursive, - new ScmRevision( revision ) ); + Commandline cl = SvnListCommand.createCommandLine( + getSvnRepository(scmUrl), fileSet, recursive, new ScmRevision(revision)); - assertCommandLine( commandLine + " http://foo.com/svn/trunk/.@", - new File( System.getProperty( "java.io.tmpdir" ) ), cl ); + assertCommandLine( + commandLine + " http://foo.com/svn/trunk/.@", new File(System.getProperty("java.io.tmpdir")), cl); } } diff --git a/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/test/java/org/apache/maven/scm/provider/svn/svnexe/command/mkdir/SvnExeMkdirCommandTckTest.java b/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/test/java/org/apache/maven/scm/provider/svn/svnexe/command/mkdir/SvnExeMkdirCommandTckTest.java index 48c04e497..bfcc498f9 100644 --- a/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/test/java/org/apache/maven/scm/provider/svn/svnexe/command/mkdir/SvnExeMkdirCommandTckTest.java +++ b/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/test/java/org/apache/maven/scm/provider/svn/svnexe/command/mkdir/SvnExeMkdirCommandTckTest.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.svn.svnexe.command.mkdir; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider.svn.svnexe.command.mkdir; import org.apache.maven.scm.provider.svn.command.mkdir.SvnMkdirCommandTckTest; @@ -27,12 +26,9 @@ * @author Maria Odea Ching * */ -public class SvnExeMkdirCommandTckTest - extends SvnMkdirCommandTckTest -{ +public class SvnExeMkdirCommandTckTest extends SvnMkdirCommandTckTest { @Override - public String getScmProviderCommand() - { + public String getScmProviderCommand() { return SVN_COMMAND_LINE; } } diff --git a/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/test/java/org/apache/maven/scm/provider/svn/svnexe/command/mkdir/SvnMkdirCommandTest.java b/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/test/java/org/apache/maven/scm/provider/svn/svnexe/command/mkdir/SvnMkdirCommandTest.java index d0e883a25..44cfe2614 100644 --- a/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/test/java/org/apache/maven/scm/provider/svn/svnexe/command/mkdir/SvnMkdirCommandTest.java +++ b/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/test/java/org/apache/maven/scm/provider/svn/svnexe/command/mkdir/SvnMkdirCommandTest.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.svn.svnexe.command.mkdir; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider.svn.svnexe.command.mkdir; import java.io.File; @@ -37,27 +36,22 @@ * @author Maria Odea Ching * */ -public class SvnMkdirCommandTest - extends ScmTestCase -{ +public class SvnMkdirCommandTest extends ScmTestCase { private File messageFile; String messageFileString; @Before @Override - public void setUp() - throws Exception - { + public void setUp() throws Exception { super.setUp(); - messageFile = new File( "mkdir-message" ); + messageFile = new File("mkdir-message"); String path = messageFile.getAbsolutePath(); - FileUtils.fileWrite( path, "create missing directory" ); + FileUtils.fileWrite(path, "create missing directory"); - if ( path.indexOf( ' ' ) >= 0 ) - { + if (path.indexOf(' ') >= 0) { path = "\"" + path + "\""; } messageFileString = "--file " + path + " --encoding UTF-8"; @@ -65,51 +59,45 @@ public void setUp() @After @Override - public void tearDown() - throws Exception - { - assertTrue( messageFile.delete() ); + public void tearDown() throws Exception { + assertTrue(messageFile.delete()); super.tearDown(); } @Test - public void testCommandLineMkdirUrl() - throws Exception - { - testCommandLine( "scm:svn:http://foo.com/svn/trunk", - "svn --non-interactive mkdir --parents http://foo.com/svn/trunk/missing@ " + messageFileString, false ); + public void testCommandLineMkdirUrl() throws Exception { + testCommandLine( + "scm:svn:http://foo.com/svn/trunk", + "svn --non-interactive mkdir --parents http://foo.com/svn/trunk/missing@ " + messageFileString, + false); } @Test - public void testCommandLineMkdirUrlWithUsername() - throws Exception - { - testCommandLine( "scm:svn:http://anonymous@foo.com/svn/trunk", - "svn --username anonymous --no-auth-cache --non-interactive mkdir --parents http://foo.com/svn/trunk/missing@ " + - messageFileString, false ); + public void testCommandLineMkdirUrlWithUsername() throws Exception { + testCommandLine( + "scm:svn:http://anonymous@foo.com/svn/trunk", + "svn --username anonymous --no-auth-cache --non-interactive mkdir --parents http://foo.com/svn/trunk/missing@ " + + messageFileString, + false); } @Test - public void testCommandLineMkdirLocalPath() - throws Exception - { - testCommandLine( "scm:svn:http://foo.com/svn/trunk", "svn --non-interactive mkdir --parents missing ", true ); + public void testCommandLineMkdirLocalPath() throws Exception { + testCommandLine("scm:svn:http://foo.com/svn/trunk", "svn --non-interactive mkdir --parents missing ", true); } - private void testCommandLine( String scmUrl, String commandLine, boolean createInLocal ) - throws Exception - { - File workingDirectory = getTestFile( "target/svn-mkdir-command-test" ); + private void testCommandLine(String scmUrl, String commandLine, boolean createInLocal) throws Exception { + File workingDirectory = getTestFile("target/svn-mkdir-command-test"); - ScmFileSet fileSet = new ScmFileSet( workingDirectory, new File( "missing" ) ); + ScmFileSet fileSet = new ScmFileSet(workingDirectory, new File("missing")); - ScmRepository repository = getScmManager().makeScmRepository( scmUrl ); + ScmRepository repository = getScmManager().makeScmRepository(scmUrl); SvnScmProviderRepository svnRepository = (SvnScmProviderRepository) repository.getProviderRepository(); - Commandline cl = SvnMkdirCommand.createCommandLine( svnRepository, fileSet, messageFile, createInLocal ); + Commandline cl = SvnMkdirCommand.createCommandLine(svnRepository, fileSet, messageFile, createInLocal); - assertCommandLine( commandLine, workingDirectory, cl ); + assertCommandLine(commandLine, workingDirectory, cl); } } diff --git a/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/test/java/org/apache/maven/scm/provider/svn/svnexe/command/remoteinfo/AbstractSvnExeRemoteInfoCommandTckTest.java b/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/test/java/org/apache/maven/scm/provider/svn/svnexe/command/remoteinfo/AbstractSvnExeRemoteInfoCommandTckTest.java index bf550f815..d954fd968 100644 --- a/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/test/java/org/apache/maven/scm/provider/svn/svnexe/command/remoteinfo/AbstractSvnExeRemoteInfoCommandTckTest.java +++ b/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/test/java/org/apache/maven/scm/provider/svn/svnexe/command/remoteinfo/AbstractSvnExeRemoteInfoCommandTckTest.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.svn.svnexe.command.remoteinfo; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,36 +16,31 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider.svn.svnexe.command.remoteinfo; import org.apache.maven.scm.command.remoteinfo.RemoteInfoScmResult; import org.apache.maven.scm.provider.svn.command.remoteinfo.AbstractSvnRemoteInfoCommandTckTest; import static org.apache.maven.scm.provider.svn.SvnScmTestUtils.SVN_COMMAND_LINE; - import static org.junit.Assert.assertTrue; /** * @author Bertrand Paquet */ -public abstract class AbstractSvnExeRemoteInfoCommandTckTest - extends AbstractSvnRemoteInfoCommandTckTest -{ +public abstract class AbstractSvnExeRemoteInfoCommandTckTest extends AbstractSvnRemoteInfoCommandTckTest { @Override - public String getScmProviderCommand() - { + public String getScmProviderCommand() { return SVN_COMMAND_LINE; } @Override - protected void checkResult( RemoteInfoScmResult result ) - { - assertTrue( result.getTags().containsKey( "maven-3.0" ) ); - String tagUrl = result.getTags().get( "maven-3.0" ); - assertTrue( tagUrl.endsWith( "/tags/maven-3.0/" ) ); - assertTrue( result.getBranches().containsKey( "MNG-3004" ) ); - String branchUrl = result.getBranches().get( "MNG-3004" ); - assertTrue( branchUrl.endsWith( "/branches/MNG-3004/" ) ); + protected void checkResult(RemoteInfoScmResult result) { + assertTrue(result.getTags().containsKey("maven-3.0")); + String tagUrl = result.getTags().get("maven-3.0"); + assertTrue(tagUrl.endsWith("/tags/maven-3.0/")); + assertTrue(result.getBranches().containsKey("MNG-3004")); + String branchUrl = result.getBranches().get("MNG-3004"); + assertTrue(branchUrl.endsWith("/branches/MNG-3004/")); } - } diff --git a/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/test/java/org/apache/maven/scm/provider/svn/svnexe/command/remoteinfo/SvnExeRemoteInfoCommandTckTest.java b/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/test/java/org/apache/maven/scm/provider/svn/svnexe/command/remoteinfo/SvnExeRemoteInfoCommandTckTest.java index 458c70fc8..1a1ce67c5 100644 --- a/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/test/java/org/apache/maven/scm/provider/svn/svnexe/command/remoteinfo/SvnExeRemoteInfoCommandTckTest.java +++ b/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/test/java/org/apache/maven/scm/provider/svn/svnexe/command/remoteinfo/SvnExeRemoteInfoCommandTckTest.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.svn.svnexe.command.remoteinfo; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider.svn.svnexe.command.remoteinfo; import org.apache.maven.scm.provider.ScmProviderRepository; import org.apache.maven.scm.provider.svn.repository.SvnScmProviderRepository; @@ -25,15 +24,10 @@ /** * @author Bertrand Paquet */ -public class SvnExeRemoteInfoCommandTckTest - extends AbstractSvnExeRemoteInfoCommandTckTest -{ +public class SvnExeRemoteInfoCommandTckTest extends AbstractSvnExeRemoteInfoCommandTckTest { @Override - protected ScmProviderRepository getScmProviderRepository() - throws Exception - { - return new SvnScmProviderRepository( "http://svn.apache.org/repos/asf/maven/maven-3/trunk" ); + protected ScmProviderRepository getScmProviderRepository() throws Exception { + return new SvnScmProviderRepository("http://svn.apache.org/repos/asf/maven/maven-3/trunk"); } - } diff --git a/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/test/java/org/apache/maven/scm/provider/svn/svnexe/command/remoteinfo/SvnExeRemoteInfoCommandTrailingSlashTckTest.java b/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/test/java/org/apache/maven/scm/provider/svn/svnexe/command/remoteinfo/SvnExeRemoteInfoCommandTrailingSlashTckTest.java index 70bfd965a..ebe6dd91a 100644 --- a/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/test/java/org/apache/maven/scm/provider/svn/svnexe/command/remoteinfo/SvnExeRemoteInfoCommandTrailingSlashTckTest.java +++ b/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/test/java/org/apache/maven/scm/provider/svn/svnexe/command/remoteinfo/SvnExeRemoteInfoCommandTrailingSlashTckTest.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.svn.svnexe.command.remoteinfo; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider.svn.svnexe.command.remoteinfo; import org.apache.maven.scm.provider.ScmProviderRepository; import org.apache.maven.scm.provider.svn.repository.SvnScmProviderRepository; @@ -25,15 +24,10 @@ /** * @author Bertrand Paquet */ -public class SvnExeRemoteInfoCommandTrailingSlashTckTest - extends AbstractSvnExeRemoteInfoCommandTckTest -{ +public class SvnExeRemoteInfoCommandTrailingSlashTckTest extends AbstractSvnExeRemoteInfoCommandTckTest { @Override - protected ScmProviderRepository getScmProviderRepository() - throws Exception - { - return new SvnScmProviderRepository( "http://svn.apache.org/repos/asf/maven/maven-3/trunk/" ); + protected ScmProviderRepository getScmProviderRepository() throws Exception { + return new SvnScmProviderRepository("http://svn.apache.org/repos/asf/maven/maven-3/trunk/"); } - } diff --git a/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/test/java/org/apache/maven/scm/provider/svn/svnexe/command/remoteinfo/SvnRemoteInfoCommandTest.java b/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/test/java/org/apache/maven/scm/provider/svn/svnexe/command/remoteinfo/SvnRemoteInfoCommandTest.java index ae6a36bfa..acfdbc953 100644 --- a/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/test/java/org/apache/maven/scm/provider/svn/svnexe/command/remoteinfo/SvnRemoteInfoCommandTest.java +++ b/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/test/java/org/apache/maven/scm/provider/svn/svnexe/command/remoteinfo/SvnRemoteInfoCommandTest.java @@ -1,4 +1,3 @@ -package org.apache.maven.scm.provider.svn.svnexe.command.remoteinfo; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -17,45 +16,39 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider.svn.svnexe.command.remoteinfo; import org.apache.maven.scm.ScmTestCase; import org.apache.maven.scm.provider.svn.repository.SvnScmProviderRepository; import org.junit.Test; import static org.apache.maven.scm.provider.svn.SvnScmTestUtils.SVN_COMMAND_LINE; - import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; /** * @author Olivier Lamy */ -public class SvnRemoteInfoCommandTest - extends ScmTestCase -{ +public class SvnRemoteInfoCommandTest extends ScmTestCase { @Test - public void testExist() - throws Exception - { - checkScmPresence( SVN_COMMAND_LINE ); + public void testExist() throws Exception { + checkScmPresence(SVN_COMMAND_LINE); SvnRemoteInfoCommand svnRemoteInfoCommand = new SvnRemoteInfoCommand(); SvnScmProviderRepository svnScmProviderRepository = - new SvnScmProviderRepository( "http://svn.apache.org/repos/asf/maven/scm/trunk/" ); - assertTrue( svnRemoteInfoCommand.remoteUrlExist( svnScmProviderRepository, null ) ); + new SvnScmProviderRepository("http://svn.apache.org/repos/asf/maven/scm/trunk/"); + assertTrue(svnRemoteInfoCommand.remoteUrlExist(svnScmProviderRepository, null)); } @Test - public void testNotExist() - throws Exception - { - checkScmPresence( SVN_COMMAND_LINE ); + public void testNotExist() throws Exception { + checkScmPresence(SVN_COMMAND_LINE); SvnRemoteInfoCommand svnRemoteInfoCommand = new SvnRemoteInfoCommand(); SvnScmProviderRepository svnScmProviderRepository = - new SvnScmProviderRepository( "http://svn.apache.org/repos/asf/maven/scm/trunk/foo/bar/beer" ); - assertFalse( svnRemoteInfoCommand.remoteUrlExist( svnScmProviderRepository, null ) ); + new SvnScmProviderRepository("http://svn.apache.org/repos/asf/maven/scm/trunk/foo/bar/beer"); + assertFalse(svnRemoteInfoCommand.remoteUrlExist(svnScmProviderRepository, null)); } } diff --git a/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/test/java/org/apache/maven/scm/provider/svn/svnexe/command/remove/SvnExeRemoveCommandTckTest.java b/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/test/java/org/apache/maven/scm/provider/svn/svnexe/command/remove/SvnExeRemoveCommandTckTest.java index 3dcf4c408..3245ea9a5 100644 --- a/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/test/java/org/apache/maven/scm/provider/svn/svnexe/command/remove/SvnExeRemoveCommandTckTest.java +++ b/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/test/java/org/apache/maven/scm/provider/svn/svnexe/command/remove/SvnExeRemoveCommandTckTest.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.svn.svnexe.command.remove; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider.svn.svnexe.command.remove; import org.apache.maven.scm.provider.svn.command.remove.SvnRemoveCommandTckTest; @@ -26,12 +25,9 @@ /** * */ -public class SvnExeRemoveCommandTckTest - extends SvnRemoveCommandTckTest -{ +public class SvnExeRemoveCommandTckTest extends SvnRemoveCommandTckTest { @Override - public String getScmProviderCommand() - { + public String getScmProviderCommand() { return SVN_COMMAND_LINE; } } diff --git a/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/test/java/org/apache/maven/scm/provider/svn/svnexe/command/status/SvnExeStatusCommandTckTest.java b/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/test/java/org/apache/maven/scm/provider/svn/svnexe/command/status/SvnExeStatusCommandTckTest.java index c19b55e7e..b1e293424 100644 --- a/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/test/java/org/apache/maven/scm/provider/svn/svnexe/command/status/SvnExeStatusCommandTckTest.java +++ b/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/test/java/org/apache/maven/scm/provider/svn/svnexe/command/status/SvnExeStatusCommandTckTest.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.svn.svnexe.command.status; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider.svn.svnexe.command.status; import org.apache.maven.scm.provider.svn.command.status.SvnStatusCommandTckTest; @@ -27,12 +26,9 @@ * @author Brett Porter * */ -public class SvnExeStatusCommandTckTest - extends SvnStatusCommandTckTest -{ +public class SvnExeStatusCommandTckTest extends SvnStatusCommandTckTest { @Override - public String getScmProviderCommand() - { + public String getScmProviderCommand() { return SVN_COMMAND_LINE; } } diff --git a/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/test/java/org/apache/maven/scm/provider/svn/svnexe/command/tag/SvnExeTagCommandTckTest.java b/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/test/java/org/apache/maven/scm/provider/svn/svnexe/command/tag/SvnExeTagCommandTckTest.java index 58a4eb33d..3f8c3ded4 100644 --- a/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/test/java/org/apache/maven/scm/provider/svn/svnexe/command/tag/SvnExeTagCommandTckTest.java +++ b/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/test/java/org/apache/maven/scm/provider/svn/svnexe/command/tag/SvnExeTagCommandTckTest.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.svn.svnexe.command.tag; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider.svn.svnexe.command.tag; import java.io.File; @@ -36,107 +35,121 @@ * @author Brett Porter * */ -public class SvnExeTagCommandTckTest - extends SvnTagCommandTckTest -{ +public class SvnExeTagCommandTckTest extends SvnTagCommandTckTest { @Override - public String getScmProviderCommand() - { + public String getScmProviderCommand() { return SVN_COMMAND_LINE; } @Test - public void testTagUserNameSvnSsh() - throws Exception - { - File messageFile = File.createTempFile( "maven-scm", "commit" ); + public void testTagUserNameSvnSsh() throws Exception { + File messageFile = File.createTempFile("maven-scm", "commit"); messageFile.deleteOnExit(); - testCommandLine( "scm:svn:svn+ssh://foo.com/svn/trunk", "svntag", messageFile, "user", - "svn --username user --no-auth-cache --non-interactive copy --file " + messageFile.getAbsolutePath() + - " --encoding UTF-8 --parents . svn+ssh://user@foo.com/svn/tags/svntag@", null ); + testCommandLine( + "scm:svn:svn+ssh://foo.com/svn/trunk", + "svntag", + messageFile, + "user", + "svn --username user --no-auth-cache --non-interactive copy --file " + messageFile.getAbsolutePath() + + " --encoding UTF-8 --parents . svn+ssh://user@foo.com/svn/tags/svntag@", + null); } @Test - public void testTagRemoteTagHttps() - throws Exception - { - File messageFile = File.createTempFile( "maven-scm", "commit" ); + public void testTagRemoteTagHttps() throws Exception { + File messageFile = File.createTempFile("maven-scm", "commit"); messageFile.deleteOnExit(); ScmTagParameters scmTagParameters = new ScmTagParameters(); - scmTagParameters.setRemoteTagging( true ); - scmTagParameters.setPinExternals( false ); - testCommandLine( "scm:svn:https://foo.com/svn/trunk", "svntag", messageFile, "user", - "svn --username user --no-auth-cache --non-interactive copy --file " + messageFile.getAbsolutePath() - + " --encoding UTF-8 --parents https://foo.com/svn/trunk@ https://foo.com/svn/tags/svntag@", scmTagParameters ); + scmTagParameters.setRemoteTagging(true); + scmTagParameters.setPinExternals(false); + testCommandLine( + "scm:svn:https://foo.com/svn/trunk", + "svntag", + messageFile, + "user", + "svn --username user --no-auth-cache --non-interactive copy --file " + messageFile.getAbsolutePath() + + " --encoding UTF-8 --parents https://foo.com/svn/trunk@ https://foo.com/svn/tags/svntag@", + scmTagParameters); } @Test - public void testTagRemoteTagHttpsWithPinExternals() - throws Exception - { - File messageFile = File.createTempFile( "maven-scm", "commit" ); + public void testTagRemoteTagHttpsWithPinExternals() throws Exception { + File messageFile = File.createTempFile("maven-scm", "commit"); messageFile.deleteOnExit(); ScmTagParameters scmTagParameters = new ScmTagParameters(); - scmTagParameters.setRemoteTagging( true ); - scmTagParameters.setPinExternals( true ); - testCommandLine( "scm:svn:https://foo.com/svn/trunk", "svntag", messageFile, "user", - "svn --username user --no-auth-cache --non-interactive copy --file " + messageFile.getAbsolutePath() - + " --encoding UTF-8 --parents --pin-externals https://foo.com/svn/trunk@ https://foo.com/svn/tags/svntag@", scmTagParameters ); + scmTagParameters.setRemoteTagging(true); + scmTagParameters.setPinExternals(true); + testCommandLine( + "scm:svn:https://foo.com/svn/trunk", + "svntag", + messageFile, + "user", + "svn --username user --no-auth-cache --non-interactive copy --file " + messageFile.getAbsolutePath() + + " --encoding UTF-8 --parents --pin-externals https://foo.com/svn/trunk@ https://foo.com/svn/tags/svntag@", + scmTagParameters); } @Test - public void testTagRemoteTagHttpsWithRevision() - throws Exception - { - File messageFile = File.createTempFile( "maven-scm", "commit" ); + public void testTagRemoteTagHttpsWithRevision() throws Exception { + File messageFile = File.createTempFile("maven-scm", "commit"); messageFile.deleteOnExit(); ScmTagParameters scmTagParameters = new ScmTagParameters(); - scmTagParameters.setRemoteTagging( true ); - scmTagParameters.setPinExternals( false ); - scmTagParameters.setScmRevision( "12" ); - testCommandLine( "scm:svn:https://foo.com/svn/trunk", "svntag", messageFile, "user", - "svn --username user --no-auth-cache --non-interactive copy --file " + messageFile.getAbsolutePath() - + " --encoding UTF-8 --parents --revision 12 https://foo.com/svn/trunk@ https://foo.com/svn/tags/svntag@", - scmTagParameters ); + scmTagParameters.setRemoteTagging(true); + scmTagParameters.setPinExternals(false); + scmTagParameters.setScmRevision("12"); + testCommandLine( + "scm:svn:https://foo.com/svn/trunk", + "svntag", + messageFile, + "user", + "svn --username user --no-auth-cache --non-interactive copy --file " + messageFile.getAbsolutePath() + + " --encoding UTF-8 --parents --revision 12 https://foo.com/svn/trunk@ https://foo.com/svn/tags/svntag@", + scmTagParameters); } @Test - public void testTagRemoteTagHttpsWithRevisionAndPinExternals() - throws Exception - { - File messageFile = File.createTempFile( "maven-scm", "commit" ); + public void testTagRemoteTagHttpsWithRevisionAndPinExternals() throws Exception { + File messageFile = File.createTempFile("maven-scm", "commit"); messageFile.deleteOnExit(); ScmTagParameters scmTagParameters = new ScmTagParameters(); - scmTagParameters.setRemoteTagging( true ); - scmTagParameters.setPinExternals( true ); - scmTagParameters.setScmRevision( "12" ); - testCommandLine( "scm:svn:https://foo.com/svn/trunk", "svntag", messageFile, "user", - "svn --username user --no-auth-cache --non-interactive copy --file " + messageFile.getAbsolutePath() - + " --encoding UTF-8 --parents --revision 12 --pin-externals https://foo.com/svn/trunk@ https://foo.com/svn/tags/svntag@", - scmTagParameters ); + scmTagParameters.setRemoteTagging(true); + scmTagParameters.setPinExternals(true); + scmTagParameters.setScmRevision("12"); + testCommandLine( + "scm:svn:https://foo.com/svn/trunk", + "svntag", + messageFile, + "user", + "svn --username user --no-auth-cache --non-interactive copy --file " + messageFile.getAbsolutePath() + + " --encoding UTF-8 --parents --revision 12 --pin-externals https://foo.com/svn/trunk@ https://foo.com/svn/tags/svntag@", + scmTagParameters); } - private void testCommandLine( String scmUrl, String tag, File messageFile, String user, String commandLine, - ScmTagParameters scmTagParameters ) - throws Exception - { - File workingDirectory = getTestFile( "target/svn-update-command-test" ); + private void testCommandLine( + String scmUrl, + String tag, + File messageFile, + String user, + String commandLine, + ScmTagParameters scmTagParameters) + throws Exception { + File workingDirectory = getTestFile("target/svn-update-command-test"); - ScmRepository repository = getScmManager().makeScmRepository( scmUrl ); + ScmRepository repository = getScmManager().makeScmRepository(scmUrl); SvnScmProviderRepository svnRepository = (SvnScmProviderRepository) repository.getProviderRepository(); - svnRepository.setUser( user ); + svnRepository.setUser(user); Commandline cl = null; - cl = SvnTagCommand.createCommandLine( svnRepository, workingDirectory, tag, messageFile, scmTagParameters ); + cl = SvnTagCommand.createCommandLine(svnRepository, workingDirectory, tag, messageFile, scmTagParameters); - assertCommandLine( commandLine, workingDirectory, cl ); + assertCommandLine(commandLine, workingDirectory, cl); } } diff --git a/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/test/java/org/apache/maven/scm/provider/svn/svnexe/command/untag/SvnExeUntagCommandTckTest.java b/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/test/java/org/apache/maven/scm/provider/svn/svnexe/command/untag/SvnExeUntagCommandTckTest.java index 92da7c6e6..7feedb1e4 100644 --- a/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/test/java/org/apache/maven/scm/provider/svn/svnexe/command/untag/SvnExeUntagCommandTckTest.java +++ b/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/test/java/org/apache/maven/scm/provider/svn/svnexe/command/untag/SvnExeUntagCommandTckTest.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.svn.svnexe.command.untag; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,10 +16,11 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider.svn.svnexe.command.untag; import java.io.File; -import org.apache.maven.scm.ScmFileSet; +import org.apache.maven.scm.ScmFileSet; import org.apache.maven.scm.provider.svn.command.untag.SvnUntagCommandTckTest; import org.apache.maven.scm.provider.svn.repository.SvnScmProviderRepository; import org.apache.maven.scm.repository.ScmRepository; @@ -34,12 +33,9 @@ * This test tests the untag command for Subversion. * */ -public class SvnExeUntagCommandTckTest - extends SvnUntagCommandTckTest -{ +public class SvnExeUntagCommandTckTest extends SvnUntagCommandTckTest { @Override - public String getScmProviderCommand() - { + public String getScmProviderCommand() { return SVN_COMMAND_LINE; } @@ -49,17 +45,20 @@ public String getScmProviderCommand() * @throws Exception in case of error */ @Test - public void testUntagSsh() - throws Exception - { - File messageFile = File.createTempFile( "maven-scm", "commit" ); + public void testUntagSsh() throws Exception { + File messageFile = File.createTempFile("maven-scm", "commit"); messageFile.deleteOnExit(); - ScmFileSet scmFileSet = new ScmFileSet( new File ( "target/svn-untag-command-test" ) ); + ScmFileSet scmFileSet = new ScmFileSet(new File("target/svn-untag-command-test")); - testCommandLine( "scm:svn:svn+ssh://foo.com/svn/trunk", scmFileSet, "svntag", messageFile, - "user", "svn --username user --no-auth-cache --non-interactive --file " - + messageFile.getAbsolutePath() + " remove svn+ssh://user@foo.com/svn/tags/svntag@" ); + testCommandLine( + "scm:svn:svn+ssh://foo.com/svn/trunk", + scmFileSet, + "svntag", + messageFile, + "user", + "svn --username user --no-auth-cache --non-interactive --file " + messageFile.getAbsolutePath() + + " remove svn+ssh://user@foo.com/svn/tags/svntag@"); } /** @@ -68,17 +67,20 @@ public void testUntagSsh() * @throws Exception in case of error */ @Test - public void testUntagHttps() - throws Exception - { - File messageFile = File.createTempFile( "maven-scm", "commit" ); + public void testUntagHttps() throws Exception { + File messageFile = File.createTempFile("maven-scm", "commit"); messageFile.deleteOnExit(); - ScmFileSet scmFileSet = new ScmFileSet( new File ( "target/svn-untag-command-test" ) ); + ScmFileSet scmFileSet = new ScmFileSet(new File("target/svn-untag-command-test")); - testCommandLine( "scm:svn:https://foo.com/svn/tags", scmFileSet, "svntag", messageFile, - "user", "svn --username user --no-auth-cache --non-interactive --file " - + messageFile.getAbsolutePath() + " remove https://foo.com/svn/tags/svntag@" ); + testCommandLine( + "scm:svn:https://foo.com/svn/tags", + scmFileSet, + "svntag", + messageFile, + "user", + "svn --username user --no-auth-cache --non-interactive --file " + messageFile.getAbsolutePath() + + " remove https://foo.com/svn/tags/svntag@"); } /** @@ -92,20 +94,19 @@ public void testUntagHttps() * @param commandLine set command line for comparison * @throws Exception in case of error */ - private void testCommandLine( String scmUrl, ScmFileSet scmFileSet, String tag, File messageFile, String user, - String commandLine ) - throws Exception - { - File workingDirectory = getTestFile( "target/svn-untag-command-test" ); + private void testCommandLine( + String scmUrl, ScmFileSet scmFileSet, String tag, File messageFile, String user, String commandLine) + throws Exception { + File workingDirectory = getTestFile("target/svn-untag-command-test"); - ScmRepository repository = getScmManager().makeScmRepository( scmUrl ); + ScmRepository repository = getScmManager().makeScmRepository(scmUrl); SvnScmProviderRepository svnRepository = (SvnScmProviderRepository) repository.getProviderRepository(); - svnRepository.setUser( user ); + svnRepository.setUser(user); - Commandline cl = new SvnUntagCommand().createCommandline( svnRepository, scmFileSet, tag, messageFile ); + Commandline cl = new SvnUntagCommand().createCommandline(svnRepository, scmFileSet, tag, messageFile); - assertCommandLine( commandLine, workingDirectory, cl ); + assertCommandLine(commandLine, workingDirectory, cl); } } diff --git a/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/test/java/org/apache/maven/scm/provider/svn/svnexe/command/untag/SvnUntagCommandTest.java b/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/test/java/org/apache/maven/scm/provider/svn/svnexe/command/untag/SvnUntagCommandTest.java index a503b0c31..c514c8091 100644 --- a/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/test/java/org/apache/maven/scm/provider/svn/svnexe/command/untag/SvnUntagCommandTest.java +++ b/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/test/java/org/apache/maven/scm/provider/svn/svnexe/command/untag/SvnUntagCommandTest.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.svn.svnexe.command.untag; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,23 +16,22 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider.svn.svnexe.command.untag; + +import java.io.File; +import org.apache.maven.scm.ScmFileSet; import org.apache.maven.scm.ScmTestCase; import org.apache.maven.scm.provider.svn.repository.SvnScmProviderRepository; import org.apache.maven.scm.repository.ScmRepository; import org.codehaus.plexus.util.cli.Commandline; - -import java.io.File; -import org.apache.maven.scm.ScmFileSet; import org.junit.Test; /** * test the subversion untag implementation * */ -public class SvnUntagCommandTest - extends ScmTestCase -{ +public class SvnUntagCommandTest extends ScmTestCase { /** * test with http repo and user @@ -42,16 +39,19 @@ public class SvnUntagCommandTest * @throws Exception in case of error */ @Test - public void testUntagHttp() - throws Exception - { + public void testUntagHttp() throws Exception { - File messageFile = File.createTempFile( "maven-scm", "untag" ); + File messageFile = File.createTempFile("maven-scm", "untag"); messageFile.deleteOnExit(); - testCommandLine( "scm:svn:http://foo.com/svn/tags", new ScmFileSet( getUntagTestFile() ), "svntag", "user", - messageFile, "svn --username user --no-auth-cache --non-interactive " - + "--file " + messageFile.getAbsolutePath() + " remove http://foo.com/svn/tags/svntag@" ); + testCommandLine( + "scm:svn:http://foo.com/svn/tags", + new ScmFileSet(getUntagTestFile()), + "svntag", + "user", + messageFile, + "svn --username user --no-auth-cache --non-interactive " + "--file " + messageFile.getAbsolutePath() + + " remove http://foo.com/svn/tags/svntag@"); } /** @@ -60,16 +60,19 @@ public void testUntagHttp() * @throws Exception in case of error */ @Test - public void testUntagSsh() - throws Exception - { + public void testUntagSsh() throws Exception { - File messageFile = File.createTempFile( "maven-scm", "untag" ); + File messageFile = File.createTempFile("maven-scm", "untag"); messageFile.deleteOnExit(); - testCommandLine( "scm:svn:svn+ssh://foo.com/svn/tags", new ScmFileSet( getUntagTestFile() ), "svntag", "user", - messageFile, "svn --username user --no-auth-cache --non-interactive " - + "--file " + messageFile.getAbsolutePath() + " remove svn+ssh://user@foo.com/svn/tags/svntag@" ); + testCommandLine( + "scm:svn:svn+ssh://foo.com/svn/tags", + new ScmFileSet(getUntagTestFile()), + "svntag", + "user", + messageFile, + "svn --username user --no-auth-cache --non-interactive " + "--file " + messageFile.getAbsolutePath() + + " remove svn+ssh://user@foo.com/svn/tags/svntag@"); } /** @@ -77,9 +80,8 @@ public void testUntagSsh() * * @return local dir */ - private File getUntagTestFile() - { - return getTestFile( "target/svn-untag-command-test" ); + private File getUntagTestFile() { + return getTestFile("target/svn-untag-command-test"); } /** @@ -89,10 +91,8 @@ private File getUntagTestFile() * @return svn repo instance * @throws Exception in case of error */ - private SvnScmProviderRepository getSvnRepository( String scmUrl ) - throws Exception - { - ScmRepository repository = getScmManager().makeScmRepository( scmUrl ); + private SvnScmProviderRepository getSvnRepository(String scmUrl) throws Exception { + ScmRepository repository = getScmManager().makeScmRepository(scmUrl); return (SvnScmProviderRepository) repository.getProviderRepository(); } @@ -108,13 +108,13 @@ private SvnScmProviderRepository getSvnRepository( String scmUrl ) * @param commandline set command line to compare actual to * @throws Exception in case of error */ - private void testCommandLine( String scmUrl, ScmFileSet scmFileSet, String tag, String user, File messageFile, - String commandline ) throws Exception - { - SvnScmProviderRepository repo = getSvnRepository( scmUrl ); + private void testCommandLine( + String scmUrl, ScmFileSet scmFileSet, String tag, String user, File messageFile, String commandline) + throws Exception { + SvnScmProviderRepository repo = getSvnRepository(scmUrl); repo.setUser(user); - Commandline cl = new SvnUntagCommand().createCommandline( repo, scmFileSet, tag, messageFile ); + Commandline cl = new SvnUntagCommand().createCommandline(repo, scmFileSet, tag, messageFile); - assertCommandLine( commandline, scmFileSet.getBasedir(), cl ); + assertCommandLine(commandline, scmFileSet.getBasedir(), cl); } } diff --git a/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/test/java/org/apache/maven/scm/provider/svn/svnexe/command/update/SvnExeUpdateCommandTckTest.java b/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/test/java/org/apache/maven/scm/provider/svn/svnexe/command/update/SvnExeUpdateCommandTckTest.java index f0997a524..9e050520f 100644 --- a/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/test/java/org/apache/maven/scm/provider/svn/svnexe/command/update/SvnExeUpdateCommandTckTest.java +++ b/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/test/java/org/apache/maven/scm/provider/svn/svnexe/command/update/SvnExeUpdateCommandTckTest.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.svn.svnexe.command.update; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider.svn.svnexe.command.update; import org.apache.maven.scm.provider.svn.command.update.SvnUpdateCommandTckTest; @@ -27,12 +26,9 @@ * @author Trygve Laugstøl * */ -public class SvnExeUpdateCommandTckTest - extends SvnUpdateCommandTckTest -{ +public class SvnExeUpdateCommandTckTest extends SvnUpdateCommandTckTest { @Override - public String getScmProviderCommand() - { + public String getScmProviderCommand() { return SVN_COMMAND_LINE; } } diff --git a/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/test/java/org/apache/maven/scm/provider/svn/svnexe/command/update/SvnUpdateCommandTest.java b/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/test/java/org/apache/maven/scm/provider/svn/svnexe/command/update/SvnUpdateCommandTest.java index d4b938a56..d9b87493b 100644 --- a/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/test/java/org/apache/maven/scm/provider/svn/svnexe/command/update/SvnUpdateCommandTest.java +++ b/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/test/java/org/apache/maven/scm/provider/svn/svnexe/command/update/SvnUpdateCommandTest.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.svn.svnexe.command.update; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,9 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider.svn.svnexe.command.update; + +import java.io.File; import org.apache.maven.scm.ScmBranch; import org.apache.maven.scm.ScmRevision; @@ -31,188 +32,173 @@ import org.codehaus.plexus.util.cli.Commandline; import org.junit.Test; -import java.io.File; - import static org.junit.Assert.assertTrue; /** * @author Emmanuel Venisse * */ -public class SvnUpdateCommandTest - extends ScmTestCase -{ +public class SvnUpdateCommandTest extends ScmTestCase { @Test - public void testCommandLineWithEmptyTag() - throws Exception - { - testCommandLine( "scm:svn:http://foo.com/svn/trunk", new ScmTag( "" ), - "svn --non-interactive update " + getUpdateTestFile().getAbsolutePath() + "@" ); + public void testCommandLineWithEmptyTag() throws Exception { + testCommandLine( + "scm:svn:http://foo.com/svn/trunk", + new ScmTag(""), + "svn --non-interactive update " + getUpdateTestFile().getAbsolutePath() + "@"); } @Test - public void testCommandLineWithEmptyBranch() - throws Exception - { - testCommandLine( "scm:svn:http://foo.com/svn/trunk", new ScmBranch( "" ), - "svn --non-interactive update " + getUpdateTestFile().getAbsolutePath() + "@" ); + public void testCommandLineWithEmptyBranch() throws Exception { + testCommandLine( + "scm:svn:http://foo.com/svn/trunk", + new ScmBranch(""), + "svn --non-interactive update " + getUpdateTestFile().getAbsolutePath() + "@"); } @Test - public void testCommandLineWithEmptyVersion() - throws Exception - { - testCommandLine( "scm:svn:http://foo.com/svn/trunk", new ScmRevision( "" ), - "svn --non-interactive update " + getUpdateTestFile().getAbsolutePath() + "@" ); + public void testCommandLineWithEmptyVersion() throws Exception { + testCommandLine( + "scm:svn:http://foo.com/svn/trunk", + new ScmRevision(""), + "svn --non-interactive update " + getUpdateTestFile().getAbsolutePath() + "@"); } @Test - public void testCommandLineWithWhitespaceTag() - throws Exception - { - testCommandLine( "scm:svn:http://foo.com/svn/trunk", new ScmTag( " " ), - "svn --non-interactive update " + getUpdateTestFile().getAbsolutePath() + "@" ); + public void testCommandLineWithWhitespaceTag() throws Exception { + testCommandLine( + "scm:svn:http://foo.com/svn/trunk", + new ScmTag(" "), + "svn --non-interactive update " + getUpdateTestFile().getAbsolutePath() + "@"); } @Test - public void testCommandLineWithWhitespaceBranch() - throws Exception - { - testCommandLine( "scm:svn:http://foo.com/svn/trunk", new ScmBranch( " " ), - "svn --non-interactive update " + getUpdateTestFile().getAbsolutePath() + "@" ); + public void testCommandLineWithWhitespaceBranch() throws Exception { + testCommandLine( + "scm:svn:http://foo.com/svn/trunk", + new ScmBranch(" "), + "svn --non-interactive update " + getUpdateTestFile().getAbsolutePath() + "@"); } @Test - public void testCommandLineWithWhitespaceRevision() - throws Exception - { - testCommandLine( "scm:svn:http://foo.com/svn/trunk", new ScmRevision( " " ), - "svn --non-interactive update " + getUpdateTestFile().getAbsolutePath() + "@" ); + public void testCommandLineWithWhitespaceRevision() throws Exception { + testCommandLine( + "scm:svn:http://foo.com/svn/trunk", + new ScmRevision(" "), + "svn --non-interactive update " + getUpdateTestFile().getAbsolutePath() + "@"); } @Test - public void testCommandLineWithoutTag() - throws Exception - { - testCommandLine( "scm:svn:http://foo.com/svn/trunk", null, - "svn --non-interactive update " + getUpdateTestFile().getAbsolutePath() + "@" ); + public void testCommandLineWithoutTag() throws Exception { + testCommandLine( + "scm:svn:http://foo.com/svn/trunk", + null, + "svn --non-interactive update " + getUpdateTestFile().getAbsolutePath() + "@"); } @Test - public void testCommandLineTag() - throws Exception - { - testCommandLine( "scm:svn:http://anonymous@foo.com/svn/trunk", new ScmRevision( "10" ), - "svn --username anonymous --no-auth-cache --non-interactive update -r 10 " + - getUpdateTestFile().getAbsolutePath() + "@" ); + public void testCommandLineTag() throws Exception { + testCommandLine( + "scm:svn:http://anonymous@foo.com/svn/trunk", + new ScmRevision("10"), + "svn --username anonymous --no-auth-cache --non-interactive update -r 10 " + + getUpdateTestFile().getAbsolutePath() + "@"); } @Test - public void testCommandLineWithUsernameAndTag() - throws Exception - { - testCommandLine( "scm:svn:http://anonymous@foo.com/svn/trunk", new ScmRevision( "10" ), - "svn --username anonymous --no-auth-cache --non-interactive update -r 10 " + - getUpdateTestFile().getAbsolutePath() + "@" ); + public void testCommandLineWithUsernameAndTag() throws Exception { + testCommandLine( + "scm:svn:http://anonymous@foo.com/svn/trunk", + new ScmRevision("10"), + "svn --username anonymous --no-auth-cache --non-interactive update -r 10 " + + getUpdateTestFile().getAbsolutePath() + "@"); } @Test - public void testCommandLineWithCygwinProperty() - throws Exception - { - if ( Os.isFamily( Os.FAMILY_WINDOWS ) ) - { - SvnUtil.setSettingsDirectory( getTestFile( "src/test/resources/svn/update/cygwin" ) ); - try - { - assertTrue( SvnUtil.getSettings().isUseCygwinPath() ); - testCommandLine( "scm:svn:http://foo.com/svn/trunk", null, - "svn --non-interactive update /mnt/c/my_working_directory@", - new File( "c:\\my_working_directory" ) ); - } - finally - { - SvnUtil.setSettingsDirectory( SvnUtil.DEFAULT_SETTINGS_DIRECTORY ); + public void testCommandLineWithCygwinProperty() throws Exception { + if (Os.isFamily(Os.FAMILY_WINDOWS)) { + SvnUtil.setSettingsDirectory(getTestFile("src/test/resources/svn/update/cygwin")); + try { + assertTrue(SvnUtil.getSettings().isUseCygwinPath()); + testCommandLine( + "scm:svn:http://foo.com/svn/trunk", + null, + "svn --non-interactive update /mnt/c/my_working_directory@", + new File("c:\\my_working_directory")); + } finally { + SvnUtil.setSettingsDirectory(SvnUtil.DEFAULT_SETTINGS_DIRECTORY); } } } @Test - public void testCommandLineWithRelativeURLTag() - throws Exception - { - testCommandLine( "scm:svn:http://foo.com/svn/trunk", new ScmBranch( "branches/my-test-branch" ), - "svn --non-interactive switch http://foo.com/svn/branches/my-test-branch@ " + - getUpdateTestFile().getAbsolutePath() + "@" ); + public void testCommandLineWithRelativeURLTag() throws Exception { + testCommandLine( + "scm:svn:http://foo.com/svn/trunk", + new ScmBranch("branches/my-test-branch"), + "svn --non-interactive switch http://foo.com/svn/branches/my-test-branch@ " + + getUpdateTestFile().getAbsolutePath() + "@"); } @Test - public void testCommandLineWithAbsoluteURLTag() - throws Exception - { - testCommandLine( "scm:svn:http://foo.com/svn/trunk", - new ScmBranch( "http://foo.com/svn/branches/my-test-branch" ), - "svn --non-interactive switch http://foo.com/svn/branches/my-test-branch@ " + - getUpdateTestFile().getAbsolutePath() + "@" ); + public void testCommandLineWithAbsoluteURLTag() throws Exception { + testCommandLine( + "scm:svn:http://foo.com/svn/trunk", + new ScmBranch("http://foo.com/svn/branches/my-test-branch"), + "svn --non-interactive switch http://foo.com/svn/branches/my-test-branch@ " + + getUpdateTestFile().getAbsolutePath() + "@"); } @Test - public void testCommandLineWithNonDeterminantBase() - throws Exception - { - testCommandLine( "scm:svn:http://foo.com/svn/some-project", new ScmBranch( "branches/my-test-branch" ), - "svn --non-interactive switch http://foo.com/svn/some-project/branches/my-test-branch@ " + - getUpdateTestFile().getAbsolutePath() + "@" ); + public void testCommandLineWithNonDeterminantBase() throws Exception { + testCommandLine( + "scm:svn:http://foo.com/svn/some-project", + new ScmBranch("branches/my-test-branch"), + "svn --non-interactive switch http://foo.com/svn/some-project/branches/my-test-branch@ " + + getUpdateTestFile().getAbsolutePath() + "@"); } @Test - public void testCommandLineWithNonDeterminantBaseTrailingSlash() - throws Exception - { - testCommandLine( "scm:svn:http://foo.com/svn/some-project/", new ScmBranch( "branches/my-test-branch" ), - "svn --non-interactive switch http://foo.com/svn/some-project/branches/my-test-branch@ " + - getUpdateTestFile().getAbsolutePath() + "@" ); + public void testCommandLineWithNonDeterminantBaseTrailingSlash() throws Exception { + testCommandLine( + "scm:svn:http://foo.com/svn/some-project/", + new ScmBranch("branches/my-test-branch"), + "svn --non-interactive switch http://foo.com/svn/some-project/branches/my-test-branch@ " + + getUpdateTestFile().getAbsolutePath() + "@"); } @Test - public void testCommandLineWithBranchSameAsBase() - throws Exception - { - testCommandLine( "scm:svn:http://foo.com/svn/tags/my-tag", new ScmTag( "tags/my-tag" ), - "svn --non-interactive switch http://foo.com/svn/tags/my-tag@ " + - getUpdateTestFile().getAbsolutePath() + "@" ); + public void testCommandLineWithBranchSameAsBase() throws Exception { + testCommandLine( + "scm:svn:http://foo.com/svn/tags/my-tag", + new ScmTag("tags/my-tag"), + "svn --non-interactive switch http://foo.com/svn/tags/my-tag@ " + + getUpdateTestFile().getAbsolutePath() + "@"); } // ---------------------------------------------------------------------- // // ---------------------------------------------------------------------- - private File getUpdateTestFile() - { - return getTestFile( "target/svn-update-command-test" ); + private File getUpdateTestFile() { + return getTestFile("target/svn-update-command-test"); } - private SvnScmProviderRepository getSvnRepository( String scmUrl ) - throws Exception - { - ScmRepository repository = getScmManager().makeScmRepository( scmUrl ); + private SvnScmProviderRepository getSvnRepository(String scmUrl) throws Exception { + ScmRepository repository = getScmManager().makeScmRepository(scmUrl); return (SvnScmProviderRepository) repository.getProviderRepository(); } - private void testCommandLine( String scmUrl, ScmVersion version, String commandLine ) - throws Exception - { + private void testCommandLine(String scmUrl, ScmVersion version, String commandLine) throws Exception { File workingDirectory = getUpdateTestFile(); - testCommandLine( scmUrl, version, commandLine, workingDirectory ); + testCommandLine(scmUrl, version, commandLine, workingDirectory); } - private void testCommandLine( String scmUrl, ScmVersion version, String commandLine, File workingDirectory ) - throws Exception - { - Commandline cl = SvnUpdateCommand.createCommandLine( getSvnRepository( scmUrl ), workingDirectory, version ); + private void testCommandLine(String scmUrl, ScmVersion version, String commandLine, File workingDirectory) + throws Exception { + Commandline cl = SvnUpdateCommand.createCommandLine(getSvnRepository(scmUrl), workingDirectory, version); - assertCommandLine( commandLine, workingDirectory, cl ); + assertCommandLine(commandLine, workingDirectory, cl); } } diff --git a/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svntest/pom.xml b/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svntest/pom.xml index f8c5c788a..e3e2a60c0 100644 --- a/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svntest/pom.xml +++ b/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svntest/pom.xml @@ -1,5 +1,4 @@ - - 4.0.0 diff --git a/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svntest/src/main/java/org/apache/maven/scm/provider/svn/SvnScmTestUtils.java b/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svntest/src/main/java/org/apache/maven/scm/provider/svn/SvnScmTestUtils.java index 924ab539e..c186e5f0d 100644 --- a/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svntest/src/main/java/org/apache/maven/scm/provider/svn/SvnScmTestUtils.java +++ b/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svntest/src/main/java/org/apache/maven/scm/provider/svn/SvnScmTestUtils.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.svn; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,118 +16,107 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider.svn; + +import java.io.File; +import java.io.FileInputStream; +import java.io.InputStream; -import org.junit.Assert; import org.apache.maven.scm.ScmTestCase; import org.codehaus.plexus.util.FileUtils; import org.codehaus.plexus.util.cli.CommandLineException; import org.codehaus.plexus.util.cli.CommandLineUtils; import org.codehaus.plexus.util.cli.Commandline; - -import java.io.File; -import java.io.FileInputStream; -import java.io.InputStream; +import org.junit.Assert; /** * @author Trygve Laugstøl * */ -public final class SvnScmTestUtils -{ +public final class SvnScmTestUtils { /** 'svn' command line */ public static final String SVN_COMMAND_LINE = "svn"; /** 'svnadmin' command line */ public static final String SVNADMIN_COMMAND_LINE = "svnadmin"; - private SvnScmTestUtils() - { - } + private SvnScmTestUtils() {} - public static void initializeRepository( File repositoryRoot ) - throws Exception - { - if ( repositoryRoot.exists() ) - { - FileUtils.deleteDirectory( repositoryRoot ); + public static void initializeRepository(File repositoryRoot) throws Exception { + if (repositoryRoot.exists()) { + FileUtils.deleteDirectory(repositoryRoot); } - Assert.assertFalse( "repositoryRoot still exists", repositoryRoot.exists() ); + Assert.assertFalse("repositoryRoot still exists", repositoryRoot.exists()); - Assert.assertTrue( "Could not make repository root directory: " + repositoryRoot.getAbsolutePath(), - repositoryRoot.mkdirs() ); + Assert.assertTrue( + "Could not make repository root directory: " + repositoryRoot.getAbsolutePath(), + repositoryRoot.mkdirs()); - ScmTestCase.execute( repositoryRoot.getParentFile(), SVNADMIN_COMMAND_LINE, - "create " + repositoryRoot.getName() ); + ScmTestCase.execute( + repositoryRoot.getParentFile(), SVNADMIN_COMMAND_LINE, "create " + repositoryRoot.getName()); - loadSvnDump( repositoryRoot, - new SvnScmTestUtils().getClass().getClassLoader().getResourceAsStream( "tck/tck.dump" ) ); + loadSvnDump( + repositoryRoot, + new SvnScmTestUtils().getClass().getClassLoader().getResourceAsStream("tck/tck.dump")); } - public static void initializeRepository( File repositoryRoot, File dump ) - throws Exception - { - if ( repositoryRoot.exists() ) - { - FileUtils.deleteDirectory( repositoryRoot ); + public static void initializeRepository(File repositoryRoot, File dump) throws Exception { + if (repositoryRoot.exists()) { + FileUtils.deleteDirectory(repositoryRoot); } - Assert.assertTrue( "Could not make repository root directory: " + repositoryRoot.getAbsolutePath(), - repositoryRoot.mkdirs() ); + Assert.assertTrue( + "Could not make repository root directory: " + repositoryRoot.getAbsolutePath(), + repositoryRoot.mkdirs()); - ScmTestCase.execute( repositoryRoot.getParentFile(), SVNADMIN_COMMAND_LINE, - "create " + repositoryRoot.getName() ); + ScmTestCase.execute( + repositoryRoot.getParentFile(), SVNADMIN_COMMAND_LINE, "create " + repositoryRoot.getName()); - Assert.assertTrue( "The dump file doesn't exist: " + dump.getAbsolutePath(), dump.exists() ); + Assert.assertTrue("The dump file doesn't exist: " + dump.getAbsolutePath(), dump.exists()); - loadSvnDump( repositoryRoot, new FileInputStream( dump ) ); + loadSvnDump(repositoryRoot, new FileInputStream(dump)); } - private static void loadSvnDump( File repositoryRoot, InputStream dumpStream ) - throws Exception - { + private static void loadSvnDump(File repositoryRoot, InputStream dumpStream) throws Exception { Commandline cl = new Commandline(); - cl.setExecutable( SVNADMIN_COMMAND_LINE ); + cl.setExecutable(SVNADMIN_COMMAND_LINE); - cl.setWorkingDirectory( repositoryRoot.getParentFile().getAbsolutePath() ); + cl.setWorkingDirectory(repositoryRoot.getParentFile().getAbsolutePath()); - cl.createArg().setValue( "load" ); + cl.createArg().setValue("load"); - cl.createArg().setValue( repositoryRoot.getAbsolutePath() ); + cl.createArg().setValue(repositoryRoot.getAbsolutePath()); CommandLineUtils.StringStreamConsumer stdout = new CommandLineUtils.StringStreamConsumer(); CommandLineUtils.StringStreamConsumer stderr = new CommandLineUtils.StringStreamConsumer(); - int exitValue = CommandLineUtils.executeCommandLine( cl, dumpStream, stdout, stderr ); - - if ( exitValue != 0 ) - { - System.err.println( "-----------------------------------------" ); - System.err.println( "Command line: " + cl ); - System.err.println( "Working directory: " + cl.getWorkingDirectory() ); - System.err.println( "-----------------------------------------" ); - System.err.println( "Standard output: " ); - System.err.println( "-----------------------------------------" ); - System.err.println( stdout.getOutput() ); - System.err.println( "-----------------------------------------" ); - - System.err.println( "Standard error: " ); - System.err.println( "-----------------------------------------" ); - System.err.println( stderr.getOutput() ); - System.err.println( "-----------------------------------------" ); + int exitValue = CommandLineUtils.executeCommandLine(cl, dumpStream, stdout, stderr); + + if (exitValue != 0) { + System.err.println("-----------------------------------------"); + System.err.println("Command line: " + cl); + System.err.println("Working directory: " + cl.getWorkingDirectory()); + System.err.println("-----------------------------------------"); + System.err.println("Standard output: "); + System.err.println("-----------------------------------------"); + System.err.println(stdout.getOutput()); + System.err.println("-----------------------------------------"); + + System.err.println("Standard error: "); + System.err.println("-----------------------------------------"); + System.err.println(stderr.getOutput()); + System.err.println("-----------------------------------------"); } - if ( exitValue != 0 ) - { - Assert.fail( "Exit value wasn't 0, was:" + exitValue ); + if (exitValue != 0) { + Assert.fail("Exit value wasn't 0, was:" + exitValue); } } - public static String getScmUrl( File repositoryRootFile ) - throws CommandLineException - { + public static String getScmUrl(File repositoryRootFile) throws CommandLineException { return "scm:svn:" + repositoryRootFile.toPath().toAbsolutePath().toUri().toASCIIString(); } } diff --git a/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svntest/src/main/java/org/apache/maven/scm/provider/svn/command/blame/SvnBlameCommandTckTest.java b/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svntest/src/main/java/org/apache/maven/scm/provider/svn/command/blame/SvnBlameCommandTckTest.java index 6d8a56627..cbaeb33e2 100644 --- a/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svntest/src/main/java/org/apache/maven/scm/provider/svn/command/blame/SvnBlameCommandTckTest.java +++ b/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svntest/src/main/java/org/apache/maven/scm/provider/svn/command/blame/SvnBlameCommandTckTest.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.svn.command.blame; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,41 +16,35 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider.svn.command.blame; + +import java.io.File; +import java.util.List; import org.apache.maven.scm.command.blame.BlameLine; import org.apache.maven.scm.command.blame.BlameScmResult; import org.apache.maven.scm.provider.svn.SvnScmTestUtils; import org.apache.maven.scm.tck.command.blame.BlameCommandTckTest; -import java.io.File; -import java.util.List; - import static org.junit.Assert.assertEquals; /** * @author Evgeny Mandrikov */ -public abstract class SvnBlameCommandTckTest - extends BlameCommandTckTest -{ - public String getScmUrl() - throws Exception - { - return SvnScmTestUtils.getScmUrl( new File( getRepositoryRoot(), "trunk" ) ); +public abstract class SvnBlameCommandTckTest extends BlameCommandTckTest { + public String getScmUrl() throws Exception { + return SvnScmTestUtils.getScmUrl(new File(getRepositoryRoot(), "trunk")); } - public void initRepo() - throws Exception - { - SvnScmTestUtils.initializeRepository( getRepositoryRoot() ); + public void initRepo() throws Exception { + SvnScmTestUtils.initializeRepository(getRepositoryRoot()); } - protected void verifyResult( BlameScmResult result ) - { + protected void verifyResult(BlameScmResult result) { List lines = result.getLines(); - assertEquals( "Expected 1 line in blame", 1, lines.size() ); - BlameLine line = lines.get( 0 ); - assertEquals( "trygvis", line.getAuthor() ); - assertEquals( "7", line.getRevision() ); + assertEquals("Expected 1 line in blame", 1, lines.size()); + BlameLine line = lines.get(0); + assertEquals("trygvis", line.getAuthor()); + assertEquals("7", line.getRevision()); } } diff --git a/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svntest/src/main/java/org/apache/maven/scm/provider/svn/command/branch/SvnBranchCommandTckTest.java b/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svntest/src/main/java/org/apache/maven/scm/provider/svn/command/branch/SvnBranchCommandTckTest.java index 79830f92e..381529963 100644 --- a/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svntest/src/main/java/org/apache/maven/scm/provider/svn/command/branch/SvnBranchCommandTckTest.java +++ b/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svntest/src/main/java/org/apache/maven/scm/provider/svn/command/branch/SvnBranchCommandTckTest.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.svn.command.branch; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,32 +16,27 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider.svn.command.branch; + +import java.io.File; import org.apache.maven.scm.provider.svn.SvnScmTestUtils; import org.apache.maven.scm.tck.command.branch.BranchCommandTckTest; -import java.io.File; - /** * This test tests the branch command. * * @author Emmanuel Venisse * */ -public class SvnBranchCommandTckTest - extends BranchCommandTckTest -{ +public class SvnBranchCommandTckTest extends BranchCommandTckTest { /** {@inheritDoc} */ - public String getScmUrl() - throws Exception - { - return SvnScmTestUtils.getScmUrl( new File( getRepositoryRoot(), "trunk" ) ); + public String getScmUrl() throws Exception { + return SvnScmTestUtils.getScmUrl(new File(getRepositoryRoot(), "trunk")); } /** {@inheritDoc} */ - public void initRepo() - throws Exception - { - SvnScmTestUtils.initializeRepository( getRepositoryRoot() ); + public void initRepo() throws Exception { + SvnScmTestUtils.initializeRepository(getRepositoryRoot()); } } diff --git a/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svntest/src/main/java/org/apache/maven/scm/provider/svn/command/checkin/SvnCheckInCommandTckTest.java b/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svntest/src/main/java/org/apache/maven/scm/provider/svn/command/checkin/SvnCheckInCommandTckTest.java index 979d309e1..63e75b4c5 100644 --- a/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svntest/src/main/java/org/apache/maven/scm/provider/svn/command/checkin/SvnCheckInCommandTckTest.java +++ b/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svntest/src/main/java/org/apache/maven/scm/provider/svn/command/checkin/SvnCheckInCommandTckTest.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.svn.command.checkin; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,30 +16,25 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider.svn.command.checkin; + +import java.io.File; import org.apache.maven.scm.provider.svn.SvnScmTestUtils; import org.apache.maven.scm.tck.command.checkin.CheckInCommandTckTest; -import java.io.File; - /** * @author Brett Porter * */ -public class SvnCheckInCommandTckTest - extends CheckInCommandTckTest -{ +public class SvnCheckInCommandTckTest extends CheckInCommandTckTest { /** {@inheritDoc} */ - public String getScmUrl() - throws Exception - { - return SvnScmTestUtils.getScmUrl( new File( getRepositoryRoot(), "trunk" ) ); + public String getScmUrl() throws Exception { + return SvnScmTestUtils.getScmUrl(new File(getRepositoryRoot(), "trunk")); } /** {@inheritDoc} */ - public void initRepo() - throws Exception - { - SvnScmTestUtils.initializeRepository( getRepositoryRoot() ); + public void initRepo() throws Exception { + SvnScmTestUtils.initializeRepository(getRepositoryRoot()); } } diff --git a/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svntest/src/main/java/org/apache/maven/scm/provider/svn/command/checkout/SvnCheckOutCommandTckTest.java b/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svntest/src/main/java/org/apache/maven/scm/provider/svn/command/checkout/SvnCheckOutCommandTckTest.java index 4965f4102..21e24edd6 100644 --- a/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svntest/src/main/java/org/apache/maven/scm/provider/svn/command/checkout/SvnCheckOutCommandTckTest.java +++ b/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svntest/src/main/java/org/apache/maven/scm/provider/svn/command/checkout/SvnCheckOutCommandTckTest.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.svn.command.checkout; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,30 +16,25 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider.svn.command.checkout; + +import java.io.File; import org.apache.maven.scm.provider.svn.SvnScmTestUtils; import org.apache.maven.scm.tck.command.checkout.CheckOutCommandTckTest; -import java.io.File; - /** * @author Emmanuel Venisse * */ -public class SvnCheckOutCommandTckTest - extends CheckOutCommandTckTest -{ +public class SvnCheckOutCommandTckTest extends CheckOutCommandTckTest { /** {@inheritDoc} */ - public String getScmUrl() - throws Exception - { - return SvnScmTestUtils.getScmUrl( new File( getRepositoryRoot(), "trunk" ) ); + public String getScmUrl() throws Exception { + return SvnScmTestUtils.getScmUrl(new File(getRepositoryRoot(), "trunk")); } /** {@inheritDoc} */ - public void initRepo() - throws Exception - { - SvnScmTestUtils.initializeRepository( getRepositoryRoot() ); + public void initRepo() throws Exception { + SvnScmTestUtils.initializeRepository(getRepositoryRoot()); } } diff --git a/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svntest/src/main/java/org/apache/maven/scm/provider/svn/command/diff/SvnDiffCommandTckTest.java b/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svntest/src/main/java/org/apache/maven/scm/provider/svn/command/diff/SvnDiffCommandTckTest.java index b86f5e31e..1738b33f2 100644 --- a/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svntest/src/main/java/org/apache/maven/scm/provider/svn/command/diff/SvnDiffCommandTckTest.java +++ b/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svntest/src/main/java/org/apache/maven/scm/provider/svn/command/diff/SvnDiffCommandTckTest.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.svn.command.diff; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,30 +16,25 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider.svn.command.diff; + +import java.io.File; import org.apache.maven.scm.provider.svn.SvnScmTestUtils; import org.apache.maven.scm.tck.command.diff.DiffCommandTckTest; -import java.io.File; - /** * @author Brett Porter * */ -public class SvnDiffCommandTckTest - extends DiffCommandTckTest -{ +public class SvnDiffCommandTckTest extends DiffCommandTckTest { /** {@inheritDoc} */ - public String getScmUrl() - throws Exception - { - return SvnScmTestUtils.getScmUrl( new File( getRepositoryRoot(), "trunk" ) ); + public String getScmUrl() throws Exception { + return SvnScmTestUtils.getScmUrl(new File(getRepositoryRoot(), "trunk")); } /** {@inheritDoc} */ - public void initRepo() - throws Exception - { - SvnScmTestUtils.initializeRepository( getRepositoryRoot() ); + public void initRepo() throws Exception { + SvnScmTestUtils.initializeRepository(getRepositoryRoot()); } } diff --git a/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svntest/src/main/java/org/apache/maven/scm/provider/svn/command/list/SvnListCommandTckTest.java b/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svntest/src/main/java/org/apache/maven/scm/provider/svn/command/list/SvnListCommandTckTest.java index 4f2a40293..670a35e9b 100644 --- a/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svntest/src/main/java/org/apache/maven/scm/provider/svn/command/list/SvnListCommandTckTest.java +++ b/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svntest/src/main/java/org/apache/maven/scm/provider/svn/command/list/SvnListCommandTckTest.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.svn.command.list; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,32 +16,27 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider.svn.command.list; + +import java.io.File; import org.apache.maven.scm.provider.svn.SvnScmTestUtils; import org.apache.maven.scm.tck.command.list.ListCommandTckTest; -import java.io.File; - /** * Test for {@code list} command * * @author Carlos Sanchez * */ -public class SvnListCommandTckTest - extends ListCommandTckTest -{ +public class SvnListCommandTckTest extends ListCommandTckTest { /** {@inheritDoc} */ - public String getScmUrl() - throws Exception - { - return SvnScmTestUtils.getScmUrl( new File( getRepositoryRoot(), "trunk" ) ); + public String getScmUrl() throws Exception { + return SvnScmTestUtils.getScmUrl(new File(getRepositoryRoot(), "trunk")); } /** {@inheritDoc} */ - public void initRepo() - throws Exception - { - SvnScmTestUtils.initializeRepository( getRepositoryRoot() ); + public void initRepo() throws Exception { + SvnScmTestUtils.initializeRepository(getRepositoryRoot()); } } diff --git a/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svntest/src/main/java/org/apache/maven/scm/provider/svn/command/mkdir/SvnMkdirCommandTckTest.java b/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svntest/src/main/java/org/apache/maven/scm/provider/svn/command/mkdir/SvnMkdirCommandTckTest.java index 728d16dcf..04f41b1e3 100644 --- a/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svntest/src/main/java/org/apache/maven/scm/provider/svn/command/mkdir/SvnMkdirCommandTckTest.java +++ b/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svntest/src/main/java/org/apache/maven/scm/provider/svn/command/mkdir/SvnMkdirCommandTckTest.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.svn.command.mkdir; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider.svn.command.mkdir; import java.io.File; @@ -36,61 +35,51 @@ * @author Maria Odea Ching * */ -public class SvnMkdirCommandTckTest - extends MkdirCommandTckTest -{ +public class SvnMkdirCommandTckTest extends MkdirCommandTckTest { /** {@inheritDoc} */ - public String getScmUrl() - throws Exception - { - return SvnScmTestUtils.getScmUrl( new File( getRepositoryRoot(), "trunk" ) ); + public String getScmUrl() throws Exception { + return SvnScmTestUtils.getScmUrl(new File(getRepositoryRoot(), "trunk")); } /** {@inheritDoc} */ - public void initRepo() - throws Exception - { - SvnScmTestUtils.initializeRepository( getRepositoryRoot() ); + public void initRepo() throws Exception { + SvnScmTestUtils.initializeRepository(getRepositoryRoot()); } @Test - public void testMkdirCommandMkdirUrl() - throws Exception - { - ScmFileSet fileSet = new ScmFileSet( getWorkingCopy(), new File( getMissingDirectory() ) ); - - MkdirScmResult result = getScmManager().mkdir( getScmRepository(), fileSet, "Mkdir message", false ); - - assertResultIsSuccess( result ); - - assertNotNull( result.getRevision() ); - - ListScmResult listResult = getScmManager().list( getScmRepository(), fileSet, true, null ); - - assertTrue( "Directory should have been found.", listResult.isSuccess() ); + public void testMkdirCommandMkdirUrl() throws Exception { + ScmFileSet fileSet = new ScmFileSet(getWorkingCopy(), new File(getMissingDirectory())); + + MkdirScmResult result = getScmManager().mkdir(getScmRepository(), fileSet, "Mkdir message", false); + + assertResultIsSuccess(result); + + assertNotNull(result.getRevision()); + + ListScmResult listResult = getScmManager().list(getScmRepository(), fileSet, true, null); + + assertTrue("Directory should have been found.", listResult.isSuccess()); } @Test - public void testMkdirCommandDirAlreadyAdded() - throws Exception - { - ScmFileSet fileSet = new ScmFileSet( getWorkingCopy(), new File( getMissingDirectory() ) ); - - MkdirScmResult result = getScmManager().mkdir( getScmRepository(), fileSet, null, false ); - - assertResultIsSuccess( result ); - - assertNotNull( result.getRevision() ); - - ListScmResult listResult = getScmManager().list( getScmRepository(), fileSet, true, null ); - - assertTrue( "Directory should have been found.", listResult.isSuccess() ); - + public void testMkdirCommandDirAlreadyAdded() throws Exception { + ScmFileSet fileSet = new ScmFileSet(getWorkingCopy(), new File(getMissingDirectory())); + + MkdirScmResult result = getScmManager().mkdir(getScmRepository(), fileSet, null, false); + + assertResultIsSuccess(result); + + assertNotNull(result.getRevision()); + + ListScmResult listResult = getScmManager().list(getScmRepository(), fileSet, true, null); + + assertTrue("Directory should have been found.", listResult.isSuccess()); + // add the directory again - result = getScmManager().mkdir( getScmRepository(), fileSet, null, false ); - - printOutputError( result ); - - assertFalse( result.isSuccess() ); + result = getScmManager().mkdir(getScmRepository(), fileSet, null, false); + + printOutputError(result); + + assertFalse(result.isSuccess()); } } diff --git a/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svntest/src/main/java/org/apache/maven/scm/provider/svn/command/remoteinfo/AbstractSvnRemoteInfoCommandTckTest.java b/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svntest/src/main/java/org/apache/maven/scm/provider/svn/command/remoteinfo/AbstractSvnRemoteInfoCommandTckTest.java index f3aebd298..232eb996f 100644 --- a/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svntest/src/main/java/org/apache/maven/scm/provider/svn/command/remoteinfo/AbstractSvnRemoteInfoCommandTckTest.java +++ b/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svntest/src/main/java/org/apache/maven/scm/provider/svn/command/remoteinfo/AbstractSvnRemoteInfoCommandTckTest.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.svn.command.remoteinfo; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,34 +16,28 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider.svn.command.remoteinfo; + +import java.io.File; import org.apache.maven.scm.provider.svn.SvnScmTestUtils; import org.apache.maven.scm.tck.command.remoteinfo.AbstractRemoteInfoCommandTckTest; -import java.io.File; - /** * @author Bertrand Paquet */ -public abstract class AbstractSvnRemoteInfoCommandTckTest - extends AbstractRemoteInfoCommandTckTest -{ +public abstract class AbstractSvnRemoteInfoCommandTckTest extends AbstractRemoteInfoCommandTckTest { /** * {@inheritDoc} */ - public String getScmUrl() - throws Exception - { - return SvnScmTestUtils.getScmUrl( new File( getRepositoryRoot(), "trunk" ) ); + public String getScmUrl() throws Exception { + return SvnScmTestUtils.getScmUrl(new File(getRepositoryRoot(), "trunk")); } /** * {@inheritDoc} */ - public void initRepo() - throws Exception - { - SvnScmTestUtils.initializeRepository( getRepositoryRoot() ); + public void initRepo() throws Exception { + SvnScmTestUtils.initializeRepository(getRepositoryRoot()); } - } diff --git a/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svntest/src/main/java/org/apache/maven/scm/provider/svn/command/remove/SvnRemoveCommandTckTest.java b/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svntest/src/main/java/org/apache/maven/scm/provider/svn/command/remove/SvnRemoveCommandTckTest.java index 8cc48ec2e..6fbc4d62c 100644 --- a/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svntest/src/main/java/org/apache/maven/scm/provider/svn/command/remove/SvnRemoveCommandTckTest.java +++ b/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svntest/src/main/java/org/apache/maven/scm/provider/svn/command/remove/SvnRemoveCommandTckTest.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.svn.command.remove; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,29 +16,24 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider.svn.command.remove; + +import java.io.File; import org.apache.maven.scm.provider.svn.SvnScmTestUtils; import org.apache.maven.scm.tck.command.remove.RemoveCommandTckTest; -import java.io.File; - /** * */ -public class SvnRemoveCommandTckTest - extends RemoveCommandTckTest -{ +public class SvnRemoveCommandTckTest extends RemoveCommandTckTest { /** {@inheritDoc} */ - public String getScmUrl() - throws Exception - { - return SvnScmTestUtils.getScmUrl( new File( getRepositoryRoot(), "trunk" ) ); + public String getScmUrl() throws Exception { + return SvnScmTestUtils.getScmUrl(new File(getRepositoryRoot(), "trunk")); } /** {@inheritDoc} */ - public void initRepo() - throws Exception - { - SvnScmTestUtils.initializeRepository( getRepositoryRoot() ); + public void initRepo() throws Exception { + SvnScmTestUtils.initializeRepository(getRepositoryRoot()); } } diff --git a/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svntest/src/main/java/org/apache/maven/scm/provider/svn/command/status/SvnStatusCommandTckTest.java b/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svntest/src/main/java/org/apache/maven/scm/provider/svn/command/status/SvnStatusCommandTckTest.java index d9c1f0941..8b7ffdf86 100644 --- a/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svntest/src/main/java/org/apache/maven/scm/provider/svn/command/status/SvnStatusCommandTckTest.java +++ b/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svntest/src/main/java/org/apache/maven/scm/provider/svn/command/status/SvnStatusCommandTckTest.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.svn.command.status; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,30 +16,25 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider.svn.command.status; + +import java.io.File; import org.apache.maven.scm.provider.svn.SvnScmTestUtils; import org.apache.maven.scm.tck.command.status.StatusCommandTckTest; -import java.io.File; - /** * @author Brett Porter * */ -public class SvnStatusCommandTckTest - extends StatusCommandTckTest -{ +public class SvnStatusCommandTckTest extends StatusCommandTckTest { /** {@inheritDoc} */ - public String getScmUrl() - throws Exception - { - return SvnScmTestUtils.getScmUrl( new File( getRepositoryRoot(), "trunk" ) ); + public String getScmUrl() throws Exception { + return SvnScmTestUtils.getScmUrl(new File(getRepositoryRoot(), "trunk")); } /** {@inheritDoc} */ - public void initRepo() - throws Exception - { - SvnScmTestUtils.initializeRepository( getRepositoryRoot() ); + public void initRepo() throws Exception { + SvnScmTestUtils.initializeRepository(getRepositoryRoot()); } } diff --git a/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svntest/src/main/java/org/apache/maven/scm/provider/svn/command/tag/SvnTagCommandTckTest.java b/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svntest/src/main/java/org/apache/maven/scm/provider/svn/command/tag/SvnTagCommandTckTest.java index 6434ab54c..0ad73b585 100644 --- a/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svntest/src/main/java/org/apache/maven/scm/provider/svn/command/tag/SvnTagCommandTckTest.java +++ b/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svntest/src/main/java/org/apache/maven/scm/provider/svn/command/tag/SvnTagCommandTckTest.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.svn.command.tag; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,32 +16,27 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider.svn.command.tag; + +import java.io.File; import org.apache.maven.scm.provider.svn.SvnScmTestUtils; import org.apache.maven.scm.tck.command.tag.TagCommandTckTest; -import java.io.File; - /** * This test tests the tag command. * * @author Brett Porter * */ -public class SvnTagCommandTckTest - extends TagCommandTckTest -{ +public class SvnTagCommandTckTest extends TagCommandTckTest { /** {@inheritDoc} */ - public String getScmUrl() - throws Exception - { - return SvnScmTestUtils.getScmUrl( new File( getRepositoryRoot(), "trunk" ) ); + public String getScmUrl() throws Exception { + return SvnScmTestUtils.getScmUrl(new File(getRepositoryRoot(), "trunk")); } /** {@inheritDoc} */ - public void initRepo() - throws Exception - { - SvnScmTestUtils.initializeRepository( getRepositoryRoot() ); + public void initRepo() throws Exception { + SvnScmTestUtils.initializeRepository(getRepositoryRoot()); } } diff --git a/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svntest/src/main/java/org/apache/maven/scm/provider/svn/command/untag/SvnUntagCommandTckTest.java b/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svntest/src/main/java/org/apache/maven/scm/provider/svn/command/untag/SvnUntagCommandTckTest.java index c8cb9d7c2..2775d72de 100644 --- a/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svntest/src/main/java/org/apache/maven/scm/provider/svn/command/untag/SvnUntagCommandTckTest.java +++ b/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svntest/src/main/java/org/apache/maven/scm/provider/svn/command/untag/SvnUntagCommandTckTest.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.svn.command.untag; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,32 +16,27 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider.svn.command.untag; + +import java.io.File; import org.apache.maven.scm.provider.svn.SvnScmTestUtils; import org.apache.maven.scm.tck.command.untag.UntagCommandTckTest; -import java.io.File; - /** * This test tests the tag command. * * @author Brett Porter * */ -public class SvnUntagCommandTckTest - extends UntagCommandTckTest -{ +public class SvnUntagCommandTckTest extends UntagCommandTckTest { /** {@inheritDoc} */ - public String getScmUrl() - throws Exception - { - return SvnScmTestUtils.getScmUrl( new File( getRepositoryRoot(), "trunk" ) ); + public String getScmUrl() throws Exception { + return SvnScmTestUtils.getScmUrl(new File(getRepositoryRoot(), "trunk")); } /** {@inheritDoc} */ - public void initRepo() - throws Exception - { - SvnScmTestUtils.initializeRepository( getRepositoryRoot() ); + public void initRepo() throws Exception { + SvnScmTestUtils.initializeRepository(getRepositoryRoot()); } } diff --git a/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svntest/src/main/java/org/apache/maven/scm/provider/svn/command/update/SvnUpdateCommandTckTest.java b/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svntest/src/main/java/org/apache/maven/scm/provider/svn/command/update/SvnUpdateCommandTckTest.java index f43643e03..71e627553 100644 --- a/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svntest/src/main/java/org/apache/maven/scm/provider/svn/command/update/SvnUpdateCommandTckTest.java +++ b/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svntest/src/main/java/org/apache/maven/scm/provider/svn/command/update/SvnUpdateCommandTckTest.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider.svn.command.update; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,30 +16,25 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider.svn.command.update; + +import java.io.File; import org.apache.maven.scm.provider.svn.SvnScmTestUtils; import org.apache.maven.scm.tck.command.update.UpdateCommandTckTest; -import java.io.File; - /** * @author Trygve Laugstøl * */ -public class SvnUpdateCommandTckTest - extends UpdateCommandTckTest -{ +public class SvnUpdateCommandTckTest extends UpdateCommandTckTest { /** {@inheritDoc} */ - public String getScmUrl() - throws Exception - { - return SvnScmTestUtils.getScmUrl( new File( getRepositoryRoot(), "trunk" ) ); + public String getScmUrl() throws Exception { + return SvnScmTestUtils.getScmUrl(new File(getRepositoryRoot(), "trunk")); } /** {@inheritDoc} */ - public void initRepo() - throws Exception - { - SvnScmTestUtils.initializeRepository( getRepositoryRoot() ); + public void initRepo() throws Exception { + SvnScmTestUtils.initializeRepository(getRepositoryRoot()); } } diff --git a/maven-scm-providers/maven-scm-providers-svn/pom.xml b/maven-scm-providers/maven-scm-providers-svn/pom.xml index 751c8c0b3..2467de6fb 100644 --- a/maven-scm-providers/maven-scm-providers-svn/pom.xml +++ b/maven-scm-providers/maven-scm-providers-svn/pom.xml @@ -1,5 +1,4 @@ - - 4.0.0 @@ -56,6 +54,6 @@ - + diff --git a/maven-scm-providers/pom.xml b/maven-scm-providers/pom.xml index ca4a05d4a..8b740a155 100644 --- a/maven-scm-providers/pom.xml +++ b/maven-scm-providers/pom.xml @@ -1,5 +1,4 @@ - - 4.0.0 - maven-scm org.apache.maven.scm + maven-scm 2.0.0-M4-SNAPSHOT diff --git a/maven-scm-test/pom.xml b/maven-scm-test/pom.xml index 48a7d6176..850514953 100644 --- a/maven-scm-test/pom.xml +++ b/maven-scm-test/pom.xml @@ -1,5 +1,4 @@ - - 4.0.0 diff --git a/maven-scm-test/src/main/java/org/apache/maven/scm/PlexusJUnit4TestSupport.java b/maven-scm-test/src/main/java/org/apache/maven/scm/PlexusJUnit4TestSupport.java index 3684085b7..0014cef2f 100644 --- a/maven-scm-test/src/main/java/org/apache/maven/scm/PlexusJUnit4TestSupport.java +++ b/maven-scm-test/src/main/java/org/apache/maven/scm/PlexusJUnit4TestSupport.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -18,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm; import java.io.File; import java.io.InputStream; @@ -46,8 +45,7 @@ * * @author Robert Scholte */ -public abstract class PlexusJUnit4TestSupport -{ +public abstract class PlexusJUnit4TestSupport { private PlexusContainer container; private static String basedir; @@ -56,41 +54,35 @@ public abstract class PlexusJUnit4TestSupport public TestName testName = new TestName(); @Before - public void setUp() - throws Exception - { + public void setUp() throws Exception { basedir = getBasedir(); } - protected String getName() - { + protected String getName() { return testName.getMethodName(); } - protected void setupContainer() - { + protected void setupContainer() { // ---------------------------------------------------------------------------- // Context Setup // ---------------------------------------------------------------------------- final DefaultContext context = new DefaultContext(); - context.put( "basedir", getBasedir() ); + context.put("basedir", getBasedir()); - customizeContext( context ); + customizeContext(context); - final boolean hasPlexusHome = context.contains( "plexus.home" ); + final boolean hasPlexusHome = context.contains("plexus.home"); - if ( !hasPlexusHome ) - { - final File f = getTestFile( "target/plexus-home" ); + if (!hasPlexusHome) { + final File f = getTestFile("target/plexus-home"); - if ( !f.isDirectory() ) - { + if (!f.isDirectory()) { f.mkdir(); } - context.put( "plexus.home", f.getAbsolutePath() ); + context.put("plexus.home", f.getAbsolutePath()); } // ---------------------------------------------------------------------------- @@ -99,42 +91,34 @@ protected void setupContainer() final String config = getCustomConfigurationName(); - final ContainerConfiguration containerConfiguration = - new DefaultContainerConfiguration() - .setName( "test" ) - .setContext( context.getContextData() ) - .setAutoWiring( true ) - .setClassPathScanning( PlexusConstants.SCANNING_CACHE ); + final ContainerConfiguration containerConfiguration = new DefaultContainerConfiguration() + .setName("test") + .setContext(context.getContextData()) + .setAutoWiring(true) + .setClassPathScanning(PlexusConstants.SCANNING_CACHE); - if ( config != null ) - { - containerConfiguration.setContainerConfiguration( config ); - } - else - { - final String resource = getConfigurationName( null ); + if (config != null) { + containerConfiguration.setContainerConfiguration(config); + } else { + final String resource = getConfigurationName(null); - containerConfiguration.setContainerConfiguration( resource ); + containerConfiguration.setContainerConfiguration(resource); } - customizeContainerConfiguration( containerConfiguration ); + customizeContainerConfiguration(containerConfiguration); - try - { - container = new DefaultPlexusContainer( containerConfiguration, getCustomModules() ); - } - catch ( final PlexusContainerException e ) - { + try { + container = new DefaultPlexusContainer(containerConfiguration, getCustomModules()); + } catch (final PlexusContainerException e) { e.printStackTrace(); - fail( "Failed to create plexus container." ); + fail("Failed to create plexus container."); } } /** * Allows test to define custom modules. */ - protected Module[] getCustomModules() - { + protected Module[] getCustomModules() { return new Module[0]; } @@ -143,56 +127,41 @@ protected Module[] getCustomModules() * * @param containerConfiguration */ - protected void customizeContainerConfiguration( final ContainerConfiguration containerConfiguration ) - { - } + protected void customizeContainerConfiguration(final ContainerConfiguration containerConfiguration) {} - protected void customizeContext( final Context context ) - { - } + protected void customizeContext(final Context context) {} - protected PlexusConfiguration customizeComponentConfiguration() - { + protected PlexusConfiguration customizeComponentConfiguration() { return null; } @After - public void tearDown() - throws Exception - { - if ( container != null ) - { + public void tearDown() throws Exception { + if (container != null) { container.dispose(); container = null; } } - protected PlexusContainer getContainer() - { - if ( container == null ) - { + protected PlexusContainer getContainer() { + if (container == null) { setupContainer(); } return container; } - protected InputStream getConfiguration() - throws Exception - { - return getConfiguration( null ); + protected InputStream getConfiguration() throws Exception { + return getConfiguration(null); } - @SuppressWarnings( "unused" ) - protected InputStream getConfiguration( final String subname ) - throws Exception - { - return getResourceAsStream( getConfigurationName( subname ) ); + @SuppressWarnings("unused") + protected InputStream getConfiguration(final String subname) throws Exception { + return getResourceAsStream(getConfigurationName(subname)); } - protected String getCustomConfigurationName() - { + protected String getCustomConfigurationName() { return null; } @@ -204,18 +173,15 @@ protected String getCustomConfigurationName() * @param subname * @return */ - protected String getConfigurationName( final String subname ) - { - return getClass().getName().replace( '.', '/' ) + ".xml"; + protected String getConfigurationName(final String subname) { + return getClass().getName().replace('.', '/') + ".xml"; } - protected InputStream getResourceAsStream( final String resource ) - { - return getClass().getResourceAsStream( resource ); + protected InputStream getResourceAsStream(final String resource) { + return getClass().getResourceAsStream(resource); } - protected ClassLoader getClassLoader() - { + protected ClassLoader getClassLoader() { return getClass().getClassLoader(); } @@ -223,101 +189,79 @@ protected ClassLoader getClassLoader() // Container access // ---------------------------------------------------------------------- - protected Object lookup( final String componentKey ) - throws Exception - { - return getContainer().lookup( componentKey ); + protected Object lookup(final String componentKey) throws Exception { + return getContainer().lookup(componentKey); } - protected Object lookup( final String role, final String roleHint ) - throws Exception - { - return getContainer().lookup( role, roleHint ); + protected Object lookup(final String role, final String roleHint) throws Exception { + return getContainer().lookup(role, roleHint); } - protected T lookup( final Class componentClass ) - throws Exception - { - return getContainer().lookup( componentClass ); + protected T lookup(final Class componentClass) throws Exception { + return getContainer().lookup(componentClass); } - protected T lookup( final Class componentClass, final String roleHint ) - throws Exception - { - return getContainer().lookup( componentClass, roleHint ); + protected T lookup(final Class componentClass, final String roleHint) throws Exception { + return getContainer().lookup(componentClass, roleHint); } - protected Map lookupMap( final Class componentClass ) - throws Exception - { - return getContainer().lookupMap( componentClass ); + protected Map lookupMap(final Class componentClass) throws Exception { + return getContainer().lookupMap(componentClass); } - protected void release( final Object component ) - throws Exception - { - getContainer().release( component ); + protected void release(final Object component) throws Exception { + getContainer().release(component); } // ---------------------------------------------------------------------- // Helper methods for sub classes // ---------------------------------------------------------------------- - public static File getTestFile( final String path ) - { - return new File( getBasedir(), path ); + public static File getTestFile(final String path) { + return new File(getBasedir(), path); } - @SuppressWarnings( "hiding" ) - public static File getTestFile( final String basedir, final String path ) - { - File basedirFile = new File( basedir ); + @SuppressWarnings("hiding") + public static File getTestFile(final String basedir, final String path) { + File basedirFile = new File(basedir); - if ( !basedirFile.isAbsolute() ) - { - basedirFile = getTestFile( basedir ); + if (!basedirFile.isAbsolute()) { + basedirFile = getTestFile(basedir); } - return new File( basedirFile, path ); + return new File(basedirFile, path); } - public static String getTestPath( final String path ) - { - return getTestFile( path ).getAbsolutePath(); + public static String getTestPath(final String path) { + return getTestFile(path).getAbsolutePath(); } - @SuppressWarnings( "hiding" ) - public static String getTestPath( final String basedir, final String path ) - { - return getTestFile( basedir, path ).getAbsolutePath(); + @SuppressWarnings("hiding") + public static String getTestPath(final String basedir, final String path) { + return getTestFile(basedir, path).getAbsolutePath(); } - public static String getBasedir() - { - if ( basedir != null ) - { + public static String getBasedir() { + if (basedir != null) { return basedir; } - basedir = System.getProperty( "basedir" ); + basedir = System.getProperty("basedir"); - if ( basedir == null ) - { - basedir = new File( "" ).getAbsolutePath(); + if (basedir == null) { + basedir = new File("").getAbsolutePath(); } return basedir; } - public String getTestConfiguration() - { - return getTestConfiguration( getClass() ); + public String getTestConfiguration() { + return getTestConfiguration(getClass()); } - public static String getTestConfiguration( final Class clazz ) - { - final String s = clazz.getName().replace( '.', '/' ); + public static String getTestConfiguration(final Class clazz) { + final String s = clazz.getName().replace('.', '/'); - return s.substring( 0, s.indexOf( "$" ) ) + ".xml"; + return s.substring(0, s.indexOf("$")) + ".xml"; } -} \ No newline at end of file +} diff --git a/maven-scm-test/src/main/java/org/apache/maven/scm/ScmTckTestCase.java b/maven-scm-test/src/main/java/org/apache/maven/scm/ScmTckTestCase.java index 059cd014f..9304d7706 100644 --- a/maven-scm-test/src/main/java/org/apache/maven/scm/ScmTckTestCase.java +++ b/maven-scm-test/src/main/java/org/apache/maven/scm/ScmTckTestCase.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm; import java.io.File; import java.util.ArrayList; @@ -39,7 +38,6 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; - import static org.junit.Assume.assumeTrue; /** @@ -56,9 +54,7 @@ * @author Torbj�rn Eikli Sm�rgrav * */ -public abstract class ScmTckTestCase - extends ScmTestCase -{ +public abstract class ScmTckTestCase extends ScmTestCase { private ScmRepository scmRepository; private List scmFileNames; @@ -68,8 +64,7 @@ public abstract class ScmTckTestCase * If the provided name is not a runnable application all tests in the class are skipped. * @return The commandline command for the specific scm provider. Or null if none is needed. */ - public String getScmProviderCommand() - { + public String getScmProviderCommand() { return null; } @@ -77,8 +72,7 @@ public String getScmProviderCommand() * @return A provider specific and valid url for the repository * @throws Exception if any */ - public abstract String getScmUrl() - throws Exception; + public abstract String getScmUrl() throws Exception; /** *

    @@ -93,8 +87,7 @@ public abstract String getScmUrl() * * @return {@link List} of {@link String} objects */ - protected List getScmFileNames() - { + protected List getScmFileNames() { return scmFileNames; } @@ -110,16 +103,14 @@ protected List getScmFileNames() * * @throws Exception if any */ - public abstract void initRepo() - throws Exception; + public abstract void initRepo() throws Exception; - public void checkScmPresence() - { + public void checkScmPresence() { String scmProviderCommand = getScmProviderCommand(); - if ( scmProviderCommand != null ) - { - assumeTrue( "Skipping tests because the required command '" + scmProviderCommand + "' is not available.", - ScmTestCase.isSystemCmd( scmProviderCommand ) ); + if (scmProviderCommand != null) { + assumeTrue( + "Skipping tests because the required command '" + scmProviderCommand + "' is not available.", + ScmTestCase.isSystemCmd(scmProviderCommand)); } } @@ -128,28 +119,25 @@ public void checkScmPresence() */ @Before @Override - public void setUp() - throws Exception - { + public void setUp() throws Exception { checkScmPresence(); super.setUp(); scmRepository = null; - scmFileNames = new ArrayList<>( 4 ); - scmFileNames.add( "/pom.xml" ); - scmFileNames.add( "/readme.txt" ); - scmFileNames.add( "/src/main/java/Application.java" ); - scmFileNames.add( "/src/test/java/Test.java" ); + scmFileNames = new ArrayList<>(4); + scmFileNames.add("/pom.xml"); + scmFileNames.add("/readme.txt"); + scmFileNames.add("/src/main/java/Application.java"); + scmFileNames.add("/src/test/java/Test.java"); initRepo(); - checkOut( getWorkingCopy(), getScmRepository() ); + checkOut(getWorkingCopy(), getScmRepository()); Iterator it = getScmFileNames().iterator(); - while ( it.hasNext() ) - { - assertFile( getWorkingCopy(), it.next() ); + while (it.hasNext()) { + assertFile(getWorkingCopy(), it.next()); } } @@ -159,19 +147,14 @@ public void setUp() * operations are performed, or the check out dirs are outside * of the normal target directory. */ - public void removeRepo() - throws Exception - { - } + public void removeRepo() throws Exception {} /** * Provided to allow removeRepo() to be called. */ @After @Override - public void tearDown() - throws Exception - { + public void tearDown() throws Exception { super.tearDown(); removeRepo(); } @@ -179,12 +162,9 @@ public void tearDown() /** * Convenience method to get the ScmRepository for this provider */ - protected ScmRepository getScmRepository() - throws Exception - { - if ( scmRepository == null ) - { - scmRepository = getScmManager().makeScmRepository( getScmUrl() ); + protected ScmRepository getScmRepository() throws Exception { + if (scmRepository == null) { + scmRepository = getScmManager().makeScmRepository(getScmUrl()); } return scmRepository; @@ -193,14 +173,12 @@ protected ScmRepository getScmRepository() /** * Convenience method to check out files from the repository */ - protected CheckOutScmResult checkOut( File workingDirectory, ScmRepository repository ) - throws Exception - { - CheckOutScmResult result = - getScmManager().getProviderByUrl( getScmUrl() ).checkOut( repository, new ScmFileSet( workingDirectory ), - (ScmVersion) null ); + protected CheckOutScmResult checkOut(File workingDirectory, ScmRepository repository) throws Exception { + CheckOutScmResult result = getScmManager() + .getProviderByUrl(getScmUrl()) + .checkOut(repository, new ScmFileSet(workingDirectory), (ScmVersion) null); - assertTrue( "Check result was successful, output: " + result.getCommandOutput(), result.isSuccess() ); + assertTrue("Check result was successful, output: " + result.getCommandOutput(), result.isSuccess()); return result; } @@ -208,13 +186,12 @@ protected CheckOutScmResult checkOut( File workingDirectory, ScmRepository repos /** * Convenience method to check in files to the repository */ - protected CheckInScmResult checkIn( File workingDirectory, ScmRepository repository ) - throws Exception - { - CheckInScmResult result = getScmManager().getProviderByUrl( getScmUrl() ) - .checkIn( repository, new ScmFileSet( workingDirectory ), (ScmVersion) null, "Initial Checkin" ); + protected CheckInScmResult checkIn(File workingDirectory, ScmRepository repository) throws Exception { + CheckInScmResult result = getScmManager() + .getProviderByUrl(getScmUrl()) + .checkIn(repository, new ScmFileSet(workingDirectory), (ScmVersion) null, "Initial Checkin"); - assertTrue( "Check result was successful, output: " + result.getCommandOutput(), result.isSuccess() ); + assertTrue("Check result was successful, output: " + result.getCommandOutput(), result.isSuccess()); return result; } @@ -222,13 +199,12 @@ protected CheckInScmResult checkIn( File workingDirectory, ScmRepository reposit /** * Convenience method to remove files from the repository */ - protected RemoveScmResult remove( File workingDirectory, ScmRepository repository ) - throws Exception - { - RemoveScmResult result = getScmManager().getProviderByUrl( getScmUrl() ) - .remove( repository, new ScmFileSet( workingDirectory ), "Initial Checkin" ); + protected RemoveScmResult remove(File workingDirectory, ScmRepository repository) throws Exception { + RemoveScmResult result = getScmManager() + .getProviderByUrl(getScmUrl()) + .remove(repository, new ScmFileSet(workingDirectory), "Initial Checkin"); - assertTrue( "Remove result was successful, output: " + result.getCommandOutput(), result.isSuccess() ); + assertTrue("Remove result was successful, output: " + result.getCommandOutput(), result.isSuccess()); return result; } @@ -236,24 +212,21 @@ protected RemoveScmResult remove( File workingDirectory, ScmRepository repositor /** * Convenience method to add a file to the working tree at the working directory */ - protected void addToWorkingTree( File workingDirectory, File file, ScmRepository repository ) - throws Exception - { - ScmProvider provider = getScmManager().getProviderByUrl( getScmUrl() ); + protected void addToWorkingTree(File workingDirectory, File file, ScmRepository repository) throws Exception { + ScmProvider provider = getScmManager().getProviderByUrl(getScmUrl()); CommandParameters commandParameters = new CommandParameters(); - commandParameters.setString( CommandParameter.FORCE_ADD, Boolean.TRUE.toString() ); + commandParameters.setString(CommandParameter.FORCE_ADD, Boolean.TRUE.toString()); - AddScmResult result = provider.add( repository, new ScmFileSet( workingDirectory, file ), commandParameters ); + AddScmResult result = provider.add(repository, new ScmFileSet(workingDirectory, file), commandParameters); - assertTrue( "Check result was successful, output: " + result.getCommandOutput(), result.isSuccess() ); + assertTrue("Check result was successful, output: " + result.getCommandOutput(), result.isSuccess()); List addedFiles = result.getAddedFiles(); - if ( new File( workingDirectory, file.getPath() ).isFile() ) - { + if (new File(workingDirectory, file.getPath()).isFile()) { // Don't check directory add because some SCM tools ignore it - assertEquals( "Expected 1 file in the added files list " + addedFiles, 1, addedFiles.size() ); + assertEquals("Expected 1 file in the added files list " + addedFiles, 1, addedFiles.size()); } } @@ -269,32 +242,28 @@ protected void addToWorkingTree( File workingDirectory, File file, ScmRepository * @param files List with {@code ScmFile}s * @return Map key=pathName, value=ScmFile */ - protected Map mapFilesByPath( List files ) - { - if ( files == null ) - { + protected Map mapFilesByPath(List files) { + if (files == null) { return null; } Map mappedFiles = new TreeMap<>(); - for ( ScmFile scmFile : files ) - { - String path = StringUtils.replace( scmFile.getPath(), "\\", "/" ); - mappedFiles.put( path, scmFile ); + for (ScmFile scmFile : files) { + String path = StringUtils.replace(scmFile.getPath(), "\\", "/"); + mappedFiles.put(path, scmFile); } return mappedFiles; } - protected EditScmResult edit( File basedir, String includes, String excludes, ScmRepository repository ) - throws Exception - { - if ( this.getScmManager().getProviderByRepository( this.getScmRepository() ).requiresEditMode() ) - { - ScmFileSet fileSet = new ScmFileSet( basedir, includes, excludes ); - return getScmManager().edit( getScmRepository(), fileSet ); + protected EditScmResult edit(File basedir, String includes, String excludes, ScmRepository repository) + throws Exception { + if (this.getScmManager() + .getProviderByRepository(this.getScmRepository()) + .requiresEditMode()) { + ScmFileSet fileSet = new ScmFileSet(basedir, includes, excludes); + return getScmManager().edit(getScmRepository(), fileSet); } - return new EditScmResult( "", "", "", true ); + return new EditScmResult("", "", "", true); } - } diff --git a/maven-scm-test/src/main/java/org/apache/maven/scm/ScmTestCase.java b/maven-scm-test/src/main/java/org/apache/maven/scm/ScmTestCase.java index f853a4fbf..f256a3b85 100644 --- a/maven-scm-test/src/main/java/org/apache/maven/scm/ScmTestCase.java +++ b/maven-scm-test/src/main/java/org/apache/maven/scm/ScmTestCase.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,14 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm; + +import java.io.File; +import java.io.FileWriter; +import java.io.IOException; +import java.util.Calendar; +import java.util.Date; +import java.util.TimeZone; import org.apache.maven.scm.manager.ScmManager; import org.apache.maven.scm.repository.ScmRepository; @@ -30,13 +36,6 @@ import org.codehaus.plexus.util.cli.Commandline; import org.junit.Before; -import java.io.File; -import java.io.FileWriter; -import java.io.IOException; -import java.util.Calendar; -import java.util.Date; -import java.util.TimeZone; - import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; @@ -53,10 +52,8 @@ * @author Jason van Zyl * */ -public abstract class ScmTestCase - extends PlexusJUnit4TestSupport -{ - protected static final TimeZone GMT_TIME_ZONE = TimeZone.getTimeZone( "GMT" ); +public abstract class ScmTestCase extends PlexusJUnit4TestSupport { + protected static final TimeZone GMT_TIME_ZONE = TimeZone.getTimeZone("GMT"); private static boolean debugExecute; @@ -64,53 +61,47 @@ public abstract class ScmTestCase @Before @Override - public void setUp() - throws Exception - { + public void setUp() throws Exception { super.setUp(); - deleteDirectory( getRepositoryRoot() ); - assertFalse( getRepositoryRoot().exists() ); - deleteDirectory( getWorkingCopy() ); - assertFalse( getWorkingCopy().exists() ); - deleteDirectory( getWorkingDirectory() ); - assertFalse( getWorkingDirectory().exists() ); - deleteDirectory( getAssertionCopy() ); - assertFalse( getAssertionCopy().exists() ); - deleteDirectory( getUpdatingCopy() ); - assertFalse( getUpdatingCopy().exists() ); + deleteDirectory(getRepositoryRoot()); + assertFalse(getRepositoryRoot().exists()); + deleteDirectory(getWorkingCopy()); + assertFalse(getWorkingCopy().exists()); + deleteDirectory(getWorkingDirectory()); + assertFalse(getWorkingDirectory().exists()); + deleteDirectory(getAssertionCopy()); + assertFalse(getAssertionCopy().exists()); + deleteDirectory(getUpdatingCopy()); + assertFalse(getUpdatingCopy().exists()); scmManager = null; } @Override - protected void customizeContainerConfiguration( final ContainerConfiguration configuration ) - { - configuration.setClassPathScanning( PlexusConstants.SCANNING_INDEX ).setAutoWiring( true ); + protected void customizeContainerConfiguration(final ContainerConfiguration configuration) { + configuration.setClassPathScanning(PlexusConstants.SCANNING_INDEX).setAutoWiring(true); } /** * @return default location of the test read/write repository */ - protected File getRepositoryRoot() - { - return PlexusJUnit4TestSupport.getTestFile( "target/scm-test/repository" ); + protected File getRepositoryRoot() { + return PlexusJUnit4TestSupport.getTestFile("target/scm-test/repository"); } /** * @return Location of the revisioned (read only) repository */ - protected File getRepository() - { - return PlexusJUnit4TestSupport.getTestFile( "/src/test/repository" ); + protected File getRepository() { + return PlexusJUnit4TestSupport.getTestFile("/src/test/repository"); } /** * @return location of the working copy (always checkout) */ - protected File getWorkingCopy() - { - return PlexusJUnit4TestSupport.getTestFile( "target/scm-test/working-copy" ); + protected File getWorkingCopy() { + return PlexusJUnit4TestSupport.getTestFile("target/scm-test/working-copy"); } /** @@ -118,101 +109,84 @@ protected File getWorkingCopy() * * @return location of the working copy (always checkout) */ - protected File getWorkingDirectory() - { + protected File getWorkingDirectory() { return getWorkingCopy(); } /** * @return default location for doing assertions on a working tree */ - protected File getAssertionCopy() - { - return PlexusJUnit4TestSupport.getTestFile( "target/scm-test/assertion-copy" ); + protected File getAssertionCopy() { + return PlexusJUnit4TestSupport.getTestFile("target/scm-test/assertion-copy"); } /** * @return default location for doing update operations on a working tree */ - protected File getUpdatingCopy() - { - return PlexusJUnit4TestSupport.getTestFile( "target/scm-test/updating-copy" ); + protected File getUpdatingCopy() { + return PlexusJUnit4TestSupport.getTestFile("target/scm-test/updating-copy"); } - protected ScmManager getScmManager() - throws Exception - { - if ( scmManager == null ) - { - scmManager = lookup( ScmManager.class ); + protected ScmManager getScmManager() throws Exception { + if (scmManager == null) { + scmManager = lookup(ScmManager.class); } return scmManager; } - protected ScmRepository makeScmRepository( String scmUrl ) - throws Exception - { - return getScmManager().makeScmRepository( scmUrl ); + protected ScmRepository makeScmRepository(String scmUrl) throws Exception { + return getScmManager().makeScmRepository(scmUrl); } - public void assertPath( String expectedPath, String actualPath ) - throws Exception - { - assertEquals( expectedPath.replace( '\\', '/' ), actualPath.replace( '\\', '/' ) ); + public void assertPath(String expectedPath, String actualPath) throws Exception { + assertEquals(expectedPath.replace('\\', '/'), actualPath.replace('\\', '/')); } - protected void assertFile( File root, String fileName ) - throws Exception - { - File file = new File( root, fileName ); + protected void assertFile(File root, String fileName) throws Exception { + File file = new File(root, fileName); - assertTrue( "Missing file: '" + file.getAbsolutePath() + "'.", file.exists() ); + assertTrue("Missing file: '" + file.getAbsolutePath() + "'.", file.exists()); - assertTrue( "File isn't a file: '" + file.getAbsolutePath() + "'.", file.isFile() ); + assertTrue("File isn't a file: '" + file.getAbsolutePath() + "'.", file.isFile()); String expected = fileName; - String actual = FileUtils.fileRead( file ); + String actual = FileUtils.fileRead(file); - assertEquals( "The file doesn't contain the expected contents. File: " + file.getAbsolutePath(), expected, - actual ); + assertEquals( + "The file doesn't contain the expected contents. File: " + file.getAbsolutePath(), expected, actual); } - protected void assertResultIsSuccess( ScmResult result ) - { - if ( result.isSuccess() ) - { + protected void assertResultIsSuccess(ScmResult result) { + if (result.isSuccess()) { return; } - printOutputError( result ); + printOutputError(result); - fail( "The command result success flag was false." ); + fail("The command result success flag was false."); } - protected void printOutputError( ScmResult result ) - { - System.err.println( "----------------------------------------------------------------------" ); - System.err.println( "Provider message" ); - System.err.println( "----------------------------------------------------------------------" ); - System.err.println( result.getProviderMessage() ); - System.err.println( "----------------------------------------------------------------------" ); - - System.err.println( "----------------------------------------------------------------------" ); - System.err.println( "Command output" ); - System.err.println( "----------------------------------------------------------------------" ); - System.err.println( result.getCommandOutput() ); - System.err.println( "----------------------------------------------------------------------" ); + protected void printOutputError(ScmResult result) { + System.err.println("----------------------------------------------------------------------"); + System.err.println("Provider message"); + System.err.println("----------------------------------------------------------------------"); + System.err.println(result.getProviderMessage()); + System.err.println("----------------------------------------------------------------------"); + + System.err.println("----------------------------------------------------------------------"); + System.err.println("Command output"); + System.err.println("----------------------------------------------------------------------"); + System.err.println(result.getCommandOutput()); + System.err.println("----------------------------------------------------------------------"); } - protected ScmFileSet getScmFileSet() - { - return new ScmFileSet( getWorkingCopy() ); + protected ScmFileSet getScmFileSet() { + return new ScmFileSet(getWorkingCopy()); } - protected static void setDebugExecute( boolean debugExecute ) - { + protected static void setDebugExecute(boolean debugExecute) { ScmTestCase.debugExecute = debugExecute; } @@ -226,151 +200,126 @@ protected static void setDebugExecute( boolean debugExecute ) * @see CommandLineUtils#executeCommandLine(Commandline, org.codehaus.plexus.util.cli.StreamConsumer, * org.codehaus.plexus.util.cli.StreamConsumer) */ - public static void execute( File workingDirectory, String executable, String arguments ) - throws Exception - { + public static void execute(File workingDirectory, String executable, String arguments) throws Exception { Commandline cl = new Commandline(); - cl.setExecutable( executable ); + cl.setExecutable(executable); - cl.setWorkingDirectory( workingDirectory.getAbsolutePath() ); + cl.setWorkingDirectory(workingDirectory.getAbsolutePath()); - cl.addArguments( CommandLineUtils.translateCommandline( arguments ) ); + cl.addArguments(CommandLineUtils.translateCommandline(arguments)); StringStreamConsumer stdout = new CommandLineUtils.StringStreamConsumer(); StringStreamConsumer stderr = new CommandLineUtils.StringStreamConsumer(); - System.out.println( "Test command line: " + cl ); - - int exitValue = CommandLineUtils.executeCommandLine( cl, stdout, stderr ); - - if ( debugExecute || exitValue != 0 ) - { - System.err.println( "-----------------------------------------" ); - System.err.println( "Command line: " + cl ); - System.err.println( "Working directory: " + cl.getWorkingDirectory() ); - System.err.println( "-----------------------------------------" ); - System.err.println( "Standard output: " ); - System.err.println( "-----------------------------------------" ); - System.err.println( stdout.getOutput() ); - System.err.println( "-----------------------------------------" ); - - System.err.println( "Standard error: " ); - System.err.println( "-----------------------------------------" ); - System.err.println( stderr.getOutput() ); - System.err.println( "-----------------------------------------" ); + System.out.println("Test command line: " + cl); + + int exitValue = CommandLineUtils.executeCommandLine(cl, stdout, stderr); + + if (debugExecute || exitValue != 0) { + System.err.println("-----------------------------------------"); + System.err.println("Command line: " + cl); + System.err.println("Working directory: " + cl.getWorkingDirectory()); + System.err.println("-----------------------------------------"); + System.err.println("Standard output: "); + System.err.println("-----------------------------------------"); + System.err.println(stdout.getOutput()); + System.err.println("-----------------------------------------"); + + System.err.println("Standard error: "); + System.err.println("-----------------------------------------"); + System.err.println(stderr.getOutput()); + System.err.println("-----------------------------------------"); } - if ( exitValue != 0 ) - { - fail( "Exit value wasn't 0, was:" + exitValue ); + if (exitValue != 0) { + fail("Exit value wasn't 0, was:" + exitValue); } } - protected static void makeDirectory( File basedir, String fileName ) - { - File dir = new File( basedir, fileName ); + protected static void makeDirectory(File basedir, String fileName) { + File dir = new File(basedir, fileName); - if ( !dir.exists() ) - { - assertTrue( dir.mkdirs() ); + if (!dir.exists()) { + assertTrue(dir.mkdirs()); } } - protected static void makeFile( File basedir, String fileName ) - throws IOException - { - makeFile( basedir, fileName, fileName ); + protected static void makeFile(File basedir, String fileName) throws IOException { + makeFile(basedir, fileName, fileName); } - public static void makeFile( File basedir, String fileName, String contents ) - throws IOException - { - File file = new File( basedir, fileName ); + public static void makeFile(File basedir, String fileName, String contents) throws IOException { + File file = new File(basedir, fileName); File parent = file.getParentFile(); - if ( !parent.exists() ) - { - assertTrue( parent.mkdirs() ); + if (!parent.exists()) { + assertTrue(parent.mkdirs()); } - try ( FileWriter writer = new FileWriter( file ) ) - { - writer.write( contents ); + try (FileWriter writer = new FileWriter(file)) { + writer.write(contents); } } - protected void deleteDirectory( File directory ) - throws IOException - { - FileUtils.deleteDirectory( directory ); + protected void deleteDirectory(File directory) throws IOException { + FileUtils.deleteDirectory(directory); } - public static Date getDate( int year, int month, int day ) - { - return getDate( year, month, day, 0, 0, 0, null ); + public static Date getDate(int year, int month, int day) { + return getDate(year, month, day, 0, 0, 0, null); } - protected static Date getDate( int year, int month, int day, TimeZone tz ) - { - return getDate( year, month, day, 0, 0, 0, tz ); + protected static Date getDate(int year, int month, int day, TimeZone tz) { + return getDate(year, month, day, 0, 0, 0, tz); } - protected static Date getDate( int year, int month, int day, int hourOfDay, int minute, int second, TimeZone tz ) - { + protected static Date getDate(int year, int month, int day, int hourOfDay, int minute, int second, TimeZone tz) { Calendar cal = Calendar.getInstance(); - if ( tz != null ) - { - cal.setTimeZone( tz ); + if (tz != null) { + cal.setTimeZone(tz); } - cal.set( year, month, day, hourOfDay, minute, second ); - cal.set( Calendar.MILLISECOND, 0 ); + cal.set(year, month, day, hourOfDay, minute, second); + cal.set(Calendar.MILLISECOND, 0); return cal.getTime(); } - public void assertCommandLine( String expectedCommand, File expectedWorkingDirectory, Commandline actualCommand ) - throws IOException - { - Commandline cl = new Commandline( expectedCommand ); - if ( expectedWorkingDirectory != null ) - { - cl.setWorkingDirectory( expectedWorkingDirectory.getAbsolutePath() ); + public void assertCommandLine(String expectedCommand, File expectedWorkingDirectory, Commandline actualCommand) + throws IOException { + Commandline cl = new Commandline(expectedCommand); + if (expectedWorkingDirectory != null) { + cl.setWorkingDirectory(expectedWorkingDirectory.getAbsolutePath()); } - String expectedCommandLineAsExecuted = StringUtils.join( cl.getShellCommandline(), " " ); - String actualCommandLineAsExecuted = StringUtils.join( actualCommand.getShellCommandline(), " " ); - assertEquals( expectedCommandLineAsExecuted, actualCommandLineAsExecuted ); + String expectedCommandLineAsExecuted = StringUtils.join(cl.getShellCommandline(), " "); + String actualCommandLineAsExecuted = StringUtils.join(actualCommand.getShellCommandline(), " "); + assertEquals(expectedCommandLineAsExecuted, actualCommandLineAsExecuted); } - public static void checkScmPresence( String scmProviderCommand ) - { - assumeTrue( "Skipping tests because the required command '" + scmProviderCommand + "' is not available.", - ScmTestCase.isSystemCmd( scmProviderCommand ) ); + public static void checkScmPresence(String scmProviderCommand) { + assumeTrue( + "Skipping tests because the required command '" + scmProviderCommand + "' is not available.", + ScmTestCase.isSystemCmd(scmProviderCommand)); } /** * @param cmd the executable to run, not null. * @return true if and only if the command is on the path */ - public static boolean isSystemCmd( String cmd ) - { - try - { - Runtime.getRuntime().exec( cmd ); + public static boolean isSystemCmd(String cmd) { + try { + Runtime.getRuntime().exec(cmd); return true; - } - catch ( IOException e ) - { + } catch (IOException e) { return false; } } - public static void printSystemCmdUnavail( String cmd, String testName ) - { - System.err.printf( "'%s' is not a system command. Ignored %s.%n", cmd, testName ); + public static void printSystemCmdUnavail(String cmd, String testName) { + System.err.printf("'%s' is not a system command. Ignored %s.%n", cmd, testName); } } diff --git a/maven-scm-test/src/main/java/org/apache/maven/scm/manager/ScmManagerStub.java b/maven-scm-test/src/main/java/org/apache/maven/scm/manager/ScmManagerStub.java index 0ba9d6c33..676ef5673 100644 --- a/maven-scm-test/src/main/java/org/apache/maven/scm/manager/ScmManagerStub.java +++ b/maven-scm-test/src/main/java/org/apache/maven/scm/manager/ScmManagerStub.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.manager; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,12 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.manager; + +import java.io.File; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; import org.apache.maven.scm.ScmBranch; import org.apache.maven.scm.ScmException; @@ -48,11 +52,6 @@ import org.apache.maven.scm.repository.ScmRepositoryStub; import org.apache.maven.scm.repository.UnknownRepositoryStructure; -import java.io.File; -import java.util.ArrayList; -import java.util.Date; -import java.util.List; - /** * Stub implementation of ScmManager for unit testing purposes. * It allows setting the expected results that the different methods will return. @@ -62,9 +61,7 @@ * @author Carlos Sanchez * */ -public class ScmManagerStub - implements ScmManager -{ +public class ScmManagerStub implements ScmManager { private ScmRepository scmRepository; @@ -75,46 +72,39 @@ public class ScmManagerStub /** * Creates a new stub with stub repository and provider, and empty list of messages */ - public ScmManagerStub() - { - setScmRepository( new ScmRepositoryStub() ); - setScmProvider( new ScmProviderStub() ); - setMessages( new ArrayList( 0 ) ); + public ScmManagerStub() { + setScmRepository(new ScmRepositoryStub()); + setScmProvider(new ScmProviderStub()); + setMessages(new ArrayList(0)); } - public void setScmProvider( ScmProvider scmProvider ) - { + public void setScmProvider(ScmProvider scmProvider) { this.scmProvider = scmProvider; } - public ScmProvider getScmProvider() - { + public ScmProvider getScmProvider() { return scmProvider; } /** * {@inheritDoc} */ - public void setScmProvider( String providerType, ScmProvider provider ) - { - setScmProvider( provider ); + public void setScmProvider(String providerType, ScmProvider provider) { + setScmProvider(provider); } /** * {@inheritDoc} */ - public void setScmProviderImplementation( String providerType, String providerImplementation ) - { - //Do nothing there + public void setScmProviderImplementation(String providerType, String providerImplementation) { + // Do nothing there } - public void setScmRepository( ScmRepository scmRepository ) - { + public void setScmRepository(ScmRepository scmRepository) { this.scmRepository = scmRepository; } - public ScmRepository getScmRepository() - { + public ScmRepository getScmRepository() { return scmRepository; } @@ -123,8 +113,7 @@ public ScmRepository getScmRepository() * * @param messages List of String objects */ - public void setMessages( List messages ) - { + public void setMessages(List messages) { this.messages = messages; } @@ -133,26 +122,22 @@ public void setMessages( List messages ) * * @return List of String objects */ - public List getMessages() - { + public List getMessages() { return messages; } /** * {@inheritDoc} */ - public ScmRepository makeScmRepository( String scmUrl ) - throws ScmRepositoryException, NoSuchScmProviderException - { + public ScmRepository makeScmRepository(String scmUrl) throws ScmRepositoryException, NoSuchScmProviderException { return getScmRepository(); } /** * {@inheritDoc} */ - public ScmRepository makeProviderScmRepository( String providerType, File path ) - throws ScmRepositoryException, UnknownRepositoryStructure, NoSuchScmProviderException - { + public ScmRepository makeProviderScmRepository(String providerType, File path) + throws ScmRepositoryException, UnknownRepositoryStructure, NoSuchScmProviderException { return getScmRepository(); } @@ -162,412 +147,356 @@ public ScmRepository makeProviderScmRepository( String providerType, File path ) * @param scmUrl ignored * @return List of String objects, the same list returned by getMessages() */ - public List validateScmRepository( String scmUrl ) - { + public List validateScmRepository(String scmUrl) { return getMessages(); } /** * {@inheritDoc} */ - public ScmProvider getProviderByUrl( String scmUrl ) - throws ScmRepositoryException, NoSuchScmProviderException - { + public ScmProvider getProviderByUrl(String scmUrl) throws ScmRepositoryException, NoSuchScmProviderException { return getScmProvider(); } /** * {@inheritDoc} */ - public ScmProvider getProviderByType( String providerType ) - throws NoSuchScmProviderException - { + public ScmProvider getProviderByType(String providerType) throws NoSuchScmProviderException { return getScmProvider(); } /** * {@inheritDoc} */ - public ScmProvider getProviderByRepository( ScmRepository repository ) - throws NoSuchScmProviderException - { + public ScmProvider getProviderByRepository(ScmRepository repository) throws NoSuchScmProviderException { return getScmProvider(); } /** * {@inheritDoc} */ - public AddScmResult add( ScmRepository repository, ScmFileSet fileSet ) - throws ScmException - { - return this.getProviderByRepository( repository ).add( repository, fileSet ); + public AddScmResult add(ScmRepository repository, ScmFileSet fileSet) throws ScmException { + return this.getProviderByRepository(repository).add(repository, fileSet); } /** * {@inheritDoc} */ - public AddScmResult add( ScmRepository repository, ScmFileSet fileSet, String message ) - throws ScmException - { - return this.getProviderByRepository( repository ).add( repository, fileSet, message ); + public AddScmResult add(ScmRepository repository, ScmFileSet fileSet, String message) throws ScmException { + return this.getProviderByRepository(repository).add(repository, fileSet, message); } /** * {@inheritDoc} */ - @SuppressWarnings( "deprecation" ) - public BranchScmResult branch( ScmRepository repository, ScmFileSet fileSet, String branchName ) - throws ScmException - { - return this.getProviderByRepository( repository ).branch( repository, fileSet, branchName ); + @SuppressWarnings("deprecation") + public BranchScmResult branch(ScmRepository repository, ScmFileSet fileSet, String branchName) throws ScmException { + return this.getProviderByRepository(repository).branch(repository, fileSet, branchName); } /** * {@inheritDoc} */ - @SuppressWarnings( "deprecation" ) - public BranchScmResult branch( ScmRepository repository, ScmFileSet fileSet, String branchName, String message ) - throws ScmException - { - return this.getProviderByRepository( repository ).branch( repository, fileSet, branchName, message ); + @SuppressWarnings("deprecation") + public BranchScmResult branch(ScmRepository repository, ScmFileSet fileSet, String branchName, String message) + throws ScmException { + return this.getProviderByRepository(repository).branch(repository, fileSet, branchName, message); } /** * {@inheritDoc} */ - public ChangeLogScmResult changeLog( ScmRepository repository, ScmFileSet fileSet, Date startDate, Date endDate, - int numDays, ScmBranch branch ) - throws ScmException - { - return this.getProviderByRepository( repository ).changeLog( repository, fileSet, startDate, endDate, numDays, - branch ); + public ChangeLogScmResult changeLog( + ScmRepository repository, ScmFileSet fileSet, Date startDate, Date endDate, int numDays, ScmBranch branch) + throws ScmException { + return this.getProviderByRepository(repository) + .changeLog(repository, fileSet, startDate, endDate, numDays, branch); } /** * {@inheritDoc} */ - public ChangeLogScmResult changeLog( ScmRepository repository, ScmFileSet fileSet, Date startDate, Date endDate, - int numDays, ScmBranch branch, String datePattern ) - throws ScmException - { - return this.getProviderByRepository( repository ).changeLog( repository, fileSet, startDate, endDate, numDays, - branch, datePattern ); + public ChangeLogScmResult changeLog( + ScmRepository repository, + ScmFileSet fileSet, + Date startDate, + Date endDate, + int numDays, + ScmBranch branch, + String datePattern) + throws ScmException { + return this.getProviderByRepository(repository) + .changeLog(repository, fileSet, startDate, endDate, numDays, branch, datePattern); } /** * {@inheritDoc} */ - public ChangeLogScmResult changeLog( ChangeLogScmRequest request ) - throws ScmException - { + public ChangeLogScmResult changeLog(ChangeLogScmRequest request) throws ScmException { final ScmRepository repository = request.getScmRepository(); - return this.getProviderByRepository( repository ).changeLog( request ); + return this.getProviderByRepository(repository).changeLog(request); } /** * {@inheritDoc} */ - public ChangeLogScmResult changeLog( ScmRepository repository, ScmFileSet fileSet, ScmVersion startVersion, - ScmVersion endVersion ) - throws ScmException - { - return this.getProviderByRepository( repository ).changeLog( repository, fileSet, startVersion, endVersion ); + public ChangeLogScmResult changeLog( + ScmRepository repository, ScmFileSet fileSet, ScmVersion startVersion, ScmVersion endVersion) + throws ScmException { + return this.getProviderByRepository(repository).changeLog(repository, fileSet, startVersion, endVersion); } /** * {@inheritDoc} */ - public ChangeLogScmResult changeLog( ScmRepository repository, ScmFileSet fileSet, ScmVersion startRevision, - ScmVersion endRevision, String datePattern ) - throws ScmException - { - return this.getProviderByRepository( repository ).changeLog( repository, fileSet, startRevision, endRevision, - datePattern ); + public ChangeLogScmResult changeLog( + ScmRepository repository, + ScmFileSet fileSet, + ScmVersion startRevision, + ScmVersion endRevision, + String datePattern) + throws ScmException { + return this.getProviderByRepository(repository) + .changeLog(repository, fileSet, startRevision, endRevision, datePattern); } /** * {@inheritDoc} */ - public CheckInScmResult checkIn( ScmRepository repository, ScmFileSet fileSet, String message ) - throws ScmException - { - return this.getProviderByRepository( repository ).checkIn( repository, fileSet, message ); + public CheckInScmResult checkIn(ScmRepository repository, ScmFileSet fileSet, String message) throws ScmException { + return this.getProviderByRepository(repository).checkIn(repository, fileSet, message); } /** * {@inheritDoc} */ - public CheckInScmResult checkIn( ScmRepository repository, ScmFileSet fileSet, ScmVersion revision, String message ) - throws ScmException - { - return this.getProviderByRepository( repository ).checkIn( repository, fileSet, revision, message ); + public CheckInScmResult checkIn(ScmRepository repository, ScmFileSet fileSet, ScmVersion revision, String message) + throws ScmException { + return this.getProviderByRepository(repository).checkIn(repository, fileSet, revision, message); } /** * {@inheritDoc} */ - public CheckOutScmResult checkOut( ScmRepository repository, ScmFileSet fileSet ) - throws ScmException - { - return this.getProviderByRepository( repository ).checkOut( repository, fileSet ); + public CheckOutScmResult checkOut(ScmRepository repository, ScmFileSet fileSet) throws ScmException { + return this.getProviderByRepository(repository).checkOut(repository, fileSet); } /** * {@inheritDoc} */ - public CheckOutScmResult checkOut( ScmRepository repository, ScmFileSet fileSet, ScmVersion version ) - throws ScmException - { - return this.getProviderByRepository( repository ).checkOut( repository, fileSet, version ); + public CheckOutScmResult checkOut(ScmRepository repository, ScmFileSet fileSet, ScmVersion version) + throws ScmException { + return this.getProviderByRepository(repository).checkOut(repository, fileSet, version); } /** * {@inheritDoc} */ - public CheckOutScmResult checkOut( ScmRepository repository, ScmFileSet fileSet, boolean recursive ) - throws ScmException - { - return this.getProviderByRepository( repository ).checkOut( repository, fileSet, recursive ); + public CheckOutScmResult checkOut(ScmRepository repository, ScmFileSet fileSet, boolean recursive) + throws ScmException { + return this.getProviderByRepository(repository).checkOut(repository, fileSet, recursive); } /** * {@inheritDoc} */ - public CheckOutScmResult checkOut( ScmRepository repository, ScmFileSet fileSet, ScmVersion version, - boolean recursive ) - throws ScmException - { - return this.getProviderByRepository( repository ).checkOut( repository, fileSet, version, recursive ); + public CheckOutScmResult checkOut( + ScmRepository repository, ScmFileSet fileSet, ScmVersion version, boolean recursive) throws ScmException { + return this.getProviderByRepository(repository).checkOut(repository, fileSet, version, recursive); } /** * {@inheritDoc} */ - public DiffScmResult diff( ScmRepository repository, ScmFileSet fileSet, ScmVersion startVersion, - ScmVersion endVersion ) - throws ScmException - { - return this.getProviderByRepository( repository ).diff( repository, fileSet, startVersion, endVersion ); + public DiffScmResult diff( + ScmRepository repository, ScmFileSet fileSet, ScmVersion startVersion, ScmVersion endVersion) + throws ScmException { + return this.getProviderByRepository(repository).diff(repository, fileSet, startVersion, endVersion); } /** * {@inheritDoc} */ - public EditScmResult edit( ScmRepository repository, ScmFileSet fileSet ) - throws ScmException - { - return this.getProviderByRepository( repository ).edit( repository, fileSet ); + public EditScmResult edit(ScmRepository repository, ScmFileSet fileSet) throws ScmException { + return this.getProviderByRepository(repository).edit(repository, fileSet); } /** * {@inheritDoc} */ - public ExportScmResult export( ScmRepository repository, ScmFileSet fileSet ) - throws ScmException - { - return this.getProviderByRepository( repository ).export( repository, fileSet ); + public ExportScmResult export(ScmRepository repository, ScmFileSet fileSet) throws ScmException { + return this.getProviderByRepository(repository).export(repository, fileSet); } /** * {@inheritDoc} */ - public ExportScmResult export( ScmRepository repository, ScmFileSet fileSet, ScmVersion version ) - throws ScmException - { - return this.getProviderByRepository( repository ).export( repository, fileSet, version ); + public ExportScmResult export(ScmRepository repository, ScmFileSet fileSet, ScmVersion version) + throws ScmException { + return this.getProviderByRepository(repository).export(repository, fileSet, version); } /** * {@inheritDoc} */ - public ExportScmResult export( ScmRepository repository, ScmFileSet fileSet, String outputDirectory ) - throws ScmException - { - return this.export( repository, fileSet, outputDirectory ); + public ExportScmResult export(ScmRepository repository, ScmFileSet fileSet, String outputDirectory) + throws ScmException { + return this.export(repository, fileSet, outputDirectory); } /** * {@inheritDoc} */ - public ExportScmResult export( ScmRepository repository, ScmFileSet fileSet, ScmVersion version, - String outputDirectory ) - throws ScmException - { - return this.getProviderByRepository( repository ).export( repository, fileSet, version, outputDirectory ); + public ExportScmResult export( + ScmRepository repository, ScmFileSet fileSet, ScmVersion version, String outputDirectory) + throws ScmException { + return this.getProviderByRepository(repository).export(repository, fileSet, version, outputDirectory); } /** * {@inheritDoc} */ - public ListScmResult list( ScmRepository repository, ScmFileSet fileSet, boolean recursive, ScmVersion version ) - throws ScmException - { - return this.getProviderByRepository( repository ).list( repository, fileSet, recursive, version ); + public ListScmResult list(ScmRepository repository, ScmFileSet fileSet, boolean recursive, ScmVersion version) + throws ScmException { + return this.getProviderByRepository(repository).list(repository, fileSet, recursive, version); } /** * {@inheritDoc} */ - public RemoveScmResult remove( ScmRepository repository, ScmFileSet fileSet, String message ) - throws ScmException - { - return this.getProviderByRepository( repository ).remove( repository, fileSet, message ); + public RemoveScmResult remove(ScmRepository repository, ScmFileSet fileSet, String message) throws ScmException { + return this.getProviderByRepository(repository).remove(repository, fileSet, message); } /** * {@inheritDoc} */ - public StatusScmResult status( ScmRepository repository, ScmFileSet fileSet ) - throws ScmException - { - return this.getProviderByRepository( repository ).status( repository, fileSet ); + public StatusScmResult status(ScmRepository repository, ScmFileSet fileSet) throws ScmException { + return this.getProviderByRepository(repository).status(repository, fileSet); } /** * {@inheritDoc} */ - @SuppressWarnings( "deprecation" ) - public TagScmResult tag( ScmRepository repository, ScmFileSet fileSet, String tagName ) - throws ScmException - { - return this.getProviderByRepository( repository ).tag( repository, fileSet, tagName ); + @SuppressWarnings("deprecation") + public TagScmResult tag(ScmRepository repository, ScmFileSet fileSet, String tagName) throws ScmException { + return this.getProviderByRepository(repository).tag(repository, fileSet, tagName); } /** * {@inheritDoc} */ - @SuppressWarnings( "deprecation" ) - public TagScmResult tag( ScmRepository repository, ScmFileSet fileSet, String tagName, String message ) - throws ScmException - { - return this.getProviderByRepository( repository ).tag( repository, fileSet, tagName, message ); + @SuppressWarnings("deprecation") + public TagScmResult tag(ScmRepository repository, ScmFileSet fileSet, String tagName, String message) + throws ScmException { + return this.getProviderByRepository(repository).tag(repository, fileSet, tagName, message); } /** * {@inheritDoc} */ - public UnEditScmResult unedit( ScmRepository repository, ScmFileSet fileSet ) - throws ScmException - { - return this.getProviderByRepository( repository ).unedit( repository, fileSet ); + public UnEditScmResult unedit(ScmRepository repository, ScmFileSet fileSet) throws ScmException { + return this.getProviderByRepository(repository).unedit(repository, fileSet); } /** * {@inheritDoc} */ - public UpdateScmResult update( ScmRepository repository, ScmFileSet fileSet ) - throws ScmException - { - return this.getProviderByRepository( repository ).update( repository, fileSet ); + public UpdateScmResult update(ScmRepository repository, ScmFileSet fileSet) throws ScmException { + return this.getProviderByRepository(repository).update(repository, fileSet); } /** * {@inheritDoc} */ - public UpdateScmResult update( ScmRepository repository, ScmFileSet fileSet, ScmVersion version ) - throws ScmException - { - return this.getProviderByRepository( repository ).update( repository, fileSet, version ); + public UpdateScmResult update(ScmRepository repository, ScmFileSet fileSet, ScmVersion version) + throws ScmException { + return this.getProviderByRepository(repository).update(repository, fileSet, version); } /** * {@inheritDoc} */ - public UpdateScmResult update( ScmRepository repository, ScmFileSet fileSet, boolean runChangelog ) - throws ScmException - { - return this.getProviderByRepository( repository ).update( repository, fileSet, runChangelog ); + public UpdateScmResult update(ScmRepository repository, ScmFileSet fileSet, boolean runChangelog) + throws ScmException { + return this.getProviderByRepository(repository).update(repository, fileSet, runChangelog); } /** * {@inheritDoc} */ - public UpdateScmResult update( ScmRepository repository, ScmFileSet fileSet, ScmVersion version, - boolean runChangelog ) - throws ScmException - { - return this.getProviderByRepository( repository ).update( repository, fileSet, version, runChangelog ); + public UpdateScmResult update( + ScmRepository repository, ScmFileSet fileSet, ScmVersion version, boolean runChangelog) + throws ScmException { + return this.getProviderByRepository(repository).update(repository, fileSet, version, runChangelog); } /** * {@inheritDoc} */ - public UpdateScmResult update( ScmRepository repository, ScmFileSet fileSet, String datePattern ) - throws ScmException - { - return this.getProviderByRepository( repository ).update( repository, fileSet, (ScmVersion) null, datePattern ); + public UpdateScmResult update(ScmRepository repository, ScmFileSet fileSet, String datePattern) + throws ScmException { + return this.getProviderByRepository(repository).update(repository, fileSet, (ScmVersion) null, datePattern); } /** * {@inheritDoc} */ - public UpdateScmResult update( ScmRepository repository, ScmFileSet fileSet, ScmVersion version, - String datePattern ) - throws ScmException - { - return this.getProviderByRepository( repository ).update( repository, fileSet, version, datePattern ); + public UpdateScmResult update(ScmRepository repository, ScmFileSet fileSet, ScmVersion version, String datePattern) + throws ScmException { + return this.getProviderByRepository(repository).update(repository, fileSet, version, datePattern); } /** * {@inheritDoc} */ - public UpdateScmResult update( ScmRepository repository, ScmFileSet fileSet, Date lastUpdate ) - throws ScmException - { - return this.getProviderByRepository( repository ).update( repository, fileSet, (ScmVersion) null, lastUpdate ); + public UpdateScmResult update(ScmRepository repository, ScmFileSet fileSet, Date lastUpdate) throws ScmException { + return this.getProviderByRepository(repository).update(repository, fileSet, (ScmVersion) null, lastUpdate); } /** * {@inheritDoc} */ - public UpdateScmResult update( ScmRepository repository, ScmFileSet fileSet, ScmVersion version, Date lastUpdate ) - throws ScmException - { - return this.getProviderByRepository( repository ).update( repository, fileSet, version, lastUpdate ); + public UpdateScmResult update(ScmRepository repository, ScmFileSet fileSet, ScmVersion version, Date lastUpdate) + throws ScmException { + return this.getProviderByRepository(repository).update(repository, fileSet, version, lastUpdate); } /** * {@inheritDoc} */ - public UpdateScmResult update( ScmRepository repository, ScmFileSet fileSet, Date lastUpdate, String datePattern ) - throws ScmException - { - return this.getProviderByRepository( repository ).update( repository, fileSet, (ScmVersion) null, lastUpdate, - datePattern ); + public UpdateScmResult update(ScmRepository repository, ScmFileSet fileSet, Date lastUpdate, String datePattern) + throws ScmException { + return this.getProviderByRepository(repository) + .update(repository, fileSet, (ScmVersion) null, lastUpdate, datePattern); } /** * {@inheritDoc} */ - public UpdateScmResult update( ScmRepository repository, ScmFileSet fileSet, ScmVersion version, Date lastUpdate, - String datePattern ) - throws ScmException - { - return this.getProviderByRepository( repository ).update( repository, fileSet, version, lastUpdate, - datePattern ); + public UpdateScmResult update( + ScmRepository repository, ScmFileSet fileSet, ScmVersion version, Date lastUpdate, String datePattern) + throws ScmException { + return this.getProviderByRepository(repository).update(repository, fileSet, version, lastUpdate, datePattern); } /** * {@inheritDoc} */ - public BlameScmResult blame( ScmRepository repository, ScmFileSet fileSet, String filename ) - throws ScmException - { - return this.getProviderByRepository( repository ).blame( repository, fileSet, filename ); + public BlameScmResult blame(ScmRepository repository, ScmFileSet fileSet, String filename) throws ScmException { + return this.getProviderByRepository(repository).blame(repository, fileSet, filename); } - public BlameScmResult blame( BlameScmRequest blameScmRequest ) - throws ScmException - { - return this.getProviderByRepository( blameScmRequest.getScmRepository() ).blame( blameScmRequest ); + public BlameScmResult blame(BlameScmRequest blameScmRequest) throws ScmException { + return this.getProviderByRepository(blameScmRequest.getScmRepository()).blame(blameScmRequest); } /** * {@inheritDoc} */ - public MkdirScmResult mkdir( ScmRepository repository, ScmFileSet fileSet, String message, boolean createInLocal ) - throws ScmException - { - return this.getProviderByRepository( repository ).mkdir( repository, fileSet, message, createInLocal ); + public MkdirScmResult mkdir(ScmRepository repository, ScmFileSet fileSet, String message, boolean createInLocal) + throws ScmException { + return this.getProviderByRepository(repository).mkdir(repository, fileSet, message, createInLocal); } } diff --git a/maven-scm-test/src/main/java/org/apache/maven/scm/provider/ScmProviderRepositoryStub.java b/maven-scm-test/src/main/java/org/apache/maven/scm/provider/ScmProviderRepositoryStub.java index 297312db2..bd4f3dd18 100644 --- a/maven-scm-test/src/main/java/org/apache/maven/scm/provider/ScmProviderRepositoryStub.java +++ b/maven-scm-test/src/main/java/org/apache/maven/scm/provider/ScmProviderRepositoryStub.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider; /** * Stub for ScmProviderRepository for unit testing purposes. @@ -27,29 +26,22 @@ * @author Carlos Sanchez * */ -public class ScmProviderRepositoryStub - extends ScmProviderRepository -{ +public class ScmProviderRepositoryStub extends ScmProviderRepository { private boolean persistCheckout = false; /** * Creates a ScmProviderRepositoryStub with null user and password, and persistCheckout false */ - public ScmProviderRepositoryStub() - { - } + public ScmProviderRepositoryStub() {} /** {@inheritDoc} */ - public boolean isPersistCheckout() - { + public boolean isPersistCheckout() { return persistCheckout; } /** {@inheritDoc} */ - public void setPersistCheckout( boolean persistCheckout ) - { + public void setPersistCheckout(boolean persistCheckout) { this.persistCheckout = persistCheckout; } - } diff --git a/maven-scm-test/src/main/java/org/apache/maven/scm/provider/ScmProviderStub.java b/maven-scm-test/src/main/java/org/apache/maven/scm/provider/ScmProviderStub.java index 76afdd13a..a400d6202 100644 --- a/maven-scm-test/src/main/java/org/apache/maven/scm/provider/ScmProviderStub.java +++ b/maven-scm-test/src/main/java/org/apache/maven/scm/provider/ScmProviderStub.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.provider; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,13 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.provider; + +import java.io.File; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Date; +import java.util.List; import org.apache.maven.scm.CommandParameters; import org.apache.maven.scm.ScmBranch; @@ -52,12 +57,6 @@ import org.apache.maven.scm.repository.ScmRepositoryException; import org.apache.maven.scm.repository.UnknownRepositoryStructure; -import java.io.File; -import java.util.ArrayList; -import java.util.Collections; -import java.util.Date; -import java.util.List; - /** * Stub implementation of ScmProvider for unit testing purposes. * It allows setting the expected results that the different methods will return. @@ -67,9 +66,7 @@ * @author Carlos Sanchez * */ -public class ScmProviderStub - implements ScmProvider -{ +public class ScmProviderStub implements ScmProvider { private String scmType, scmSpecificFilename; @@ -116,799 +113,695 @@ public class ScmProviderStub /** * Create a new ScmProviderStub with bogus (not null) attributes */ - public ScmProviderStub() - { - setScmSpecificFilename( "" ); - setAddScmResult( new AddScmResult( "", Collections.emptyList() ) ); - setBranchScmResult( new BranchScmResult( "", Collections.emptyList() ) ); - setChangeLogScmResult( new ChangeLogScmResult( "", "", "", true ) ); - setCheckInScmResult( new CheckInScmResult( "", "", "", true ) ); - setCheckOutScmResult( new CheckOutScmResult( "", "", "", true ) ); - setDiffScmResult( new DiffScmResult( "", "", "", true ) ); - setEditScmResult( new EditScmResult( "", "", "", true ) ); - setExportScmResult( new ExportScmResult( "", "", "", true ) ); - setRemoveScmResult( new RemoveScmResult( "", "", "", true ) ); - setStatusScmResult( new StatusScmResult( "", "", "", true ) ); - setTagScmResult( new TagScmResult( "", "", "", true ) ); - setUnEditScmResult( new UnEditScmResult( "", "", "", true ) ); - setUntagScmResult( new UntagScmResult( "", "", "", true ) ); - setUpdateScmResult( new UpdateScmResult( "", "", "", true ) ); - setBlameScmResult( new BlameScmResult( "", "", "", true ) ); - setMkdirScmResult( new MkdirScmResult( "", "", "", true ) ); + public ScmProviderStub() { + setScmSpecificFilename(""); + setAddScmResult(new AddScmResult("", Collections.emptyList())); + setBranchScmResult(new BranchScmResult("", Collections.emptyList())); + setChangeLogScmResult(new ChangeLogScmResult("", "", "", true)); + setCheckInScmResult(new CheckInScmResult("", "", "", true)); + setCheckOutScmResult(new CheckOutScmResult("", "", "", true)); + setDiffScmResult(new DiffScmResult("", "", "", true)); + setEditScmResult(new EditScmResult("", "", "", true)); + setExportScmResult(new ExportScmResult("", "", "", true)); + setRemoveScmResult(new RemoveScmResult("", "", "", true)); + setStatusScmResult(new StatusScmResult("", "", "", true)); + setTagScmResult(new TagScmResult("", "", "", true)); + setUnEditScmResult(new UnEditScmResult("", "", "", true)); + setUntagScmResult(new UntagScmResult("", "", "", true)); + setUpdateScmResult(new UpdateScmResult("", "", "", true)); + setBlameScmResult(new BlameScmResult("", "", "", true)); + setMkdirScmResult(new MkdirScmResult("", "", "", true)); } /** * {@inheritDoc} */ - public String sanitizeTagName( String tag ) - { + public String sanitizeTagName(String tag) { return tag; } /** * {@inheritDoc} */ - public boolean validateTagName( String tag ) - { + public boolean validateTagName(String tag) { return true; } /** * {@inheritDoc} */ - public String getScmType() - { + public String getScmType() { return scmType; } - public void setScmSpecificFilename( String scmSpecificFilename ) - { + public void setScmSpecificFilename(String scmSpecificFilename) { this.scmSpecificFilename = scmSpecificFilename; } - public boolean requiresEditMode() - { + public boolean requiresEditMode() { return requiresEditmode; } - public void setAddScmResult( AddScmResult addScmResult ) - { + public void setAddScmResult(AddScmResult addScmResult) { this.addScmResult = addScmResult; } - public AddScmResult getAddScmResult() - { + public AddScmResult getAddScmResult() { return addScmResult; } - public void setBranchScmResult( BranchScmResult branchScmResult ) - { + public void setBranchScmResult(BranchScmResult branchScmResult) { this.branchScmResult = branchScmResult; } - public BranchScmResult getBranchScmResult() - { + public BranchScmResult getBranchScmResult() { return branchScmResult; } - public void setCheckInScmResult( CheckInScmResult checkInScmResult ) - { + public void setCheckInScmResult(CheckInScmResult checkInScmResult) { this.checkInScmResult = checkInScmResult; } - public CheckInScmResult getCheckInScmResult() - { + public CheckInScmResult getCheckInScmResult() { return checkInScmResult; } - public void setCheckOutScmResult( CheckOutScmResult checkOutScmResult ) - { + public void setCheckOutScmResult(CheckOutScmResult checkOutScmResult) { this.checkOutScmResult = checkOutScmResult; } - public CheckOutScmResult getCheckOutScmResult() - { + public CheckOutScmResult getCheckOutScmResult() { return checkOutScmResult; } - public void setChangeLogScmResult( ChangeLogScmResult changeLogScmResult ) - { + public void setChangeLogScmResult(ChangeLogScmResult changeLogScmResult) { this.changeLogScmResult = changeLogScmResult; } - public ChangeLogScmResult getChangeLogScmResult() - { + public ChangeLogScmResult getChangeLogScmResult() { return changeLogScmResult; } - public void setDiffScmResult( DiffScmResult diffScmResult ) - { + public void setDiffScmResult(DiffScmResult diffScmResult) { this.diffScmResult = diffScmResult; } - public DiffScmResult getDiffScmResult() - { + public DiffScmResult getDiffScmResult() { return diffScmResult; } - public ExportScmResult getExportScmResult() - { + public ExportScmResult getExportScmResult() { return exportScmResult; } - public void setExportScmResult( ExportScmResult exportScmResult ) - { + public void setExportScmResult(ExportScmResult exportScmResult) { this.exportScmResult = exportScmResult; } - public void setTagScmResult( TagScmResult tagScmResult ) - { + public void setTagScmResult(TagScmResult tagScmResult) { this.tagScmResult = tagScmResult; } - public TagScmResult getTagScmResult() - { + public TagScmResult getTagScmResult() { return tagScmResult; } - public void setUntagScmResult( UntagScmResult untagScmResult ) - { + public void setUntagScmResult(UntagScmResult untagScmResult) { this.untagScmResult = untagScmResult; } - public UntagScmResult getUntagScmResult() - { + public UntagScmResult getUntagScmResult() { return untagScmResult; } - public void setRemoveScmResult( RemoveScmResult removeScmResult ) - { + public void setRemoveScmResult(RemoveScmResult removeScmResult) { this.removeScmResult = removeScmResult; } - public RemoveScmResult getRemoveScmResult() - { + public RemoveScmResult getRemoveScmResult() { return removeScmResult; } - public void setStatusScmResult( StatusScmResult statusScmResult ) - { + public void setStatusScmResult(StatusScmResult statusScmResult) { this.statusScmResult = statusScmResult; } - public StatusScmResult getStatusScmResult() - { + public StatusScmResult getStatusScmResult() { return statusScmResult; } - public void setUpdateScmResult( UpdateScmResult updateScmResult ) - { + public void setUpdateScmResult(UpdateScmResult updateScmResult) { this.updateScmResult = updateScmResult; } - public UpdateScmResult getUpdateScmResult() - { + public UpdateScmResult getUpdateScmResult() { return updateScmResult; } - public void setEditScmResult( EditScmResult editScmResult ) - { + public void setEditScmResult(EditScmResult editScmResult) { this.editScmResult = editScmResult; } - public EditScmResult getEditScmResult() - { + public EditScmResult getEditScmResult() { return editScmResult; } - public void setUnEditScmResult( UnEditScmResult unEditScmResult ) - { + public void setUnEditScmResult(UnEditScmResult unEditScmResult) { this.unEditScmResult = unEditScmResult; } - public UnEditScmResult getUnEditScmResult() - { + public UnEditScmResult getUnEditScmResult() { return unEditScmResult; } - public void setListScmResult( ListScmResult listScmResult ) - { + public void setListScmResult(ListScmResult listScmResult) { this.listScmResult = listScmResult; } - public ListScmResult getListScmResult() - { + public ListScmResult getListScmResult() { return listScmResult; } - public void setBlameScmResult( BlameScmResult blameScmResult ) - { + public void setBlameScmResult(BlameScmResult blameScmResult) { this.blameScmResult = blameScmResult; } - public BlameScmResult getBlameScmResult() - { + public BlameScmResult getBlameScmResult() { return blameScmResult; } - public MkdirScmResult getMkdirScmResult() - { + public MkdirScmResult getMkdirScmResult() { return mkdirScmResult; } - public void setMkdirScmResult( MkdirScmResult mkdirScmResult ) - { + public void setMkdirScmResult(MkdirScmResult mkdirScmResult) { this.mkdirScmResult = mkdirScmResult; } /** * {@inheritDoc} */ - public ScmProviderRepository makeProviderScmRepository( String scmSpecificUrl, char delimiter ) - throws ScmRepositoryException - { + public ScmProviderRepository makeProviderScmRepository(String scmSpecificUrl, char delimiter) + throws ScmRepositoryException { return scmProviderRepository; } /** * {@inheritDoc} */ - public ScmProviderRepository makeProviderScmRepository( File path ) - throws ScmRepositoryException, UnknownRepositoryStructure - { + public ScmProviderRepository makeProviderScmRepository(File path) + throws ScmRepositoryException, UnknownRepositoryStructure { return scmProviderRepository; } /** * {@inheritDoc} */ - public List validateScmUrl( String scmSpecificUrl, char delimiter ) - { + public List validateScmUrl(String scmSpecificUrl, char delimiter) { return errors; } /** * {@inheritDoc} */ - public String getScmSpecificFilename() - { + public String getScmSpecificFilename() { return scmSpecificFilename; } /** * {@inheritDoc} */ - public AddScmResult add( ScmRepository repository, ScmFileSet fileSet ) - throws ScmException - { + public AddScmResult add(ScmRepository repository, ScmFileSet fileSet) throws ScmException { return getAddScmResult(); } /** * {@inheritDoc} */ - public AddScmResult add( ScmRepository repository, ScmFileSet fileSet, String message ) - throws ScmException - { + public AddScmResult add(ScmRepository repository, ScmFileSet fileSet, String message) throws ScmException { return getAddScmResult(); } - public AddScmResult add( ScmRepository repository, ScmFileSet fileSet, CommandParameters commandParameters ) - throws ScmException - { + public AddScmResult add(ScmRepository repository, ScmFileSet fileSet, CommandParameters commandParameters) + throws ScmException { return getAddScmResult(); } /** * {@inheritDoc} */ - public BranchScmResult branch( ScmRepository repository, ScmFileSet fileSet, String branchName ) - throws ScmException - { + public BranchScmResult branch(ScmRepository repository, ScmFileSet fileSet, String branchName) throws ScmException { return getBranchScmResult(); } /** * {@inheritDoc} */ - public BranchScmResult branch( ScmRepository repository, ScmFileSet fileSet, String branchName, String message ) - throws ScmException - { + public BranchScmResult branch(ScmRepository repository, ScmFileSet fileSet, String branchName, String message) + throws ScmException { return getBranchScmResult(); } /** * {@inheritDoc} */ - public BranchScmResult branch( ScmRepository repository, ScmFileSet fileSet, String branchName, - ScmBranchParameters scmBranchParameters ) - throws ScmException - { + public BranchScmResult branch( + ScmRepository repository, ScmFileSet fileSet, String branchName, ScmBranchParameters scmBranchParameters) + throws ScmException { return getBranchScmResult(); } /** * {@inheritDoc} */ - public ChangeLogScmResult changeLog( ScmRepository repository, ScmFileSet fileSet, Date startDate, Date endDate, - int numDays, String branch ) - throws ScmException - { + public ChangeLogScmResult changeLog( + ScmRepository repository, ScmFileSet fileSet, Date startDate, Date endDate, int numDays, String branch) + throws ScmException { return getChangeLogScmResult(); } /** * {@inheritDoc} */ - public ChangeLogScmResult changeLog( ScmRepository repository, ScmFileSet fileSet, Date startDate, Date endDate, - int numDays, String branch, String datePattern ) - throws ScmException - { + public ChangeLogScmResult changeLog( + ScmRepository repository, + ScmFileSet fileSet, + Date startDate, + Date endDate, + int numDays, + String branch, + String datePattern) + throws ScmException { return getChangeLogScmResult(); } /** * {@inheritDoc} */ - public ChangeLogScmResult changeLog( ScmRepository repository, ScmFileSet fileSet, String startTag, String endTag ) - throws ScmException - { + public ChangeLogScmResult changeLog(ScmRepository repository, ScmFileSet fileSet, String startTag, String endTag) + throws ScmException { return getChangeLogScmResult(); } /** * {@inheritDoc} */ - public ChangeLogScmResult changeLog( ScmRepository repository, ScmFileSet fileSet, String startTag, String endTag, - String datePattern ) - throws ScmException - { + public ChangeLogScmResult changeLog( + ScmRepository repository, ScmFileSet fileSet, String startTag, String endTag, String datePattern) + throws ScmException { return getChangeLogScmResult(); } /** * {@inheritDoc} */ - public ChangeLogScmResult changeLog( ScmRepository repository, ScmFileSet fileSet, Date startDate, Date endDate, - int numDays, ScmBranch branch ) - throws ScmException - { + public ChangeLogScmResult changeLog( + ScmRepository repository, ScmFileSet fileSet, Date startDate, Date endDate, int numDays, ScmBranch branch) + throws ScmException { return getChangeLogScmResult(); } /** * {@inheritDoc} */ - public ChangeLogScmResult changeLog( ScmRepository repository, ScmFileSet fileSet, Date startDate, Date endDate, - int numDays, ScmBranch branch, String datePattern ) - throws ScmException - { + public ChangeLogScmResult changeLog( + ScmRepository repository, + ScmFileSet fileSet, + Date startDate, + Date endDate, + int numDays, + ScmBranch branch, + String datePattern) + throws ScmException { return getChangeLogScmResult(); } - public ChangeLogScmResult changeLog( ChangeLogScmRequest scmRequest ) - throws ScmException - { + public ChangeLogScmResult changeLog(ChangeLogScmRequest scmRequest) throws ScmException { return getChangeLogScmResult(); } /** * {@inheritDoc} */ - public ChangeLogScmResult changeLog( ScmRepository repository, ScmFileSet fileSet, ScmVersion startVersion, - ScmVersion endVersion ) - throws ScmException - { + public ChangeLogScmResult changeLog( + ScmRepository repository, ScmFileSet fileSet, ScmVersion startVersion, ScmVersion endVersion) + throws ScmException { return getChangeLogScmResult(); } /** * {@inheritDoc} */ - public ChangeLogScmResult changeLog( ScmRepository repository, ScmFileSet fileSet, ScmVersion startRevision, - ScmVersion endRevision, String datePattern ) - throws ScmException - { + public ChangeLogScmResult changeLog( + ScmRepository repository, + ScmFileSet fileSet, + ScmVersion startRevision, + ScmVersion endRevision, + String datePattern) + throws ScmException { return getChangeLogScmResult(); } /** * {@inheritDoc} */ - public CheckInScmResult checkIn( ScmRepository repository, ScmFileSet fileSet, String tag, String message ) - throws ScmException - { + public CheckInScmResult checkIn(ScmRepository repository, ScmFileSet fileSet, String tag, String message) + throws ScmException { return getCheckInScmResult(); } /** * {@inheritDoc} */ - public CheckInScmResult checkIn( ScmRepository repository, ScmFileSet fileSet, String message ) - throws ScmException - { + public CheckInScmResult checkIn(ScmRepository repository, ScmFileSet fileSet, String message) throws ScmException { return getCheckInScmResult(); } /** * {@inheritDoc} */ - public CheckInScmResult checkIn( ScmRepository repository, ScmFileSet fileSet, ScmVersion revision, String message ) - throws ScmException - { + public CheckInScmResult checkIn(ScmRepository repository, ScmFileSet fileSet, ScmVersion revision, String message) + throws ScmException { return getCheckInScmResult(); } /** * {@inheritDoc} */ - public CheckOutScmResult checkOut( ScmRepository scmRepository, ScmFileSet scmFileSet, String tag, - boolean recursive ) - throws ScmException - { + public CheckOutScmResult checkOut(ScmRepository scmRepository, ScmFileSet scmFileSet, String tag, boolean recursive) + throws ScmException { return getCheckOutScmResult(); } /** * {@inheritDoc} */ - public CheckOutScmResult checkOut( ScmRepository repository, ScmFileSet fileSet, String tag ) - throws ScmException - { + public CheckOutScmResult checkOut(ScmRepository repository, ScmFileSet fileSet, String tag) throws ScmException { return getCheckOutScmResult(); } /** * {@inheritDoc} */ - public CheckOutScmResult checkOut( ScmRepository repository, ScmFileSet fileSet ) - throws ScmException - { + public CheckOutScmResult checkOut(ScmRepository repository, ScmFileSet fileSet) throws ScmException { return getCheckOutScmResult(); } /** * {@inheritDoc} */ - public CheckOutScmResult checkOut( ScmRepository repository, ScmFileSet fileSet, ScmVersion version ) - throws ScmException - { + public CheckOutScmResult checkOut(ScmRepository repository, ScmFileSet fileSet, ScmVersion version) + throws ScmException { return getCheckOutScmResult(); } /** * {@inheritDoc} */ - public CheckOutScmResult checkOut( ScmRepository scmRepository, ScmFileSet scmFileSet, boolean recursive ) - throws ScmException - { + public CheckOutScmResult checkOut(ScmRepository scmRepository, ScmFileSet scmFileSet, boolean recursive) + throws ScmException { return getCheckOutScmResult(); } /** * {@inheritDoc} */ - public CheckOutScmResult checkOut( ScmRepository scmRepository, ScmFileSet scmFileSet, ScmVersion version, - boolean recursive ) - throws ScmException - { + public CheckOutScmResult checkOut( + ScmRepository scmRepository, ScmFileSet scmFileSet, ScmVersion version, boolean recursive) + throws ScmException { return getCheckOutScmResult(); } @Override - public CheckOutScmResult checkOut( ScmRepository scmRepository, ScmFileSet scmFileSet, ScmVersion version, - CommandParameters commandParameters ) - throws ScmException - { + public CheckOutScmResult checkOut( + ScmRepository scmRepository, ScmFileSet scmFileSet, ScmVersion version, CommandParameters commandParameters) + throws ScmException { return getCheckOutScmResult(); } /** * {@inheritDoc} */ - public DiffScmResult diff( ScmRepository repository, ScmFileSet fileSet, String startRevision, String endRevision ) - throws ScmException - { + public DiffScmResult diff(ScmRepository repository, ScmFileSet fileSet, String startRevision, String endRevision) + throws ScmException { return getDiffScmResult(); } /** * {@inheritDoc} */ - public DiffScmResult diff( ScmRepository scmRepository, ScmFileSet scmFileSet, ScmVersion startVersion, - ScmVersion endVersion ) - throws ScmException - { + public DiffScmResult diff( + ScmRepository scmRepository, ScmFileSet scmFileSet, ScmVersion startVersion, ScmVersion endVersion) + throws ScmException { return getDiffScmResult(); } /** * @return getUpdateScmResult() always */ - public UpdateScmResult update( ScmRepository repository, ScmFileSet fileSet, String tag, Date lastUpdate, - String datePattern, boolean runChangelog ) - throws ScmException - { + public UpdateScmResult update( + ScmRepository repository, + ScmFileSet fileSet, + String tag, + Date lastUpdate, + String datePattern, + boolean runChangelog) + throws ScmException { return getUpdateScmResult(); } /** * {@inheritDoc} */ - public EditScmResult edit( ScmRepository repository, ScmFileSet fileSet ) - throws ScmException - { + public EditScmResult edit(ScmRepository repository, ScmFileSet fileSet) throws ScmException { return getEditScmResult(); } /** * {@inheritDoc} */ - public ExportScmResult export( ScmRepository repository, ScmFileSet fileSet, String tag ) - throws ScmException - { + public ExportScmResult export(ScmRepository repository, ScmFileSet fileSet, String tag) throws ScmException { return getExportScmResult(); } /** * {@inheritDoc} */ - public ExportScmResult export( ScmRepository repository, ScmFileSet fileSet, String tag, String outputDirectory ) - throws ScmException - { + public ExportScmResult export(ScmRepository repository, ScmFileSet fileSet, String tag, String outputDirectory) + throws ScmException { return getExportScmResult(); } /** * {@inheritDoc} */ - public ExportScmResult export( ScmRepository repository, ScmFileSet fileSet ) - throws ScmException - { + public ExportScmResult export(ScmRepository repository, ScmFileSet fileSet) throws ScmException { return getExportScmResult(); } /** * {@inheritDoc} */ - public ExportScmResult export( ScmRepository repository, ScmFileSet fileSet, ScmVersion version ) - throws ScmException - { + public ExportScmResult export(ScmRepository repository, ScmFileSet fileSet, ScmVersion version) + throws ScmException { return getExportScmResult(); } /** * {@inheritDoc} */ - public ExportScmResult export( ScmRepository repository, ScmFileSet fileSet, ScmVersion version, - String outputDirectory ) - throws ScmException - { + public ExportScmResult export( + ScmRepository repository, ScmFileSet fileSet, ScmVersion version, String outputDirectory) + throws ScmException { return getExportScmResult(); } /** * {@inheritDoc} */ - public ListScmResult list( ScmRepository repository, ScmFileSet fileSet, boolean recursive, String tag ) - throws ScmException - { + public ListScmResult list(ScmRepository repository, ScmFileSet fileSet, boolean recursive, String tag) + throws ScmException { return getListScmResult(); } /** * {@inheritDoc} */ - public ListScmResult list( ScmRepository repository, ScmFileSet fileSet, boolean recursive, ScmVersion version ) - throws ScmException - { + public ListScmResult list(ScmRepository repository, ScmFileSet fileSet, boolean recursive, ScmVersion version) + throws ScmException { return getListScmResult(); } /** * {@inheritDoc} */ - public RemoveScmResult remove( ScmRepository repository, ScmFileSet fileSet, String message ) - throws ScmException - { + public RemoveScmResult remove(ScmRepository repository, ScmFileSet fileSet, String message) throws ScmException { return getRemoveScmResult(); } /** * {@inheritDoc} */ - public StatusScmResult status( ScmRepository repository, ScmFileSet fileSet ) - throws ScmException - { + public StatusScmResult status(ScmRepository repository, ScmFileSet fileSet) throws ScmException { return getStatusScmResult(); } /** * {@inheritDoc} */ - public TagScmResult tag( ScmRepository repository, ScmFileSet fileSet, String tag ) - throws ScmException - { + public TagScmResult tag(ScmRepository repository, ScmFileSet fileSet, String tag) throws ScmException { return getTagScmResult(); } /** * {@inheritDoc} */ - public TagScmResult tag( ScmRepository repository, ScmFileSet fileSet, String tag, String message ) - throws ScmException - { + public TagScmResult tag(ScmRepository repository, ScmFileSet fileSet, String tag, String message) + throws ScmException { return getTagScmResult(); } - public TagScmResult tag( ScmRepository repository, ScmFileSet fileSet, String tagName, - ScmTagParameters scmTagParameters ) - throws ScmException - { + public TagScmResult tag( + ScmRepository repository, ScmFileSet fileSet, String tagName, ScmTagParameters scmTagParameters) + throws ScmException { return getTagScmResult(); } - public UntagScmResult untag( ScmRepository repository, ScmFileSet fileSet, CommandParameters parameters ) - throws ScmException - { + public UntagScmResult untag(ScmRepository repository, ScmFileSet fileSet, CommandParameters parameters) + throws ScmException { return getUntagScmResult(); } /** * {@inheritDoc} */ - public UpdateScmResult update( ScmRepository repository, ScmFileSet fileSet, String tag ) - throws ScmException - { + public UpdateScmResult update(ScmRepository repository, ScmFileSet fileSet, String tag) throws ScmException { return getUpdateScmResult(); } /** * {@inheritDoc} */ - public UpdateScmResult update( ScmRepository repository, ScmFileSet fileSet, String tag, boolean runChangelog ) - throws ScmException - { + public UpdateScmResult update(ScmRepository repository, ScmFileSet fileSet, String tag, boolean runChangelog) + throws ScmException { return getUpdateScmResult(); } /** * {@inheritDoc} */ - public UpdateScmResult update( ScmRepository repository, ScmFileSet fileSet, String tag, String datePattern ) - throws ScmException - { + public UpdateScmResult update(ScmRepository repository, ScmFileSet fileSet, String tag, String datePattern) + throws ScmException { return getUpdateScmResult(); } /** * {@inheritDoc} */ - public UpdateScmResult update( ScmRepository repository, ScmFileSet fileSet, String tag, Date lastUpdate ) - throws ScmException - { + public UpdateScmResult update(ScmRepository repository, ScmFileSet fileSet, String tag, Date lastUpdate) + throws ScmException { return getUpdateScmResult(); } /** * {@inheritDoc} */ - public UpdateScmResult update( ScmRepository repository, ScmFileSet fileSet, String tag, Date lastUpdate, - String datePattern ) - throws ScmException - { + public UpdateScmResult update( + ScmRepository repository, ScmFileSet fileSet, String tag, Date lastUpdate, String datePattern) + throws ScmException { return getUpdateScmResult(); } /** * {@inheritDoc} */ - public UpdateScmResult update( ScmRepository repository, ScmFileSet fileSet ) - throws ScmException - { + public UpdateScmResult update(ScmRepository repository, ScmFileSet fileSet) throws ScmException { return getUpdateScmResult(); } /** * {@inheritDoc} */ - public UpdateScmResult update( ScmRepository repository, ScmFileSet fileSet, ScmVersion version ) - throws ScmException - { + public UpdateScmResult update(ScmRepository repository, ScmFileSet fileSet, ScmVersion version) + throws ScmException { return getUpdateScmResult(); } /** * {@inheritDoc} */ - public UpdateScmResult update( ScmRepository repository, ScmFileSet fileSet, boolean runChangelog ) - throws ScmException - { + public UpdateScmResult update(ScmRepository repository, ScmFileSet fileSet, boolean runChangelog) + throws ScmException { return getUpdateScmResult(); } /** * {@inheritDoc} */ - public UpdateScmResult update( ScmRepository repository, ScmFileSet fileSet, ScmVersion version, - boolean runChangelog ) - throws ScmException - { + public UpdateScmResult update( + ScmRepository repository, ScmFileSet fileSet, ScmVersion version, boolean runChangelog) + throws ScmException { return getUpdateScmResult(); } /** * {@inheritDoc} */ - public UpdateScmResult update( ScmRepository repository, ScmFileSet fileSet, ScmVersion version, - String datePattern ) - throws ScmException - { + public UpdateScmResult update(ScmRepository repository, ScmFileSet fileSet, ScmVersion version, String datePattern) + throws ScmException { return getUpdateScmResult(); } /** * {@inheritDoc} */ - public UpdateScmResult update( ScmRepository repository, ScmFileSet fileSet, ScmVersion version, Date lastUpdate ) - throws ScmException - { + public UpdateScmResult update(ScmRepository repository, ScmFileSet fileSet, ScmVersion version, Date lastUpdate) + throws ScmException { return getUpdateScmResult(); } /** * {@inheritDoc} */ - public UpdateScmResult update( ScmRepository repository, ScmFileSet fileSet, ScmVersion version, Date lastUpdate, - String datePattern ) - throws ScmException - { + public UpdateScmResult update( + ScmRepository repository, ScmFileSet fileSet, ScmVersion version, Date lastUpdate, String datePattern) + throws ScmException { return getUpdateScmResult(); } /** * {@inheritDoc} */ - public UnEditScmResult unedit( ScmRepository repository, ScmFileSet fileSet ) - throws ScmException - { + public UnEditScmResult unedit(ScmRepository repository, ScmFileSet fileSet) throws ScmException { return getUnEditScmResult(); } /** * {@inheritDoc} */ - public BlameScmResult blame( ScmRepository repository, ScmFileSet fileSet, String filename ) - throws ScmException - { + public BlameScmResult blame(ScmRepository repository, ScmFileSet fileSet, String filename) throws ScmException { return getBlameScmResult(); } - public BlameScmResult blame( BlameScmRequest blameScmRequest ) - throws ScmException - { + public BlameScmResult blame(BlameScmRequest blameScmRequest) throws ScmException { return getBlameScmResult(); } /** * {@inheritDoc} */ - public MkdirScmResult mkdir( ScmRepository repository, ScmFileSet fileSet, String message, boolean createInLocal ) - throws ScmException - { + public MkdirScmResult mkdir(ScmRepository repository, ScmFileSet fileSet, String message, boolean createInLocal) + throws ScmException { return getMkdirScmResult(); } - public InfoScmResult info( ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters ) - throws ScmException - { - return new InfoScmResult( "", "", "", true ); + public InfoScmResult info(ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters) + throws ScmException { + return new InfoScmResult("", "", "", true); } - public RemoteInfoScmResult remoteInfo( ScmProviderRepository repository, ScmFileSet fileSet, - CommandParameters parameters ) - throws ScmException - { - return new RemoteInfoScmResult( "", null, null ); + public RemoteInfoScmResult remoteInfo( + ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters) throws ScmException { + return new RemoteInfoScmResult("", null, null); } } diff --git a/maven-scm-test/src/main/java/org/apache/maven/scm/repository/ScmRepositoryStub.java b/maven-scm-test/src/main/java/org/apache/maven/scm/repository/ScmRepositoryStub.java index fc6c6a714..6703df361 100644 --- a/maven-scm-test/src/main/java/org/apache/maven/scm/repository/ScmRepositoryStub.java +++ b/maven-scm-test/src/main/java/org/apache/maven/scm/repository/ScmRepositoryStub.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.repository; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.repository; import org.apache.maven.scm.provider.ScmProviderRepositoryStub; @@ -29,16 +28,12 @@ * @author Carlos Sanchez * */ -public class ScmRepositoryStub - extends ScmRepository -{ +public class ScmRepositoryStub extends ScmRepository { /** * Creates a new stub with a new ScmProviderRepositoryStub as scmProviderRepository */ - public ScmRepositoryStub() - { - super( "stub-provider", new ScmProviderRepositoryStub() ); + public ScmRepositoryStub() { + super("stub-provider", new ScmProviderRepositoryStub()); } - } diff --git a/maven-scm-test/src/main/java/org/apache/maven/scm/tck/command/blame/BlameCommandTckTest.java b/maven-scm-test/src/main/java/org/apache/maven/scm/tck/command/blame/BlameCommandTckTest.java index a25605753..623dc32d8 100644 --- a/maven-scm-test/src/main/java/org/apache/maven/scm/tck/command/blame/BlameCommandTckTest.java +++ b/maven-scm-test/src/main/java/org/apache/maven/scm/tck/command/blame/BlameCommandTckTest.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.tck.command.blame; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,9 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.tck.command.blame; + +import java.util.Date; import org.apache.maven.scm.ScmFileSet; import org.apache.maven.scm.ScmTckTestCase; @@ -31,8 +32,6 @@ import org.apache.maven.scm.repository.ScmRepository; import org.junit.Test; -import java.util.Date; - import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotEquals; import static org.junit.Assert.assertNotNull; @@ -41,86 +40,80 @@ /** * @author Evgeny Mandrikov */ -public abstract class BlameCommandTckTest - extends ScmTckTestCase -{ +public abstract class BlameCommandTckTest extends ScmTckTestCase { private static final String COMMIT_MSG = "Second changelog"; @Test - public void testBlameCommand() - throws Exception - { + public void testBlameCommand() throws Exception { ScmRepository repository = getScmRepository(); ScmManager manager = getScmManager(); - ScmProvider provider = manager.getProviderByRepository( getScmRepository() ); - ScmFileSet fileSet = new ScmFileSet( getWorkingCopy() ); + ScmProvider provider = manager.getProviderByRepository(getScmRepository()); + ScmFileSet fileSet = new ScmFileSet(getWorkingCopy()); BlameScmResult result; BlameLine line; // === readme.txt === - BlameScmRequest blameScmRequest = new BlameScmRequest( repository, fileSet ); - blameScmRequest.setFilename( "readme.txt" ); - //result = manager.blame( repository, fileSet, "readme.txt" ); - result = manager.blame( blameScmRequest ); - assertNotNull( "The command returned a null result.", result ); - assertResultIsSuccess( result ); - assertEquals( "Expected 1 line in blame", 1, result.getLines().size() ); - line = result.getLines().get( 0 ); + BlameScmRequest blameScmRequest = new BlameScmRequest(repository, fileSet); + blameScmRequest.setFilename("readme.txt"); + // result = manager.blame( repository, fileSet, "readme.txt" ); + result = manager.blame(blameScmRequest); + assertNotNull("The command returned a null result.", result); + assertResultIsSuccess(result); + assertEquals("Expected 1 line in blame", 1, result.getLines().size()); + line = result.getLines().get(0); String initialRevision = line.getRevision(); - //Make a timestamp that we know are after initial revision but before the second + // Make a timestamp that we know are after initial revision but before the second Date timeBeforeSecond = new Date(); // Current time // pause a couple seconds... - Thread.sleep( 2000 ); - //Make a change to the readme.txt and commit the change - this.edit( getWorkingCopy(), "readme.txt", null, getScmRepository() ); - ScmTestCase.makeFile( getWorkingCopy(), "/readme.txt", "changed readme.txt" ); - CheckInScmResult checkInResult = provider.checkIn( getScmRepository(), fileSet, COMMIT_MSG ); - assertTrue( "Unable to checkin changes to the repository", checkInResult.isSuccess() ); + Thread.sleep(2000); + // Make a change to the readme.txt and commit the change + this.edit(getWorkingCopy(), "readme.txt", null, getScmRepository()); + ScmTestCase.makeFile(getWorkingCopy(), "/readme.txt", "changed readme.txt"); + CheckInScmResult checkInResult = provider.checkIn(getScmRepository(), fileSet, COMMIT_MSG); + assertTrue("Unable to checkin changes to the repository", checkInResult.isSuccess()); - result = manager.blame( repository, fileSet, "readme.txt" ); + result = manager.blame(repository, fileSet, "readme.txt"); // pause a couple seconds... - Thread.sleep( 2000 ); + Thread.sleep(2000); Date timeAfterSecond = new Date(); // Current time - assertNotNull( "The command returned a null result.", result ); - assertResultIsSuccess( result ); + assertNotNull("The command returned a null result.", result); + assertResultIsSuccess(result); - assertEquals( "Expected 1 line in blame", 1, result.getLines().size() ); - line = result.getLines().get( 0 ); + assertEquals("Expected 1 line in blame", 1, result.getLines().size()); + line = result.getLines().get(0); - assertNotNull( "Expected not null author", line.getAuthor() ); - assertNotNull( "Expected not null revision", line.getRevision() ); - assertNotNull( "Expected not null date", line.getDate() ); + assertNotNull("Expected not null author", line.getAuthor()); + assertNotNull("Expected not null revision", line.getRevision()); + assertNotNull("Expected not null date", line.getDate()); - assertNotEquals( "Expected another revision", initialRevision, line.getRevision() ); - if ( isTestDateTime() ) - { - assertDateBetween( timeBeforeSecond, timeAfterSecond, line.getDate() ); + assertNotEquals("Expected another revision", initialRevision, line.getRevision()); + if (isTestDateTime()) { + assertDateBetween(timeBeforeSecond, timeAfterSecond, line.getDate()); } // === pom.xml === - result = manager.blame( repository, fileSet, "pom.xml" ); + result = manager.blame(repository, fileSet, "pom.xml"); - assertNotNull( "The command returned a null result.", result ); + assertNotNull("The command returned a null result.", result); - assertResultIsSuccess( result ); + assertResultIsSuccess(result); - verifyResult( result ); + verifyResult(result); } - protected boolean isTestDateTime() - { + protected boolean isTestDateTime() { return true; } - protected void assertDateBetween( Date start, Date end, Date actual ) - { - assertTrue( "Expected date between " + start + " and " + end + ", but was " + actual, - start.before( actual ) && actual.before( end ) ); + protected void assertDateBetween(Date start, Date end, Date actual) { + assertTrue( + "Expected date between " + start + " and " + end + ", but was " + actual, + start.before(actual) && actual.before(end)); } - protected abstract void verifyResult( BlameScmResult result ); + protected abstract void verifyResult(BlameScmResult result); } diff --git a/maven-scm-test/src/main/java/org/apache/maven/scm/tck/command/branch/BranchCommandTckTest.java b/maven-scm-test/src/main/java/org/apache/maven/scm/tck/command/branch/BranchCommandTckTest.java index 4e7dea5a4..7eea40aca 100644 --- a/maven-scm-test/src/main/java/org/apache/maven/scm/tck/command/branch/BranchCommandTckTest.java +++ b/maven-scm-test/src/main/java/org/apache/maven/scm/tck/command/branch/BranchCommandTckTest.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.tck.command.branch; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,10 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.tck.command.branch; + +import java.io.File; +import java.io.FileWriter; import org.apache.maven.scm.ScmBranch; import org.apache.maven.scm.ScmFileSet; @@ -29,9 +31,6 @@ import org.codehaus.plexus.util.IOUtil; import org.junit.Test; -import java.io.File; -import java.io.FileWriter; - import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; @@ -41,76 +40,67 @@ * @author Emmanuel Venisse * */ -public abstract class BranchCommandTckTest - extends ScmTckTestCase -{ +public abstract class BranchCommandTckTest extends ScmTckTestCase { - protected String getBranch() - { + protected String getBranch() { return "test-branch"; } @Test - public void testBranchCommandTest() - throws Exception - { + public void testBranchCommandTest() throws Exception { String branch = getBranch(); - @SuppressWarnings( "deprecation" ) BranchScmResult branchResult = - getScmManager().getProviderByUrl( getScmUrl() ).branch( getScmRepository(), - new ScmFileSet( getWorkingCopy() ), branch ); + @SuppressWarnings("deprecation") + BranchScmResult branchResult = getScmManager() + .getProviderByUrl(getScmUrl()) + .branch(getScmRepository(), new ScmFileSet(getWorkingCopy()), branch); - assertResultIsSuccess( branchResult ); + assertResultIsSuccess(branchResult); // see https://issues.apache.org/jira/browse/SCM-754 - //assertEquals( "check all 4 files branched", 4, branchResult.getBranchedFiles().size() ); + // assertEquals( "check all 4 files branched", 4, branchResult.getBranchedFiles().size() ); - File readmeTxt = new File( getWorkingCopy(), "readme.txt" ); + File readmeTxt = new File(getWorkingCopy(), "readme.txt"); - assertEquals( "check readme.txt contents", "/readme.txt", FileUtils.fileRead( readmeTxt ) ); + assertEquals("check readme.txt contents", "/readme.txt", FileUtils.fileRead(readmeTxt)); - this.edit( getWorkingCopy(), "readme.txt", null, getScmRepository() ); - changeReadmeTxt( readmeTxt ); + this.edit(getWorkingCopy(), "readme.txt", null, getScmRepository()); + changeReadmeTxt(readmeTxt); CheckInScmResult checkinResult = - getScmManager().checkIn( getScmRepository(), new ScmFileSet( getWorkingCopy() ), "commit message" ); + getScmManager().checkIn(getScmRepository(), new ScmFileSet(getWorkingCopy()), "commit message"); - assertResultIsSuccess( checkinResult ); + assertResultIsSuccess(checkinResult); CheckOutScmResult checkoutResult = - getScmManager().checkOut( getScmRepository(), new ScmFileSet( getAssertionCopy() ) ); + getScmManager().checkOut(getScmRepository(), new ScmFileSet(getAssertionCopy())); - assertResultIsSuccess( checkoutResult ); + assertResultIsSuccess(checkoutResult); - readmeTxt = new File( getAssertionCopy(), "readme.txt" ); + readmeTxt = new File(getAssertionCopy(), "readme.txt"); - assertEquals( "check readme.txt contents", "changed file", FileUtils.fileRead( readmeTxt ) ); + assertEquals("check readme.txt contents", "changed file", FileUtils.fileRead(readmeTxt)); - deleteDirectory( getAssertionCopy() ); + deleteDirectory(getAssertionCopy()); - assertFalse( "check previous assertion copy deleted", getAssertionCopy().exists() ); + assertFalse("check previous assertion copy deleted", getAssertionCopy().exists()); - checkoutResult = getScmManager().getProviderByUrl( getScmUrl() ).checkOut( getScmRepository(), - new ScmFileSet( getAssertionCopy() ), - new ScmBranch( branch ) ); + checkoutResult = getScmManager() + .getProviderByUrl(getScmUrl()) + .checkOut(getScmRepository(), new ScmFileSet(getAssertionCopy()), new ScmBranch(branch)); - assertResultIsSuccess( checkoutResult ); + assertResultIsSuccess(checkoutResult); - assertEquals( "check readme.txt contents is from branched version", "/readme.txt", - FileUtils.fileRead( readmeTxt ) ); + assertEquals( + "check readme.txt contents is from branched version", "/readme.txt", FileUtils.fileRead(readmeTxt)); } - private void changeReadmeTxt( File readmeTxt ) - throws Exception - { - FileWriter output = new FileWriter( readmeTxt ); - try - { - output.write( "changed file" ); - } - finally - { - IOUtil.close( output ); + private void changeReadmeTxt(File readmeTxt) throws Exception { + FileWriter output = new FileWriter(readmeTxt); + try { + output.write("changed file"); + } finally { + IOUtil.close(output); } } } diff --git a/maven-scm-test/src/main/java/org/apache/maven/scm/tck/command/changelog/ChangeLogCommandTckTest.java b/maven-scm-test/src/main/java/org/apache/maven/scm/tck/command/changelog/ChangeLogCommandTckTest.java index a5c0a7ff8..cd0421b4f 100644 --- a/maven-scm-test/src/main/java/org/apache/maven/scm/tck/command/changelog/ChangeLogCommandTckTest.java +++ b/maven-scm-test/src/main/java/org/apache/maven/scm/tck/command/changelog/ChangeLogCommandTckTest.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.tck.command.changelog; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,11 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.tck.command.changelog; + +import java.util.Collections; +import java.util.Date; +import java.util.List; import org.apache.maven.scm.ChangeSet; import org.apache.maven.scm.ScmBranch; @@ -32,10 +35,6 @@ import org.apache.maven.scm.provider.ScmProvider; import org.junit.Test; -import java.util.Collections; -import java.util.Date; -import java.util.List; - import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; @@ -49,9 +48,7 @@ * * @author Torbj�rn Eikli Sm�rgrav */ -public abstract class ChangeLogCommandTckTest - extends ScmTckTestCase -{ +public abstract class ChangeLogCommandTckTest extends ScmTckTestCase { private static final String COMMIT_MSG = "Second changelog"; private static final String COMMIT_TAG = "v3.14"; @@ -59,47 +56,46 @@ public abstract class ChangeLogCommandTckTest * In some SCMs (Hg) adding a tag creates an extra commit which offsets the expectations. * @return If an extra commit will be present for a tag. */ - public boolean isTagAnExtraCommit() - { + public boolean isTagAnExtraCommit() { return false; } @Test - public void testChangeLogCommand() - throws Exception - { - Thread.sleep( 1000 ); - ScmProvider provider = getScmManager().getProviderByRepository( getScmRepository() ); - ScmFileSet fileSet = new ScmFileSet( getWorkingCopy() ); + public void testChangeLogCommand() throws Exception { + Thread.sleep(1000); + ScmProvider provider = getScmManager().getProviderByRepository(getScmRepository()); + ScmFileSet fileSet = new ScmFileSet(getWorkingCopy()); ChangeLogScmResult firstResult = - provider.changeLog( getScmRepository(), fileSet, null, null, 0, (ScmBranch) null, null ); - assertTrue( firstResult.getProviderMessage() + ": " + firstResult.getCommandLine() + "\n" - + firstResult.getCommandOutput(), firstResult.isSuccess() ); + provider.changeLog(getScmRepository(), fileSet, null, null, 0, (ScmBranch) null, null); + assertTrue( + firstResult.getProviderMessage() + ": " + firstResult.getCommandLine() + "\n" + + firstResult.getCommandOutput(), + firstResult.isSuccess()); // for svn and git the repo get recreated for each test and therefore initial changelog size is 1 int firstLogSize = firstResult.getChangeLog().getChangeSets().size(); - assertTrue( "Unexpected initial log size", firstLogSize >= 1 ); + assertTrue("Unexpected initial log size", firstLogSize >= 1); // Make a timestamp that we know are after initial revision but before the second - Date timeBeforeSecond = new Date(); //Current time + Date timeBeforeSecond = new Date(); // Current time // pause a couple seconds... [SCM-244] - Thread.sleep( 2000 ); + Thread.sleep(2000); - //Make a change to the readme.txt and commit the change - this.edit( getWorkingCopy(), "readme.txt", null, getScmRepository() ); - ScmTestCase.makeFile( getWorkingCopy(), "/readme.txt", "changed readme.txt" ); - CheckInScmResult checkInResult = provider.checkIn( getScmRepository(), fileSet, COMMIT_MSG ); - assertTrue( "Unable to checkin changes to the repository", checkInResult.isSuccess() ); + // Make a change to the readme.txt and commit the change + this.edit(getWorkingCopy(), "readme.txt", null, getScmRepository()); + ScmTestCase.makeFile(getWorkingCopy(), "/readme.txt", "changed readme.txt"); + CheckInScmResult checkInResult = provider.checkIn(getScmRepository(), fileSet, COMMIT_MSG); + assertTrue("Unable to checkin changes to the repository", checkInResult.isSuccess()); ScmTagParameters scmTagParameters = new ScmTagParameters(); - TagScmResult tagResult = provider.tag( getScmRepository(), fileSet, COMMIT_TAG, scmTagParameters ); - assertTrue( "Unable to tag the changes in the repository", tagResult.isSuccess() ); + TagScmResult tagResult = provider.tag(getScmRepository(), fileSet, COMMIT_TAG, scmTagParameters); + assertTrue("Unable to tag the changes in the repository", tagResult.isSuccess()); - ChangeLogScmRequest changeLogScmRequest = new ChangeLogScmRequest( getScmRepository(), fileSet ); - ChangeLogScmResult secondResult = provider.changeLog( changeLogScmRequest ); - assertTrue( secondResult.getProviderMessage(), secondResult.isSuccess() ); + ChangeLogScmRequest changeLogScmRequest = new ChangeLogScmRequest(getScmRepository(), fileSet); + ChangeLogScmResult secondResult = provider.changeLog(changeLogScmRequest); + assertTrue(secondResult.getProviderMessage(), secondResult.isSuccess()); List changeSets = secondResult.getChangeLog().getChangeSets(); @@ -107,35 +103,34 @@ public void testChangeLogCommand() boolean lastCommitIsCausedByTagging = false; int lastCodeCommitIndex = 0; - if ( isTagAnExtraCommit() ) - { + if (isTagAnExtraCommit()) { // This is for example Mercurial which creates an extra commit after tagging. lastCommitIsCausedByTagging = true; expectedChangeSets += 1; lastCodeCommitIndex = 1; } - assertEquals( expectedChangeSets, changeSets.size() ); + assertEquals(expectedChangeSets, changeSets.size()); // Check if the tag has been retrieved again - ChangeSet changeSetWithTag = changeSets.get( lastCodeCommitIndex ); - assertEquals( Collections.singletonList( COMMIT_TAG ), changeSetWithTag.getTags() ); + ChangeSet changeSetWithTag = changeSets.get(lastCodeCommitIndex); + assertEquals(Collections.singletonList(COMMIT_TAG), changeSetWithTag.getTags()); - //Now only retrieve the changelog after timeBeforeSecondChangeLog + // Now only retrieve the changelog after timeBeforeSecondChangeLog Date currentTime = new Date(); - changeLogScmRequest = new ChangeLogScmRequest( getScmRepository(), fileSet ); - changeLogScmRequest.setStartDate( timeBeforeSecond ); - changeLogScmRequest.setEndDate( currentTime ); - changeLogScmRequest.setScmBranch( new ScmBranch( "" ) ); - ChangeLogScmResult thirdResult = provider.changeLog( changeLogScmRequest ); + changeLogScmRequest = new ChangeLogScmRequest(getScmRepository(), fileSet); + changeLogScmRequest.setStartDate(timeBeforeSecond); + changeLogScmRequest.setEndDate(currentTime); + changeLogScmRequest.setScmBranch(new ScmBranch("")); + ChangeLogScmResult thirdResult = provider.changeLog(changeLogScmRequest); - //Thorough assert of the last result - assertTrue( thirdResult.getProviderMessage(), thirdResult.isSuccess() ); + // Thorough assert of the last result + assertTrue(thirdResult.getProviderMessage(), thirdResult.isSuccess()); List thirdChangeSets = thirdResult.getChangeLog().getChangeSets(); - assertEquals( lastCommitIsCausedByTagging ? 2 : 1, thirdChangeSets.size() ); - ChangeSet changeset = thirdChangeSets.get( lastCodeCommitIndex ); - assertTrue( changeset.getDate().after( timeBeforeSecond ) ); - assertTrue( changeset.getComment().startsWith( COMMIT_MSG ) ); + assertEquals(lastCommitIsCausedByTagging ? 2 : 1, thirdChangeSets.size()); + ChangeSet changeset = thirdChangeSets.get(lastCodeCommitIndex); + assertTrue(changeset.getDate().after(timeBeforeSecond)); + assertTrue(changeset.getComment().startsWith(COMMIT_MSG)); } } diff --git a/maven-scm-test/src/main/java/org/apache/maven/scm/tck/command/checkin/CheckInCommandTckTest.java b/maven-scm-test/src/main/java/org/apache/maven/scm/tck/command/checkin/CheckInCommandTckTest.java index 936bba04c..53869cd9a 100644 --- a/maven-scm-test/src/main/java/org/apache/maven/scm/tck/command/checkin/CheckInCommandTckTest.java +++ b/maven-scm-test/src/main/java/org/apache/maven/scm/tck/command/checkin/CheckInCommandTckTest.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.tck.command.checkin; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,13 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.tck.command.checkin; + +import java.io.File; +import java.io.FileWriter; +import java.io.PrintWriter; +import java.util.List; +import java.util.Map; import org.apache.maven.scm.ScmFile; import org.apache.maven.scm.ScmFileSet; @@ -33,12 +38,6 @@ import org.junit.Assume; import org.junit.Test; -import java.io.File; -import java.io.FileWriter; -import java.io.PrintWriter; -import java.util.List; -import java.util.Map; - import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; @@ -49,263 +48,244 @@ * * @author Brett Porter */ -public abstract class CheckInCommandTckTest - extends ScmTckTestCase -{ +public abstract class CheckInCommandTckTest extends ScmTckTestCase { @Test - public void testCheckInCommandTest() - throws Exception - { + public void testCheckInCommandTest() throws Exception { // Make sure that the correct files was checked out - File fooJava = new File( getWorkingCopy(), "src/main/java/Foo.java" ); + File fooJava = new File(getWorkingCopy(), "src/main/java/Foo.java"); - File barJava = new File( getWorkingCopy(), "src/main/java/Bar.java" ); + File barJava = new File(getWorkingCopy(), "src/main/java/Bar.java"); - File readmeTxt = new File( getWorkingCopy(), "readme.txt" ); + File readmeTxt = new File(getWorkingCopy(), "readme.txt"); - assertFalse( "check Foo.java doesn't yet exist", fooJava.canRead() ); + assertFalse("check Foo.java doesn't yet exist", fooJava.canRead()); - assertFalse( "check Bar.java doesn't yet exist", barJava.canRead() ); + assertFalse("check Bar.java doesn't yet exist", barJava.canRead()); - assertTrue( "check can read readme.txt", readmeTxt.canRead() ); + assertTrue("check can read readme.txt", readmeTxt.canRead()); // Change the files - createFooJava( fooJava ); + createFooJava(fooJava); - createBarJava( barJava ); + createBarJava(barJava); - changeReadmeTxt( readmeTxt ); + changeReadmeTxt(readmeTxt); - AddScmResult addResult = getScmManager().add( getScmRepository(), - new ScmFileSet( getWorkingCopy(), "src/main/java/Foo.java", - null ) ); + AddScmResult addResult = getScmManager() + .add(getScmRepository(), new ScmFileSet(getWorkingCopy(), "src/main/java/Foo.java", null)); - assertResultIsSuccess( addResult ); + assertResultIsSuccess(addResult); List files = addResult.getAddedFiles(); - assertNotNull( files ); - assertEquals( 1, files.size() ); + assertNotNull(files); + assertEquals(1, files.size()); // SCM-998: filename separators not yet harmonized - assertEquals( "src/main/java/Foo.java", FilenameUtils.normalizeFilename( files.get( 0 ).getPath() ) ); + assertEquals( + "src/main/java/Foo.java", + FilenameUtils.normalizeFilename(files.get(0).getPath())); CheckInScmResult result = - getScmManager().checkIn( getScmRepository(), new ScmFileSet( getWorkingCopy() ), "Commit message" ); + getScmManager().checkIn(getScmRepository(), new ScmFileSet(getWorkingCopy()), "Commit message"); - assertResultIsSuccess( result ); + assertResultIsSuccess(result); files = result.getCheckedInFiles(); - assertNotNull( files ); - assertEquals( 2, files.size() ); + assertNotNull(files); + assertEquals(2, files.size()); - Map fileMap = mapFilesByPath( files ); - ScmFile file1 = fileMap.get( "src/main/java/Foo.java" ); - assertNotNull( file1 ); - assertEquals( ScmFileStatus.CHECKED_IN, file1.getStatus() ); + Map fileMap = mapFilesByPath(files); + ScmFile file1 = fileMap.get("src/main/java/Foo.java"); + assertNotNull(file1); + assertEquals(ScmFileStatus.CHECKED_IN, file1.getStatus()); - ScmFile file2 = fileMap.get( "readme.txt" ); - assertNotNull( file2 ); - assertEquals( ScmFileStatus.CHECKED_IN, file2.getStatus() ); + ScmFile file2 = fileMap.get("readme.txt"); + assertNotNull(file2); + assertEquals(ScmFileStatus.CHECKED_IN, file2.getStatus()); CheckOutScmResult checkoutResult = - getScmManager().checkOut( getScmRepository(), new ScmFileSet( getAssertionCopy() ) ); + getScmManager().checkOut(getScmRepository(), new ScmFileSet(getAssertionCopy())); - assertResultIsSuccess( checkoutResult ); + assertResultIsSuccess(checkoutResult); - fooJava = new File( getAssertionCopy(), "src/main/java/Foo.java" ); + fooJava = new File(getAssertionCopy(), "src/main/java/Foo.java"); - barJava = new File( getAssertionCopy(), "src/main/java/Bar.java" ); + barJava = new File(getAssertionCopy(), "src/main/java/Bar.java"); - readmeTxt = new File( getAssertionCopy(), "readme.txt" ); + readmeTxt = new File(getAssertionCopy(), "readme.txt"); - assertTrue( "check can read Foo.java", fooJava.canRead() ); + assertTrue("check can read Foo.java", fooJava.canRead()); - assertFalse( "check Bar.java doesn't exist", barJava.canRead() ); + assertFalse("check Bar.java doesn't exist", barJava.canRead()); - assertTrue( "check can read readme.txt", readmeTxt.canRead() ); + assertTrue("check can read readme.txt", readmeTxt.canRead()); - assertEquals( "check readme.txt contents", "changed file", FileUtils.fileRead( readmeTxt ) ); + assertEquals("check readme.txt contents", "changed file", FileUtils.fileRead(readmeTxt)); } @Test - public void testCheckInCommandPartialFileset() - throws Exception - { + public void testCheckInCommandPartialFileset() throws Exception { // Make sure that the correct files was checked out - File fooJava = new File( getWorkingCopy(), "src/main/java/Foo.java" ); + File fooJava = new File(getWorkingCopy(), "src/main/java/Foo.java"); - File barJava = new File( getWorkingCopy(), "src/main/java/Bar.java" ); + File barJava = new File(getWorkingCopy(), "src/main/java/Bar.java"); - File readmeTxt = new File( getWorkingCopy(), "readme.txt" ); + File readmeTxt = new File(getWorkingCopy(), "readme.txt"); - assertFalse( "check Foo.java doesn't yet exist", fooJava.canRead() ); + assertFalse("check Foo.java doesn't yet exist", fooJava.canRead()); - assertFalse( "check Bar.java doesn't yet exist", barJava.canRead() ); + assertFalse("check Bar.java doesn't yet exist", barJava.canRead()); - assertTrue( "check can read readme.txt", readmeTxt.canRead() ); + assertTrue("check can read readme.txt", readmeTxt.canRead()); // Change the files - createFooJava( fooJava ); + createFooJava(fooJava); - createBarJava( barJava ); + createBarJava(barJava); - changeReadmeTxt( readmeTxt ); + changeReadmeTxt(readmeTxt); - AddScmResult addResult = - getScmManager().getProviderByUrl( getScmUrl() ).add( getScmRepository(), - new ScmFileSet( getWorkingCopy(), - "src/main/java/Foo.java", null ) ); + AddScmResult addResult = getScmManager() + .getProviderByUrl(getScmUrl()) + .add(getScmRepository(), new ScmFileSet(getWorkingCopy(), "src/main/java/Foo.java", null)); - assertResultIsSuccess( addResult ); + assertResultIsSuccess(addResult); - CheckInScmResult result = - getScmManager().checkIn( getScmRepository(), new ScmFileSet( getWorkingCopy(), "**/Foo.java", null ), - "Commit message" ); + CheckInScmResult result = getScmManager() + .checkIn(getScmRepository(), new ScmFileSet(getWorkingCopy(), "**/Foo.java", null), "Commit message"); - assertResultIsSuccess( result ); + assertResultIsSuccess(result); List files = result.getCheckedInFiles(); - assertNotNull( files ); - assertEquals( 1, files.size() ); + assertNotNull(files); + assertEquals(1, files.size()); - ScmFile file1 = files.get( 0 ); - assertEquals( ScmFileStatus.CHECKED_IN, file1.getStatus() ); - assertPath( "src/main/java/Foo.java", file1.getPath() ); + ScmFile file1 = files.get(0); + assertEquals(ScmFileStatus.CHECKED_IN, file1.getStatus()); + assertPath("src/main/java/Foo.java", file1.getPath()); CheckOutScmResult checkoutResult = - getScmManager().checkOut( getScmRepository(), new ScmFileSet( getAssertionCopy() ) ); + getScmManager().checkOut(getScmRepository(), new ScmFileSet(getAssertionCopy())); - assertResultIsSuccess( checkoutResult ); + assertResultIsSuccess(checkoutResult); - fooJava = new File( getAssertionCopy(), "src/main/java/Foo.java" ); + fooJava = new File(getAssertionCopy(), "src/main/java/Foo.java"); - barJava = new File( getAssertionCopy(), "src/main/java/Bar.java" ); + barJava = new File(getAssertionCopy(), "src/main/java/Bar.java"); - readmeTxt = new File( getAssertionCopy(), "readme.txt" ); + readmeTxt = new File(getAssertionCopy(), "readme.txt"); - assertTrue( "check can read Foo.java", fooJava.canRead() ); + assertTrue("check can read Foo.java", fooJava.canRead()); - assertFalse( "check Bar.java doesn't exist", barJava.canRead() ); + assertFalse("check Bar.java doesn't exist", barJava.canRead()); - assertTrue( "check can read readme.txt", readmeTxt.canRead() ); + assertTrue("check can read readme.txt", readmeTxt.canRead()); - assertEquals( "check readme.txt contents", "/readme.txt", FileUtils.fileRead( readmeTxt ) ); + assertEquals("check readme.txt contents", "/readme.txt", FileUtils.fileRead(readmeTxt)); } @Test - public void testCheckInCommandFilesetWithBasedirOtherThanWorkingCopyRoot() - throws Exception - { - ScmProvider scmProvider = getScmManager().getProviderByUrl( getScmUrl() ); + public void testCheckInCommandFilesetWithBasedirOtherThanWorkingCopyRoot() throws Exception { + ScmProvider scmProvider = getScmManager().getProviderByUrl(getScmUrl()); - Assume.assumeFalse( "Local provider does not properly support basedir", - scmProvider.getScmType().equals( "local" ) ); + Assume.assumeFalse( + "Local provider does not properly support basedir", + scmProvider.getScmType().equals("local")); // Make sure that the correct files was checked out - File fooJava = new File( getWorkingCopy(), "src/main/java/Foo.java" ); + File fooJava = new File(getWorkingCopy(), "src/main/java/Foo.java"); - assertFalse( "check Foo.java doesn't yet exist", fooJava.canRead() ); + assertFalse("check Foo.java doesn't yet exist", fooJava.canRead()); // Change the files - createFooJava( fooJava ); + createFooJava(fooJava); - AddScmResult addResult = - scmProvider.add( getScmRepository(), new ScmFileSet( new File( getWorkingCopy(), "src" ), - "main/java/Foo.java", null ) ); + AddScmResult addResult = scmProvider.add( + getScmRepository(), new ScmFileSet(new File(getWorkingCopy(), "src"), "main/java/Foo.java", null)); - assertResultIsSuccess( addResult ); + assertResultIsSuccess(addResult); List files = addResult.getAddedFiles(); - assertNotNull( files ); - assertEquals( 1, files.size() ); + assertNotNull(files); + assertEquals(1, files.size()); // SCM-998: filename separators not yet harmonized - assertEquals( "main/java/Foo.java", FilenameUtils.normalizeFilename( files.get( 0 ).getPath() ) ); + assertEquals( + "main/java/Foo.java", + FilenameUtils.normalizeFilename(files.get(0).getPath())); - CheckInScmResult result = - getScmManager().checkIn( getScmRepository(), new ScmFileSet( new File( getWorkingCopy(), "src" ), - "**/Foo.java", null ), - "Commit message" ); + CheckInScmResult result = getScmManager() + .checkIn( + getScmRepository(), + new ScmFileSet(new File(getWorkingCopy(), "src"), "**/Foo.java", null), + "Commit message"); - assertResultIsSuccess( result ); + assertResultIsSuccess(result); files = result.getCheckedInFiles(); - assertNotNull( files ); - assertEquals( 1, files.size() ); + assertNotNull(files); + assertEquals(1, files.size()); - ScmFile file1 = files.get( 0 ); - assertEquals( ScmFileStatus.CHECKED_IN, file1.getStatus() ); - assertPath( "main/java/Foo.java", file1.getPath() ); + ScmFile file1 = files.get(0); + assertEquals(ScmFileStatus.CHECKED_IN, file1.getStatus()); + assertPath("main/java/Foo.java", file1.getPath()); CheckOutScmResult checkoutResult = - getScmManager().checkOut( getScmRepository(), new ScmFileSet( getAssertionCopy() ) ); - - assertResultIsSuccess( checkoutResult ); + getScmManager().checkOut(getScmRepository(), new ScmFileSet(getAssertionCopy())); - fooJava = new File( getAssertionCopy(), "src/main/java/Foo.java" ); + assertResultIsSuccess(checkoutResult); - assertTrue( "check can read Foo.java", fooJava.canRead() ); + fooJava = new File(getAssertionCopy(), "src/main/java/Foo.java"); + assertTrue("check can read Foo.java", fooJava.canRead()); } - private void createFooJava( File fooJava ) - throws Exception - { - FileWriter output = new FileWriter( fooJava ); + private void createFooJava(File fooJava) throws Exception { + FileWriter output = new FileWriter(fooJava); - PrintWriter printer = new PrintWriter( output ); - try - { - printer.println( "public class Foo" ); - printer.println( "{" ); + PrintWriter printer = new PrintWriter(output); + try { + printer.println("public class Foo"); + printer.println("{"); - printer.println( " public void foo()" ); - printer.println( " {" ); - printer.println( " int i = 10;" ); - printer.println( " }" ); + printer.println(" public void foo()"); + printer.println(" {"); + printer.println(" int i = 10;"); + printer.println(" }"); - printer.println( "}" ); - } - finally - { - IOUtil.close( output ); - IOUtil.close( printer ); + printer.println("}"); + } finally { + IOUtil.close(output); + IOUtil.close(printer); } } - private void createBarJava( File barJava ) - throws Exception - { - FileWriter output = new FileWriter( barJava ); + private void createBarJava(File barJava) throws Exception { + FileWriter output = new FileWriter(barJava); - PrintWriter printer = new PrintWriter( output ); + PrintWriter printer = new PrintWriter(output); - printer.println( "public class Bar" ); - printer.println( "{" ); + printer.println("public class Bar"); + printer.println("{"); - printer.println( " public int bar()" ); - printer.println( " {" ); - printer.println( " return 20;" ); - printer.println( " }" ); + printer.println(" public int bar()"); + printer.println(" {"); + printer.println(" return 20;"); + printer.println(" }"); - printer.println( "}" ); + printer.println("}"); printer.close(); output.close(); } - private void changeReadmeTxt( File readmeTxt ) - throws Exception - { + private void changeReadmeTxt(File readmeTxt) throws Exception { FileWriter output = null; - try - { - output = new FileWriter( readmeTxt ); + try { + output = new FileWriter(readmeTxt); - output.write( "changed file" ); - } - finally - { - IOUtil.close( output ); + output.write("changed file"); + } finally { + IOUtil.close(output); } } } diff --git a/maven-scm-test/src/main/java/org/apache/maven/scm/tck/command/checkout/CheckOutCommandTckTest.java b/maven-scm-test/src/main/java/org/apache/maven/scm/tck/command/checkout/CheckOutCommandTckTest.java index 71f1119a4..dc189694e 100644 --- a/maven-scm-test/src/main/java/org/apache/maven/scm/tck/command/checkout/CheckOutCommandTckTest.java +++ b/maven-scm-test/src/main/java/org/apache/maven/scm/tck/command/checkout/CheckOutCommandTckTest.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.tck.command.checkout; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.tck.command.checkout; import java.util.Iterator; import java.util.List; @@ -37,35 +36,29 @@ * @author Trygve Laugstøl * */ -public abstract class CheckOutCommandTckTest - extends ScmTckTestCase -{ +public abstract class CheckOutCommandTckTest extends ScmTckTestCase { @Test - public void testCheckOutCommandTest() - throws Exception - { - deleteDirectory( getWorkingCopy() ); + public void testCheckOutCommandTest() throws Exception { + deleteDirectory(getWorkingCopy()); - CheckOutScmResult result = checkOut( getWorkingCopy(), getScmRepository() ); + CheckOutScmResult result = checkOut(getWorkingCopy(), getScmRepository()); - assertResultIsSuccess( result ); + assertResultIsSuccess(result); List checkedOutFiles = result.getCheckedOutFiles(); - if ( checkedOutFiles.size() != 4 ) - { - SortedSet files = new TreeSet( checkedOutFiles ); + if (checkedOutFiles.size() != 4) { + SortedSet files = new TreeSet(checkedOutFiles); int i = 0; - for ( Iterator it = files.iterator(); it.hasNext(); i++ ) - { + for (Iterator it = files.iterator(); it.hasNext(); i++) { ScmFile scmFile = it.next(); - System.out.println( "" + i + ": " + scmFile ); + System.out.println("" + i + ": " + scmFile); } - fail( "Expected 4 files in the updated files list, was " + checkedOutFiles.size() ); + fail("Expected 4 files in the updated files list, was " + checkedOutFiles.size()); } } } diff --git a/maven-scm-test/src/main/java/org/apache/maven/scm/tck/command/diff/DiffCommandTckTest.java b/maven-scm-test/src/main/java/org/apache/maven/scm/tck/command/diff/DiffCommandTckTest.java index d70237dff..b72896e8b 100644 --- a/maven-scm-test/src/main/java/org/apache/maven/scm/tck/command/diff/DiffCommandTckTest.java +++ b/maven-scm-test/src/main/java/org/apache/maven/scm/tck/command/diff/DiffCommandTckTest.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.tck.command.diff; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,13 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.tck.command.diff; + +import java.io.File; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.TreeSet; import org.apache.maven.scm.ScmFile; import org.apache.maven.scm.ScmFileSet; @@ -29,12 +34,6 @@ import org.apache.maven.scm.repository.ScmRepository; import org.junit.Test; -import java.io.File; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.TreeSet; - import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; @@ -45,14 +44,10 @@ * @author Brett Porter * */ -public abstract class DiffCommandTckTest - extends ScmTckTestCase -{ +public abstract class DiffCommandTckTest extends ScmTckTestCase { @Test - public void testDiffCommand() - throws Exception - { + public void testDiffCommand() throws Exception { ScmRepository repository = getScmRepository(); // ---------------------------------------------------------------------- @@ -69,84 +64,84 @@ public void testDiffCommand() // // /readme.txt - ScmTestCase.makeFile( getWorkingCopy(), "/readme.txt", "changed readme.txt" ); + ScmTestCase.makeFile(getWorkingCopy(), "/readme.txt", "changed readme.txt"); // /project.xml - ScmTestCase.makeFile( getWorkingCopy(), "/project.xml", "changed project.xml" ); + ScmTestCase.makeFile(getWorkingCopy(), "/project.xml", "changed project.xml"); - addToWorkingTree( getWorkingCopy(), new File( "project.xml" ), repository ); + addToWorkingTree(getWorkingCopy(), new File("project.xml"), repository); // /src/test/java/org - ScmTestCase.makeDirectory( getWorkingCopy(), "/src/test/java/org" ); + ScmTestCase.makeDirectory(getWorkingCopy(), "/src/test/java/org"); - addToWorkingTree( getWorkingCopy(), new File( "src/test/java/org" ), repository ); + addToWorkingTree(getWorkingCopy(), new File("src/test/java/org"), repository); // /src/main/java/org/Foo.java - ScmTestCase.makeFile( getWorkingCopy(), "/src/main/java/org/Foo.java" ); + ScmTestCase.makeFile(getWorkingCopy(), "/src/main/java/org/Foo.java"); - addToWorkingTree( getWorkingCopy(), new File( "src/main/java/org" ), repository ); + addToWorkingTree(getWorkingCopy(), new File("src/main/java/org"), repository); // src/main/java/org/Foo.java - addToWorkingTree( getWorkingCopy(), new File( "src/main/java/org/Foo.java" ), repository ); + addToWorkingTree(getWorkingCopy(), new File("src/main/java/org/Foo.java"), repository); // ---------------------------------------------------------------------- // Diff the project // ---------------------------------------------------------------------- - ScmProvider provider = getScmManager().getProviderByUrl( getScmUrl() ); - ScmFileSet fileSet = new ScmFileSet( getWorkingCopy() ); - DiffScmResult result = provider.diff( repository, fileSet, null, (ScmVersion) null ); + ScmProvider provider = getScmManager().getProviderByUrl(getScmUrl()); + ScmFileSet fileSet = new ScmFileSet(getWorkingCopy()); + DiffScmResult result = provider.diff(repository, fileSet, null, (ScmVersion) null); - assertNotNull( "The command returned a null result.", result ); + assertNotNull("The command returned a null result.", result); - assertResultIsSuccess( result ); + assertResultIsSuccess(result); List changedFiles = result.getChangedFiles(); Map differences = result.getDifferences(); - assertEquals( "Expected 3 files in the changed files list " + changedFiles, 3, changedFiles.size() ); + assertEquals("Expected 3 files in the changed files list " + changedFiles, 3, changedFiles.size()); - assertEquals( "Expected 3 files in the differences list " + differences, 3, differences.size() ); + assertEquals("Expected 3 files in the differences list " + differences, 3, differences.size()); // ---------------------------------------------------------------------- // Assert the files in the changed files list // ---------------------------------------------------------------------- - Iterator files = new TreeSet( changedFiles ).iterator(); + Iterator files = new TreeSet(changedFiles).iterator(); - //Check Foo.java + // Check Foo.java ScmFile file = files.next(); - assertPath( "src/main/java/org/Foo.java", file.getPath() ); + assertPath("src/main/java/org/Foo.java", file.getPath()); - assertTrue( file.getStatus().isDiff() ); + assertTrue(file.getStatus().isDiff()); String postRangeStr = "+/src/main/java/org/Foo.java\n\\ No newline at end of file\n"; - String actualStr = differences.get( file.getPath() ).toString(); - assertTrue( actualStr.endsWith( postRangeStr ) ); + String actualStr = differences.get(file.getPath()).toString(); + assertTrue(actualStr.endsWith(postRangeStr)); - //Check readme.txt + // Check readme.txt file = files.next(); - assertPath( "readme.txt", file.getPath() ); + assertPath("readme.txt", file.getPath()); - assertTrue( file.getStatus().isDiff() ); + assertTrue(file.getStatus().isDiff()); postRangeStr = - "-/readme.txt\n\\ No newline at end of file\n+changed readme.txt\n\\ No newline at end of file\n"; - actualStr = differences.get( file.getPath() ).toString(); - assertTrue( actualStr.endsWith( postRangeStr ) ); + "-/readme.txt\n\\ No newline at end of file\n+changed readme.txt\n\\ No newline at end of file\n"; + actualStr = differences.get(file.getPath()).toString(); + assertTrue(actualStr.endsWith(postRangeStr)); - //Check project.xml + // Check project.xml file = files.next(); - assertPath( "project.xml", file.getPath() ); + assertPath("project.xml", file.getPath()); postRangeStr = "+changed project.xml\n\\ No newline at end of file\n"; - actualStr = differences.get( file.getPath() ).toString(); - assertTrue( actualStr.endsWith( postRangeStr ) ); + actualStr = differences.get(file.getPath()).toString(); + assertTrue(actualStr.endsWith(postRangeStr)); - assertTrue( file.getStatus().isDiff() ); + assertTrue(file.getStatus().isDiff()); } } diff --git a/maven-scm-test/src/main/java/org/apache/maven/scm/tck/command/list/ListCommandTckTest.java b/maven-scm-test/src/main/java/org/apache/maven/scm/tck/command/list/ListCommandTckTest.java index 63e49008f..ad097eb28 100644 --- a/maven-scm-test/src/main/java/org/apache/maven/scm/tck/command/list/ListCommandTckTest.java +++ b/maven-scm-test/src/main/java/org/apache/maven/scm/tck/command/list/ListCommandTckTest.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.tck.command.list; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.tck.command.list; import java.io.File; import java.util.List; @@ -40,53 +39,45 @@ * @author Carlos Sanchez * */ -public abstract class ListCommandTckTest - extends ScmTckTestCase -{ +public abstract class ListCommandTckTest extends ScmTckTestCase { @Test - public void testListCommandTest() - throws Exception - { - ScmFileSet fileSet = new ScmFileSet( new File( "." ), new File( "." ) ); + public void testListCommandTest() throws Exception { + ScmFileSet fileSet = new ScmFileSet(new File("."), new File(".")); - List files = runList( fileSet, false ); + List files = runList(fileSet, false); - assertEquals( "The result of the list command doesn't have all the files in SCM: " + files, 3, files.size() ); + assertEquals("The result of the list command doesn't have all the files in SCM: " + files, 3, files.size()); } @Test - public void testListCommandRecursiveTest() - throws Exception - { - ScmFileSet fileSet = new ScmFileSet( new File( "." ), new File( "." ) ); + public void testListCommandRecursiveTest() throws Exception { + ScmFileSet fileSet = new ScmFileSet(new File("."), new File(".")); - List files = runList( fileSet, true ); + List files = runList(fileSet, true); - assertEquals( "The result of the list command doesn't have all the files in SCM: " + files, 10, files.size() ); + assertEquals("The result of the list command doesn't have all the files in SCM: " + files, 10, files.size()); } @Test - public void testListCommandUnexistantFileTest() - throws Exception - { - ScmFileSet fileSet = new ScmFileSet( new File( "." ), new File( "/void" ) ); + public void testListCommandUnexistantFileTest() throws Exception { + ScmFileSet fileSet = new ScmFileSet(new File("."), new File("/void")); - ScmProvider provider = getScmManager().getProviderByUrl( getScmUrl() ); + ScmProvider provider = getScmManager().getProviderByUrl(getScmUrl()); - ListScmResult result = provider.list( getScmRepository(), fileSet, false, (ScmVersion) null ); + ListScmResult result = provider.list(getScmRepository(), fileSet, false, (ScmVersion) null); - assertFalse( "Found file when shouldn't", result.isSuccess() ); + assertFalse("Found file when shouldn't", result.isSuccess()); } - private List runList( ScmFileSet fileSet, boolean recursive ) - throws Exception - { - ScmProvider provider = getScmManager().getProviderByUrl( getScmUrl() ); + private List runList(ScmFileSet fileSet, boolean recursive) throws Exception { + ScmProvider provider = getScmManager().getProviderByUrl(getScmUrl()); - ListScmResult result = provider.list( getScmRepository(), fileSet, recursive, (ScmVersion) null ); + ListScmResult result = provider.list(getScmRepository(), fileSet, recursive, (ScmVersion) null); - assertTrue( "SCM command failed: " + result.getCommandLine() + " : " + result.getProviderMessage() - + ( result.getCommandOutput() == null ? "" : ": " + result.getCommandOutput() ), result.isSuccess() ); + assertTrue( + "SCM command failed: " + result.getCommandLine() + " : " + result.getProviderMessage() + + (result.getCommandOutput() == null ? "" : ": " + result.getCommandOutput()), + result.isSuccess()); return result.getFiles(); } diff --git a/maven-scm-test/src/main/java/org/apache/maven/scm/tck/command/mkdir/MkdirCommandTckTest.java b/maven-scm-test/src/main/java/org/apache/maven/scm/tck/command/mkdir/MkdirCommandTckTest.java index 2e393ff5d..1097fdeee 100644 --- a/maven-scm-test/src/main/java/org/apache/maven/scm/tck/command/mkdir/MkdirCommandTckTest.java +++ b/maven-scm-test/src/main/java/org/apache/maven/scm/tck/command/mkdir/MkdirCommandTckTest.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.tck.command.mkdir; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.tck.command.mkdir; import java.io.File; @@ -31,30 +30,26 @@ /** * This test tests the mkdir command. - * + * * @author Maria Odea Ching * */ -public abstract class MkdirCommandTckTest - extends ScmTckTestCase -{ +public abstract class MkdirCommandTckTest extends ScmTckTestCase { @Test - public void testMkdirCommandMkdirLocal() - throws Exception - { - ScmFileSet fileSet = new ScmFileSet( getWorkingCopy(), new File( getMissingDirectory() ) ); + public void testMkdirCommandMkdirLocal() throws Exception { + ScmFileSet fileSet = new ScmFileSet(getWorkingCopy(), new File(getMissingDirectory())); - MkdirScmResult result = getScmManager().mkdir( getScmRepository(), fileSet, null, true ); + MkdirScmResult result = getScmManager().mkdir(getScmRepository(), fileSet, null, true); - assertResultIsSuccess( result ); + assertResultIsSuccess(result); - assertNotNull( result.getCreatedDirs() ); + assertNotNull(result.getCreatedDirs()); - assertEquals( "Directory should have been added.", 1, result.getCreatedDirs().size() ); + assertEquals( + "Directory should have been added.", 1, result.getCreatedDirs().size()); } - protected String getMissingDirectory() - { + protected String getMissingDirectory() { return "missing"; } } diff --git a/maven-scm-test/src/main/java/org/apache/maven/scm/tck/command/remoteinfo/AbstractRemoteInfoCommandTckTest.java b/maven-scm-test/src/main/java/org/apache/maven/scm/tck/command/remoteinfo/AbstractRemoteInfoCommandTckTest.java index 56b4edd6e..3f21524ae 100644 --- a/maven-scm-test/src/main/java/org/apache/maven/scm/tck/command/remoteinfo/AbstractRemoteInfoCommandTckTest.java +++ b/maven-scm-test/src/main/java/org/apache/maven/scm/tck/command/remoteinfo/AbstractRemoteInfoCommandTckTest.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.tck.command.remoteinfo; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.tck.command.remoteinfo; import org.apache.maven.scm.ScmFileSet; import org.apache.maven.scm.ScmTckTestCase; @@ -35,23 +34,18 @@ * * @author Bertrand Paquet */ -public abstract class AbstractRemoteInfoCommandTckTest - extends ScmTckTestCase -{ +public abstract class AbstractRemoteInfoCommandTckTest extends ScmTckTestCase { - protected abstract void checkResult( RemoteInfoScmResult result ); + protected abstract void checkResult(RemoteInfoScmResult result); - protected abstract ScmProviderRepository getScmProviderRepository() - throws Exception; + protected abstract ScmProviderRepository getScmProviderRepository() throws Exception; @Test - public void testRemoteInfoCommand() - throws Exception - { - ScmProvider provider = getScmManager().getProviderByRepository( getScmRepository() ); + public void testRemoteInfoCommand() throws Exception { + ScmProvider provider = getScmManager().getProviderByRepository(getScmRepository()); RemoteInfoScmResult result = - provider.remoteInfo( getScmProviderRepository(), new ScmFileSet( getWorkingCopy() ), null ); + provider.remoteInfo(getScmProviderRepository(), new ScmFileSet(getWorkingCopy()), null); - checkResult( result ); + checkResult(result); } } diff --git a/maven-scm-test/src/main/java/org/apache/maven/scm/tck/command/remove/RemoveCommandTckTest.java b/maven-scm-test/src/main/java/org/apache/maven/scm/tck/command/remove/RemoveCommandTckTest.java index a338f748e..0c7f61c8e 100644 --- a/maven-scm-test/src/main/java/org/apache/maven/scm/tck/command/remove/RemoveCommandTckTest.java +++ b/maven-scm-test/src/main/java/org/apache/maven/scm/tck/command/remove/RemoveCommandTckTest.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.tck.command.remove; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.tck.command.remove; import java.io.File; import java.util.List; @@ -36,57 +35,53 @@ import static org.junit.Assert.assertNotNull; /** This test tests the remove command. */ -public abstract class RemoveCommandTckTest - extends ScmTckTestCase -{ +public abstract class RemoveCommandTckTest extends ScmTckTestCase { @Test - public void testRemoveCommand() - throws Exception - { + public void testRemoveCommand() throws Exception { // existence has been tested in ScmTckTestCase.setup() already - ScmFileSet fileSet = new ScmFileSet( getWorkingCopy(), "src/main/java/Application.java" ); - RemoveScmResult removeResult = getScmManager().remove( getScmRepository(), fileSet, "remove1" ); + ScmFileSet fileSet = new ScmFileSet(getWorkingCopy(), "src/main/java/Application.java"); + RemoveScmResult removeResult = getScmManager().remove(getScmRepository(), fileSet, "remove1"); - assertResultIsSuccess( removeResult ); + assertResultIsSuccess(removeResult); // check removed files List files = removeResult.getRemovedFiles(); - assertNotNull( files ); - assertEquals( 1, files.size() ); - ScmFile file1 = files.get( 0 ); - assertEquals( ScmFileStatus.DELETED, file1.getStatus() ); - assertPath( "src/main/java/Application.java", file1.getPath() ); + assertNotNull(files); + assertEquals(1, files.size()); + ScmFile file1 = files.get(0); + assertEquals(ScmFileStatus.DELETED, file1.getStatus()); + assertPath("src/main/java/Application.java", file1.getPath()); // remove file with different basedir - fileSet = new ScmFileSet( new File( getWorkingCopy(), "src" ), new File( "test/java/Test.java" ) ); - removeResult = getScmManager().remove( getScmRepository(), fileSet, "remove2" ); + fileSet = new ScmFileSet(new File(getWorkingCopy(), "src"), new File("test/java/Test.java")); + removeResult = getScmManager().remove(getScmRepository(), fileSet, "remove2"); - assertResultIsSuccess( removeResult ); + assertResultIsSuccess(removeResult); // check removed files files = removeResult.getRemovedFiles(); - assertNotNull( files ); - assertEquals( 1, files.size() ); - file1 = files.get( 0 ); - assertEquals( ScmFileStatus.DELETED, file1.getStatus() ); - assertPath( "test/java/Test.java", file1.getPath() ); + assertNotNull(files); + assertEquals(1, files.size()); + file1 = files.get(0); + assertEquals(ScmFileStatus.DELETED, file1.getStatus()); + assertPath("test/java/Test.java", file1.getPath()); // checkin changes CheckInScmResult checkinResult = - getScmManager().checkIn( getScmRepository(), new ScmFileSet( getWorkingCopy() ), "Commit message" ); + getScmManager().checkIn(getScmRepository(), new ScmFileSet(getWorkingCopy()), "Commit message"); - assertResultIsSuccess( checkinResult ); + assertResultIsSuccess(checkinResult); // do a new checkout CheckOutScmResult checkoutResult = - getScmManager().checkOut( getScmRepository(), new ScmFileSet( getAssertionCopy() ) ); + getScmManager().checkOut(getScmRepository(), new ScmFileSet(getAssertionCopy())); - assertResultIsSuccess( checkoutResult ); + assertResultIsSuccess(checkoutResult); - File applicationJava = new File( getAssertionCopy(), "src/main/java/Application.java" ); + File applicationJava = new File(getAssertionCopy(), "src/main/java/Application.java"); - assertFalse( "Application.java does exist even though it has been removed before", applicationJava.canRead() ); + assertFalse("Application.java does exist even though it has been removed before", applicationJava.canRead()); - File testJava = new File( getAssertionCopy(), "src/test/java/Test.java" ); + File testJava = new File(getAssertionCopy(), "src/test/java/Test.java"); - assertFalse( "Test.java does exist even though it has been removed before", testJava.canRead() ); + assertFalse("Test.java does exist even though it has been removed before", testJava.canRead()); } } diff --git a/maven-scm-test/src/main/java/org/apache/maven/scm/tck/command/status/StatusCommandTckTest.java b/maven-scm-test/src/main/java/org/apache/maven/scm/tck/command/status/StatusCommandTckTest.java index 2c338db46..220641f3d 100644 --- a/maven-scm-test/src/main/java/org/apache/maven/scm/tck/command/status/StatusCommandTckTest.java +++ b/maven-scm-test/src/main/java/org/apache/maven/scm/tck/command/status/StatusCommandTckTest.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.tck.command.status; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,12 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.tck.command.status; + +import java.io.File; +import java.util.Iterator; +import java.util.List; +import java.util.TreeSet; import org.apache.maven.scm.ScmFile; import org.apache.maven.scm.ScmFileSet; @@ -30,11 +34,6 @@ import org.apache.maven.scm.repository.ScmRepository; import org.junit.Test; -import java.io.File; -import java.util.Iterator; -import java.util.List; -import java.util.TreeSet; - import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; @@ -58,35 +57,27 @@ * @author Brett Porter * */ -public abstract class StatusCommandTckTest - extends ScmTckTestCase -{ +public abstract class StatusCommandTckTest extends ScmTckTestCase { - protected void commit( File workingDirectory, ScmRepository repository ) - throws Exception - { - CheckInScmResult result = getScmManager().checkIn( repository, new ScmFileSet( workingDirectory ), "No msg" ); + protected void commit(File workingDirectory, ScmRepository repository) throws Exception { + CheckInScmResult result = getScmManager().checkIn(repository, new ScmFileSet(workingDirectory), "No msg"); - assertTrue( "Check result was successful, output: " + result.getCommandOutput(), result.isSuccess() ); + assertTrue("Check result was successful, output: " + result.getCommandOutput(), result.isSuccess()); List committedFiles = result.getCheckedInFiles(); - assertEquals( "Expected 2 files in the committed files list " + committedFiles, 2, committedFiles.size() ); + assertEquals("Expected 2 files in the committed files list " + committedFiles, 2, committedFiles.size()); } - protected boolean commitUpdateCopy() - { + protected boolean commitUpdateCopy() { return false; } - @Test - public void testStatusCommand() - throws Exception - { - ScmRepository repository = makeScmRepository( getScmUrl() ); + public void testStatusCommand() throws Exception { + ScmRepository repository = makeScmRepository(getScmUrl()); - checkOut( getUpdatingCopy(), repository ); + checkOut(getUpdatingCopy(), repository); // ---------------------------------------------------------------------- // Change the files @@ -98,32 +89,32 @@ public void testStatusCommand() */ // /readme.txt - this.edit( getWorkingCopy(), "readme.txt", null, getScmRepository() ); - ScmTestCase.makeFile( getWorkingCopy(), "/readme.txt", "changed readme.txt" ); + this.edit(getWorkingCopy(), "readme.txt", null, getScmRepository()); + ScmTestCase.makeFile(getWorkingCopy(), "/readme.txt", "changed readme.txt"); // /project.xml - ScmTestCase.makeFile( getWorkingCopy(), "/project.xml", "changed project.xml" ); + ScmTestCase.makeFile(getWorkingCopy(), "/project.xml", "changed project.xml"); - addToWorkingTree( getWorkingCopy(), new File( "project.xml" ), getScmRepository() ); + addToWorkingTree(getWorkingCopy(), new File("project.xml"), getScmRepository()); - commit( getWorkingCopy(), getScmRepository() ); + commit(getWorkingCopy(), getScmRepository()); // /pom.xml - this.edit( getUpdatingCopy(), "pom.xml", null, repository ); - ScmTestCase.makeFile( getUpdatingCopy(), "/pom.xml", "changed pom.xml" ); + this.edit(getUpdatingCopy(), "pom.xml", null, repository); + ScmTestCase.makeFile(getUpdatingCopy(), "/pom.xml", "changed pom.xml"); // /src/test/java/org - ScmTestCase.makeDirectory( getUpdatingCopy(), "/src/test/java/org" ); + ScmTestCase.makeDirectory(getUpdatingCopy(), "/src/test/java/org"); - addToWorkingTree( getUpdatingCopy(), new File( "src/test/java/org" ), repository ); + addToWorkingTree(getUpdatingCopy(), new File("src/test/java/org"), repository); // /src/main/java/org/Foo.java - ScmTestCase.makeFile( getUpdatingCopy(), "/src/main/java/org/Foo.java" ); + ScmTestCase.makeFile(getUpdatingCopy(), "/src/main/java/org/Foo.java"); - addToWorkingTree( getUpdatingCopy(), new File( "src/main/java/org" ), repository ); + addToWorkingTree(getUpdatingCopy(), new File("src/main/java/org"), repository); // src/main/java/org/Foo.java - addToWorkingTree( getUpdatingCopy(), new File( "src/main/java/org/Foo.java" ), repository ); + addToWorkingTree(getUpdatingCopy(), new File("src/main/java/org/Foo.java"), repository); ScmManager scmManager = getScmManager(); @@ -134,39 +125,38 @@ public void testStatusCommand() // check that readme and project.xml are not updated/created // ---------------------------------------------------------------------- - StatusScmResult result = scmManager.getProviderByUrl( getScmUrl() ) - .status( repository, new ScmFileSet( getUpdatingCopy() ) ); + StatusScmResult result = + scmManager.getProviderByUrl(getScmUrl()).status(repository, new ScmFileSet(getUpdatingCopy())); - if ( this.commitUpdateCopy() ) - { - //this is needed for perforce so that teardown can remove its client workspace, no harm for cvs/svn/git - commit( getUpdatingCopy(), repository ); + if (this.commitUpdateCopy()) { + // this is needed for perforce so that teardown can remove its client workspace, no harm for cvs/svn/git + commit(getUpdatingCopy(), repository); } - assertNotNull( "The command returned a null result.", result ); + assertNotNull("The command returned a null result.", result); - assertResultIsSuccess( result ); + assertResultIsSuccess(result); List changedFiles = result.getChangedFiles(); - assertEquals( "Expected 2 files in the updated files list " + changedFiles, 2, changedFiles.size() ); + assertEquals("Expected 2 files in the updated files list " + changedFiles, 2, changedFiles.size()); // ---------------------------------------------------------------------- // Assert the files in the updated files list // ---------------------------------------------------------------------- - Iterator files = new TreeSet( changedFiles ).iterator(); + Iterator files = new TreeSet(changedFiles).iterator(); ScmFile file = files.next(); - assertPath( "src/main/java/org/Foo.java", file.getPath() ); - assertEquals( ScmFileStatus.ADDED, file.getStatus() ); + assertPath("src/main/java/org/Foo.java", file.getPath()); + assertEquals(ScmFileStatus.ADDED, file.getStatus()); file = files.next(); - assertPath( "pom.xml", file.getPath() ); - assertEquals( ScmFileStatus.MODIFIED, file.getStatus() ); + assertPath("pom.xml", file.getPath()); + assertEquals(ScmFileStatus.MODIFIED, file.getStatus()); - assertFile( getUpdatingCopy(), "/readme.txt" ); + assertFile(getUpdatingCopy(), "/readme.txt"); - assertFalse( "project.xml created incorrectly", new File( getUpdatingCopy(), "/project.xml" ).exists() ); + assertFalse("project.xml created incorrectly", new File(getUpdatingCopy(), "/project.xml").exists()); } } diff --git a/maven-scm-test/src/main/java/org/apache/maven/scm/tck/command/tag/TagCommandTckTest.java b/maven-scm-test/src/main/java/org/apache/maven/scm/tck/command/tag/TagCommandTckTest.java index 8eae4f425..73f192b4e 100644 --- a/maven-scm-test/src/main/java/org/apache/maven/scm/tck/command/tag/TagCommandTckTest.java +++ b/maven-scm-test/src/main/java/org/apache/maven/scm/tck/command/tag/TagCommandTckTest.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.tck.command.tag; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,10 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.tck.command.tag; + +import java.io.File; +import java.io.FileWriter; import org.apache.maven.scm.ScmFileSet; import org.apache.maven.scm.ScmTag; @@ -29,9 +31,6 @@ import org.codehaus.plexus.util.IOUtil; import org.junit.Test; -import java.io.File; -import java.io.FileWriter; - import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; @@ -41,77 +40,66 @@ * @author Brett Porter * */ -public abstract class TagCommandTckTest - extends ScmTckTestCase -{ +public abstract class TagCommandTckTest extends ScmTckTestCase { - protected String getTagName() - { + protected String getTagName() { return "test-tag"; } @Test - public void testTagCommandTest() - throws Exception - { + public void testTagCommandTest() throws Exception { String tag = getTagName(); - @SuppressWarnings( "deprecation" ) TagScmResult tagResult = - getScmManager().getProviderByUrl( getScmUrl() ).tag( getScmRepository(), new ScmFileSet( getWorkingCopy() ), - tag ); + @SuppressWarnings("deprecation") + TagScmResult tagResult = getScmManager() + .getProviderByUrl(getScmUrl()) + .tag(getScmRepository(), new ScmFileSet(getWorkingCopy()), tag); - assertResultIsSuccess( tagResult ); + assertResultIsSuccess(tagResult); // see https://issues.apache.org/jira/browse/SCM-754 // assertEquals( "check all 4 files tagged", 4, tagResult.getTaggedFiles().size() ); - File readmeTxt = new File( getWorkingCopy(), "readme.txt" ); + File readmeTxt = new File(getWorkingCopy(), "readme.txt"); - assertEquals( "check readme.txt contents", "/readme.txt", FileUtils.fileRead( readmeTxt ) ); + assertEquals("check readme.txt contents", "/readme.txt", FileUtils.fileRead(readmeTxt)); - this.edit( getWorkingCopy(), "readme.txt", null, getScmRepository() ); - changeReadmeTxt( readmeTxt ); + this.edit(getWorkingCopy(), "readme.txt", null, getScmRepository()); + changeReadmeTxt(readmeTxt); CheckInScmResult checkinResult = - getScmManager().checkIn( getScmRepository(), new ScmFileSet( getWorkingCopy() ), "commit message" ); + getScmManager().checkIn(getScmRepository(), new ScmFileSet(getWorkingCopy()), "commit message"); - assertResultIsSuccess( checkinResult ); + assertResultIsSuccess(checkinResult); CheckOutScmResult checkoutResult = - getScmManager().checkOut( getScmRepository(), new ScmFileSet( getAssertionCopy() ) ); + getScmManager().checkOut(getScmRepository(), new ScmFileSet(getAssertionCopy())); - assertResultIsSuccess( checkoutResult ); + assertResultIsSuccess(checkoutResult); - readmeTxt = new File( getAssertionCopy(), "readme.txt" ); + readmeTxt = new File(getAssertionCopy(), "readme.txt"); - assertEquals( "check readme.txt contents", "changed file", FileUtils.fileRead( readmeTxt ) ); + assertEquals("check readme.txt contents", "changed file", FileUtils.fileRead(readmeTxt)); - deleteDirectory( getAssertionCopy() ); + deleteDirectory(getAssertionCopy()); - assertFalse( "check previous assertion copy deleted", getAssertionCopy().exists() ); + assertFalse("check previous assertion copy deleted", getAssertionCopy().exists()); - checkoutResult = getScmManager().getProviderByUrl( getScmUrl() ).checkOut( getScmRepository(), - new ScmFileSet( getAssertionCopy() ), - new ScmTag( tag ) ); + checkoutResult = getScmManager() + .getProviderByUrl(getScmUrl()) + .checkOut(getScmRepository(), new ScmFileSet(getAssertionCopy()), new ScmTag(tag)); - assertResultIsSuccess( checkoutResult ); + assertResultIsSuccess(checkoutResult); - assertEquals( "check readme.txt contents is from tagged version", "/readme.txt", - FileUtils.fileRead( readmeTxt ) ); + assertEquals("check readme.txt contents is from tagged version", "/readme.txt", FileUtils.fileRead(readmeTxt)); } - private void changeReadmeTxt( File readmeTxt ) - throws Exception - { - FileWriter output = new FileWriter( readmeTxt ); - try - { - output.write( "changed file" ); + private void changeReadmeTxt(File readmeTxt) throws Exception { + FileWriter output = new FileWriter(readmeTxt); + try { + output.write("changed file"); + } finally { + IOUtil.close(output); } - finally - { - IOUtil.close( output ); - } - } } diff --git a/maven-scm-test/src/main/java/org/apache/maven/scm/tck/command/untag/UntagCommandTckTest.java b/maven-scm-test/src/main/java/org/apache/maven/scm/tck/command/untag/UntagCommandTckTest.java index 481ed4c7d..8885242de 100644 --- a/maven-scm-test/src/main/java/org/apache/maven/scm/tck/command/untag/UntagCommandTckTest.java +++ b/maven-scm-test/src/main/java/org/apache/maven/scm/tck/command/untag/UntagCommandTckTest.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.tck.command.untag; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.tck.command.untag; import org.apache.maven.scm.CommandParameter; import org.apache.maven.scm.CommandParameters; @@ -38,51 +37,39 @@ /** * This test tests the untag command. */ -public abstract class UntagCommandTckTest - extends ScmTckTestCase -{ +public abstract class UntagCommandTckTest extends ScmTckTestCase { - protected String getTagName() - { + protected String getTagName() { return "test-untag"; } @Test - public void testUntagCommandTest() - throws Exception - { + public void testUntagCommandTest() throws Exception { String tag = getTagName(); - ScmProvider scmProvider = getScmManager().getProviderByUrl( getScmUrl() ); + ScmProvider scmProvider = getScmManager().getProviderByUrl(getScmUrl()); ScmRepository scmRepository = getScmRepository(); - ScmFileSet files = new ScmFileSet( getWorkingCopy() ); - TagScmResult tagResult = scmProvider.tag( scmRepository, files, tag, new ScmTagParameters() ); + ScmFileSet files = new ScmFileSet(getWorkingCopy()); + TagScmResult tagResult = scmProvider.tag(scmRepository, files, tag, new ScmTagParameters()); - assertResultIsSuccess( tagResult ); + assertResultIsSuccess(tagResult); CommandParameters params = new CommandParameters(); - params.setString( CommandParameter.TAG_NAME, tag ); + params.setString(CommandParameter.TAG_NAME, tag); - UntagScmResult untagResult = scmProvider.untag( scmRepository, files, params ); + UntagScmResult untagResult = scmProvider.untag(scmRepository, files, params); - assertResultIsSuccess( untagResult ); + assertResultIsSuccess(untagResult); - try - { - untagResult = scmProvider.untag( scmRepository, files, params ); - assertFalse( untagResult.isSuccess() ); // already been deleted - } - catch ( ScmException ignored ) - { + try { + untagResult = scmProvider.untag(scmRepository, files, params); + assertFalse(untagResult.isSuccess()); // already been deleted + } catch (ScmException ignored) { } - try - { + try { CheckOutScmResult checkoutResult = - getScmManager().checkOut( scmRepository, new ScmFileSet( getAssertionCopy() ), new ScmTag( tag ) ); - assertFalse( checkoutResult.isSuccess() ); // can't check out a deleted tags - } - catch ( ScmException ignored ) - { + getScmManager().checkOut(scmRepository, new ScmFileSet(getAssertionCopy()), new ScmTag(tag)); + assertFalse(checkoutResult.isSuccess()); // can't check out a deleted tags + } catch (ScmException ignored) { } } - } diff --git a/maven-scm-test/src/main/java/org/apache/maven/scm/tck/command/update/UpdateCommandTckTest.java b/maven-scm-test/src/main/java/org/apache/maven/scm/tck/command/update/UpdateCommandTckTest.java index 6c5c4db1b..1c8cd485c 100644 --- a/maven-scm-test/src/main/java/org/apache/maven/scm/tck/command/update/UpdateCommandTckTest.java +++ b/maven-scm-test/src/main/java/org/apache/maven/scm/tck/command/update/UpdateCommandTckTest.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.tck.command.update; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.tck.command.update; import java.io.File; import java.util.Date; @@ -61,40 +60,36 @@ * @author Trygve Laugstøl * */ -public abstract class UpdateCommandTckTest - extends ScmTckTestCase -{ +public abstract class UpdateCommandTckTest extends ScmTckTestCase { - private void commit( File workingDirectory, ScmRepository repository ) - throws Exception - { - CheckInScmResult result = getScmManager().checkIn( repository, new ScmFileSet( workingDirectory ), "No msg" ); + private void commit(File workingDirectory, ScmRepository repository) throws Exception { + CheckInScmResult result = getScmManager().checkIn(repository, new ScmFileSet(workingDirectory), "No msg"); - assertTrue( "Check result was successful, output: " + result.getCommandOutput(), result.isSuccess() ); + assertTrue("Check result was successful, output: " + result.getCommandOutput(), result.isSuccess()); List committedFiles = result.getCheckedInFiles(); assertEquals( - "Expected 3 files in the committed files list:\n " + StringUtils.join( committedFiles.iterator(), "\n " ), - 3, committedFiles.size() ); + "Expected 3 files in the committed files list:\n " + + StringUtils.join(committedFiles.iterator(), "\n "), + 3, + committedFiles.size()); } @Test - public void testUpdateCommand() - throws Exception - { + public void testUpdateCommand() throws Exception { - deleteDirectory( getUpdatingCopy() ); + deleteDirectory(getUpdatingCopy()); - assertFalse( getUpdatingCopy().exists() ); + assertFalse(getUpdatingCopy().exists()); - //deleteDirectory( getWorkingCopy() ); + // deleteDirectory( getWorkingCopy() ); - //assertFalse( getUpdatingCopy().exists() ); + // assertFalse( getUpdatingCopy().exists() ); - ScmRepository repository = makeScmRepository( getScmUrl() ); + ScmRepository repository = makeScmRepository(getScmUrl()); - checkOut( getUpdatingCopy(), repository ); + checkOut(getUpdatingCopy(), repository); // ---------------------------------------------------------------------- // Change the files @@ -110,82 +105,80 @@ public void testUpdateCommand() */ // /readme.txt - this.edit( getWorkingCopy(), "readme.txt", null, getScmRepository() ); - ScmTestCase.makeFile( getWorkingCopy(), "/readme.txt", "changed readme.txt" ); + this.edit(getWorkingCopy(), "readme.txt", null, getScmRepository()); + ScmTestCase.makeFile(getWorkingCopy(), "/readme.txt", "changed readme.txt"); // /project.xml - ScmTestCase.makeFile( getWorkingCopy(), "/project.xml", "changed project.xml" ); + ScmTestCase.makeFile(getWorkingCopy(), "/project.xml", "changed project.xml"); - addToWorkingTree( getWorkingCopy(), new File( "project.xml" ), getScmRepository() ); + addToWorkingTree(getWorkingCopy(), new File("project.xml"), getScmRepository()); // /src/test/java/org - ScmTestCase.makeDirectory( getWorkingCopy(), "/src/test/java/org" ); + ScmTestCase.makeDirectory(getWorkingCopy(), "/src/test/java/org"); - addToWorkingTree( getWorkingCopy(), new File( "src/test/java/org" ), getScmRepository() ); + addToWorkingTree(getWorkingCopy(), new File("src/test/java/org"), getScmRepository()); // /src/main/java/org/Foo.java - ScmTestCase.makeFile( getWorkingCopy(), "/src/main/java/org/Foo.java" ); + ScmTestCase.makeFile(getWorkingCopy(), "/src/main/java/org/Foo.java"); - addToWorkingTree( getWorkingCopy(), new File( "src/main/java/org" ), getScmRepository() ); + addToWorkingTree(getWorkingCopy(), new File("src/main/java/org"), getScmRepository()); // src/main/java/org/Foo.java - addToWorkingTree( getWorkingCopy(), new File( "src/main/java/org/Foo.java" ), getScmRepository() ); + addToWorkingTree(getWorkingCopy(), new File("src/main/java/org/Foo.java"), getScmRepository()); ScmManager scmManager = getScmManager(); - Date lastUpdate = new Date( System.currentTimeMillis() - 1000000 ); + Date lastUpdate = new Date(System.currentTimeMillis() - 1000000); - commit( getWorkingCopy(), getScmRepository() ); + commit(getWorkingCopy(), getScmRepository()); - Thread.sleep( 5000 ); + Thread.sleep(5000); // ---------------------------------------------------------------------- // Update the project // ---------------------------------------------------------------------- - UpdateScmResult result = scmManager.update( repository, new ScmFileSet( getUpdatingCopy() ), lastUpdate ); + UpdateScmResult result = scmManager.update(repository, new ScmFileSet(getUpdatingCopy()), lastUpdate); - assertNotNull( "The command returned a null result.", result ); + assertNotNull("The command returned a null result.", result); - assertResultIsSuccess( result ); + assertResultIsSuccess(result); List updatedFiles = result.getUpdatedFiles(); List changedSets = result.getChanges(); - assertEquals( "Expected 3 files in the updated files list " + updatedFiles, 3, updatedFiles.size() ); + assertEquals("Expected 3 files in the updated files list " + updatedFiles, 3, updatedFiles.size()); - assertNotNull( "The changed files list is null", changedSets ); + assertNotNull("The changed files list is null", changedSets); - assertFalse( "The changed files list is empty ", changedSets.isEmpty() ); + assertFalse("The changed files list is empty ", changedSets.isEmpty()); - for ( ChangeSet changeSet : changedSets ) - { - System.out.println( changeSet.toXML() ); + for (ChangeSet changeSet : changedSets) { + System.out.println(changeSet.toXML()); } // ---------------------------------------------------------------------- // Assert the files in the updated files list // ---------------------------------------------------------------------- - Iterator files = new TreeSet( updatedFiles ).iterator(); + Iterator files = new TreeSet(updatedFiles).iterator(); - //Foo.java + // Foo.java ScmFile file = files.next(); - assertPath( "src/main/java/org/Foo.java", file.getPath() ); - //TODO : Consolidate file status so that we can remove "|| ADDED" term - assertTrue( file.getStatus().isUpdate() || file.getStatus() == ScmFileStatus.ADDED ); + assertPath("src/main/java/org/Foo.java", file.getPath()); + // TODO : Consolidate file status so that we can remove "|| ADDED" term + assertTrue(file.getStatus().isUpdate() || file.getStatus() == ScmFileStatus.ADDED); - //readme.txt + // readme.txt file = files.next(); - assertPath( "readme.txt", file.getPath() ); - assertTrue( file.getStatus().isUpdate() ); + assertPath("readme.txt", file.getPath()); + assertTrue(file.getStatus().isUpdate()); - //project.xml + // project.xml file = files.next(); - assertPath( "project.xml", file.getPath() ); - //TODO : Consolidate file status so that we can remove "|| ADDED" term - assertTrue( file.getStatus().isUpdate() || file.getStatus() == ScmFileStatus.ADDED ); + assertPath("project.xml", file.getPath()); + // TODO : Consolidate file status so that we can remove "|| ADDED" term + assertTrue(file.getStatus().isUpdate() || file.getStatus() == ScmFileStatus.ADDED); } - } diff --git a/maven-scm-test/src/test/java/org/apache/maven/scm/manager/ScmManagerStubTest.java b/maven-scm-test/src/test/java/org/apache/maven/scm/manager/ScmManagerStubTest.java index 6d62901f3..4c40d45a0 100644 --- a/maven-scm-test/src/test/java/org/apache/maven/scm/manager/ScmManagerStubTest.java +++ b/maven-scm-test/src/test/java/org/apache/maven/scm/manager/ScmManagerStubTest.java @@ -1,5 +1,3 @@ -package org.apache.maven.scm.manager; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,6 +16,11 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.scm.manager; + +import java.io.File; +import java.util.ArrayList; +import java.util.List; import org.apache.maven.scm.provider.ScmProvider; import org.apache.maven.scm.provider.ScmProviderStub; @@ -26,10 +29,6 @@ import org.junit.Before; import org.junit.Test; -import java.io.File; -import java.util.ArrayList; -import java.util.List; - import static org.junit.Assert.assertSame; /** @@ -38,8 +37,7 @@ * @author Carlos Sanchez * */ -public class ScmManagerStubTest -{ +public class ScmManagerStubTest { private ScmManagerStub scmManagerStub; @@ -50,82 +48,68 @@ public class ScmManagerStubTest private ScmRepository scmRepository; @Before - public void setUp() - throws Exception - { - messages = new ArrayList<>( 0 ); + public void setUp() throws Exception { + messages = new ArrayList<>(0); scmProvider = new ScmProviderStub(); scmRepository = new ScmRepositoryStub(); scmManagerStub = new ScmManagerStub(); - scmManagerStub.setMessages( messages ); - scmManagerStub.setScmProvider( scmProvider ); - scmManagerStub.setScmRepository( scmRepository ); + scmManagerStub.setMessages(messages); + scmManagerStub.setScmProvider(scmProvider); + scmManagerStub.setScmRepository(scmRepository); } /* * Test method for 'org.apache.maven.scm.manager.ScmManagerStub.makeScmRepository(String)' */ @Test - public void testMakeScmRepository() - throws Exception - { - ScmRepository repository = scmManagerStub.makeScmRepository( "" ); - assertSame( scmRepository, repository ); + public void testMakeScmRepository() throws Exception { + ScmRepository repository = scmManagerStub.makeScmRepository(""); + assertSame(scmRepository, repository); } /* * Test method for 'org.apache.maven.scm.manager.ScmManagerStub.makeProviderScmRepository(String, File)' */ @Test - public void testMakeProviderScmRepository() - throws Exception - { - ScmRepository repository = scmManagerStub.makeProviderScmRepository( "", new File( "" ) ); - assertSame( scmRepository, repository ); + public void testMakeProviderScmRepository() throws Exception { + ScmRepository repository = scmManagerStub.makeProviderScmRepository("", new File("")); + assertSame(scmRepository, repository); } /* * Test method for 'org.apache.maven.scm.manager.ScmManagerStub.validateScmRepository(String)' */ @Test - public void testValidateScmRepository() - { - List list = scmManagerStub.validateScmRepository( "" ); - assertSame( messages, list ); + public void testValidateScmRepository() { + List list = scmManagerStub.validateScmRepository(""); + assertSame(messages, list); } /* * Test method for 'org.apache.maven.scm.manager.ScmManagerStub.getProviderByUrl(String)' */ @Test - public void testGetProviderByUrl() - throws Exception - { - ScmProvider providerByUrl = scmManagerStub.getProviderByUrl( "" ); - assertSame( scmProvider, providerByUrl ); + public void testGetProviderByUrl() throws Exception { + ScmProvider providerByUrl = scmManagerStub.getProviderByUrl(""); + assertSame(scmProvider, providerByUrl); } /* * Test method for 'org.apache.maven.scm.manager.ScmManagerStub.getProviderByType(String)' */ @Test - public void testGetProviderByType() - throws Exception - { - ScmProvider providerByType = scmManagerStub.getProviderByType( "" ); - assertSame( scmProvider, providerByType ); + public void testGetProviderByType() throws Exception { + ScmProvider providerByType = scmManagerStub.getProviderByType(""); + assertSame(scmProvider, providerByType); } /* * Test method for 'org.apache.maven.scm.manager.ScmManagerStub.getProviderByRepository(ScmRepository)' */ @Test - public void testGetProviderByRepository() - throws Exception - { - ScmProvider providerByRepository = scmManagerStub.getProviderByRepository( new ScmRepositoryStub() ); - assertSame( scmProvider, providerByRepository ); + public void testGetProviderByRepository() throws Exception { + ScmProvider providerByRepository = scmManagerStub.getProviderByRepository(new ScmRepositoryStub()); + assertSame(scmProvider, providerByRepository); } - } diff --git a/pom.xml b/pom.xml index c5cdb4d8d..25711c659 100644 --- a/pom.xml +++ b/pom.xml @@ -1,5 +1,4 @@ - - 4.0.0 org.apache.maven maven-parent - 36 + 39 @@ -39,6 +37,53 @@ https://maven.apache.org/scm/ 2003 + + + Petr Kozelka + + + Svend Hansen + + + Ralf Thielow + + + Mads Mohr Christensen + + + Frederic Camblor + + + Raul Wegmann + + + Darryl L. Miles + + + Ludovic Lebegue + + + Richard DiCroce + + + Thomas Meyer + + + Gary L Peskin + + + Guy Chauliac + + + Niels Basjes + + + Georg Tsakumagos + tsakumagos@gmail.com + Europe/Berlin + + + Maven Developer List @@ -103,8 +148,8 @@ scm:git:https://gitbox.apache.org/repos/asf/maven-scm.git scm:git:https://gitbox.apache.org/repos/asf/maven-scm.git - https://github.com/apache/maven-scm/tree/${project.scm.tag} maven-scm-2.0.0-M1 + https://github.com/apache/maven-scm/tree/${project.scm.tag} @@ -204,6 +249,11 @@ plexus-classworlds 2.6.0 + + org.codehaus.plexus + plexus-component-annotations + 2.1.1 + javax.inject javax.inject @@ -223,8 +273,8 @@ com.google.inject guice - no_aop 4.2.3 + no_aop org.codehaus.plexus @@ -272,6 +322,19 @@ + + + + false + + + true + + apache.snapshots + https://repository.apache.org/content/groups/snapshots-group/ + + + @@ -328,63 +391,16 @@ check-java-1.7-compat - process-classes check + process-classes - - - Petr Kozelka - - - Svend Hansen - - - Ralf Thielow - - - Mads Mohr Christensen - - - Frederic Camblor - - - Raul Wegmann - - - Darryl L. Miles - - - Ludovic Lebegue - - - Richard DiCroce - - - Thomas Meyer - - - Gary L Peskin - - - Guy Chauliac - - - Niels Basjes - - - Georg Tsakumagos - tsakumagos@gmail.com - Europe/Berlin - - - reporting @@ -447,10 +463,10 @@ aggregate - false aggregate + false @@ -467,10 +483,10 @@ aggregate - false aggregate + false @@ -496,10 +512,10 @@ aggregate - false checkstyle-aggregate + false @@ -529,9 +545,7 @@ org.apache.rat - - apache-rat-plugin - + apache-rat-plugin [0.11,) check @@ -543,12 +557,8 @@ - - org.apache.maven.plugins - - - maven-enforcer-plugin - + org.apache.maven.plugins + maven-enforcer-plugin [1.3.1,) enforce @@ -560,12 +570,8 @@ - - org.apache.maven.plugins - - - maven-remote-resources-plugin - + org.apache.maven.plugins + maven-remote-resources-plugin [1.5,) process @@ -585,17 +591,4 @@ - - - apache.snapshots - https://repository.apache.org/content/groups/snapshots-group/ - - false - - - true - - - -