• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java AbbreviatedObjectId类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: checkDiffEmpty

import org.eclipse.jgit.lib.AbbreviatedObjectId; //导入依赖的package包/类
private void checkDiffEmpty(List<DiffEntry> diffs){
    if (diffs.isEmpty()) {
        System.out.println("No diff");
    } else {
        System.out.println("Check if there are plugins to update");
        for (DiffEntry entry : diffs) {
            String editFilePath = entry.getPath(DiffEntry.Side.NEW);
            if (editFilePath.contains("neembuu-uploader-uploaders/src/neembuu/uploader/uploaders")) {
                AbbreviatedObjectId newId = entry.getNewId();
                String sha = newId.name();
                pluginsToUpdate.add(new PluginToUpdate(new File(gitDirectory, editFilePath), sha));
                System.out.println(sha + " -> " + editFilePath);
            }
        }
    }
}
 
开发者ID:Neembuu-Uploader,项目名称:neembuu-uploader,代码行数:17,代码来源:UpdaterGenerator.java


示例2: updateTodoLog

import org.eclipse.jgit.lib.AbbreviatedObjectId; //导入依赖的package包/类
public static void updateTodoLog(NotificationService notification, PullRequestKey request, Map<AbbreviatedObjectId, Commit> mappedCommits, List<RebaseTodoLine> steps) {
    for(int i = 0; i < steps.size(); i++) {
        RebaseTodoLine step = steps.get(i);
        if(!mappedCommits.containsKey(step.getCommit())) {
            notification.sendMessage(request, "Perform " + step.getCommit().toString() + " Action[remove]");
            steps.remove(i);
            i--;
            continue;
        }
        Commit commit = mappedCommits.get(step.getCommit());
        if(commit.getState() == State.DELETE) {
            notification.sendMessage(request, "Perform " + step.getCommit().toString() + " " + " Action[remove]");
            steps.remove(i);
            i--;
            continue;
        }
        try {
            step.setAction(Action.parse(commit.getState().name().toLowerCase()));
        } catch (Exception e) {
            e.printStackTrace();
        }
        notification.sendMessage(request, "Perform " + step.getCommit().toString() + " " + step.getAction());
    }
}
 
开发者ID:aslakknutsen,项目名称:github-merge,代码行数:25,代码来源:GitUtil.java


示例3: open

import org.eclipse.jgit.lib.AbbreviatedObjectId; //导入依赖的package包/类
private byte[] open(ObjectReader reader, FileMode mode,
                    AbbreviatedObjectId id) throws IOException {
    if (mode == FileMode.MISSING)
        return new byte[] { };

    if (mode.getObjectType() != Constants.OBJ_BLOB)
        return new byte[] { };

    if (!id.isComplete()) {
        Collection<ObjectId> ids = reader.resolve(id);
        if (ids.size() == 1)
            id = AbbreviatedObjectId.fromObjectId(ids.iterator().next());
        else if (ids.size() == 0)
            throw new MissingObjectException(id, Constants.OBJ_BLOB);
        else
            throw new AmbiguousObjectException(id, ids);
    }

    ObjectLoader ldr = reader.open(id.toObjectId());
    return ldr.getCachedBytes(bigFileThreshold);
}
 
开发者ID:m4rzEE1,项目名称:ninja_chic-,代码行数:22,代码来源:LineContextDiffer.java


示例4: getStart

import org.eclipse.jgit.lib.AbbreviatedObjectId; //导入依赖的package包/类
private static Optional<ObjectId> getStart(ListMultimap<String, String> params,
    ObjectReader reader) throws IOException {
  List<String> values = params.get(START_PARAM);
  switch (values.size()) {
    case 0:
      return Optional.absent();
    case 1:
      Collection<ObjectId> ids = reader.resolve(AbbreviatedObjectId.fromString(values.get(0)));
      if (ids.size() != 1) {
        return null;
      }
      return Optional.of(Iterables.getOnlyElement(ids));
    default:
      return null;
  }
}
 
开发者ID:afrojer,项目名称:gitiles,代码行数:17,代码来源:LogServlet.java


示例5: parseLines

