use of git4idea.GitBranch in project intellij-community by JetBrains.
the class GitMerger method mergeCommit.
public void mergeCommit(@NotNull VirtualFile root) throws VcsException {
GitSimpleHandler handler = new GitSimpleHandler(myProject, root, GitCommand.COMMIT);
handler.setStdoutSuppressed(false);
File messageFile = assertNotNull(myRepositoryManager.getRepositoryForRoot(root)).getRepositoryFiles().getMergeMessageFile();
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();
}
use of git4idea.GitBranch in project intellij-community by JetBrains.
the class GitUIUtil method setupRootChooser.
/**
* Setup root chooser with specified elements and link selection to the current branch label.
*
* @param project a context project
* @param roots git roots for the project
* @param defaultRoot a default root
* @param gitRootChooser git root selector
* @param currentBranchLabel current branch label (might be null)
*/
public static void setupRootChooser(@NotNull final Project project, @NotNull final List<VirtualFile> roots, @Nullable final VirtualFile defaultRoot, @NotNull final JComboBox gitRootChooser, @Nullable final JLabel currentBranchLabel) {
for (VirtualFile root : roots) {
gitRootChooser.addItem(root);
}
gitRootChooser.setRenderer(getVirtualFileListCellRenderer());
gitRootChooser.setSelectedItem(defaultRoot != null ? defaultRoot : roots.get(0));
if (currentBranchLabel != null) {
final ActionListener listener = new ActionListener() {
public void actionPerformed(final ActionEvent e) {
VirtualFile root = (VirtualFile) gitRootChooser.getSelectedItem();
assert root != null : "The root must not be null";
GitRepository repo = GitUtil.getRepositoryManager(project).getRepositoryForRoot(root);
assert repo != null : "The repository must not be null";
GitBranch current = repo.getCurrentBranch();
if (current == null) {
currentBranchLabel.setText(NO_CURRENT_BRANCH);
} else {
currentBranchLabel.setText(current.getName());
}
}
};
listener.actionPerformed(null);
gitRootChooser.addActionListener(listener);
}
}
Aggregations