本文整理汇总了Java中org.eclipse.jgit.api.errors.NoHeadException类的典型用法代码示例。如果您正苦于以下问题:Java NoHeadException类的具体用法?Java NoHeadException怎么用?Java NoHeadException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
NoHeadException类属于org.eclipse.jgit.api.errors包,在下文中一共展示了NoHeadException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getFirstCommits
import org.eclipse.jgit.api.errors.NoHeadException; //导入依赖的package包/类
private List<RevCommit> getFirstCommits(Git git, ObjectId objectId, String path, int length)
throws MissingObjectException, IncorrectObjectTypeException, NoHeadException, GitAPIException {
LogCommand command = git.log();
if (objectId != null) {
command.add(objectId);
}
if (StringUtils.isNotBlank(path)) {
command.addPath(path);
}
Iterator<RevCommit> iterator = command.setMaxCount(length).call().iterator();
List<RevCommit> list = new ArrayList<RevCommit>();
for (int i = 0; i < length; i++) {
if (iterator.hasNext()) {
list.add(iterator.next());
} else {
break;
}
}
return list;
}
示例2: main
import org.eclipse.jgit.api.errors.NoHeadException; //导入依赖的package包/类
public static void main(final String[] args) throws NoWorkTreeException,
NoHeadException, IOException, GitAPIException {
if (args.length != 4) {
System.err
.println("Usage <datafile> <prefix> <repositoryDir> <outputFilePrefix>");
System.exit(-1);
}
final SvnToGitMapper mapper = new SvnToGitMapper(args[2]);
final RepentDataParser rdp = new RepentDataParser(new File(args[0]),
mapper.mapSvnToGit(), args[1], new Predicate<Integer>() {
@Override
public boolean test(final Integer t) {
return t > 250;
}
});
final List<Renaming> renamings = rdp.parse();
final Multimap<String, Renaming> renamingsPerSha = mapRenamingsToTargetSha(renamings);
final BindingExtractor be = new BindingExtractor(args[2],
renamingsPerSha);
be.doWalk();
writeJson(args[3], "_variables.json", be.renamedVariablesDatapoints);
writeJson(args[3], "_methoddeclarations.json",
be.renamedMethodDeclarationsDatapoints);
}
示例3: main
import org.eclipse.jgit.api.errors.NoHeadException; //导入依赖的package包/类
/**
* @param args
* @throws IOException
* @throws GitAPIException
* @throws NoHeadException
* @throws NoWorkTreeException
*/
public static void main(final String[] args) throws IOException,
NoWorkTreeException, NoHeadException, GitAPIException {
if (args.length != 3) {
System.err.println("Usage <datafile> <prefix> <repositoryDir>");
System.exit(-1);
}
final SvnToGitMapper mapper = new SvnToGitMapper(args[2]);
final RepentDataParser rdp = new RepentDataParser(new File(args[0]),
mapper.mapSvnToGit(), args[1], new Predicate<Integer>() {
@Override
public boolean test(final Integer t) {
return t < 250;
}
});
final List<Renaming> renamings = rdp.parse();
for (final Renaming renaming : renamings) {
System.out.println(renaming);
}
System.out.println("Num Renamings: " + renamings.size());
}
示例4: mapSvnToGit
import org.eclipse.jgit.api.errors.NoHeadException; //导入依赖的package包/类
public BiMap<Integer, String> mapSvnToGit() throws IOException,
NoWorkTreeException, NoHeadException, GitAPIException {
final BiMap<Integer, String> mappings = HashBiMap.create();
final Git repository = GitCommitUtils
.getGitRepository(repositoryDirectory);
for (final RevCommit commit : GitCommitUtils
.getAllCommitsTopological(repository)) {
final String message = commit.getFullMessage();
if (!message.contains("git-svn-id")) {
continue;
}
final Matcher matcher = svnIdMatcher.matcher(message);
matcher.find();
mappings.put(Integer.parseInt(matcher.group(1)), commit.name());
}
return mappings;
}
示例5: getRepositoryHistory
import org.eclipse.jgit.api.errors.NoHeadException; //导入依赖的package包/类
public static List<CommitWrapper> getRepositoryHistory(Git git) throws NoHeadException, GitAPIException, MissingObjectException, IncorrectObjectTypeException, IOException {
RevWalk walk = new RevWalk(git.getRepository());
RevCommit commit = null;
List<CommitWrapper> commits = new ArrayList<>();
Iterable<RevCommit> logs = git.log().call();
Iterator<RevCommit> i = logs.iterator();
while (i.hasNext()) {
commit = walk.parseCommit( i.next());
if(null != commit ) {
CommitWrapper commitWrapper = new CommitWrapper(commit);
commits.add(commitWrapper);
}
}
return commits;
}
示例6: pullRepository
import org.eclipse.jgit.api.errors.NoHeadException; //导入依赖的package包/类
public static void pullRepository() {
try {
logger.info("Scanning devices folder for changes.");
git.add().addFilepattern(".").call();
Status status = git.status().call();
if (status.getChanged().size()>0 || status.getAdded().size()>0 || status.getModified().size()>0) {
logger.info("Changes have been found. Doing a hard reset (removing user modifications).");
ResetCommand reset = git.reset();
reset.setMode(ResetType.HARD);
reset.setRef(Constants.HEAD);
reset.call();
}
logger.info("Pulling changes from github.");
git.pull().call();
} catch (NoHeadException e) {
logger.info("Pull failed. Trying to clone repository instead");
closeRepository();
cloneRepository();
}
catch (Exception e1) {
closeRepository();
}
}
示例7: call
import org.eclipse.jgit.api.errors.NoHeadException; //导入依赖的package包/类
public Git call(final GitOperationsStep gitOperationsStep, Git git,
CredentialsProvider cp, String gitRepoUrl, File gitRepoFolder)
throws IllegalArgumentException, IOException,
ConcurrentRefUpdateException, InvalidTagNameException,
NoHeadException, GitAPIException {
TagCommand tc = git.tag().setAnnotated(annotated)
.setForceUpdate(forceUpdate).setSigned(signed);
if (!Const.isEmpty(this.message)) {
tc = tc.setMessage(gitOperationsStep
.environmentSubstitute(this.message));
}
if (!Const.isEmpty(this.name)) {
tc = tc.setName(gitOperationsStep.environmentSubstitute(this.name));
}
tc.call();
return git;
}
示例8: numCommits
import org.eclipse.jgit.api.errors.NoHeadException; //导入依赖的package包/类
public static int numCommits(final File directory,
final List<String> keywords) throws NoHeadException, IOException,
GitAPIException {
List<String> allCommitMessages = GitCommitUtils
.getAllCommitMessages(directory.getAbsolutePath());
int matchingCommits = 0;
for (final String message : allCommitMessages) {
boolean matches = false;
for (final String keyword : keywords) {
if (message.contains(keyword)) {
matches = true;
break;
}
}
matchingCommits += matches ? 1 : 0;
}
return matchingCommits;
}
示例9: getAllCommitMessages
import org.eclipse.jgit.api.errors.NoHeadException; //导入依赖的package包/类
/**
* Return a list of all commit messages.
*
* @param repositoryDir
* @return
* @throws IOException
* @throws NoHeadException
* @throws GitAPIException
*/
public static List<String> getAllCommitMessages(final String repositoryDir)
throws IOException, NoHeadException, GitAPIException {
final List<String> commitSet = Lists.newArrayList();
final Git git = getGitRepository(repositoryDir);
final RevWalk walk = new RevWalk(git.getRepository());
final Iterable<RevCommit> logs = git.log().call();
final Iterator<RevCommit> i = logs.iterator();
while (i.hasNext()) {
final RevCommit commit = walk.parseCommit(i.next());
commitSet.add(commit.getFullMessage());
}
return commitSet;
}
示例10: getCommits
import org.eclipse.jgit.api.errors.NoHeadException; //导入依赖的package包/类
/**
* Get all the commits of a repository in a set.
*
* @param repositoryDir
* the directory of the repository. Should not have trailing
* slash.
* @return
* @throws IOException
* @throws GitAPIException
* @throws NoHeadException
*/
public static List<ObjectId> getCommits(final String repositoryDir)
throws IOException, NoHeadException, GitAPIException {
final List<ObjectId> commitSet = Lists.newArrayList();
final Git git = getGitRepository(repositoryDir);
final RevWalk walk = new RevWalk(git.getRepository());
final Iterable<RevCommit> logs = git.log().call();
final Iterator<RevCommit> i = logs.iterator();
while (i.hasNext()) {
final RevCommit commit = walk.parseCommit(i.next());
commitSet.add(commit.getId());
}
return commitSet;
}
示例11: getCommitsWithTime
import org.eclipse.jgit.api.errors.NoHeadException; //导入依赖的package包/类
/**
* Return all the commits given the time.
*
* @param git
* @return
* @throws IOException
* @throws NoHeadException
* @throws GitAPIException
*/
public static SortedMap<Integer, RevCommit> getCommitsWithTime(final Git git)
throws IOException, NoHeadException, GitAPIException {
final SortedMap<Integer, RevCommit> commitsInTime = Maps.newTreeMap();
final RevWalk walk = new RevWalk(git.getRepository());
final Iterable<RevCommit> logs = git.log().call();
final Iterator<RevCommit> i = logs.iterator();
while (i.hasNext()) {
final RevCommit commit = walk.parseCommit(i.next());
commitsInTime.put(commit.getCommitTime(), commit);
}
return commitsInTime;
}
示例12: assertCommit
import org.eclipse.jgit.api.errors.NoHeadException; //导入依赖的package包/类
private void assertCommit(Path dir, String expectedSha1) throws IOException, NoHeadException, GitAPIException {
try (Git git = Git.open(dir.toFile())) {
Iterable<RevCommit> history = git.log().call();
String foundSha1 = history.iterator().next().getName();
Assert.assertEquals(String.format("Git repository in [%s] not at the expected revision", dir), expectedSha1,
foundSha1);
}
}
示例13: testCheckout
import org.eclipse.jgit.api.errors.NoHeadException; //导入依赖的package包/类
@Test
public void testCheckout() throws IOException, ScmException, NoHeadException, GitAPIException {
Path dir = targetDir.resolve("test-repo");
SrcdepsCoreUtils.ensureDirectoryExistsAndEmpty(dir);
/* first clone */
BuildRequest cloningRequest = BuildRequest.builder() //
.srcVersion(SrcVersion.parse("0.0.1-SRC-tag-0.0.1")) //
.dependentProjectRootDirectory(dir) //
.projectRootDirectory(dir) //
.scmUrl("git:https://github.com/srcdeps/srcdeps-test-artifact.git") //
.versionsMavenPluginVersion(Maven.getDefaultVersionsMavenPluginVersion()) //
.gradleModelTransformer(CharStreamSource.defaultModelTransformer()) //
.build();
JGitScm jGitScm = new JGitScm();
jGitScm.checkout(cloningRequest);
/* ensure that the tag is there through checking that it has a known commit hash */
assertCommit(dir, "19ef91ed30fd8b1a459803ee0c279dcf8e236184");
/* try if the fetch works after we have cloned already */
BuildRequest fetchingRequest = BuildRequest.builder() //
.srcVersion(SrcVersion.parse("0.0.1-SRC-revision-0a5ab902099b24c2b13ed1dad8c5f537458bcc89")) //
.dependentProjectRootDirectory(dir) //
.projectRootDirectory(dir) //
.scmUrl("git:https://github.com/srcdeps/srcdeps-test-artifact.git") //
.versionsMavenPluginVersion(Maven.getDefaultVersionsMavenPluginVersion()) //
.gradleModelTransformer(CharStreamSource.defaultModelTransformer()) //
.build();
jGitScm.fetchAndReset(fetchingRequest);
/* ensure that the WC's HEAD has the known commit hash */
assertCommit(dir, "0a5ab902099b24c2b13ed1dad8c5f537458bcc89");
}
示例14: getFileInfos
import org.eclipse.jgit.api.errors.NoHeadException; //导入依赖的package包/类
private List<FileInfo> getFileInfos(Git git, ObjectId objectId, TreeWalk treeWalk)
throws MissingObjectException, IncorrectObjectTypeException, CorruptObjectException, IOException, NoHeadException, GitAPIException {
List<FileInfo> files = new ArrayList<>();
while (treeWalk.next()) {
RevCommit commit = getFirstCommit(git, objectId, treeWalk.getPathString());
CommitInfo commitInfo = new CommitInfo(commit);
files.add(new FileInfo(treeWalk.getObjectId(0), treeWalk.isSubtree(), treeWalk.getNameString(), treeWalk.getPathString(), commitInfo));
}
return files;
}
示例15: main
import org.eclipse.jgit.api.errors.NoHeadException; //导入依赖的package包/类
/**
* @param args
* @throws GitAPIException
* @throws IOException
* @throws NoHeadException
* @throws NoWorkTreeException
*/
public static void main(final String[] args) throws NoWorkTreeException,
NoHeadException, IOException, GitAPIException {
if (args.length != 1) {
System.err.println("Usage <repository>");
System.exit(-1);
}
final SvnToGitMapper mapper = new SvnToGitMapper(args[0]);
System.out.println(mapper.mapSvnToGit());
}