当前位置: 首页>>代码示例>>Java>>正文


Java Git.close方法代码示例

本文整理汇总了Java中org.eclipse.jgit.api.Git.close方法的典型用法代码示例。如果您正苦于以下问题:Java Git.close方法的具体用法?Java Git.close怎么用?Java Git.close使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.eclipse.jgit.api.Git的用法示例。


在下文中一共展示了Git.close方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: invoke

import org.eclipse.jgit.api.Git; //导入方法依赖的package包/类
@Override
public Boolean invoke(File file, VirtualChannel channel){
    try{
        Git git = Git.cloneRepository()
                .setURI(url)
                .setDirectory(localDir)
                .setTransportConfigCallback(getTransportConfigCallback())
                .setCredentialsProvider(new UsernamePasswordCredentialsProvider(username, password))
                .call();

        // Default branch to checkout is master
        if(branch==null || branch.isEmpty()){
            branch = "master";
        } else if (cloneType.equals("branch")){
            branch = "origin" + File.separator + branch;
        }
        git.checkout().setName(branch).call();
        git.close();
        }catch(GitAPIException e){
            status = false;
            e.printStackTrace(listener.getLogger());
        }
    return status;
}
 
开发者ID:warriorframework,项目名称:warrior-jenkins-plugin,代码行数:25,代码来源:WarriorPluginBuilder.java

示例2: testPull

import org.eclipse.jgit.api.Git; //导入方法依赖的package包/类
@Test
public void testPull() throws Exception {
  // source: db2, target: db
  setupRemote();
  Git git2 = new Git( db2 );

  // put some file in the source repo and sync
  File sourceFile = new File( db2.getWorkTree(), "SomeFile.txt" );
  FileUtils.writeStringToFile( sourceFile, "Hello world" );
  git2.add().addFilepattern( "SomeFile.txt" ).call();
  git2.commit().setMessage( "Initial commit for source" ).call();
  PullResult pullResult = git.pull().call();

  // change the source file
  FileUtils.writeStringToFile( sourceFile, "Another change" );
  git2.add().addFilepattern( "SomeFile.txt" ).call();
  git2.commit().setMessage( "Some change in remote" ).call();
  git2.close();

  assertTrue( uiGit.pull() );
}
 
开发者ID:HiromuHota,项目名称:pdi-git-plugin,代码行数:22,代码来源:UIGitTest.java

示例3: clone

import org.eclipse.jgit.api.Git; //导入方法依赖的package包/类
/**
 * Cloning the remote git repo to local directory
 * @param remoteUri remote git url e.g. git://gitli.example.com/project/repo.git
 * @param localDir local destination clone directory
 * @throws IOException
 * @throws GitAPIException
 */
public static void clone(String remoteUri, String localDir) throws IOException, GitAPIException {
  //create local git directory
  File localGitRepo = new File(localDir);
  if (localGitRepo.exists()) {
    if (localGitRepo.isDirectory()) {
      // clean up directory
      FileUtils.cleanDirectory(localGitRepo);
    } else {
      throw new IOException("File exists: " + localDir);
    }
  } else {
    localGitRepo.mkdirs();
  }

  Git g = Git.cloneRepository().setURI(remoteUri).setDirectory(localGitRepo).call();
  g.close();
}
 
开发者ID:thomas-young-2013,项目名称:wherehowsX,代码行数:25,代码来源:GitUtil.java

示例4: cloneProject

import org.eclipse.jgit.api.Git; //导入方法依赖的package包/类
/**
 * Clones the project
 * @param projectUri - URI of the project
 * @return file where the project was cloned
 */
