本文整理了Java中org.eclipse.jgit.api.Git.getRepository()
方法的一些代码示例,展示了Git.getRepository()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Git.getRepository()
方法的具体详情如下:
包路径:org.eclipse.jgit.api.Git
类名称:Git
方法名:getRepository
[英]Get repository
[中]获取存储库
代码示例来源:origin: stackoverflow.com
Git git = new Git(localRepository);
StoredConfig config = git.getRepository().getConfig();
config.setString("remote", "origin", "url", "http://github.com/user/repo");
config.save();
代码示例来源:origin: gocd/gocd
void cleanAndResetToMaster() throws IOException {
try {
git.reset().setMode(ResetCommand.ResetType.HARD).call();
checkout("master");
deleteBranch(BRANCH_AT_REVISION);
deleteBranch(BRANCH_AT_HEAD);
} catch (Exception e) {
String currentBranch = git.getRepository().getBranch();
LOGGER.error("Error while trying to clean up config repository, CurrentBranch: {} \n : \n Message: {} \n StackTrace: {}", currentBranch, e.getMessage(), e.getStackTrace(), e);
throw new RuntimeException(e);
}
}
代码示例来源:origin: jphp-group/jphp
@Signature
public ArrayMemory getTags() {
Map<String, Ref> tags = getWrappedObject().getRepository().getTags();
ArrayMemory memory = new ArrayMemory();
for (Map.Entry<String, Ref> entry : tags.entrySet()) {
memory.put(entry.getKey(), GitUtils.valueOf(entry.getValue()));
}
return memory;
}
代码示例来源:origin: jphp-group/jphp
@Signature
public void init(boolean bare) throws IOException {
getWrappedObject().getRepository().create(bare);
}
代码示例来源:origin: jphp-group/jphp
@Signature
public String getBranch() throws IOException {
return getWrappedObject().getRepository().getBranch();
}
代码示例来源:origin: jphp-group/jphp
@Signature
public RepositoryState getState() {
return getWrappedObject().getRepository().getRepositoryState();
}
代码示例来源:origin: jphp-group/jphp
@Signature
public String getFullBranch() throws IOException {
return getWrappedObject().getRepository().getFullBranch();
}
代码示例来源:origin: jphp-group/jphp
@Signature
public File getDirectory() {
return getWrappedObject().getRepository().getDirectory();
}
代码示例来源:origin: jphp-group/jphp
@Signature
public String getRemoteName(String name) {
return getWrappedObject().getRepository().getRemoteName(name);
}
代码示例来源:origin: jphp-group/jphp
@Signature
public boolean isBare() {
return getWrappedObject().getRepository().isBare();
}
代码示例来源:origin: jphp-group/jphp
@Signature
public File getWorkTree() throws IOException {
return getWrappedObject().getRepository().getWorkTree();
}
代码示例来源:origin: spring-cloud/spring-cloud-config
private boolean isClean(Git git, String label) {
StatusCommand status = git.status();
try {
BranchTrackingStatus trackingStatus = BranchTrackingStatus.of(git.getRepository(), label);
boolean isBranchAhead = trackingStatus != null && trackingStatus.getAheadCount() > 0;
return status.call().isClean() && !isBranchAhead;
}
catch (Exception e) {
String message = "Could not execute status command on local repository. Cause: ("
+ e.getClass().getSimpleName() + ") " + e.getMessage();
warn(message, e);
return false;
}
}
代码示例来源:origin: jphp-group/jphp
@Signature
public Memory findRef(String name) throws IOException {
Ref ref = getWrappedObject().getRepository().findRef(name);
return ref == null ? Memory.NULL : GitUtils.valueOf(ref);
}
代码示例来源:origin: jphp-group/jphp
@Signature
public Memory exactRef(String name) throws IOException {
Ref ref = getWrappedObject().getRepository().exactRef(name);
return ref == null ? Memory.NULL : GitUtils.valueOf(ref);
}
代码示例来源:origin: jphp-group/jphp
@Signature
public boolean isExists() throws IOException {
return getWrappedObject().getRepository().getObjectDatabase().exists();
}
代码示例来源:origin: jphp-group/jphp
@Signature
public Memory resolve(String revstr) throws IOException {
return GitUtils.valueOf(getWrappedObject().getRepository().resolve(revstr));
}
代码示例来源:origin: gocd/gocd
@Test
public void shouldSwitchToMasterAndDeleteTempBranches() throws Exception, GitAPIException {
configRepo.checkin(goConfigRevision("v1", "md5-1"));
configRepo.createBranch(ConfigRepository.BRANCH_AT_HEAD, configRepo.getCurrentRevCommit());
configRepo.createBranch(ConfigRepository.BRANCH_AT_REVISION, configRepo.getCurrentRevCommit());
configRepo.git().checkout().setName(ConfigRepository.BRANCH_AT_REVISION).call();
assertThat(configRepo.git().getRepository().getBranch(), is(ConfigRepository.BRANCH_AT_REVISION));
assertThat(configRepo.git().branchList().call().size(), is(3));
configRepo.cleanAndResetToMaster();
assertThat(configRepo.git().getRepository().getBranch(), is("master"));
assertThat(configRepo.git().branchList().call().size(), is(1));
}
代码示例来源:origin: gocd/gocd
@Test
public void shouldCleanAndResetToMasterDuringInitialization() throws Exception {
configRepo.checkin(goConfigRevision("v1", "md5-1"));
configRepo.createBranch(ConfigRepository.BRANCH_AT_REVISION, configRepo.getCurrentRevCommit());
configRepo.git().checkout().setName(ConfigRepository.BRANCH_AT_REVISION).call();
assertThat(configRepo.git().getRepository().getBranch(), is(ConfigRepository.BRANCH_AT_REVISION));
new ConfigRepository(systemEnvironment).initialize();
assertThat(configRepo.git().getRepository().getBranch(), is("master"));
assertThat(configRepo.git().branchList().call().size(), is(1));
}
代码示例来源:origin: jphp-group/jphp
@Signature
public Memory resolveCommit(String revstr) throws IOException, GitAPIException {
ObjectId objectId = getWrappedObject().getRepository().resolve(revstr);
if (objectId == null) {
return Memory.NULL;
}
LogCommand command = getWrappedObject()
.log()
.add(objectId)
.setMaxCount(1);
Iterable<RevCommit> call = command.call();
for (RevCommit revCommit : call) {
return GitUtils.valueOf(revCommit);
}
return Memory.NULL;
}
代码示例来源:origin: gocd/gocd
@Test
public void shouldCleanAndResetToMasterOnceMergeFlowIsComplete() throws Exception {
String original = "first\nsecond\n";
String changeOnBranch = "first\nsecond\nthird\n";
String changeOnMaster = "1st\nsecond\n";
String oldMd5 = "md5-1";
configRepo.checkin(goConfigRevision(original, oldMd5));
configRepo.checkin(goConfigRevision(changeOnMaster, "md5-2"));
configRepo.getConfigMergedWithLatestRevision(goConfigRevision(changeOnBranch, "md5-3"), oldMd5);
assertThat(configRepo.git().getRepository().getBranch(), is("master"));
assertThat(configRepo.git().branchList().call().size(), is(1));
}
内容来源于网络,如有侵权,请联系作者删除!