001package org.apache.maven.scm.provider.git.jgit; 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.command.info.GitInfoItem; 030import org.apache.maven.scm.provider.git.jgit.command.add.JGitAddCommand; 031import org.apache.maven.scm.provider.git.jgit.command.blame.JGitBlameCommand; 032import org.apache.maven.scm.provider.git.jgit.command.branch.JGitBranchCommand; 033import org.apache.maven.scm.provider.git.jgit.command.changelog.JGitChangeLogCommand; 034import org.apache.maven.scm.provider.git.jgit.command.checkin.JGitCheckInCommand; 035import org.apache.maven.scm.provider.git.jgit.command.checkout.JGitCheckOutCommand; 036import org.apache.maven.scm.provider.git.jgit.command.diff.JGitDiffCommand; 037import org.apache.maven.scm.provider.git.jgit.command.info.JGitInfoCommand; 038import org.apache.maven.scm.provider.git.jgit.command.list.JGitListCommand; 039import org.apache.maven.scm.provider.git.jgit.command.remoteinfo.JGitRemoteInfoCommand; 040import org.apache.maven.scm.provider.git.jgit.command.status.JGitStatusCommand; 041import org.apache.maven.scm.provider.git.jgit.command.tag.JGitTagCommand; 042import org.apache.maven.scm.repository.ScmRepositoryException; 043 044/** 045 * @author <a href="mailto:struberg@yahoo.de">Mark Struberg</a> 046 * @author Dominik Bartholdi (imod) 047 * @plexus.component role="org.apache.maven.scm.provider.ScmProvider" role-hint="jgit" 048 * @since 1.9 049 */ 050public class JGitScmProvider 051 extends AbstractGitScmProvider 052{ 053 /** 054 * {@inheritDoc} 055 */ 056 protected GitCommand getAddCommand() 057 { 058 return new JGitAddCommand(); 059 } 060 061 /** 062 * {@inheritDoc} 063 */ 064 protected GitCommand getBranchCommand() 065 { 066 return new JGitBranchCommand(); 067 } 068 069 /** 070 * {@inheritDoc} 071 */ 072 protected GitCommand getChangeLogCommand() 073 { 074 return new JGitChangeLogCommand(); 075 } 076 077 /** 078 * {@inheritDoc} 079 */ 080 protected GitCommand getCheckInCommand() 081 { 082 return new JGitCheckInCommand(); 083 } 084 085 /** 086 * {@inheritDoc} 087 */ 088 protected GitCommand getCheckOutCommand() 089 { 090 return new JGitCheckOutCommand(); 091 } 092 093 /** 094 * {@inheritDoc} 095 */ 096 protected GitCommand getDiffCommand() 097 { 098 return new JGitDiffCommand(); 099 } 100 101 /** 102 * {@inheritDoc} 103 */ 104 protected GitCommand getExportCommand() 105 { 106 throw new UnsupportedOperationException( "getExportCommand" ); 107 } 108 109 /** 110 * {@inheritDoc} 111 */ 112 protected GitCommand getRemoveCommand() 113 { 114 throw new UnsupportedOperationException( "getRemoveCommand" ); 115 } 116 117 /** 118 * {@inheritDoc} 119 */ 120 protected GitCommand getStatusCommand() 121 { 122 return new JGitStatusCommand(); 123 } 124 125 /** 126 * {@inheritDoc} 127 */ 128 protected GitCommand getTagCommand() 129 { 130 return new JGitTagCommand(); 131 } 132 133 /** 134 * {@inheritDoc} 135 */ 136 protected GitCommand getUpdateCommand() 137 { 138 throw new UnsupportedOperationException( "getUpdateCommand" ); 139 } 140 141 /** 142 * {@inheritDoc} 143 */ 144 protected GitCommand getListCommand() 145 { 146 return new JGitListCommand(); 147 } 148 149 /** 150 * {@inheritDoc} 151 */ 152 public GitCommand getInfoCommand() 153 { 154 return new JGitInfoCommand(); 155 } 156 157 /** 158 * {@inheritDoc} 159 */ 160 protected String getRepositoryURL( File path ) 161 throws ScmException 162 { 163 // Note: I need to supply just 1 absolute path, but ScmFileSet won't let 164 // me without 165 // a basedir (which isn't used here anyway), so use a dummy file. 166 InfoScmResult result = info( null, new ScmFileSet( new File( "" ), path ), null ); 167 168 if ( result.getInfoItems().size() != 1 ) 169 { 170 throw new ScmRepositoryException( 171 "Cannot find URL: " + ( result.getInfoItems().size() == 0 ? "no" : "multiple" ) 172 + " items returned by the info command" ); 173 } 174 175 return ( (GitInfoItem) result.getInfoItems().get( 0 ) ).getURL(); 176 } 177 178 /** 179 * {@inheritDoc} 180 */ 181 protected GitCommand getBlameCommand() 182 { 183 return new JGitBlameCommand(); 184 } 185 186 /** 187 * {@inheritDoc} 188 */ 189 protected GitCommand getRemoteInfoCommand() 190 { 191 return new JGitRemoteInfoCommand(); 192 } 193}