本文整理汇总了Java中org.eclipse.jgit.api.Git.wrap方法的典型用法代码示例。如果您正苦于以下问题:Java Git.wrap方法的具体用法?Java Git.wrap怎么用?Java Git.wrap使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.jgit.api.Git
的用法示例。
在下文中一共展示了Git.wrap方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: pull
import org.eclipse.jgit.api.Git; //导入方法依赖的package包/类
@SneakyThrows
protected void pull() {
try (
Repository db = createRepository();
Git git = Git.wrap(db);
) {
String branchName = gitProperties.getBranchName();
try {
git.checkout().setName(branchName).call();
git.pull().setCredentialsProvider(createCredentialsProvider()).call();
} catch (RefNotFoundException e) {
log.info("Branch {} not found in local repository", branchName);
git.fetch().setCredentialsProvider(createCredentialsProvider()).call();
git.checkout()
.setCreateBranch(true)
.setName(branchName)
.setUpstreamMode(TRACK)
.setStartPoint(DEFAULT_REMOTE_NAME + "/" + branchName).
call();
git.pull().setCredentialsProvider(createCredentialsProvider()).call();
}
}
}
示例2: initGitRepo
import org.eclipse.jgit.api.Git; //导入方法依赖的package包/类
@Before
public void initGitRepo() throws Exception {
gitWorkTree = new File(gitRepoDir.getRoot(), testName.getMethodName()).getAbsoluteFile();
final Repository gitRepo = new FileRepositoryBuilder().setWorkTree(gitWorkTree).build();
gitRepo.create();
git = Git.wrap(gitRepo);
gitUri = "git+file://" +
(gitWorkTree.getPath().startsWith(File.separator) ? "" : "/") +
gitWorkTree.getPath().replace(File.separatorChar, '/') +
"/.git";
// Start the master branch with an empty commit.
git.commit().setMessage("Initial commit").call();
}
示例3: checkoutAllBranches
import org.eclipse.jgit.api.Git; //导入方法依赖的package包/类
private void checkoutAllBranches(Repository repository) throws GitAPIException {
final Git git = Git.wrap(repository);
for (final Ref ref : git.branchList().setListMode(ListBranchCommand.ListMode.REMOTE).call()) {
final String refName = ref.getName();
final String branchName = refName.substring(refName.lastIndexOf('/') + 1);
try {
git.checkout().setCreateBranch(true).setName(branchName).setStartPoint("origin/" + branchName).call();
} catch (RefAlreadyExistsException e) {
LOGGER.warning("Already exists, so ignoring " + e.getMessage());
}
}
}
示例4: createNewFileAndPush
import org.eclipse.jgit.api.Git; //导入方法依赖的package包/类
private void createNewFileAndPush(Repository repository, String newFile, String content, String commitMessage)
throws IOException, GitAPIException {
final File root = repository.getDirectory().getParentFile();
Files.write(Paths.get(root.getPath(), newFile), content.getBytes());
final Git git = Git.wrap(repository);
git.add().addFilepattern(".").call();
git.commit().setMessage(commitMessage).call();
git.push().call();
}
示例5: commitAndPush
import org.eclipse.jgit.api.Git; //导入方法依赖的package包/类
@SneakyThrows
protected void commitAndPush(String commitMsg) {
try (
Repository db = createRepository();
Git git = Git.wrap(db);
) {
git.add().addFilepattern(".").call();
git.commit().setAll(true).setMessage(commitMsg).call();
git.push().setCredentialsProvider(createCredentialsProvider()).call();
}
}
示例6: getWorkingFileRepository
import org.eclipse.jgit.api.Git; //导入方法依赖的package包/类
private Git getWorkingFileRepository() throws GitAPIException {
// Check for existing repo
if (config.getWorkingFileRepository().getObjectDatabase().exists()) {
return Git.wrap(config.getWorkingFileRepository());
}
// Clone new repo
return config.configure(pushRepository.clone(Git.cloneRepository())).setBare(true).call();
}
示例7: git
import org.eclipse.jgit.api.Git; //导入方法依赖的package包/类
public Git git() {
return Git.wrap(getRepository());
}
示例8: setSubmodule
import org.eclipse.jgit.api.Git; //导入方法依赖的package包/类
/**
* Sets the given submodule as the current repository
*
* @param submodule
* - the name of the submodule
* @throws IOException
* @throws GitAPIException
*/
public void setSubmodule(String submodule) throws IOException {
Repository parentRepository = git.getRepository();
Repository submoduleRepository = SubmoduleWalk.getSubmoduleRepository(parentRepository, submodule);
git = Git.wrap(submoduleRepository);
fireRepositoryChanged();
}