本文整理汇总了Java中git4idea.branch.GitBranchUtil.tracked方法的典型用法代码示例。如果您正苦于以下问题:Java GitBranchUtil.tracked方法的具体用法?Java GitBranchUtil.tracked怎么用?Java GitBranchUtil.tracked使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类git4idea.branch.GitBranchUtil
的用法示例。
在下文中一共展示了GitBranchUtil.tracked方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: GitBranchesSearcher
import git4idea.branch.GitBranchUtil; //导入方法依赖的package包/类
public GitBranchesSearcher(final Project project, final VirtualFile root, final boolean findRemote) throws VcsException {
LOG.debug("constructing, root: " + root.getPath() + " findRemote = " + findRemote);
final Set<GitBranch> usedBranches = new HashSet<GitBranch>();
myLocal = GitBranchUtil.getCurrentBranch(project, root);
LOG.debug("local: " + myLocal);
if (myLocal == null) return;
usedBranches.add(myLocal);
GitBranch remote = myLocal;
while (true) {
remote = GitBranchUtil.tracked(project, root, remote.getName());
if (remote == null) {
LOG.debug("remote == null, exiting");
return;
}
if ((! findRemote) || remote.isRemote()) {
LOG.debug("remote found, isRemote: " + remote.isRemote() + " remoteName: " + remote.getFullName());
myRemote = remote;
return;
}
if (usedBranches.contains(remote)) {
LOG.debug("loop found for: " + remote.getFullName() + ", exiting");
return;
}
usedBranches.add(remote);
}
}
示例2: getLastRevision
import git4idea.branch.GitBranchUtil; //导入方法依赖的package包/类
/**
* Get current revision for the file under git
*
* @param project a project
* @param filePath a file path
* @return a revision number or null if the file is unversioned or new
* @throws VcsException if there is problem with running git
*/
@Nullable
public static ItemLatestState getLastRevision(final Project project, FilePath filePath) throws VcsException {
VirtualFile root = GitUtil.getGitRoot(filePath);
GitBranch c = GitBranchUtil.getCurrentBranch(project, root);
GitBranch t = c == null ? null : GitBranchUtil.tracked(project, root, c.getName());
if (t == null) {
return new ItemLatestState(getCurrentRevision(project, filePath, null), true, false);
}
filePath = getLastCommitName(project, filePath);
GitSimpleHandler h = new GitSimpleHandler(project, root, GitCommand.LOG);
GitLogParser parser = new GitLogParser(project, GitLogParser.NameStatus.STATUS, HASH, COMMIT_TIME, PARENTS);
h.setSilent(true);
h.addParameters("-n1", parser.getPretty(), "--name-status", t.getFullName());
h.endOptions();
h.addRelativePaths(filePath);
String result = h.run();
if (result.length() == 0) {
return null;
}
GitLogRecord record = parser.parseOneRecord(result);
if (record == null) {
return null;
}
final List<Change> changes = record.parseChanges(project, root);
boolean exists = changes.isEmpty() || !FileStatus.DELETED.equals(changes.get(0).getFileStatus());
record.setUsedHandler(h);
return new ItemLatestState(new GitRevisionNumber(record.getHash(), record.getDate()), exists, false);
}
示例3: getLastRevision
import git4idea.branch.GitBranchUtil; //导入方法依赖的package包/类
/**
* Get current revision for the file under git
*
* @param project a project
* @param filePath a file path
* @return a revision number or null if the file is unversioned or new
* @throws VcsException if there is problem with running git
*/
@Nullable
public static ItemLatestState getLastRevision(final Project project, FilePath filePath) throws VcsException {
VirtualFile root = GitUtil.getGitRoot(filePath);
GitBranch c = GitBranchUtil.getCurrentBranch(project, root);
GitBranch t = c == null ? null : GitBranchUtil.tracked(project, root, c.getName());
if (t == null) {
return new ItemLatestState(getCurrentRevision(project, filePath, null), true, false);
}
filePath = getLastCommitName(project, filePath);
GitSimpleHandler h = new GitSimpleHandler(project, root, GitCommand.LOG);
GitLogParser parser = new GitLogParser(project, GitLogParser.NameStatus.STATUS, HASH, COMMIT_TIME, SHORT_PARENTS);
h.setSilent(true);
h.addParameters("-n1", parser.getPretty(), "--name-status", t.getFullName());
h.endOptions();
h.addRelativePaths(filePath);
String result = h.run();
if (result.length() == 0) {
return null;
}
GitLogRecord record = parser.parseOneRecord(result);
if (record == null) {
return null;
}
final List<Change> changes = record.parseChanges(project, root);
boolean exists = changes.isEmpty() || !FileStatus.DELETED.equals(changes.get(0).getFileStatus());
record.setUsedHandler(h);
return new ItemLatestState(new GitRevisionNumber(record.getHash(), record.getDate()), exists, false);
}