Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions plugin/src/main/java/consulo/git/action/ContextMenuGroup.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package consulo.git.action;

import consulo.annotation.component.ActionImpl;
import consulo.annotation.component.ActionParentRef;
import consulo.annotation.component.ActionRef;
import consulo.git.localize.GitLocalize;
import consulo.ui.ex.action.AnSeparator;
import git4idea.actions.GitMenu;

/**
* @author UNV
* @since 2025-11-09
*/
@ActionImpl(
id = "Git.ContextMenu",
children = {
@ActionRef(type = FileActionsGroup.class),
@ActionRef(type = AnSeparator.class),
@ActionRef(type = RepositoryContextMenuGroup.class)
},
parents = @ActionParentRef(@ActionRef(id = "VcsGroup"))
)
public class ContextMenuGroup extends GitMenu {
public ContextMenuGroup() {
getTemplatePresentation().setTextValue(GitLocalize.groupContextMenuText());
setPopup(true);
}
}
40 changes: 40 additions & 0 deletions plugin/src/main/java/consulo/git/action/FileActionsGroup.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package consulo.git.action;

import consulo.annotation.component.ActionImpl;
import consulo.annotation.component.ActionRef;
import consulo.application.dumb.DumbAware;
import consulo.localize.LocalizeValue;
import consulo.ui.ex.action.AnSeparator;
import consulo.ui.ex.action.DefaultActionGroup;
import git4idea.actions.GitAdd;
import git4idea.actions.GitCompareWithBranchAction;
import git4idea.actions.GitResolveConflictsAction;

