Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Add icons to menus #157

Draft
wants to merge 1 commit into
base: develop
Choose a base branch
from
Draft
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
16 changes: 8 additions & 8 deletions src/commands/branchingCommands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,23 @@ import ViewUtils from '../utils/viewUtils';
import ShowRefsView from '../views/showRefsView';

const branchingCommands = [
{ label: 'b', description: 'Checkout', action: checkout },
{ label: 'l', description: 'Checkout local branch', action: checkoutLocal },
{ label: 'c', description: 'Checkout new branch', action: checkoutNewBranch },
{ label: 'b', icon: 'git-branch', description: 'Checkout', action: checkout },
{ label: 'l', icon: 'device-desktop', description: 'Checkout local branch', action: checkoutLocal },
{ label: 'c', icon: 'git-branch-create', description: 'Checkout new branch', action: checkoutNewBranch },
// { label: "w", description: "Checkout new worktree", action: checkout },
// { label: "y", description: "Checkout pull-request", action: checkout },
// { label: "s", description: "Create new spin-off", action: createNewSpinoff },
{ label: 'n', description: 'Create new branch', action: createNewBranch },
{ label: 'n', icon: 'git-branch-create', description: 'Create new branch', action: createNewBranch },
// { label: "W", description: "Create new worktree", action: checkout },
// { label: "Y", description: "Create from pull-request", action: checkout },
// { label: 'C', description: 'Configure', action: configureBranch },
{ label: 'm', description: 'Rename', action: renameBranch },
{ label: 'x', description: 'Reset', action: resetBranch },
{ label: 'k', description: 'Delete', action: deleteBranch },
{ label: 'm', icon: 'edit', description: 'Rename', action: renameBranch },
{ label: 'x', icon: 'discard', description: 'Reset', action: resetBranch },
{ label: 'k', icon: 'trash', description: 'Delete', action: deleteBranch },
];

const forgeBranchingCommands = [
{ label: 'y', description: 'Checkout pull request', action: checkoutPullRequest },
{ label: 'y', icon: 'git-pull-request', description: 'Checkout pull request', action: checkoutPullRequest },
];

