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


Java AddCommand类代码示例

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


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

示例1: makeVersion

import org.eclipse.jgit.api.AddCommand; //导入依赖的package包/类
@Override
public VersionInfo makeVersion(FileVersion... fileVersions) throws IOException {
  persistence.makeVersion(fileVersions);
  Repository repository = getRepository(fileVersions[0].getFile());
  Git git = new Git(repository);
  try {
    AddCommand adder = git.add();
    for (FileVersion fileVersion : fileVersions) {
      adder.addFilepattern(getPath(fileVersion.getFile(), repository));
    }
    adder.call();
    commit(git, String.format("[FitNesse] Updated files: %s.", formatFileVersions(fileVersions)), fileVersions[0].getAuthor());
  } catch (GitAPIException e) {
    throw new IOException("Unable to commit changes", e);
  }
  return VersionInfo.makeVersionInfo(fileVersions[0].getAuthor(), fileVersions[0].getLastModificationTime());
}
 
开发者ID:fitnesse,项目名称:fitnesse-git-plugin,代码行数:18,代码来源:GitFileVersionsController.java

示例2: addFiles

import org.eclipse.jgit.api.AddCommand; //导入依赖的package包/类
/**
 * Adds the files returned from {@link #filePatternGetter} and then calls {@link #updateFiles(List)}
 */
public final void addFiles() {
    try {
        AddCommand addCmd = git.getOrThrow().add();
        // insure add command will add newly staged files
        addCmd.setUpdate(false);

        // add files
        List<String> files = filePatternGetter.get();
        files.forEach(addCmd::addFilepattern);

        addCmd.call();

        updateFiles(files);
    } catch (GitAPIException e) {
        handleGitAPIException(e);
    }
}
 
开发者ID:JordanMartinez,项目名称:JGitFX,代码行数:21,代码来源:AddMenuItem.java

示例3: addAndCommitSelectedFiles

import org.eclipse.jgit.api.AddCommand; //导入依赖的package包/类
/**
 * Adds the files that were selected and commits them. Note: the {@link AddCommand}
 * and {@link CommitCommand} are used in this method. {@link AddCommand#setWorkingTreeIterator(WorkingTreeIterator)}
 * can be configured fia {@link #setWorkingTreeIterator(WorkingTreeIterator)} before calling this method,
 * and the {@code CommitCommand} can be configured via {@link #configureCommitCommand(CommitCommand)}.
 * @return the result of {@link #createResult(DirCache, RevCommit, List)} or null if
 *         a {@link GitAPIException} is thrown.
 */
protected final R addAndCommitSelectedFiles() {
    List<String> selectedFiles = getDialogPane().getSelectedFiles();
    try {
        AddCommand add = getGitOrThrow().add();
        selectedFiles.forEach(add::addFilepattern);
        workingTreeIterator.ifPresent(add::setWorkingTreeIterator);
        DirCache cache = add.call();

        CommitCommand commit = getGitOrThrow().commit();
        configureCommitCommand(commit);
        RevCommit revCommit = commit.call();

        return createResult(cache, revCommit, selectedFiles);
    } catch (GitAPIException e) {
        handleGitAPIException(e);
        return null;
    }
}
 
开发者ID:JordanMartinez,项目名称:JGitFX,代码行数:27,代码来源:CommitDialogBase.java

示例4: add

import org.eclipse.jgit.api.AddCommand; //导入依赖的package包/类
@Override
public void add(AddParams params) throws GitException {
  AddCommand addCommand = getGit().add().setUpdate(params.isUpdate());

  List<String> filePatterns = params.getFilePattern();
  if (filePatterns.isEmpty()) {
    filePatterns = AddRequest.DEFAULT_PATTERN;
  }
  filePatterns.forEach(addCommand::addFilepattern);

  try {
    addCommand.call();

    addDeletedFilesToIndexIfNeeded(filePatterns);
  } catch (GitAPIException exception) {
    throw new GitException(exception.getMessage(), exception);
  }
}
 
开发者ID:eclipse,项目名称:che,代码行数:19,代码来源:JGitConnection.java

示例5: update

import org.eclipse.jgit.api.AddCommand; //导入依赖的package包/类
/**
 * Adds all of the files in the directory to the git repository, commits the changes, and pushes to the remote.
 *
 * @param commitMessage to use in commit
 * @throws MojoExecutionException if the files cannot be added, commited, or pushed
 */
public void update(String commitMessage) throws MojoExecutionException {
    log.info("Adding directory contents to git");
    AddCommand add = git.add();
    if (forEachPath(workingDir, add::addFilepattern)) {
        try {
            add.call();
            git.commit().setMessage(commitMessage).call();
            log.info("Pushing changes to remote branch \"" + branch + "\" at : \"" + uri + "\"");
            git.push().call();
        } catch (GitAPIException e) {
            throw new MojoExecutionException("Could not commit and push changes", e);
        }
    } else {
        log.warn("Nothing to add");
    }
}
 
开发者ID:windy1,项目名称:ghp-maven-plugin,代码行数:23,代码来源:GitHubPages.java