/**
* @author UNV
* @since 2025-11-09
*/
@ActionImpl(
id = "Git.FileActions",
children = {
@ActionRef(id = "CheckinFiles"),
@ActionRef(type = GitAdd.class),
@ActionRef(type = AnSeparator.class),
@ActionRef(id = "Annotate"),
@ActionRef(id = "Show.Current.Revision"),
@ActionRef(id = "Compare.SameVersion"),
@ActionRef(id = "Compare.LastVersion"),
@ActionRef(id = "Compare.Selected"),
@ActionRef(type = GitCompareWithBranchAction.class),
@ActionRef(id = "Vcs.ShowTabbedFileHistory"),
@ActionRef(id = "Vcs.ShowHistoryForBlock"),
@ActionRef(type = AnSeparator.class),
@ActionRef(id = "ChangesView.Revert"),
@ActionRef(type = GitResolveConflictsAction.class)
}
)
public class FileActionsGroup extends DefaultActionGroup implements DumbAware {
public FileActionsGroup() {
super(LocalizeValue.empty(), false);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package consulo.git.action;

import consulo.annotation.component.ActionImpl;
import consulo.annotation.component.ActionRef;
import consulo.application.dumb.DumbAware;
import consulo.localize.LocalizeValue;
import consulo.ui.ex.action.AnSeparator;
import consulo.ui.ex.action.DefaultActionGroup;
import git4idea.actions.*;
import git4idea.ui.branch.GitBranchesAction;

/**
* @author UNV
* @since 2025-11-09
*/
@ActionImpl(
id = "GitRepositoryActions",
children = {
@ActionRef(type = GitBranchesAction.class),
@ActionRef(type = GitTag.class),
@ActionRef(type = GitMerge.class),
@ActionRef(type = GitStash.class),
@ActionRef(type = GitUnstash.class),
@ActionRef(type = GitResetHead.class),
@ActionRef(type = AnSeparator.class),
@ActionRef(type = GitFetch.class),
@ActionRef(type = GitPull.class),
@ActionRef(id = "Vcs.Push"),
@ActionRef(type = AnSeparator.class),
@ActionRef(type = GitRebase.class),
@ActionRef(type = GitRebaseAbort.class),
@ActionRef(type = GitRebaseContinue.class),
@ActionRef(type = GitRebaseSkip.class),
@ActionRef(type = AnSeparator.class)
}
)
public class RepositoryActionsGroup extends DefaultActionGroup implements DumbAware {
public RepositoryActionsGroup() {
super(LocalizeValue.empty(), false);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package consulo.git.action;

import consulo.annotation.component.ActionImpl;
import consulo.annotation.component.ActionRef;
import consulo.application.dumb.DumbAware;
import consulo.git.localize.GitLocalize;
import consulo.ui.ex.action.DefaultActionGroup;

/**
* @author UNV
* @since 2025-11-09
*/
@ActionImpl(
id = "Git.RepositoryContextMenu",
children = @ActionRef(type = RepositoryActionsGroup.class)
)
public class RepositoryContextMenuGroup extends DefaultActionGroup implements DumbAware {
public RepositoryContextMenuGroup() {
super(GitLocalize.groupRepositoryContextMenuText(), true);
}
}
34 changes: 34 additions & 0 deletions plugin/src/main/java/consulo/git/action/VcsMenuGroup.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package consulo.git.action;

import consulo.annotation.component.ActionImpl;
import consulo.annotation.component.ActionParentRef;
import consulo.annotation.component.ActionRef;
import consulo.annotation.component.ActionRefAnchor;
import consulo.git.localize.GitLocalize;
import consulo.ui.ex.action.AnSeparator;
import git4idea.actions.GitFileActionGroup;
import git4idea.actions.GitMenu;

/**
* @author UNV
* @since 2025-11-09
*/
@ActionImpl(
id = "Git.Menu",
children = {
@ActionRef(type = GitFileActionGroup.class),
@ActionRef(type = AnSeparator.class),
@ActionRef(type = RepositoryActionsGroup.class)
},
parents = @ActionParentRef(
value = @ActionRef(id = "VcsGlobalGroup"),
anchor = ActionRefAnchor.AFTER,
relatedToAction = @ActionRef(id = "Vcs.Specific")
)
)
public class VcsMenuGroup extends GitMenu {
public VcsMenuGroup() {
getTemplatePresentation().setTextValue(GitLocalize.groupVcsMenuText());
setPopup(true);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@
*/
package git4idea.actions;

import consulo.annotation.component.ActionImpl;
import consulo.git.localize.GitLocalize;
import consulo.localize.LocalizeValue;
import consulo.project.Project;
import consulo.util.collection.ContainerUtil;
import consulo.versionControlSystem.FilePath;
import consulo.versionControlSystem.VcsException;
import consulo.versionControlSystem.change.Change;
Expand All @@ -38,7 +40,12 @@
import java.util.Collections;
import java.util.List;

@ActionImpl(id = "Git.CompareWithBranch")
public class GitCompareWithBranchAction extends DvcsCompareWithBranchAction<GitRepository> {
public GitCompareWithBranchAction() {
getTemplatePresentation().setTextValue(GitLocalize.actionCompareWithBranchText());
}

@Override
protected boolean noBranchesToCompare(@Nonnull GitRepository repository) {
int locals = repository.getBranches().getLocalBranches().size();
Expand All @@ -61,7 +68,7 @@ protected List<String> getBranchNamesExceptCurrent(@Nonnull GitRepository reposi
localBranches.remove(repository.getCurrentBranch());
}

List<String> branchNames = ContainerUtil.newArrayList();
List<String> branchNames = new ArrayList<>();
for (GitBranch branch : localBranches) {
branchNames.add(branch.getName());
}
Expand All @@ -85,11 +92,11 @@ protected Collection<Change> getDiffChanges(
@Nonnull String branchToCompare
) throws VcsException {
FilePath filePath = VcsUtil.getFilePath(file);
final GitRepository gitRepository = GitUtil.getRepositoryManager(project).getRepositoryForFile(file);
GitRepository gitRepository = GitUtil.getRepositoryManager(project).getRepositoryForFile(file);
if (gitRepository == null) {
throw new VcsException("Couldn't find Git Repository for " + file.getName());
}
final VirtualFile gitRepositoryRoot = gitRepository.getRoot();
VirtualFile gitRepositoryRoot = gitRepository.getRoot();
GitRevisionNumber compareRevisionNumber = new GitRevisionNumber(branchToCompare);
Collection<Change> changes =
GitChangeUtils.getDiffWithWorkingDir(project, gitRepositoryRoot, branchToCompare, Collections.singletonList(filePath), false);
Expand All @@ -100,8 +107,8 @@ protected Collection<Change> getDiffChanges(
}
return changes.isEmpty() && !filePath.isDirectory()
? VcsUtil.createChangesWithCurrentContentForFile(
filePath,
GitContentRevision.createRevision(filePath, compareRevisionNumber, project, null)
) : changes;
filePath,
GitContentRevision.createRevision(filePath, compareRevisionNumber, project, null)
) : changes;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import consulo.annotation.component.ActionRef;
import consulo.application.dumb.DumbAware;
import consulo.codeEditor.Editor;
import consulo.git.action.FileActionsGroup;
import consulo.ui.ex.action.DefaultActionGroup;
import consulo.virtualFileSystem.VirtualFile;
import consulo.util.collection.JBIterable;
Expand All @@ -20,7 +21,7 @@
// from kotlin
@ActionImpl(
id = "Git.MainMenu.FileActions",
children = @ActionRef(id = "Git.FileActions")
children = @ActionRef(type = FileActionsGroup.class)
)
public class GitFileActionGroup extends DefaultActionGroup implements DumbAware {
public GitFileActionGroup() {
Expand Down
21 changes: 17 additions & 4 deletions plugin/src/main/java/git4idea/actions/GitInit.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,20 @@
*/
package git4idea.actions;

import consulo.annotation.component.ActionImpl;
import consulo.annotation.component.ActionParentRef;
import consulo.annotation.component.ActionRef;
import consulo.application.progress.ProgressIndicator;
import consulo.application.progress.Task;
import consulo.fileChooser.FileChooserDescriptor;
import consulo.fileChooser.FileChooserDescriptorFactory;
import consulo.fileChooser.IdeaFileChooser;
import consulo.git.localize.GitLocalize;
import consulo.ide.ServiceManager;
import consulo.localize.LocalizeValue;
import consulo.project.Project;
import consulo.project.ProjectManager;
import consulo.project.ui.notification.NotificationService;
import consulo.ui.annotation.RequiredUIAccess;
import consulo.ui.ex.action.AnActionEvent;
import consulo.ui.ex.action.DumbAwareAction;
Expand All @@ -45,10 +50,15 @@
/**
* Initialize git repository action
*/
@ActionImpl(id = "Git.Init", parents = @ActionParentRef(@ActionRef(id = "Vcs.Import")))
public class GitInit extends DumbAwareAction {
public GitInit() {
super(GitLocalize.actionInitText());
}

@Override
@RequiredUIAccess
public void actionPerformed(final AnActionEvent e) {
public void actionPerformed(AnActionEvent e) {
Project project = e.getData(Project.KEY);
if (project == null) {
project = ProjectManager.getInstance().getDefaultProject();
Expand All @@ -66,7 +76,7 @@ public void actionPerformed(final AnActionEvent e) {
}

@RequiredUIAccess
private static void doInit(final Project project, FileChooserDescriptor fcd, VirtualFile baseDir, final VirtualFile finalBaseDir) {
private static void doInit(final Project project, FileChooserDescriptor fcd, VirtualFile baseDir, VirtualFile finalBaseDir) {
IdeaFileChooser.chooseFile(
fcd,
project,
Expand All @@ -86,7 +96,10 @@ private static void doInit(final Project project, FileChooserDescriptor fcd, Vir
if (!result.success()) {
GitVcs vcs = GitVcs.getInstance(project);
if (vcs != null && vcs.getExecutableValidator().checkExecutableAndNotifyIfNeeded()) {
VcsNotifier.getInstance(project).notifyError("Git init failed", result.getErrorOutputAsHtmlString());
NotificationService.getInstance().newError(VcsNotifier.IMPORTANT_ERROR_NOTIFICATION)
.title(LocalizeValue.localizeTODO("Git init failed"))
.content(LocalizeValue.localizeTODO(result.getErrorOutputAsHtmlString()))
.notify(project);
}
return;
}
Expand All @@ -105,7 +118,7 @@ public void run(@Nonnull ProgressIndicator indicator) {
);
}

public static void refreshAndConfigureVcsMappings(final Project project, final VirtualFile root, final String path) {
public static void refreshAndConfigureVcsMappings(Project project, VirtualFile root, String path) {
VirtualFileUtil.markDirtyAndRefresh(false, true, false, root);
ProjectLevelVcsManager manager = ProjectLevelVcsManager.getInstance(project);
manager.setDirectoryMappings(VcsUtil.addMapping(manager.getDirectoryMappings(), path, GitVcs.NAME));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
@ActionRef(id = "Vcs.Show.Log"),
@ActionRef(type = MainMenuPatchGroup.class),
@ActionRef(type = MainMenuUncommittedChangesGroup.class),
@ActionRef(id = "Git.MainMenu.FileActions"),
@ActionRef(type = GitFileActionGroup.class),
@ActionRef(type = AnSeparator.class),
//@ActionRef(type = GitConfigureRemotesAction.class),
//@ActionRef(type = GitCloneAction.class),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ action.branches.text:
text: _Branches...
action.checkout.revision.text:
text: Checkout Revision
action.init.text:
text: Create Git Repository...
action.compare.with.branch.text:
text: Compare with Branch or Tag...
action.create.new.branch.description:
text: Create new branch starting from the selected commit
action.create.new.branch.text:
Expand Down Expand Up @@ -461,6 +465,8 @@ git4idea.vcs.name:
text: Git
group.Git.MainMenu.MergeActions.text:
text: _Merge
group.context.menu.text:
text: _Git
group.log.context.menu.text:
text: Git Log Context Menu
group.log.toolbar.text:
Expand All @@ -473,6 +479,10 @@ group.main.menu.rebase.actions.text:
text: _Rebase
group.main.menu.uncommitted.changes.text:
text: _Uncommitted Changes
group.repository.context.menu.text:
text: _Repository
group.vcs.menu.text:
text: _Git
index.file.error:
text: Updating file in the index failed
init.add.root.message:
Expand Down
Loading
Loading