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