001package org.apache.maven.scm.provider.git.gitexe; 002 003/* 004 * Licensed to the Apache Software Foundation (ASF) under one 005 * or more contributor license agreements. See the NOTICE file 006 * distributed with this work for additional information 007 * regarding copyright ownership. The ASF licenses this file 008 * to you under the Apache License, Version 2.0 (the 009 * "License"); you may not use this file except in compliance 010 * with the License. You may obtain a copy of the License at 011 * 012 * http://www.apache.org/licenses/LICENSE-2.0 013 * 014 * Unless required by applicable law or agreed to in writing, 015 * software distributed under the License is distributed on an 016 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 017 * KIND, either express or implied. See the License for the 018 * specific language governing permissions and limitations 019 * under the License. 020 */ 021 022import java.io.File; 023 024import org.apache.maven.scm.ScmException; 025import org.apache.maven.scm.ScmFileSet; 026import org.apache.maven.scm.command.info.InfoScmResult; 027import org.apache.maven.scm.provider.git.AbstractGitScmProvider; 028import org.apache.maven.scm.provider.git.command.GitCommand; 029import org.apache.maven.scm.provider.git.gitexe.command.add.GitAddCommand; 030import org.apache.maven.scm.provider.git.gitexe.command.blame.GitBlameCommand; 031import org.apache.maven.scm.provider.git.gitexe.command.branch.GitBranchCommand; 032import org.apache.maven.scm.provider.git.gitexe.command.changelog.GitChangeLogCommand; 033import org.apache.maven.scm.provider.git.gitexe.command.checkin.GitCheckInCommand; 034import org.apache.maven.scm.provider.git.gitexe.command.checkout.GitCheckOutCommand; 035import org.apache.maven.scm.provider.git.gitexe.command.diff.GitDiffCommand; 036import org.apache.maven.scm.provider.git.gitexe.command.info.GitInfoCommand; 037import org.apache.maven.scm.provider.git.gitexe.command.list.GitListCommand; 038import org.apache.maven.scm.provider.git.gitexe.command.remoteinfo.GitRemoteInfoCommand; 039import org.apache.maven.scm.provider.git.gitexe.command.remove.GitRemoveCommand; 040import org.apache.maven.scm.provider.git.gitexe.command.status.GitStatusCommand; 041import org.apache.maven.scm.provider.git.gitexe.command.tag.GitTagCommand; 042import org.apache.maven.scm.provider.git.gitexe.command.update.GitUpdateCommand; 043import org.apache.maven.scm.provider.git.repository.GitScmProviderRepository; 044import org.apache.maven.scm.repository.ScmRepositoryException; 045 046/** 047 * @author <a href="mailto:evenisse@apache.org">Emmanuel Venisse</a> 048 * 049 * @plexus.component role="org.apache.maven.scm.provider.ScmProvider" role-hint="git" 050 */ 051public class GitExeScmProvider 052 extends AbstractGitScmProvider 053{ 054 /** {@inheritDoc} */ 055 protected GitCommand getAddCommand() 056 { 057 return new GitAddCommand(); 058 } 059 060 /** {@inheritDoc} */ 061 protected GitCommand getBranchCommand() 062 { 063 return new GitBranchCommand(); 064 } 065 066 /** {@inheritDoc} */ 067 protected GitCommand getChangeLogCommand() 068 { 069 return new GitChangeLogCommand(); 070 } 071 072 /** {@inheritDoc} */ 073 protected GitCommand getCheckInCommand() 074 { 075 return new GitCheckInCommand(); 076 } 077 078 /** {@inheritDoc} */ 079 protected GitCommand getCheckOutCommand() 080 { 081 return new GitCheckOutCommand(); 082 } 083 084 /** {@inheritDoc} */ 085 protected GitCommand getDiffCommand() 086 { 087 return new GitDiffCommand(); 088 } 089 090 /** {@inheritDoc} */ 091 protected GitCommand getExportCommand() 092 { 093 return null; //X TODO 094 } 095 096 /** {@inheritDoc} */ 097 protected GitCommand getRemoveCommand() 098 { 099 return new GitRemoveCommand(); 100 } 101 102 /** {@inheritDoc} */ 103 protected GitCommand getStatusCommand() 104 { 105 return new GitStatusCommand(); 106 } 107 108 /** {@inheritDoc} */ 109 protected GitCommand getTagCommand() 110 { 111 return new GitTagCommand(); 112 } 113 114 /** {@inheritDoc} */ 115 protected GitCommand getUpdateCommand() 116 { 117 return new GitUpdateCommand(); 118 } 119 120 /** {@inheritDoc} */ 121 protected GitCommand getListCommand() 122 { 123 return new GitListCommand(); 124 } 125 126 /** {@inheritDoc} */ 127 public GitCommand getInfoCommand() 128 { 129 return new GitInfoCommand(); 130 } 131 132 /** {@inheritDoc} */ 133 protected GitCommand getBlameCommand() 134 { 135 return new GitBlameCommand(); 136 } 137 138 /** {@inheritDoc} */ 139 protected GitCommand getRemoteInfoCommand() 140 { 141 return new GitRemoteInfoCommand(); 142 } 143 144 /** {@inheritDoc} */ 145 protected String getRepositoryURL( File path ) 146 throws ScmException 147 { 148 // Note: I need to supply just 1 absolute path, but ScmFileSet won't let me without 149 // a basedir (which isn't used here anyway), so use a dummy file. 150 // and a dummy ScmProviderRepository 151 InfoScmResult result = info( new GitScmProviderRepository( path.getPath() ), new ScmFileSet( path ), null ); 152 153 if ( result.getInfoItems().size() != 1 ) 154 { 155 throw new ScmRepositoryException( "Cannot find URL: " 156 + ( result.getInfoItems().size() == 0 ? "no" : "multiple" ) + " items returned by the info command" ); 157 } 158 159 return result.getInfoItems().get( 0 ).getURL(); 160 } 161}