mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Add a tooltip to Git sign-off checkbox (IDEA-65721)
Display how the signature will look like if the current user information is available.
This commit is contained in:
@@ -17,6 +17,7 @@ package git4idea;
|
||||
|
||||
import com.intellij.openapi.Disposable;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.components.ServiceManager;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Condition;
|
||||
@@ -50,6 +51,10 @@ public class GitUserRegistry implements Disposable, VcsListener {
|
||||
myFactory = factory;
|
||||
}
|
||||
|
||||
public static GitUserRegistry getInstance(@NotNull Project project) {
|
||||
return ServiceManager.getService(project, GitUserRegistry.class);
|
||||
}
|
||||
|
||||
public void activate() {
|
||||
myProject.getMessageBus().connect().subscribe(ProjectLevelVcsManager.VCS_CONFIGURATION_CHANGED, this);
|
||||
directoryMappingChanged();
|
||||
|
||||
@@ -300,7 +300,7 @@ public class GitVcs extends AbstractVcs<CommittedChangeList> {
|
||||
if (myRepositoryForAnnotationsListener == null) {
|
||||
myRepositoryForAnnotationsListener = new GitRepositoryForAnnotationsListener(myProject);
|
||||
}
|
||||
ServiceManager.getService(myProject, GitUserRegistry.class).activate();
|
||||
GitUserRegistry.getInstance(myProject).activate();
|
||||
}
|
||||
|
||||
private void checkExecutableAndVersion() {
|
||||
|
||||
@@ -51,10 +51,12 @@ import com.intellij.util.textCompletion.ValuesCompletionProvider.ValuesCompletio
|
||||
import com.intellij.util.ui.GridBag;
|
||||
import com.intellij.util.ui.JBUI;
|
||||
import com.intellij.vcs.log.VcsFullCommitDetails;
|
||||
import com.intellij.vcs.log.VcsUser;
|
||||
import com.intellij.vcs.log.VcsUserRegistry;
|
||||
import com.intellij.vcs.log.util.VcsUserUtil;
|
||||
import com.intellij.vcsUtil.VcsFileUtil;
|
||||
import com.intellij.vcsUtil.VcsUtil;
|
||||
import git4idea.GitUserRegistry;
|
||||
import git4idea.GitUtil;
|
||||
import git4idea.GitVcs;
|
||||
import git4idea.branch.GitBranchUtil;
|
||||
@@ -81,6 +83,7 @@ import java.util.*;
|
||||
import java.util.List;
|
||||
|
||||
import static com.intellij.dvcs.DvcsUtil.getShortRepositoryName;
|
||||
import static com.intellij.openapi.util.text.StringUtil.escapeXml;
|
||||
import static com.intellij.openapi.vcs.changes.ChangesUtil.getAfterPath;
|
||||
import static com.intellij.openapi.vcs.changes.ChangesUtil.getBeforePath;
|
||||
import static com.intellij.util.ObjectUtils.assertNotNull;
|
||||
@@ -712,6 +715,7 @@ public class GitCheckinEnvironment implements CheckinEnvironment {
|
||||
myAmendComponent = new MyAmendComponent(project, panel);
|
||||
mySignOffCheckbox = new JBCheckBox("Sign-off commit", mySettings.shouldSignOffCommit());
|
||||
mySignOffCheckbox.setMnemonic(KeyEvent.VK_G);
|
||||
mySignOffCheckbox.setToolTipText(getToolTip(project, panel));
|
||||
|
||||
GridBag gb = new GridBag().
|
||||
setDefaultAnchor(GridBagConstraints.WEST).
|
||||
@@ -723,6 +727,14 @@ public class GitCheckinEnvironment implements CheckinEnvironment {
|
||||
myPanel.add(myAmendComponent.getComponent(), gb.nextLine().next().coverLine());
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private String getToolTip(@NotNull Project project, @NotNull CheckinProjectPanel panel) {
|
||||
VcsUser user = getFirstItem(mapNotNull(panel.getRoots(), it -> GitUserRegistry.getInstance(project).getUser(it)));
|
||||
String signature = user != null ? escapeXml(VcsUserUtil.toExactString(user)) : "";
|
||||
return "<html>Adds the following line at the end of the commit message:<br/>" +
|
||||
"Signed-off by: " + signature + "</html>";
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private List<String> getAuthors(@NotNull Project project) {
|
||||
Set<String> authors = new HashSet<>(getUsersList(project));
|
||||
|
||||
Reference in New Issue
Block a user