示例6: commit

import org.eclipse.jgit.api.AddCommand; //导入依赖的package包/类
public void commit(File repo, List<String> fileUpdates) {
    if (fileUpdates.isEmpty()) {
        return;
    }

    try {
        Git gitHandle = Git.open(repo);
        AddCommand addCommand = gitHandle.add();
        for (String fileUpdate : fileUpdates) {
            addCommand = addCommand.addFilepattern(fileUpdate);
            LOG.info("git add'ing {}", fileUpdate);

        }
        DirCache addResult = addCommand.call();
        RevCommit commitResult = gitHandle.commit().setCommitter("dev search agent", "[email protected]").setMessage("Automated change performed by dev-search-agent").call();

        LOG.info("git commit'd: {}", commitResult.toString());
    } catch (GitAPIException | IOException e) {
        throw new RuntimeException("Problem pushing " + repo.getPath(), e);
    }
}
 
开发者ID:raymyers,项目名称:dev-search,代码行数:22,代码来源:GitService.java

示例7: createGitRepoWithPom

import org.eclipse.jgit.api.AddCommand; //导入依赖的package包/类
public static String createGitRepoWithPom(final File path, final InputStream pom, final File... files) throws Exception {
    File repo = new File(path, "repo");
    if(repo.exists() == false) {
        Files.createDirectory(repo.toPath());
    }
    Git git = Git.init().setDirectory(repo).call();
    String gitUrl = "file://" + repo.getAbsolutePath();

    FileUtils.copyInputStreamToFile(pom, new File(repo, "pom.xml"));
    AddCommand add = git.add();
    add.addFilepattern("pom.xml");
    for (File f : files) {
        add.addFilepattern(f.getName());
    }
    add.call();
    CommitCommand commit = git.commit();
    commit.setMessage("initial commit").call();
    return gitUrl;
}
 
开发者ID:kiegroup,项目名称:kie-wb-common,代码行数:20,代码来源:MavenTestUtils.java

示例8: addAllAndCommit

import org.eclipse.jgit.api.AddCommand; //导入依赖的package包/类
static void addAllAndCommit(Git git, UserProfile user, String commitMsg) throws GitAPIException {
    AddCommand addCommand = git.add()
        .addFilepattern(".")
        .addFilepattern("application.json");

    CommitCommand commitCmd = git.commit();

    if (user != null && user.name() != null && user.email() != null) {
        commitCmd.setCommitter(user.name(), user.email());
    }
    if (commitMsg != null) {
        commitCmd.setMessage(commitMsg);
    }

    GitHandler.commit(() -> {
        addCommand.call();
        return commitCmd.call();
    });
}
 
开发者ID:liveoak-io,项目名称:liveoak,代码行数:20,代码来源:GitHelper.java

示例9: addAll

import org.eclipse.jgit.api.AddCommand; //导入依赖的package包/类
/**
 * Adds multiple files to the staging area. Preparing the for commit
 * 
 * @param fileNames
 *          - the names of the files to be added
 */
public void addAll(List<FileStatus> files) {

	try {
	  
	  RmCommand removeCmd = null;
	  AddCommand addCmd = null;
	  
		for (FileStatus file : files) {
			if (file.getChangeType() == GitChangeType.MISSING) {
			  if (removeCmd == null) {
			    removeCmd = git.rm();
			  }
         removeCmd.addFilepattern(file.getFileLocation());
			} else {
			  if (addCmd == null) {
			    addCmd = git.add();
			  }
         addCmd.addFilepattern(file.getFileLocation());
			}
		}
		
		if (removeCmd != null) {
		  removeCmd.call();
		}
		
		if (addCmd != null) {
		  addCmd.call();
		}
		
		fireFileStateChanged(new ChangeEvent(GitCommand.STAGE, getPaths(files)));
	} catch (GitAPIException e) {
		if (logger.isDebugEnabled()) {
			logger.debug(e, e);
		}
	}
}
 
开发者ID:oxygenxml,项目名称:oxygen-git-plugin,代码行数:43,代码来源:GitAccess.java

示例10: commit

import org.eclipse.jgit.api.AddCommand; //导入依赖的package包/类
/**
 * Creates a commit in the repo, by modifying the given file.
 * The git commitID will be stored in the scenario in front of the given app identifier. 
 * @param fileName the filename to be touched, added and commited into the repo.
 * @param id the application identifier to use to store the git commitID in front of
 * @return the builder itself to continue building the scenario
 */
public ScenarioBuilder commit(String fileName, String id) {
    File content = new File(scenario.getRepositoryLocation(), fileName);
    try {
        AddCommand add = git.add().addFilepattern(fileName);
        Files.touch(content);
        add.call();
        RevCommit rc = git.commit().setMessage("content " + id).call();
        scenario.getCommits().put(id, rc.getId());
    } catch (Exception ex) {
        throw new IllegalStateException(String.format("error creating a commit with new file %s", content), ex);
    }
    return this;
}
 
开发者ID:jgitver,项目名称:jgitver,代码行数:21,代码来源:Scenarios.java