import org.eclipse.jgit.lib.AbbreviatedObjectId; //导入依赖的package包/类
public static List<RebaseTodoLine> parseLines(List<RebaseResponse.RebaseTodoLine> lines) {
    List<RebaseTodoLine> rebaseTodoLines = new ArrayList<>();

    for (RebaseResponse.RebaseTodoLine line : lines) {
        RebaseTodoLine rebaseTodoLine = new RebaseTodoLine(
                RebaseTodoLine.Action.valueOf(line.getAction().name()),
                AbbreviatedObjectId.fromString(line.getCommit()),
                line.getShortMessage());

        rebaseTodoLines.add(rebaseTodoLine);
    }

    return rebaseTodoLines;
}
 
开发者ID:Coding,项目名称:WebIDE-Backend,代码行数:15,代码来源:RebaseTodoUtils.java


示例6: readBlob

import org.eclipse.jgit.lib.AbbreviatedObjectId; //导入依赖的package包/类
private IdentifiableResource readBlob (Repository aRepo, String aPath, String aBlobId) throws Exception {
  try (ObjectReader reader = aRepo.newObjectReader()) {
    if(aBlobId.equals(LATEST)) {
      List<IdentifiableResource> headFiles = getHeadFiles(aRepo, aPath);
      Assert.notEmpty(headFiles,"could not find: " + aPath + ":" + aBlobId);
      return headFiles.get(0);
    }
    ObjectId objectId = aRepo.resolve(aBlobId);
    Assert.notNull(objectId,"could not find: " + aPath + ":" + aBlobId);
    byte[] data = reader.open(objectId).getBytes();
    AbbreviatedObjectId abbreviated = reader.abbreviate(objectId);
    return new IdentifiableResource(aPath+":"+abbreviated.name(), new ByteArrayResource(data));
  }
}
 
开发者ID:creactiviti,项目名称:piper,代码行数:15,代码来源:JGitTemplate.java


示例7: accept

import org.eclipse.jgit.lib.AbbreviatedObjectId; //导入依赖的package包/类
@Override
public boolean accept(RevCommit cmit) {
	ObjectId id = cmit.getId();
	AbbreviatedObjectId abbreviatedId = id.abbreviate(7);
	return revStrings.contains(abbreviatedId.name())
			|| revStrings.contains(id.name());
}
 
开发者ID:link-intersystems,项目名称:GitDirStat,代码行数:8,代码来源:RevstrCommitSelection.java


示例8: resolve

import org.eclipse.jgit.lib.AbbreviatedObjectId; //导入依赖的package包/类
@Override
public Collection<ObjectId> resolve(AbbreviatedObjectId id) throws IOException {
  Set<ObjectId> result = new HashSet<>();
  for (ObjectId insId : inserted.keySet()) {
    if (id.prefixCompare(insId) == 0) {
      result.add(insId);
    }
  }
  result.addAll(reader.resolve(id));
  return result;
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:12,代码来源:InMemoryInserter.java


示例9: map

import org.eclipse.jgit.lib.AbbreviatedObjectId; //导入依赖的package包/类
public static Map<AbbreviatedObjectId, Commit> map(List<Commit> commits) {
    Map<AbbreviatedObjectId, Commit> mapped = new HashMap<>();
    for(Commit commit : commits) {
        mapped.put(AbbreviatedObjectId.fromString(commit.getId().substring(0, 7)), commit);
    }
    return mapped;
}
 
开发者ID:aslakknutsen,项目名称:github-merge,代码行数:8,代码来源:GitUtil.java


示例10: format

import org.eclipse.jgit.lib.AbbreviatedObjectId; //导入依赖的package包/类
private String format(AbbreviatedObjectId id) {
    if (id.isComplete()) {
        try {
            id = objectReader.abbreviate(id.toObjectId(), abbreviationLength);
        } catch (IOException cannotAbbreviate) {
            // Ignore this. We'll report the full identity.
        } finally {
            // reader.release();
        }
    }
    return id.name();
}
 
开发者ID:m4rzEE1,项目名称:ninja_chic-,代码行数:13,代码来源:LineContextDiffer.java


示例11: onOptionsItemSelected

import org.eclipse.jgit.lib.AbbreviatedObjectId; //导入依赖的package包/类
@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
        case android.R.id.home:
            String revision = getIntent().getStringExtra(REVISION);

            Intent intent = AbbreviatedObjectId.isId(revision)?commitViewIntentFor(getIntent().getExtras()).toIntent():branchViewerIntentFor(gitdir(), revision);
            return homewardsWith(this, intent);
    }
    return super.onOptionsItemSelected(item);
}
 