File cloneProject(URI projectUri) {
	try {
		log.info("Cloning repo from [{}] to [{}]", projectUri, this.basedir);
		Git git = cloneToBasedir(projectUri, this.basedir);
		if (git != null) {
			git.close();
		}
		File clonedRepo = git.getRepository().getWorkTree();
		log.info("Cloned repo to [{}]", clonedRepo);
		return clonedRepo;
	}
	catch (Exception e) {
		throw new IllegalStateException("Exception occurred while cloning repo", e);
	}
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-release-tools,代码行数:21,代码来源:GitRepo.java

示例5: checkoutBranch

import org.eclipse.jgit.api.Git; //导入方法依赖的package包/类
private Ref checkoutBranch(File projectDir, String branch)
		throws GitAPIException {
	Git git = this.gitFactory.open(projectDir);
	CheckoutCommand command = git.checkout().setName(branch);
	try {
		if (shouldTrack(git, branch)) {
			trackBranch(command, branch);
		}
		return command.call();
	}
	catch (GitAPIException e) {
		deleteBaseDirIfExists();
		throw e;
	} finally {
		git.close();
	}
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-release-tools,代码行数:18,代码来源:GitRepo.java

示例6: cloneRepo

import org.eclipse.jgit.api.Git; //导入方法依赖的package包/类
public boolean cloneRepo( String directory, String uri ) {
  CloneCommand cmd = Git.cloneRepository();
  cmd.setDirectory( new File( directory ) );
  cmd.setURI( uri );
  cmd.setCredentialsProvider( credentialsProvider );
  try {
    Git git = cmd.call();
    git.close();
    return true;
  } catch ( Exception e ) {
    if ( ( e instanceof TransportException )
        && ( ( e.getMessage().contains( "Authentication is required but no CredentialsProvider has been registered" )
          || e.getMessage().contains( "not authorized" ) ) ) ) {
      if ( promptUsernamePassword() ) {
        return cloneRepo( directory, uri );
      }
    } else {
      showMessageBox( BaseMessages.getString( PKG, "Dialog.Error" ), e.getMessage() );
    }
  }
  return false;
}
 
开发者ID:HiromuHota,项目名称:pdi-git-plugin,代码行数:23,代码来源:UIGit.java

示例7: init

import org.eclipse.jgit.api.Git; //导入方法依赖的package包/类
@Override
public void init(MavenSession session, Logger logger) throws RevisionGeneratorException {
    Git git = null;
    try {
        if (session.getExecutionRootDirectory() == null) {
            revision = "1.0-SNAPSHOT";
            dirty = true;
        } else {
            File gitDir = new FileRepositoryBuilder()
                    .findGitDir(new F‌ile(session.getExecutionRootDirectory()))
                    .getGitDir();
            if (gitDir != null && gitDir.exists()) {
                git = Git.open(gitDir);
                init(git, logger);
            } else {
                revision = "1.0-SNAPSHOT";
                dirty = true;
            }
        }
    } catch (IOException ex) {
        throw new RevisionGeneratorException("Issue opening Git repository for the project", ex);
    } finally {
        if (git != null) {
            git.close();
        }
    }
}
 
开发者ID:IG-Group,项目名称:cdversion-maven-extension,代码行数:28,代码来源:GitRevisionGenerator.java

示例8: getRepoMetadata

import org.eclipse.jgit.api.Git; //导入方法依赖的package包/类
/**
 * Fetch all commit metadata from the repo
 * @param repoDir repository directory
 * @return list of commit metadata
 * @throws IOException
 * @throws GitAPIException
 */
public static List<CommitMetadata> getRepoMetadata(String repoDir) throws IOException, GitAPIException {

  List<CommitMetadata> metadataList = new ArrayList<>();

  FileRepositoryBuilder builder = new FileRepositoryBuilder();
  Repository repository = builder.setGitDir(new File(repoDir, ".git")).readEnvironment().findGitDir().build();

  // Current branch may not be master. Instead of hard coding determine the current branch
  String currentBranch = repository.getBranch();
  Ref head = repository.getRef("refs/heads/" + currentBranch); // current branch may not be "master"
  if (head == null) {
    return metadataList;
  }

  Git git = new Git(repository);

  RevWalk walk = new RevWalk(repository);
  RevCommit commit = walk.parseCommit(head.getObjectId());

  TreeWalk treeWalk = new TreeWalk(repository);
  treeWalk.addTree(commit.getTree());
  treeWalk.setRecursive(true);
  while (treeWalk.next()) {
    String filePath = treeWalk.getPathString();
    Iterable<RevCommit> commitLog = git.log().add(repository.resolve(Constants.HEAD)).addPath(filePath).call();
    for (RevCommit r : commitLog) {
      CommitMetadata metadata = new CommitMetadata(r.getName());
      metadata.setFilePath(filePath);
      metadata.setFileName(FilenameUtils.getName(filePath));
      metadata.setMessage(r.getShortMessage().trim());
      // Difference between committer and author
      // refer to: http://git-scm.com/book/ch2-3.html
      PersonIdent committer = r.getCommitterIdent();
      PersonIdent author = r.getAuthorIdent();
      metadata.setAuthor(author.getName());
      metadata.setAuthorEmail(author.getEmailAddress());
      metadata.setCommitter(committer.getName());
      metadata.setCommitterEmail(committer.getEmailAddress());
      metadata.setCommitTime(committer.getWhen());
      metadataList.add(metadata);
    }
  }
  git.close();
  return metadataList;
}
 
开发者ID:thomas-young-2013,项目名称:wherehowsX,代码行数:53,代码来源:GitUtil.java


注:本文中的org.eclipse.jgit.api.Git.close方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。