示例11: doCreateDirectory

import org.eclipse.jgit.api.AddCommand; //导入依赖的package包/类
protected CommitInfo doCreateDirectory(Git git, String path) throws Exception {
    File file = getRelativeFile(path);
    if (file.exists()) {
        return null;
    }
    file.mkdirs();
    String filePattern = getFilePattern(path);
    AddCommand add = git.add().addFilepattern(filePattern).addFilepattern(".");
    add.call();

    CommitCommand commit = git.commit().setAll(true).setAuthor(personIdent).setMessage(message);
    RevCommit revCommit = commitThenPush(git, commit);
    return createCommitInfo(revCommit);
}
 
开发者ID:fabric8io,项目名称:fabric8-forge,代码行数:15,代码来源:RepositoryResource.java

示例12: doWrite

import org.eclipse.jgit.api.AddCommand; //导入依赖的package包/类
protected CommitInfo doWrite(Git git, String path, byte[] contents, PersonIdent personIdent, String commitMessage) throws Exception {
    File file = getRelativeFile(path);
    file.getParentFile().mkdirs();

    Files.writeToFile(file, contents);

    String filePattern = getFilePattern(path);
    AddCommand add = git.add().addFilepattern(filePattern).addFilepattern(".");
    add.call();

    CommitCommand commit = git.commit().setAll(true).setAuthor(personIdent).setMessage(commitMessage);
    RevCommit revCommit = commitThenPush(git, commit);
    return createCommitInfo(revCommit);
}
 
开发者ID:fabric8io,项目名称:fabric8-forge,代码行数:15,代码来源:RepositoryResource.java

示例13: add

import org.eclipse.jgit.api.AddCommand; //导入依赖的package包/类
@Override
public void add(String itemToAdd) {
    
    AddCommand command = _git.add();
    command.addFilepattern(itemToAdd);
    try {
        command.call();
    } catch (Throwable e) {
        throw new RuntimeException(String.format("Failed to add  [%s]", itemToAdd), e);
    }
    
}
 
开发者ID:Verigreen,项目名称:verigreen,代码行数:13,代码来源:JGitOperator.java

示例14: dumpConfiguration

import org.eclipse.jgit.api.AddCommand; //导入依赖的package包/类
public void dumpConfiguration(Configuration config, Entry e) throws Exception {
	Preconditions.checkNotNull(config, "Configuration must be supplied.");
	Preconditions.checkNotNull(e, "Entry must be supplied.");
	AddCommand add = git.add();
	CommitCommand commit = git.commit();
	try {
		//Dump Zookeeper
		String instanceId = config.getConnector().getInstance().getInstanceID();
		String zkPath = Constants.ZROOT + "/" + instanceId;
		File zkDump = new File(gitDir, ZK_DUMP_FILE);
		LOG.debug("Dump ZooKeeper configuration at {} to {}", zkPath, zkDump);
		FileOutputStream out = new FileOutputStream(zkDump);
		DumpZookeeper.run(out, zkPath);
		out.close();
		//Dump the configuration
		LOG.debug("Dumping Accumulo configuration to {}", gitDir);
		DumpConfigCommand command = new DumpConfigCommand();
		command.allConfiguration = true;
		command.directory = gitDir.getAbsolutePath();
		Instance instance = config.getConnector().getInstance();
		String principal = config.getUsername();
		PasswordToken token = new PasswordToken(config.getPassword().getBytes());
		Admin.printConfig(instance, principal, token, command);
		//Add, commit, and tag
		add.addFilepattern(".").call();
		commit.setMessage("Backup " + e.getUUID().toString()).call();
		git.tag().setName(e.getUUID().toString()).call();
		LOG.debug("Git tag {} created.", e.getUUID());
		//Should we remove all of the files from the existing git workspace?
	} catch (Exception ex) {
		LOG.error("Error saving configuration", ex);
		git.reset().setMode(ResetType.HARD).setRef("HEAD").call();
		throw ex;
	}
}
 
开发者ID:dlmarion,项目名称:raccovery,代码行数:36,代码来源:AccumuloConfigurations.java

示例15: addFiles

import org.eclipse.jgit.api.AddCommand; //导入依赖的package包/类
/**
 * @see gov.va.isaac.interfaces.sync.ProfileSyncI#addFiles(java.io.File, java.util.Set)
 */
@Override
public void addFiles(String... files) throws IllegalArgumentException, IOException
{
	try
	{
		log.info("Add Files called {}", Arrays.toString(files));
		Git git = getGit();
		if (files.length == 0)
		{
			log.debug("No files to add");
		}
		else
		{
			AddCommand ac = git.add();
			for (String file : files)
			{
				ac.addFilepattern(file);
			}
			ac.call();
		}
		log.info("addFiles Complete.  Current status: " + statusToString(git.status().call()));
	}
	catch (GitAPIException e)
	{
		log.error("Unexpected", e);
		throw new IOException("Internal error", e);
	}
}
 
开发者ID:Apelon-VA,项目名称:ISAAC,代码行数:32,代码来源:SyncServiceGIT.java


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