开发者ID:m4rzEE1,项目名称:ninja_chic-,代码行数:12,代码来源:BlobViewerActivity.java


示例12: testInit_gitLogApiException

import org.eclipse.jgit.lib.AbbreviatedObjectId; //导入依赖的package包/类
@Test
public void testInit_gitLogApiException()
        throws RevisionGeneratorException,
        GitAPIException, 
        IOException {
        
    String branch = "master";
    String hash = UUID.randomUUID().toString().replaceAll("-", "");
    String abbreviatedHash = hash.substring(0, 5);
    AbbreviatedObjectId abbreviatedObjectId = AbbreviatedObjectId.fromString(abbreviatedHash);
    
    Repository repo = mock(Repository.class);
    Ref headRef = mock(Ref.class);
    ObjectId headObjectId = mock(ObjectId.class);
    LogCommand logCmd = mock(LogCommand.class);
    
    GitAPIException exception = new NoHeadException("Dummy Git API Exception");

    when(git.getRepository()).thenReturn(repo);
    when(repo.isBare()).thenReturn(Boolean.FALSE);
    when(repo.getBranch()).thenReturn(branch);
    when(repo.getRef(eq("HEAD"))).thenReturn(headRef);
    when(headRef.getObjectId()).thenReturn(headObjectId);
    when(headObjectId.abbreviate(eq(5))).thenReturn(abbreviatedObjectId);
    when(git.log()).thenReturn(logCmd);
    when(logCmd.setMaxCount(1)).thenReturn(logCmd);
    when(logCmd.call()).thenThrow(exception);
    
    exceptions.expect(RevisionGeneratorException.class);
    exceptions.expectMessage("Issue getting Git CommitTime");
    exceptions.expectCause(IsInstanceOf.any(GitAPIException.class));

    try {
        item.init(git, logger);
    } finally {
        verify(git).getRepository();
        verify(git).log();
        verify(repo).isBare();
        verify(repo).getRef(eq("HEAD"));
        verify(repo).getBranch();
        verify(headRef, times(2)).getObjectId();
        verify(headObjectId).abbreviate(eq(5));
        verify(logCmd).setMaxCount(eq(1));
        verify(logCmd).call();
        verifyNoMoreInteractions(git);
        verifyNoMoreInteractions(repo);
        verifyNoMoreInteractions(headRef);
        verifyNoMoreInteractions(headObjectId);
        verifyNoMoreInteractions(logCmd);
        verifyZeroInteractions(logger);
    }
}
 
开发者ID:IG-Group,项目名称:cdversion-maven-extension,代码行数:53,代码来源:GitRevisionGeneratorTest.java


示例13: testInit_gitStatusApiException

