1from __future__ import absolute_import, division, unicode_literals
2
3from .. import cmds
4from .. import guicmds
5from ..widgets import archive
6from ..widgets import browse
7from ..widgets import compare
8from ..widgets import createbranch
9from ..widgets import createtag
10from ..widgets import dag
11from ..widgets import editremotes
12from ..widgets import finder
13from ..widgets import grep
14from ..widgets import merge
15from ..widgets import patch
16from ..widgets import recent
17from ..widgets import remote
18from ..widgets import search
19from ..widgets import stash
20
21COMMANDS = {
22    'Others::LaunchEditor': {
23        'title': 'Launch Editor',
24        'action': cmds.run(cmds.LaunchEditor),
25        'icon': 'edit',
26    },
27    'Others::RevertUnstagedEdits': {
28        'title': 'Revert Unstaged Edits...',
29        'action': cmds.run(cmds.RevertUnstagedEdits),
30        'icon': 'undo',
31    },
32    'File::NewRepo': {
33        'title': 'New Repository...',
34        'action': guicmds.open_new_repo,
35        'icon': 'new',
36    },
37    'File::OpenRepo': {
38        'title': 'Open...',
39        'action': guicmds.open_repo,
40        'icon': 'folder',
41    },
42    'File::OpenRepoNewWindow': {
43        'title': 'Open in New Window...',
44        'action': guicmds.open_repo_in_new_window,
45        'icon': 'folder',
46    },
47    # 'File::CloneRepo': {
48    #     'title': 'Clone...',
49    #     'action': guicmds.spawn_clone,
50    #     'icon': 'repo'
51    # },
52    'File::Refresh': {
53        'title': 'Refresh...',
54        'action': cmds.run(cmds.Refresh),
55        'icon': 'sync',
56    },
57    'File::FindFiles': {
58        'title': 'Find Files',
59        'action': finder.finder,
60        'icon': 'zoom_in',
61    },
62    'File::EditRemotes': {
63        'title': 'Edit Remotes...',
64        'action': editremotes.editor,
65        'icon': None,
66    },
67    'File::RecentModified': {
68        'title': 'Recently Modified Files...',
69        'action': recent.browse_recent_files,
70        'icon': None,
71    },
72    'File::ApplyPatches': {
73        'title': 'Apply Patches...',
74        'action': patch.apply_patches,
75        'icon': None,
76    },
77    'File::ExportPatches': {
78        'title': 'Export Patches...',
79        'action': guicmds.export_patches,
80        'icon': None,
81    },
82    'File::SaveAsTarZip': {
83        'title': 'Save As Tarball/Zip...',
84        'action': archive.save_archive,
85        'icon': 'file_zip',
86    },
87    # 'File::Preferences': {
88    #     'title': 'Preferences',
89    #     'action': prefs.preferences,
90    #     'icon': 'configure'
91    # },
92    'Actions::Fetch': {'title': 'Fetch...', 'action': remote.fetch, 'icon': None},
93    'Actions::Pull': {'title': 'Pull...', 'action': remote.pull, 'icon': 'pull'},
94    'Actions::Push': {'title': 'Push...', 'action': remote.push, 'icon': 'push'},
95    'Actions::Stash': {'title': 'Stash...', 'action': stash.view, 'icon': None},
96    'Actions::CreateTag': {
97        'title': 'Create Tag...',
98        'action': createtag.create_tag,
99        'icon': 'tag',
100    },
101    'Actions::CherryPick': {
102        'title': 'Cherry-Pick...',
103        'action': guicmds.cherry_pick,
104        'icon': None,
105    },
106    'Actions::Merge': {
107        'title': 'Merge...',
108        'action': merge.local_merge,
109        'icon': 'merge',
110    },
111    'Actions::AbortMerge': {
112        'title': 'Abort Merge...',
113        'action': cmds.run(cmds.AbortMerge),
114        'icon': None,
115    },
116    'Actions::UpdateSubmodules': {
117        'title': 'Update All Submodules...',
118        'action': cmds.run(cmds.SubmodulesUpdate),
119        'icon': None,
120    },
121    'Actions::ResetSoft': {
122        'title': 'Reset Branch (Soft)',
123        'action': guicmds.reset_soft,
124        'icon': 'style_dialog_reset',
125        'tooltip': cmds.ResetSoft.tooltip('<commit>'),
126    },
127    'Actions::ResetMixed': {
128        'title': 'Reset Branch and Stage (Mixed)',
129        'action': guicmds.reset_mixed,
130        'icon': 'style_dialog_reset',
131        'tooltip': cmds.ResetMixed.tooltip('<commit>'),
132    },
133    'Actions::RestoreWorktree': {
134        'title': 'Restore Worktree',
135        'action': guicmds.restore_worktree,
136        'icon': 'edit',
137        'tooltip': cmds.RestoreWorktree.tooltip('<commit>'),
138    },
139    'Actions::ResetKeep': {
140        'title': 'Restore Worktree and Reset All (Keep Unstaged Changes)',
141        'action': guicmds.reset_keep,
142        'icon': 'style_dialog_reset',
143        'tooltip': cmds.ResetKeep.tooltip('<commit>'),
144    },
145    'Actions::ResetHard': {
146        'title': 'Restore Worktre and Reset All (Hard)',
147        'action': guicmds.reset_hard,
148        'icon': 'style_dialog_reset',
149        'tooltip': cmds.ResetHard.tooltip('<commit>'),
150    },
151    'Actions::Grep': {
152        'title': 'Grep',
153        'action': grep.grep,
154        'icon': 'search',
155    },
156    'Actions::Search': {
157        'title': 'Search...',
158        'action': search.search,
159        'icon': 'search',
160    },
161    'Commit::Stage': {
162        'title': 'Stage',
163        'action': cmds.run(cmds.StageOrUnstage),
164        'icon': 'add',
165    },
166    'Commit::AmendLast': {
167        'title': 'Amend Last Commit',
168        'action': cmds.run(cmds.AmendMode),
169        'icon': 'edit',
170    },
171    'Commit::UndoLastCommit': {
172        'title': 'Undo Last Commit',
173        'action': cmds.run(cmds.UndoLastCommit),
174        'icon': 'style_dialog_discard',
175    },
176    'Commit::StageAll': {
177        'title': 'Stage All Untracked',
178        'action': cmds.run(cmds.StageUntracked),
179    },
180    'Commit::UnstageAll': {
181        'title': 'Unstage All',
182        'action': cmds.run(cmds.UnstageAll),
183        'icon': 'remove',
184    },
185    'Commit::Unstage': {
186        'title': 'Unstage',
187        'action': cmds.run(cmds.UnstageSelected),
188        'icon': 'remove',
189    },
190    'Commit::LoadCommitMessage': {
191        'title': 'Load Commit Message...',
192        'action': guicmds.load_commitmsg,
193    },
194    'Commit::GetCommitMessageTemplate': {
195        'title': 'Get Commit Message Template',
196        'action': cmds.run(cmds.LoadCommitMessageFromTemplate),
197    },
198    'Diff::Difftool': {
199        'title': 'Launch Diff tool',
200        'action': cmds.run(cmds.LaunchDifftool),
201        'icon': 'diff',
202    },
203    'Diff::Expression': {
204        'title': 'Expression...',
205        'action': guicmds.diff_expression,
206        'icon': None,
207    },
208    'Diff::Branches': {
209        'title': 'Branches...',
210        'action': compare.compare_branches,
211        'icon': None,
212    },
213    'Diff::Diffstat': {
214        'title': 'Diffstat',
215        'action': cmds.run(cmds.Diffstat),
216        'icon': None,
217    },
218    'Branch::Review': {
219        'title': 'Review...',
220        'action': guicmds.review_branch,
221        'icon': None,
222    },
223    'Branch::Create': {
224        'title': 'Create...',
225        'action': createbranch.create_new_branch,
226        'icon': None,
227    },
228    'Branch::Checkout': {
229        'title': 'Checkout...',
230        'action': guicmds.checkout_branch,
231        'icon': None,
232    },
233    'Branch::Delete': {
234        'title': 'Delete...',
235        'action': guicmds.delete_branch,
236        'icon': None,
237    },
238    'Branch::DeleteRemote': {
239        'title': 'Delete Remote Branch...',
240        'action': guicmds.delete_remote_branch,
241        'icon': None,
242    },
243    'Branch::Rename': {
244        'title': 'Rename Branch...',
245        'action': guicmds.rename_branch,
246        'icon': None,
247    },
248    'Branch::BrowseCurrent': {
249        'title': 'Browse Current Branch...',
250        'action': guicmds.browse_current,
251        'icon': None,
252    },
253    'Branch::BrowseOther': {
254        'title': 'Browse Other Branch...',
255        'action': guicmds.browse_other,
256        'icon': None,
257    },
258    'Branch::VisualizeCurrent': {
259        'title': 'Visualize Current Branch...',
260        'action': cmds.run(cmds.VisualizeCurrent),
261        'icon': None,
262    },
263    'Branch::VisualizeAll': {
264        'title': 'Visualize All Branches...',
265        'action': cmds.run(cmds.VisualizeAll),
266        'icon': None,
267    },
268    'View::FileBrowser': {
269        'title': 'File Browser...',
270        'action': browse.worktree_browser,
271        'icon': 'cola',
272    },
273    'View::DAG': {'title': 'DAG...', 'action': dag.git_dag, 'icon': 'cola'},
274}
275#     'Rebase::StartInteractive': {
276#         'title': 'Start Interactive Rebase...',
277#         'action': lambda: app().activeWindow().rebase_start(),
278#         'icon': None
279#     },
280#     'Rebase::Edit': {
281#         'title': 'Edit...',
282#         'action': lambda: cmds.rebase_edit_todo(),
283#         'icon': None
284#     },
285#     'Rebase::Continue': {
286#         'title': 'Continue',
287#         'action': lambda: cmds.rebase_continue(),
288#         'icon': None
289#     },
290#     'Rebase::SkipCurrentPatch': {
291#         'title': 'Skip Current Patch',
292#         'action': lambda: cmds.rebase_skip(),
293#         'icon': None
294#     },
295#     'Rebase::Abort': {
296#         'title': 'Abort',
297#         'action': lambda: cmds.rebase_abort(),
298#         'icon': None
299#     }
300