export async function branching(repository: MagitRepository) {
Expand Down
7 changes: 4 additions & 3 deletions src/commands/cherryPickingCommands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,14 @@ import * as CommitCommands from '../commands/commitCommands';
const whileCherryPickingMenu = {
title: 'Cherry-picking',
commands: [
{ label: 'A', description: 'Continue', action: continueCherryPick },
{ label: 's', description: 'Skip', action: (state: MenuState) => cherryPickControlCommand(state, '--skip') },
{ label: 'a', description: 'Abort', action: (state: MenuState) => cherryPickControlCommand(state, '--abort') }
{ label: 'A', icon: 'debug-continue', description: 'Continue', action: continueCherryPick },
{ label: 's', icon: 'debug-step-over', description: 'Skip', action: (state: MenuState) => cherryPickControlCommand(state, '--skip') },
{ label: 'a', icon: 'debug-stop', description: 'Abort', action: (state: MenuState) => cherryPickControlCommand(state, '--abort') }
]
};

const cherryPickingMenu = {
// FIXME find icons?
title: 'Cherry-picking',
commands: [
{ label: 'A', description: 'Pick', action: pick },
Expand Down
18 changes: 9 additions & 9 deletions src/commands/commitCommands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,21 @@ import { magitConfig } from '../extension';
const commitMenu = {
title: 'Committing',
commands: [
{ label: 'c', description: 'Commit', action: commit },
{ label: 'a', description: 'Amend', action: (menuState: MenuState) => ammendCommit(menuState, ['--amend']) },
{ label: 'e', description: 'Extend', action: (menuState: MenuState) => ammendCommit(menuState, ['--amend', '--no-edit']) },
{ label: 'w', description: 'Reword', action: (menuState: MenuState) => rewordCommit(menuState, ['--amend', '--only']) },
{ label: 'f', description: 'Fixup', action: (menuState: MenuState) => fixup(menuState) },
{ label: 'F', description: 'Instant Fixup', action: (menuState: MenuState) => instantFixup(menuState) },
{ label: 'c', description: 'Commit', icon: 'git-commit', action: commit },
{ label: 'a', description: 'Amend', icon: 'discard', action: (menuState: MenuState) => ammendCommit(menuState, ['--amend']) },
{ label: 'e', description: 'Extend', icon: 'zap', action: (menuState: MenuState) => ammendCommit(menuState, ['--amend', '--no-edit']) },
{ label: 'w', description: 'Reword', icon: 'edit', action: (menuState: MenuState) => rewordCommit(menuState, ['--amend', '--only']) },
{ label: 'f', description: 'Fixup', icon: 'fold-up', action: (menuState: MenuState) => fixup(menuState) },
{ label: 'F', description: 'Instant Fixup', icon: 'rocket', action: (menuState: MenuState) => instantFixup(menuState) },
]
};

export async function magitCommit(repository: MagitRepository) {

const switches = [
{ key: '-a', name: '--all', description: 'Stage all modified and deleted files' },
{ key: '-e', name: '--allow-empty', description: 'Allow empty commit' },
{ key: '-s', name: '--signoff', description: 'Add Signed-off-by line' },
{ key: '-a', name: '--all', icon: 'files', description: 'Stage all modified and deleted files' },
{ key: '-e', name: '--allow-empty', icon: 'circle-large-outline', description: 'Allow empty commit' },
{ key: '-s', name: '--signoff', icon: 'law', description: 'Add Signed-off-by line' },
];

return MenuUtil.showMenu(commitMenu, { repository, switches });
Expand Down
14 changes: 7 additions & 7 deletions src/commands/diffingCommands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ import ViewUtils from '../utils/viewUtils';
const diffingMenu = {
title: 'Diffing',
commands: [
{ label: 'r', description: 'Diff range', action: diffRange },
{ label: 'p', description: 'Diff paths', action: diffPaths },
{ label: 'u', description: 'Diff unstaged', action: diffUnstaged },
{ label: 's', description: 'Diff staged', action: diffStaged },
{ label: 'w', description: 'Diff worktree', action: diffWorktree },
{ label: 'c', description: 'Show commit', action: showCommit },
{ label: 't', description: 'Show stash', action: showStash },
{ label: 'r', description: 'Diff range', icon: 'git-commit', action: diffRange },
{ label: 'p', description: 'Diff paths', icon: 'file', action: diffPaths },
{ label: 'u', description: 'Diff unstaged', icon: 'remove', action: diffUnstaged },
{ label: 's', description: 'Diff staged', icon: 'add', action: diffStaged },
{ label: 'w', description: 'Diff worktree', icon: 'list-tree', action: diffWorktree },
{ label: 'c', description: 'Show commit', icon: 'eye', action: showCommit },
{ label: 't', description: 'Show stash', icon: 'package', action: showStash },
]
};

Expand Down
16 changes: 8 additions & 8 deletions src/commands/fetchingCommands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,26 +10,26 @@ export async function fetching(repository: MagitRepository): Promise<any> {

if (repository.HEAD?.pushRemote) {
const pushRemote = repository.HEAD?.pushRemote;
fetchingMenuItems.push({ label: 'p', description: pushRemote.remote, action: fetchFromPushRemote });
fetchingMenuItems.push({ label: 'p', description: pushRemote.remote, icon: 'repo', action: fetchFromPushRemote });
}

if (repository.HEAD?.upstream) {
const upstream = repository.HEAD?.upstream;
fetchingMenuItems.push({ label: 'u', description: upstream.remote, action: fetchFromUpstream });
fetchingMenuItems.push({ label: 'u', description: upstream.remote, icon: 'repo-pull', action: fetchFromUpstream });
}

fetchingMenuItems.push({ label: 'e', description: 'elsewhere', action: fetchFromElsewhere });
fetchingMenuItems.push({ label: 'e', description: 'elsewhere', icon: 'repo-clone', action: fetchFromElsewhere });

fetchingMenuItems.push({ label: 'a', description: 'all remotes', action: fetchAll });
fetchingMenuItems.push({ label: 'a', description: 'all remotes', icon: 'list-flat', action: fetchAll });

fetchingMenuItems.push({ label: 'o', description: 'another branch', action: fetchAnotherBranch });
fetchingMenuItems.push({ label: 'o', description: 'another branch', icon: 'git-branch', action: fetchAnotherBranch });

if (repository.submodules.length) {
fetchingMenuItems.push({ label: 's', description: 'submodules', action: fetchSubmodules });
fetchingMenuItems.push({ label: 's', description: 'submodules', icon: 'file-submodule', action: fetchSubmodules });
}

const switches: Switch[] = [
{ key: '-p', name: '--prune', description: 'Prune deleted branches' }
{ key: '-p', name: '--prune', description: 'Prune deleted branches', icon: 'trash' }
];

return MenuUtil.showMenu({ title: 'Fetching', commands: fetchingMenuItems }, { repository, switches });
Expand Down Expand Up @@ -83,4 +83,4 @@ export async function fetchSubmodules({ repository, switches }: MenuState) {

const args = ['fetch', '--verbose', '--recurse-submodules', ...MenuUtil.switchesToArgs(switches)];
return gitRun(repository.gitRepository, args);
}
}
12 changes: 6 additions & 6 deletions src/commands/filePopupCommands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,21 @@ import * as Diffing from './diffingCommands';
const filePopupMenu = {
title: 'File Actions',
commands: [
{ label: 's', description: 'Stage', action: ({ repository, data }: MenuState) => Staging.stageFile(repository, data as Uri) },
{ label: 'u', description: 'Unstage', action: ({ repository, data }: MenuState) => Staging.unstageFile(repository, data as Uri) },
{ label: 'c', description: 'Commit', action: ({ repository }: MenuState) => Commit.magitCommit(repository) },
{ label: 's', description: 'Stage', icon: 'add', action: ({ repository, data }: MenuState) => Staging.stageFile(repository, data as Uri) },
{ label: 'u', description: 'Unstage', icon: 'remove', action: ({ repository, data }: MenuState) => Staging.unstageFile(repository, data as Uri) },
{ label: 'c', description: 'Commit', icon: 'git-commit', action: ({ repository }: MenuState) => Commit.magitCommit(repository) },
// { label: 'D', description: 'Diff...', action: () => { } },
{ label: 'd', description: 'Diff', action: ({ repository, data }: MenuState) => Diffing.diffFile(repository, data as Uri) },
{ label: 'd', description: 'Diff', icon: 'diff', action: ({ repository, data }: MenuState) => Diffing.diffFile(repository, data as Uri) },
// { label: 'L', description: 'Log...', action: () => { } },
// { label: 'l', description: 'log', action: ({ repository, data }: MenuState) => logFile(repository, data as Uri) },
// { label: 't', description: 'trace', action: () => { } },
// { label: 'B', description: 'Blame...', action: () => { } },
{ label: 'b', description: 'Blame', action: ({ repository, data }: MenuState) => Blaming.blameFile(repository, data as Uri) },
{ label: 'b', description: 'Blame', icon: 'person', action: ({ repository, data }: MenuState) => Blaming.blameFile(repository, data as Uri) },
// { label: 'n', description: 'prev blob', action: () => { } },
// { label: 'n', description: 'next blob', action: () => { } }
]
};

export async function filePopup(repository: MagitRepository, fileUri: Uri) {
return MenuUtil.showMenu(filePopupMenu, { repository, data: fileUri });
}
}
6 changes: 3 additions & 3 deletions src/commands/ignoringCommands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import * as Constants from '../common/constants';
const ignoringMenu = {
title: 'Ignoring',
commands: [
{ label: 'l', description: 'Ignore locally', action: ({ repository }: MenuState) => ignore(repository) },
{ label: 'g', description: 'Ignore globally (add to .gitignore)', action: ({ repository }: MenuState) => ignore(repository, true) }
{ label: 'l', description: 'Ignore locally', icon: 'device-desktop', action: ({ repository }: MenuState) => ignore(repository) },
{ label: 'g', description: 'Ignore globally (add to .gitignore)', icon: 'repo', action: ({ repository }: MenuState) => ignore(repository, true) }
]
};

Expand Down Expand Up @@ -58,4 +58,4 @@ async function ignore(repository: MagitRepository, globally = false) {
});
});
}
}
}
14 changes: 7 additions & 7 deletions src/commands/loggingCommands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ import LogView from '../views/logView';
const loggingMenu = {
title: 'Logging',
commands: [
{ label: 'l', description: 'Log current', action: wrap(logCurrent) },
{ label: 'o', description: 'Log other', action: wrap(logOther) },
{ label: 'h', description: 'Log HEAD', action: wrap(logHead) },
{ label: 'L', description: 'Log local branches', action: wrap(logLocalBranches) },
{ label: 'b', description: 'Log branches', action: wrap(logBranches) },
{ label: 'a', description: 'Log references', action: wrap(logReferences) },
{ label: 'l', description: 'Log current', icon: 'git-commit', action: wrap(logCurrent) },
{ label: 'o', description: 'Log other', icon: 'git-branch', action: wrap(logOther) },
{ label: 'h', description: 'Log HEAD', icon: 'git-compare', action: wrap(logHead) },
{ label: 'L', description: 'Log local branches', icon: 'device-desktop', action: wrap(logLocalBranches) },
{ label: 'b', description: 'Log branches', icon: 'repo-forked', action: wrap(logBranches) },
{ label: 'a', description: 'Log references', icon: 'references', action: wrap(logReferences) },
]
};

Expand Down Expand Up @@ -164,4 +164,4 @@ function parseLog(stdout: string): MagitLogEntry[] {
}
});
return commits;
}
}
12 changes: 6 additions & 6 deletions src/commands/mergingCommands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ import MagitUtils from '../utils/magitUtils';
const mergingMenu = {
title: 'Merging',
commands: [
{ label: 'm', description: 'Merge', action: merge },
{ label: 'e', description: 'Merge and edit message', action: (state: MenuState) => merge(state, false, false, true) },
{ label: 'n', description: 'Merge, don\'t commit', action: (state: MenuState) => merge(state, true, false, false) },
{ label: 'a', description: 'Absorb', action: absorb },
{ label: 'm', icon: 'git-merge', description: 'Merge', action: merge },
{ label: 'e', icon: 'edit', description: 'Merge and edit message', action: (state: MenuState) => merge(state, false, false, true) },
{ label: 'n', icon: 'git-pull-request', description: 'Merge, don\'t commit', action: (state: MenuState) => merge(state, true, false, false) },
{ label: 'a', icon: 'filter', description: 'Absorb', action: absorb },
// { label: 'p', description: 'Preview Merge', action: mergePreview },
{ label: 's', description: 'Squash Merge', action: (state: MenuState) => merge(state, false, true, false) },
{ label: 's', icon: 'gather', description: 'Squash Merge', action: (state: MenuState) => merge(state, false, true, false) },
// { label: 'i', description: 'Merge into', action: mergeInto },
]
};
Expand Down Expand Up @@ -116,4 +116,4 @@ async function abortMerge({ repository }: MenuState) {
const args = ['merge', '--abort'];
return gitRun(repository.gitRepository, args);
}
}
}
8 changes: 4 additions & 4 deletions src/commands/pullingCommands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ function generatePullingMenu(repository: MagitRepository) {

if (repository.HEAD?.pushRemote) {
const pushRemote = repository.HEAD?.pushRemote;
pullingMenuItems.push({ label: 'p', description: `${pushRemote.remote}/${pushRemote.name}`, action: pullFromPushRemote });
pullingMenuItems.push({ label: 'p', description: `${pushRemote.remote}/${pushRemote.name}`, icon: 'repo', action: pullFromPushRemote });
}

if (repository.HEAD?.upstream) {
const upstream = repository.HEAD?.upstream;
pullingMenuItems.push({ label: 'u', description: `${upstream.remote}/${upstream.name}`, action: pullFromUpstream });
pullingMenuItems.push({ label: 'u', description: `${upstream.remote}/${upstream.name}`, icon: 'repo-pull', action: pullFromUpstream });
}

pullingMenuItems.push({ label: 'e', description: 'elsewhere', action: pullFromElsewhere });
pullingMenuItems.push({ label: 'e', description: 'elsewhere', icon: 'repo-clone', action: pullFromElsewhere });
return { title: 'Pulling', commands: pullingMenuItems };
}

Expand Down Expand Up @@ -58,4 +58,4 @@ async function pullFromElsewhere({ repository, switches }: MenuState) {
const args = ['pull', ...MenuUtil.switchesToArgs(switches), remote, branch];
return gitRun(repository.gitRepository, args);
}
}
}
26 changes: 13 additions & 13 deletions src/commands/pushingCommands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,33 +13,33 @@ function generatePushingMenu(repository: MagitRepository) {

if (repository.HEAD?.pushRemote) {
const pushRemote = repository.HEAD?.pushRemote;
pushingMenuItems.push({ label: 'p', description: `${pushRemote.remote}/${pushRemote.name}`, action: pushToPushRemote });
pushingMenuItems.push({ label: 'p', icon: 'repo', description: `${pushRemote.remote}/${pushRemote.name}`, action: pushToPushRemote });
} else {
pushingMenuItems.push({ label: 'p', description: `pushRemote, after setting that`, action: pushSetPushRemote });
pushingMenuItems.push({ label: 'p', icon: 'repo', description: `pushRemote, after setting that`, action: pushSetPushRemote });
}

if (repository.HEAD?.upstream) {
const upstream = repository.HEAD?.upstream;
pushingMenuItems.push({ label: 'u', description: `${upstream.remote}/${upstream.name}`, action: pushUpstream });
pushingMenuItems.push({ label: 'u', icon: 'repo-pull', description: `${upstream.remote}/${upstream.name}`, action: pushUpstream });
} else {
pushingMenuItems.push({ label: 'u', description: `@{upstream}, after setting that`, action: pushSetUpstream });
pushingMenuItems.push({ label: 'u', icon: 'repo-pull', description: `@{upstream}, after setting that`, action: pushSetUpstream });
}

pushingMenuItems.push({ label: 'e', description: 'elsewhere', action: pushElsewhere });
pushingMenuItems.push({ label: 'o', description: 'another branch/commit', action: pushOther });
pushingMenuItems.push({ label: 'T', description: 'a tag', action: pushTag });
pushingMenuItems.push({ label: 't', description: 'all tags', action: pushAllTags });
pushingMenuItems.push({ label: 'e', description: 'elsewhere', icon: 'repo-clone', action: pushElsewhere });
pushingMenuItems.push({ label: 'o', description: 'another branch/commit', icon: 'git-commit', action: pushOther });
pushingMenuItems.push({ label: 'T', description: 'a tag', icon: 'tag', action: pushTag });
pushingMenuItems.push({ label: 't', description: 'all tags', icon: 'tag', action: pushAllTags });

return { title: 'Pushing', commands: pushingMenuItems };
}

export async function pushing(repository: MagitRepository) {

const switches = [
{ key: '-f', name: '--force-with-lease', description: 'Force with lease' },
{ key: '-F', name: '--force', description: 'Force' },
{ key: '-h', name: '--no-verify', description: 'Disable hooks' },
{ key: '-d', name: '--dry-run', description: 'Dry run' }
{ key: '-f', name: '--force-with-lease', description: 'Force with lease', 'icon': 'repo-force-push' },
{ key: '-F', name: '--force', description: 'Force', 'icon': 'repo-force-push' },
{ key: '-h', name: '--no-verify', description: 'Disable hooks', 'icon': 'eye-closed' },
{ key: '-d', name: '--dry-run', description: 'Dry run', 'icon': 'discard' }
];

return MenuUtil.showMenu(generatePushingMenu(repository), { repository, switches });
Expand Down Expand Up @@ -166,4 +166,4 @@ async function pushAllTags({ repository, switches }: MenuState) {
const args = ['push', ...MenuUtil.switchesToArgs(switches), remote, '--tags'];
return gitRun(repository.gitRepository, args);
}
}
}
Loading