import org.eclipse.jgit.lib.AbbreviatedObjectId; //导入依赖的package包/类
@Test
public void testInit_gitStatusApiException()
        throws RevisionGeneratorException,
        GitAPIException, 
        IOException {

    String branch = "master";
    String hash = UUID.randomUUID().toString().replaceAll("-", "")+UUID.randomUUID().toString().replaceAll("-", "").substring(0,8);
    String abbreviatedHash = hash.substring(0, 5);
    AbbreviatedObjectId abbreviatedObjectId = AbbreviatedObjectId.fromString(abbreviatedHash);
    int commitTime = (int) (System.currentTimeMillis()/1000);
    
    RevCommit headCommit = createRevCommit(hash, commitTime);
    
    
    Repository repo = mock(Repository.class);
    Ref headRef = mock(Ref.class);
    ObjectId headObjectId = mock(ObjectId.class);
    LogCommand logCmd = mock(LogCommand.class);
    StatusCommand statusCmd = mock(StatusCommand.class);
    
    GitAPIException exception = new NoHeadException("Dummy Git API Exception");

    when(git.getRepository()).thenReturn(repo);
    when(repo.isBare()).thenReturn(Boolean.FALSE);
    when(repo.getBranch()).thenReturn(branch);
    when(repo.getRef(eq("HEAD"))).thenReturn(headRef);
    when(headRef.getObjectId()).thenReturn(headObjectId);
    when(headObjectId.abbreviate(eq(5))).thenReturn(abbreviatedObjectId);
    when(git.log()).thenReturn(logCmd);
    when(logCmd.setMaxCount(1)).thenReturn(logCmd);
    when(logCmd.call()).thenReturn(Arrays.asList(headCommit));
    when(git.status()).thenReturn(statusCmd);
    when(statusCmd.call()).thenThrow(exception);
    
    exceptions.expect(RevisionGeneratorException.class);
    exceptions.expectMessage("Issue getting Git Status");
    exceptions.expectCause(IsInstanceOf.any(GitAPIException.class));

    try {
        item.init(git, logger);
    } finally {
        verify(git).getRepository();
        verify(git).log();
        verify(repo).isBare();
        verify(repo).getRef(eq("HEAD"));
        verify(repo).getBranch();
        verify(headRef, times(2)).getObjectId();
        verify(headObjectId).abbreviate(eq(5));
        verify(logCmd).setMaxCount(eq(1));
        verify(logCmd).call();
        verify(git).status();
        verify(statusCmd).call();
        verifyNoMoreInteractions(git);
        verifyNoMoreInteractions(repo);
        verifyNoMoreInteractions(headRef);
        verifyNoMoreInteractions(headObjectId);
        verifyNoMoreInteractions(logCmd);
        verifyNoMoreInteractions(statusCmd);
        verifyZeroInteractions(logger);
    }
}
 
开发者ID:IG-Group,项目名称:cdversion-maven-extension,代码行数:63,代码来源:GitRevisionGeneratorTest.java


示例14: resolve

import org.eclipse.jgit.lib.AbbreviatedObjectId; //导入依赖的package包/类
@Override
public Collection<ObjectId> resolve(AbbreviatedObjectId id)
		throws IOException {
	return delegate.resolve(id);
}
 
开发者ID:link-intersystems,项目名称:GitDirStat,代码行数:6,代码来源:IndexUpdate.java


示例15: fileName

import org.eclipse.jgit.lib.AbbreviatedObjectId; //导入依赖的package包/类
private static String fileName(RevWalk rw, RevCommit commit) throws IOException {
  AbbreviatedObjectId id = rw.getObjectReader().abbreviate(commit, 7);
  return id.name() + ".diff";
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:5,代码来源:GetPatch.java


示例16: getFileContent

import org.eclipse.jgit.lib.AbbreviatedObjectId; //导入依赖的package包/类
private Optional<FileContent> getFileContent(Git git, String path, AbbreviatedObjectId abbreviatedObjectId) {
  if (abbreviatedObjectId == null || path.equals("/dev/null")) {
    return Optional.empty();
  }
  return Optional.of(getFileContent(git, path, abbreviatedObjectId.toObjectId()));
}
 
开发者ID:kamegu,项目名称:git-webapp,代码行数:7,代码来源:GitOperation.java


示例17: shortenRevName

import org.eclipse.jgit.lib.AbbreviatedObjectId; //导入依赖的package包/类
public static String shortenRevName(String revision) {
    return AbbreviatedObjectId.isId(revision)?revision.substring(0,4):shortenRefName(revision);
}
 
开发者ID:m4rzEE1,项目名称:ninja_chic-,代码行数:4,代码来源:Repos.java


示例18: nameIsId

import org.eclipse.jgit.lib.AbbreviatedObjectId; //导入依赖的package包/类
public boolean nameIsId() {
  return AbbreviatedObjectId.isId(name)
      && (AbbreviatedObjectId.fromString(name).prefixCompare(id) == 0);
}
 
开发者ID:afrojer,项目名称:gitiles,代码行数:5,代码来源:Revision.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java RepositoryId类代码示例发布时间:2022-05-22
下一篇:
Java ProjectSdksModel类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap