本文整理汇总了Java中org.eclipse.jgit.api.AddCommand.call方法的典型用法代码示例。如果您正苦于以下问题:Java AddCommand.call方法的具体用法?Java AddCommand.call怎么用?Java AddCommand.call使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.jgit.api.AddCommand
的用法示例。
在下文中一共展示了AddCommand.call方法的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());
}
示例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);
}
}
示例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;
}
}
示例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);
}
}
示例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");
}
}
示例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);
}
}
示例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;
}
示例8: 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);
}
}
}
示例9: 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;
}
示例10: 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);
}
示例11: 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);
}
示例12: 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);
}
}
示例13: 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);
}
}
示例14: commitAndPush
import org.eclipse.jgit.api.AddCommand; //导入方法依赖的package包/类
/**
* Adds all the files of the specified directory in the local git repository
* (git add .), then commits the changes (git commit .), and finally pushes
* the changes on the remote repository (git push)
*
* @param directory the directory in which the local git repository is located
* @param username the username to be used while pushing
* @param password the password matching with the provided username to be used
* for authentication
* @param message the commit message to be used
* @throws GitAPIException if something's going wrong while interacting with Git
* @throws IOException if something's going wrong while manipulating the local
* repository
*/
public static void commitAndPush(@NonNull File directory, String username,
String password, String message) throws GitAPIException,
IOException {
try {
final Git git = Git.open(directory);
// run the add
final AddCommand addCommand = git.add();
for (final String filePath : directory.list())
if (!".git".equals(filePath))
addCommand.addFilepattern(filePath);
addCommand.call();
log.info("Added content of the directory" + directory
+ " in the Git repository located in "
+ directory.toString());
// and then commit
final PersonIdent author = new PersonIdent(username, "");
git.commit().setCommitter(author).setMessage(message)
.setAuthor(author).call();
log.info("Commited the changes in the Git repository...");
// and finally push
final UsernamePasswordCredentialsProvider userCredential = new UsernamePasswordCredentialsProvider(
username, password);
git.push().setCredentialsProvider(userCredential).call();
log.info("Pushed the changes in remote Git repository...");
} catch (final GitAPIException e) {
log.error(e.getMessage(), e);
throw e;
}
}
示例15: addAll
import org.eclipse.jgit.api.AddCommand; //导入方法依赖的package包/类
DirCache addAll() {
try {
AddCommand addCmd = git.add().addFilepattern(".");
return addCmd.call();
} catch (GitAPIException ex) {
throw new IllegalStateException("Cannot add files", ex);
}
}