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