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
6 changes: 6 additions & 0 deletions src/command/Commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -568,6 +568,12 @@ define(function (require, exports, module) {
/** Toggles display of untracked files */
exports.CMD_GIT_TOGGLE_UNTRACKED = "git-toggle-untracked";

/** Toggles global history view in history panel */
exports.CMD_GIT_HISTORY_GLOBAL = "git-history-global";

/** Toggles file history view in history panel */
exports.CMD_GIT_HISTORY_FILE = "git-history-file";

// DEPRECATED: Working Set Commands
DeprecationWarning.deprecateConstant(exports, "SORT_WORKINGSET_BY_ADDED", "CMD_WORKINGSET_SORT_BY_ADDED");
DeprecationWarning.deprecateConstant(exports, "SORT_WORKINGSET_BY_NAME", "CMD_WORKINGSET_SORT_BY_NAME");
Expand Down
2 changes: 2 additions & 0 deletions src/extensions/default/Git/src/Constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,6 @@ define(function (require, exports) {
exports.CMD_GIT_AUTHORS_OF_SELECTION = Commands.CMD_GIT_AUTHORS_OF_SELECTION;
exports.CMD_GIT_AUTHORS_OF_FILE = Commands.CMD_GIT_AUTHORS_OF_FILE;
exports.CMD_GIT_TOGGLE_UNTRACKED = Commands.CMD_GIT_TOGGLE_UNTRACKED;
exports.CMD_GIT_HISTORY_GLOBAL = Commands.CMD_GIT_HISTORY_GLOBAL;
exports.CMD_GIT_HISTORY_FILE = Commands.CMD_GIT_HISTORY_FILE;
});
20 changes: 16 additions & 4 deletions src/extensions/default/Git/src/Main.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ define(function (require, exports) {
const CMD_ADD_TO_IGNORE = "git.addToIgnore",
CMD_REMOVE_FROM_IGNORE = "git.removeFromIgnore",
$icon = $(`<a id='git-toolbar-icon' title="${Strings.STATUSBAR_SHOW_GIT}" href='#'></a>`)
.addClass("forced-hidden")
.prependTo($(".bottom-buttons"));
.addClass("forced-hidden")
.prependTo($(".bottom-buttons"));

let gitEnabled = false;

Expand Down Expand Up @@ -160,7 +160,7 @@ define(function (require, exports) {
const displayStr = StringUtils.format(Strings.RESET_DETAIL, commitDetailStr, gitCmdUsed);
Utils.askQuestion(title,
message + "<br><br>" + displayStr,
{ booleanResponse: true, noescape: true ,
{ booleanResponse: true, noescape: true,
customOkBtn: Strings.RESET, customOkBtnClass: "danger"})
.then(function (response) {
if (response === true) {
Expand Down Expand Up @@ -228,7 +228,10 @@ define(function (require, exports) {
// "More options" context menu commands
Constants.CMD_GIT_DISCARD_ALL_CHANGES,
Constants.CMD_GIT_UNDO_LAST_COMMIT,
Constants.CMD_GIT_TOGGLE_UNTRACKED
Constants.CMD_GIT_TOGGLE_UNTRACKED,

Constants.CMD_GIT_HISTORY_GLOBAL,
Constants.CMD_GIT_HISTORY_FILE
];

// Disable each command
Expand Down Expand Up @@ -257,6 +260,9 @@ define(function (require, exports) {
gitSubMenu.addMenuItem(Constants.CMD_GIT_GOTO_PREVIOUS_CHANGE);
gitSubMenu.addMenuItem(Constants.CMD_GIT_CLOSE_UNMODIFIED);
gitSubMenu.addMenuDivider();
gitSubMenu.addMenuItem(Constants.CMD_GIT_HISTORY_GLOBAL);
gitSubMenu.addMenuItem(Constants.CMD_GIT_HISTORY_FILE);
gitSubMenu.addMenuDivider();
gitSubMenu.addMenuItem(Constants.CMD_GIT_AUTHORS_OF_SELECTION);
gitSubMenu.addMenuItem(Constants.CMD_GIT_AUTHORS_OF_FILE);
gitSubMenu.addMenuDivider();
Expand Down Expand Up @@ -304,6 +310,9 @@ define(function (require, exports) {
optionsCmenu.addMenuItem(Constants.CMD_GIT_DISCARD_ALL_CHANGES);
optionsCmenu.addMenuItem(Constants.CMD_GIT_UNDO_LAST_COMMIT);
optionsCmenu.addMenuDivider();
optionsCmenu.addMenuItem(Constants.CMD_GIT_HISTORY_GLOBAL);
optionsCmenu.addMenuItem(Constants.CMD_GIT_HISTORY_FILE);
optionsCmenu.addMenuDivider();
optionsCmenu.addMenuItem(Constants.CMD_GIT_AUTHORS_OF_SELECTION);
optionsCmenu.addMenuItem(Constants.CMD_GIT_AUTHORS_OF_FILE);
optionsCmenu.addMenuDivider();
Expand Down Expand Up @@ -370,6 +379,9 @@ define(function (require, exports) {
Utils.enableCommand(Constants.CMD_GIT_AUTHORS_OF_SELECTION, enabled);
Utils.enableCommand(Constants.CMD_GIT_AUTHORS_OF_FILE, enabled);

Utils.enableCommand(Constants.CMD_GIT_HISTORY_GLOBAL, enabled);
Utils.enableCommand(Constants.CMD_GIT_HISTORY_FILE, enabled);

Utils.enableCommand(Constants.CMD_GIT_COMMIT_CURRENT, enabled);
Utils.enableCommand(Constants.CMD_GIT_COMMIT_ALL, enabled);

Expand Down
8 changes: 8 additions & 0 deletions src/extensions/default/Git/src/Panel.js
Original file line number Diff line number Diff line change
Expand Up @@ -1348,6 +1348,14 @@ define(function (require, exports) {
CommandManager.register(Strings.HIDE_UNTRACKED, Constants.CMD_GIT_TOGGLE_UNTRACKED, handleToggleUntracked);
CommandManager.register(Strings.GIT_INIT, Constants.CMD_GIT_INIT, EventEmitter.getEmitter(Events.HANDLE_GIT_INIT));
CommandManager.register(Strings.GIT_CLONE, Constants.CMD_GIT_CLONE, EventEmitter.getEmitter(Events.HANDLE_GIT_CLONE));
CommandManager.register(Strings.GIT_SHOW_HISTORY, Constants.CMD_GIT_HISTORY_GLOBAL, ()=>{
toggle(true);
EventEmitter.emit(Events.HISTORY_SHOW_GLOBAL);
});
CommandManager.register(Strings.GIT_SHOW_FILE_HISTORY, Constants.CMD_GIT_HISTORY_FILE, ()=>{
toggle(true);
EventEmitter.emit(Events.HISTORY_SHOW_FILE);
});

// Show gitPanel when appropriate
if (Preferences.get("panelEnabled") && Setup.isExtensionActivated()) {
Expand Down
2 changes: 2 additions & 0 deletions src/nls/root/strings.js
Original file line number Diff line number Diff line change
Expand Up @@ -1446,6 +1446,8 @@ define({
"TOOLTIP_REFRESH_PANEL": "Refresh panel",
"TOOLTIP_SHOW_FILE_HISTORY": "Show file history",
"TOOLTIP_SHOW_HISTORY": "Show history",
"GIT_SHOW_FILE_HISTORY": "File Commit history",
"GIT_SHOW_HISTORY": "Commit history",
"UNDO_CHANGES": "Discard changes",
"UNDO_CHANGES_BTN": "Discard changes\u2026",
"UNDO_LAST_LOCAL_COMMIT": "Undo last local (not pushed) commit\u2026",
Expand Down
30 changes: 24 additions & 6 deletions test/spec/Extn-Git-integ-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -310,12 +310,7 @@ define(function (require, exports, module) {
}, `History list to be visible: ${visible}`);
}

async function testHistoryToggle(whichHistory) {
const $historyToggleButton = $gitPanel.find(whichHistory);

$historyToggleButton.trigger("click");
await waitForHistoryVisible(true);

function _verifyHistoryCommits() {
const $historyList = $gitPanel.find("#git-history-list");

// Check if the first and second commits are displayed
Expand All @@ -325,6 +320,15 @@ define(function (require, exports, module) {
// Verify the content of the first and second commits
expect($historyCommits.eq(0).text().trim()).toBe("second commit");
expect($historyCommits.eq(1).text().trim()).toBe("first commit");
}

async function testHistoryToggle(whichHistory) {
const $historyToggleButton = $gitPanel.find(whichHistory);

$historyToggleButton.trigger("click");
await waitForHistoryVisible(true);

_verifyHistoryCommits();

$historyToggleButton.trigger("click");
await waitForHistoryVisible(false);
Expand All @@ -338,6 +342,20 @@ define(function (require, exports, module) {
await testHistoryToggle(".git-file-history");
});

it("should show history commands work as expected", async () => {
await waitForHistoryVisible(false);

await __PR.execCommand(Commands.CMD_GIT_HISTORY_GLOBAL);
await waitForHistoryVisible(true);
_verifyHistoryCommits();
await __PR.execCommand(Commands.CMD_GIT_TOGGLE_PANEL);
await waitForHistoryVisible(false);

await __PR.execCommand(Commands.CMD_GIT_HISTORY_FILE);
await waitForHistoryVisible(true);
_verifyHistoryCommits();
});

async function waitForHistoryViewerVisible(visible) {
await awaitsFor(() => {
return $("#history-viewer").is(":visible") === visible;
Expand Down
Loading