本文整理汇总了Java中git4idea.branch.GitBranchUtil.getCurrentBranch方法的典型用法代码示例。如果您正苦于以下问题:Java GitBranchUtil.getCurrentBranch方法的具体用法?Java GitBranchUtil.getCurrentBranch怎么用?Java GitBranchUtil.getCurrentBranch使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类git4idea.branch.GitBranchUtil
的用法示例。
在下文中一共展示了GitBranchUtil.getCurrentBranch方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: mergeCommit
import git4idea.branch.GitBranchUtil; //导入方法依赖的package包/类
public void mergeCommit(VirtualFile root) throws VcsException {
GitSimpleHandler handler = new GitSimpleHandler(myProject, root, GitCommand.COMMIT);
handler.setStdoutSuppressed(false);
File gitDir = new File(VfsUtilCore.virtualToIoFile(root), GitUtil.DOT_GIT);
File messageFile = new File(gitDir, GitRepositoryFiles.MERGE_MSG);
if (!messageFile.exists()) {
final GitBranch branch = GitBranchUtil.getCurrentBranch(myProject, root);
final String branchName = branch != null ? branch.getName() : "";
handler.addParameters("-m", "Merge branch '" + branchName + "' of " + root.getPresentableUrl() + " with conflicts.");
} else {
handler.addParameters("-F", messageFile.getAbsolutePath());
}
handler.endOptions();
handler.run();
}
示例2: 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);
}
}
示例3: resolveUpdateMethod
import git4idea.branch.GitBranchUtil; //导入方法依赖的package包/类
@NotNull
public static UpdateMethod resolveUpdateMethod(@NotNull Project project, @NotNull VirtualFile root) {
GitLocalBranch branch = GitBranchUtil.getCurrentBranch(project, root);
boolean rebase = false;
if (branch != null) {
try {
String rebaseValue = GitConfigUtil.getValue(project, root, "branch." + branch.getName() + ".rebase");
rebase = rebaseValue != null && rebaseValue.equalsIgnoreCase("true");
}
catch (VcsException e) {
LOG.warn("Couldn't get git config branch." + branch.getName() + ".rebase", e);
}
}
return rebase ? UpdateMethod.REBASE : UpdateMethod.MERGE;
}
示例4: 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);
}
示例5: getDefaultUpdaterForBranch
import git4idea.branch.GitBranchUtil; //导入方法依赖的package包/类
@NotNull
private static GitUpdater getDefaultUpdaterForBranch(@NotNull Project project, @NotNull Git git, @NotNull VirtualFile root,
@NotNull Map<VirtualFile, GitBranchPair> trackedBranches,
@NotNull ProgressIndicator progressIndicator, @NotNull UpdatedFiles updatedFiles) {
try {
final GitBranch branchName = GitBranchUtil.getCurrentBranch(project, root);
final String rebase = GitConfigUtil.getValue(project, root, "branch." + branchName + ".rebase");
if (rebase != null && rebase.equalsIgnoreCase("true")) {
return new GitRebaseUpdater(project, git, root, trackedBranches, progressIndicator, updatedFiles);
}
} catch (VcsException e) {
LOG.info("getDefaultUpdaterForBranch branch", e);
}
return new GitMergeUpdater(project, git, root, trackedBranches, progressIndicator, updatedFiles);
}
示例6: mergeCommit
import git4idea.branch.GitBranchUtil; //导入方法依赖的package包/类
public void mergeCommit(VirtualFile root) throws VcsException {
GitSimpleHandler handler = new GitSimpleHandler(myProject, root, GitCommand.COMMIT);
File gitDir = new File(VfsUtilCore.virtualToIoFile(root), GitUtil.DOT_GIT);
File messageFile = new File(gitDir, GitRepositoryFiles.MERGE_MSG);
if (!messageFile.exists()) {
final GitBranch branch = GitBranchUtil.getCurrentBranch(myProject, root);
final String branchName = branch != null ? branch.getName() : "";
handler.addParameters("-m", "Merge branch '" + branchName + "' of " + root.getPresentableUrl() + " with conflicts.");
} else {
handler.addParameters("-F", messageFile.getAbsolutePath());
}
handler.endOptions();
handler.run();
}
示例7: 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);
}