summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBartosz Grabski <bartosz.grabski@pl.ibm.com>2014-07-30 17:59:46 +0200
committerMaciej Bendkowski <maciej.bendkowski@pl.ibm.com>2014-07-30 12:04:50 -0400
commit552273801553e4a0fb76a9958bec4a6b42af66a7 (patch)
tree791c475a3031b7e445520d3f22fb3b4ab01d8ac5
parent85baa53ce0f179503c5a8a1be3e721f16c49ed13 (diff)
downloadorg.eclipse.orion.client-origin/bug359273.zip
org.eclipse.orion.client-origin/bug359273.tar.gz
org.eclipse.orion.client-origin/bug359273.tar.bz2
Bug 359273 - support git stash - WIP client sideorigin/bug359273
Change-Id: Ib08a493fb0393dec1d43cadab0e2871c34614cbf Signed-off-by: Bartosz Grabski <bartosz.grabski@pl.ibm.com>
-rw-r--r--bundles/org.eclipse.orion.client.git/web/git/git-repository.js9
-rw-r--r--bundles/org.eclipse.orion.client.git/web/git/nls/root/gitmessages.js16
-rw-r--r--bundles/org.eclipse.orion.client.git/web/orion/git/gitClient.js129
-rw-r--r--bundles/org.eclipse.orion.client.git/web/orion/git/gitCommands.js107
-rw-r--r--bundles/org.eclipse.orion.client.git/web/orion/git/gitRepositoryExplorer.js3
-rw-r--r--bundles/org.eclipse.orion.client.git/web/orion/git/logic/gitCommon.js30
-rw-r--r--bundles/org.eclipse.orion.client.git/web/orion/git/logic/gitStash.js117
-rw-r--r--bundles/org.eclipse.orion.client.git/web/orion/git/util.js2
-rw-r--r--bundles/org.eclipse.orion.client.git/web/orion/git/widgets/gitCommitList.js40
9 files changed, 431 insertions, 22 deletions
diff --git a/bundles/org.eclipse.orion.client.git/web/git/git-repository.js b/bundles/org.eclipse.orion.client.git/web/git/git-repository.js
index a97a474..cfc2592 100644
--- a/bundles/org.eclipse.orion.client.git/web/git/git-repository.js
+++ b/bundles/org.eclipse.orion.client.git/web/git/git-repository.js
@@ -75,9 +75,10 @@ mBootstrap.startup().then(function(core) {
new KeyBinding.KeyBinding('h', true, true), new mCommandRegistry.URLBinding("openGitCommit", "commitName")); //$NON-NLS-2$ //$NON-NLS-1$ //$NON-NLS-0$
//TODO: remove when getting rid of multi repos page
- commandRegistry.registerCommandContribution("itemLevelCommandsMini", "eclipse.orion.git.applyPatch", 100); //$NON-NLS-0$
- commandRegistry.registerCommandContribution("itemLevelCommandsMini", "eclipse.orion.git.pull", 200); //$NON-NLS-1$ //$NON-NLS-0$
- commandRegistry.registerCommandContribution("itemLevelCommandsMini", "eclipse.git.deleteClone", 300); //$NON-NLS-1$ //$NON-NLS-0$
+ commandRegistry.registerCommandContribution("itemLevelCommandsMini", "eclipse.orion.git.createStash", 100); //$NON-NLS-0$
+ commandRegistry.registerCommandContribution("itemLevelCommandsMini", "eclipse.orion.git.applyPatch", 200); //$NON-NLS-0$
+ commandRegistry.registerCommandContribution("itemLevelCommandsMini", "eclipse.orion.git.pull", 300); //$NON-NLS-1$ //$NON-NLS-0$
+ commandRegistry.registerCommandContribution("itemLevelCommandsMini", "eclipse.git.deleteClone", 400); //$NON-NLS-1$ //$NON-NLS-0$
// object contributions
commandRegistry.registerCommandContribution("itemLevelCommands", "eclipse.openCloneContent", 100); //$NON-NLS-1$ //$NON-NLS-0$
@@ -101,6 +102,8 @@ mBootstrap.startup().then(function(core) {
commandRegistry.registerCommandContribution("itemLevelCommands", "eclipse.orion.git.addTag", 1); //$NON-NLS-1$ //$NON-NLS-0$
commandRegistry.registerCommandContribution("itemLevelCommands", "eclipse.orion.git.cherryPick", 2); //$NON-NLS-1$ //$NON-NLS-0$
commandRegistry.registerCommandContribution("itemLevelCommands", "eclipse.orion.git.revert", 3); //$NON-NLS-1$ //$NON-NLS-0$
+ commandRegistry.registerCommandContribution("itemLevelCommands", "eclipse.orion.git.dropStash",4); //$NON-NLS-1$ //$NON-NLS-0$
+ commandRegistry.registerCommandContribution("itemLevelCommands", "eclipse.orion.git.applyStash",5); //$NON-NLS-1$ //$NON-NLS-0$
// page navigation contributions
commandRegistry.registerCommandContribution("pageNavigationActions", "eclipse.orion.git.previousTagPage", 1);
diff --git a/bundles/org.eclipse.orion.client.git/web/git/nls/root/gitmessages.js b/bundles/org.eclipse.orion.client.git/web/git/nls/root/gitmessages.js
index e2bfc8e..3ca9d62 100644
--- a/bundles/org.eclipse.orion.client.git/web/git/nls/root/gitmessages.js
+++ b/bundles/org.eclipse.orion.client.git/web/git/nls/root/gitmessages.js
@@ -457,5 +457,19 @@ define({
"FileSelected": "${0} file selected",
"FilesSelected": "${0} files selected",
"CommitPush": "Commit and Push",
- "Commits and pushes files to the default remote": "Commits and pushes files to the default remote"
+ "Commits and pushes files to the default remote": "Commits and pushes files to the default remote",
+ "Commit and push ${0} file(s)": "Commit and push ${0} file(s)",
+ "Commits and pushes files to the default remote": "Commits and pushes files to the default remote",
+ "Stash" : "Stash",
+ "Stashes all files from change list":"Stashes all files from change list",
+ "Apply":"Apply",
+ "Applies changes from selected stash entry":"Applies changes from selected stash entry",
+ "Drop":"Drop",
+ "Drops selected stash entries. If none are selected drops whole stash":"Drops selected stash entries. If none are selected drops whole stash",
+ "Stash operation performed successfully":"Stash operation performed successfully",
+ "Stash apply operation performed successfully. Working directory updated":"Stash apply operation performed successfully. Working directory updated",
+ "Stash drop operation performed succesfully. Dropped stash item ${0}":"Stash drop operation performed succesfully. Dropped stash item ${0}",
+ "Stash drop operation performed successfully. Dropped whole stash":"Stash drop operation performed successfully. Dropped whole stash",
+ "Stash":"Stash",
+ "Getting git stashed changes...":"Getting git stashed changes.."
});
diff --git a/bundles/org.eclipse.orion.client.git/web/orion/git/gitClient.js b/bundles/org.eclipse.orion.client.git/web/orion/git/gitClient.js
index 80b241a..318123c 100644
--- a/bundles/org.eclipse.orion.client.git/web/orion/git/gitClient.js
+++ b/bundles/org.eclipse.orion.client.git/web/orion/git/gitClient.js
@@ -992,7 +992,134 @@ eclipse.GitService = (function() {
_handleGitServiceResponseError: function(deferred, error){
deferred.reject(error);
- }
+ },
+
+ /**
+ *
+ * @param {String} location Location to send request to
+ * @param {Object} options Additional options (e.g. applyIndex) for apply command
+ * @returns {Deferred}
+ */
+ doStashApply : function (location, options) {
+ var service = this;
+
+ if (!options) options = {};
+ options.type = "apply"; //$NON-NLS-0$
+
+ var clientDeferred = new Deferred();
+ xhr("POST", location, { //$NON-NLS-0$
+ headers : {
+ "Orion-Version" : "1", //$NON-NLS-0$ //$NON-NLS-1$
+ "Content-Type" : contentType //$NON-NLS-0$
+ },
+ timeout : 15000,
+ handleAs : "json", //$NON-NLS-0$
+ data: JSON.stringify(options)
+ }).then(function(result) {
+ service._getGitServiceResponse(clientDeferred, result);
+ }, function(error){
+ service._handleGitServiceResponseError(clientDeferred, error);
+ });
+
+ return clientDeferred;
+ },
+ /**
+ *
+ * @param {String} location Location to send request to
+ * @param {Object} options Additional options (e.g. includeUntracked) for create command
+ * @returns {Deferred}
+ */
+ doStashCreate : function (location, options) {
+ var service = this;
+
+ if (!options) options = {};
+ options.type = "create"; //$NON-NLS-0$
+
+ var clientDeferred = new Deferred();
+ xhr("POST", location, { //$NON-NLS-0$
+ headers : {
+ "Orion-Version" : "1", //$NON-NLS-0$ //$NON-NLS-1$
+ "Content-Type" : contentType //$NON-NLS-0$
+ },
+ timeout : 15000,
+ handleAs : "json", //$NON-NLS-0$
+ data: JSON.stringify(options)
+ }).then(function(result) {
+ service._getGitServiceResponse(clientDeferred, result);
+ }, function(error){
+ service._handleGitServiceResponseError(clientDeferred, error);
+ });
+
+ return clientDeferred;
+ },
+
+ /**
+ *
+ * @param {String} location Location to send request to
+ * @param {Object} pagination Can have page and pageSize set to determine pagination (both positive numbers)
+ * @returns {Deferred}
+ */
+ doStashList : function(location, pagination) {
+ var service = this;
+
+ if (pagination) {
+ if (pagination.page && pagination.pageSize) {
+ location = location+"?page="+options.page+"&pageSize="+options.pageSize; //$NON-NLS-0$ //$NON-NLS-1$
+ } else if (pagination.page) {
+ location = location+"?page="+options.page; //$NON-NLS-0$
+ } else if (pagination.pageSize) {
+ location = location+"?pageSize="+options.pageSize; //$NON-NLS-0$
+ }
+ }
+
+ var clientDeferred = new Deferred();
+ xhr("GET", location, { //$NON-NLS-0$
+ headers : {
+ "Orion-Version" : "1", //$NON-NLS-0$ //$NON-NLS-1$
+ "Content-Type" : contentType //$NON-NLS-0$
+ },
+ timeout : 15000,
+ handleAs : "json" //$NON-NLS-0$
+ }).then(function(result) {
+ service._getGitServiceResponse(clientDeferred, result);
+ }, function(error){
+ service._handleGitServiceResponseError(clientDeferred, error);
+ });
+
+ return clientDeferred;
+ },
+
+ /**
+ *
+ * Performs stash drop. If no additional options are provided then drops the first stash ref available.
+ * Otherwise drops provided stash ref in dropRef or drops all if dropAll set to true
+ *
+ * @param {String} location Location to send request to
+ * @param {Object} options Can contain non-negative integer dropRef pointing to stash ref to or -1 to drop all.
+ * @returns {Deferred}
+ */
+ doStashDrop : function(location, options) {
+ var service = this;
+
+ if (options && options.stashRef) location += "?dropIndex="+options.stashRef; //$NON-NLS-0$
+
+ var clientDeferred = new Deferred();
+ xhr("DELETE", location, { //$NON-NLS-0$
+ headers : {
+ "Orion-Version" : "1", //$NON-NLS-0$ //$NON-NLS-1$
+ "Content-Type" : contentType //$NON-NLS-0$
+ },
+ timeout : 15000,
+ handleAs : "json" //$NON-NLS-0$
+ }).then(function(result) {
+ service._getGitServiceResponse(clientDeferred, result);
+ }, function(error){
+ service._handleGitServiceResponseError(clientDeferred, error);
+ });
+
+ return clientDeferred;
+ }
+
};
return GitService;
}());
diff --git a/bundles/org.eclipse.orion.client.git/web/orion/git/gitCommands.js b/bundles/org.eclipse.orion.client.git/web/orion/git/gitCommands.js
index b510d8e..75a1e42 100644
--- a/bundles/org.eclipse.orion.client.git/web/orion/git/gitCommands.js
+++ b/bundles/org.eclipse.orion.client.git/web/orion/git/gitCommands.js
@@ -13,9 +13,9 @@
define(['i18n!git/nls/gitmessages', 'require', 'orion/Deferred', 'orion/i18nUtil', 'orion/webui/littlelib', 'orion/commands', 'orion/commandRegistry', 'orion/git/util', 'orion/compare/compareUtils', 'orion/git/gitPreferenceStorage', 'orion/git/gitConfigPreference',
'orion/git/widgets/ConfirmPushDialog', 'orion/git/widgets/RemotePrompterDialog', 'orion/git/widgets/ReviewRequestDialog', 'orion/git/widgets/CloneGitRepositoryDialog',
- 'orion/git/widgets/GitCredentialsDialog', 'orion/git/widgets/OpenCommitDialog', 'orion/git/widgets/CommitDialog', 'orion/git/widgets/ApplyPatchDialog', 'orion/URL-shim', 'orion/PageLinks', 'orion/URITemplate','orion/git/logic/gitPush','orion/git/logic/gitCommit', 'orion/objects'],
+ 'orion/git/widgets/GitCredentialsDialog', 'orion/git/widgets/OpenCommitDialog', 'orion/git/widgets/CommitDialog', 'orion/git/widgets/ApplyPatchDialog', 'orion/URL-shim', 'orion/PageLinks', 'orion/URITemplate','orion/git/logic/gitPush','orion/git/logic/gitCommit', 'orion/git/logic/gitStash','orion/git/logic/gitCommon','orion/objects','orion/PageUtil'],
function(messages, require, Deferred, i18nUtil, lib, mCommands, mCommandRegistry, mGitUtil, mCompareUtils, GitPreferenceStorage, GitConfigPreference, mConfirmPush, mRemotePrompter,
- mReviewRequest, mCloneGitRepository, mGitCredentials, mOpenCommit, mCommit, mApplyPatch, _, PageLinks, URITemplate, mGitPushLogic, mGitCommitLogic, objects) {
+ mReviewRequest, mCloneGitRepository, mGitCredentials, mOpenCommit, mCommit, mApplyPatch, _, PageLinks, URITemplate, mGitPushLogic, mGitCommitLogic, mGitStashLogic, mGitCommonLogic, objects, PageUtil) {
/**
* @namespace The global container for eclipse APIs.
@@ -489,7 +489,8 @@ var exports = {};
}
},
visibleWhen: function(item){
- return item.Type === "Tag" || item.Type === "Commit"; //$NON-NLS-0$
+ var stashParent = item.parent ? item.parent.Type === "Stash" : false; //$NON-NLS-0$
+ return !stashParent && (item.Type === "Tag" || item.Type === "Commit"); //$NON-NLS-0$
}
});
commandService.addCommand(checkoutTagCommand);
@@ -1493,7 +1494,8 @@ var exports = {};
}
},
visibleWhen : function(item) {
- return item.Type === "Commit"; //$NON-NLS-0$
+ var stashParent = item.parent ? item.parent.Type === "Stash" : false; //$NON-NLS-0$
+ return !stashParent && item.Type === "Commit"; //$NON-NLS-0$
}
});
commandService.addCommand(addTagCommand);
@@ -1657,7 +1659,8 @@ var exports = {};
},
visibleWhen : function(item) {
- return item.Type === "Commit"; //$NON-NLS-0$
+ var stashParent = item.parent ? item.parent.Type === "Stash" : false; //$NON-NLS-0$
+ return !stashParent && item.Type === "Commit"; //$NON-NLS-0$
}
});
commandService.addCommand(cherryPickCommand);
@@ -1698,7 +1701,8 @@ var exports = {};
},
visibleWhen : function(item) {
- return item.Type === "Commit"; //$NON-NLS-0$
+ var stashParent = item.parent ? item.parent.Type === "Stash" : false; //$NON-NLS-0$
+ return !stashParent && item.Type === "Commit"; //$NON-NLS-0$
}
});
commandService.addCommand(revertCommand);
@@ -2856,21 +2860,34 @@ var exports = {};
commandService : commandService,
};
+ var stashOptions = commitOptions;
+
var pushLogic = mGitPushLogic(pushOptions);
var commitLogic = mGitCommitLogic(commitOptions);
+ var stashLogic = mGitStashLogic(stashOptions);
var commitCallback = commitLogic.perform;
- var displayErrorOnStatus = commitLogic.displayErrorOnStatus;
+ var displayErrorOnStatus = mGitCommonLogic.displayErrorOnStatus;
+ var displaySuccessOnStatus = mGitCommonLogic.displaySuccessOnStatus;
var pushCallback = pushLogic.perform;
+ var stashCreateCallback = stashLogic.performStashCreate;
+ var stashApplyCallback = stashLogic.performStashApply;
+ var stashDropCallback = stashLogic.performStashDrop;
+ var stashListCallback = stashLogic.performStashList;
+
+ var params = PageUtil.matchResourceParameters();
+
+ var showHidden = params["stash.show"] ? true : false;
+
var commitAndPushCommand = new mCommands.Command({
- name: messages["CommitPush"],
- tooltip: messages["Commits and pushes files to the default remote"],
- id: "eclipse.orion.git.commitAndPushCommand",
+ name: messages["CommitPush"], //$NON-NLS-0$
+ tooltip: messages["Commits and pushes files to the default remote"], //$NON-NLS-0$
+ id: "eclipse.orion.git.commitAndPushCommand", //$NON-NLS-0$
callback: function(data) {
commitCallback(data).then(function() {
- serviceRegistry.getService("orion.git.provider").getGitBranch(data.items.Clone.BranchLocation).then(
+ serviceRegistry.getService("orion.git.provider").getGitBranch(data.items.Clone.BranchLocation).then( //$NON-NLS-0$
function(resp) {
var branches = resp.Children;
var currentBranch;
@@ -2902,11 +2919,77 @@ var exports = {};
});
},
visibleWhen: function(item) {
- return true;
+ return showHidden;
}
});
commandService.addCommand(commitAndPushCommand);
+
+ var createStashCommand = new mCommands.Command({
+ name: messages["Stash"], //$NON-NLS-0$
+ tooltip: messages["Stashes all files from change list"], //$NON-NLS-0$
+ id: "eclipse.orion.git.createStash", //$NON-NLS-0$
+ callback: function(data) {
+ stashCreateCallback(data).then(function(data) {
+ refresh();
+ displaySuccessOnStatus(messages["Stash operation performed successfully"],serviceRegistry); //$NON-NLS-0$
+ },function(err) {
+ displayErrorOnStatus(err,serviceRegistry);
+ });
+ },
+ visibleWhen: function(item) {
+ return showHidden;
+ }
+ });
+
+ commandService.addCommand(createStashCommand);
+
+ var applyStashCommand = new mCommands.Command({
+ name: messages["Apply"], //$NON-NLS-0$
+ tooltip: messages["Applies changes from selected stash entry"], //$NON-NLS-0$
+ id: "eclipse.orion.git.applyStash", //$NON-NLS-0$
+ callback: function(data) {
+ stashApplyCallback(data).then(function(data) {
+ refresh();
+ displaySuccessOnStatus(messages["Stash apply operation performed successfully. Working directory updated"],serviceRegistry); //$NON-NLS-0$
+ },function(err) {
+ displayErrorOnStatus(err,serviceRegistry);
+ });
+ },
+ visibleWhen: function(item) {
+ return showHidden && (item.Type === "Stash" || (item.Type === "Commit" && item.parent.Type === "Stash"));
+ }
+
+ });
+
+ commandService.addCommand(applyStashCommand);
+
+ var dropStashCommand = new mCommands.Command({
+ name: messages["Drop"], //$NON-NLS-0$
+ tooltip: messages["Drops selected stash entries. If none are selected drops whole stash"], //$NON-NLS-0$
+ id: "eclipse.orion.git.dropStash", //$NON-NLS-0$
+ callback: function(data) {
+ stashDropCallback(data).then(function(data) {
+ refresh();
+ if (stashRef === -1) {
+ displaySuccessOnStatus(messages["Stash drop operation performed successfully. Dropped whole stash"],serviceRegistry); //$NON-NLS-0$
+ } else if (stashRef) {
+ displaySuccessOnStatus(i18nUtil.formatMessage(messages["Stash drop operation performed succesfully. Dropped stash item ${0}"],itemToBeDropped),serviceRegistry); //$NON-NLS-0$
+ } else {
+ displaySuccessOnStatus(i18nUtil.formatMessage(messages["Stash drop operation performed succesfully. Dropped stash item ${0}"],0),serviceRegistry); //$NON-NLS-0$
+ }
+ },function(err) {
+ displayErrorOnStatus(err,serviceRegistry);
+ });
+ },
+ visibleWhen: function(item) {
+ return showHidden && (item.Type === "Stash" || (item.Type === "Commit" && item.parent.Type === "Stash"));
+ }
+
+ });
+
+ commandService.addCommand(dropStashCommand);
+
};
diff --git a/bundles/org.eclipse.orion.client.git/web/orion/git/gitRepositoryExplorer.js b/bundles/org.eclipse.orion.client.git/web/orion/git/gitRepositoryExplorer.js
index 6a77c9c..a0a8470 100644
--- a/bundles/org.eclipse.orion.client.git/web/orion/git/gitRepositoryExplorer.js
+++ b/bundles/org.eclipse.orion.client.git/web/orion/git/gitRepositoryExplorer.js
@@ -169,6 +169,7 @@ exports.GitRepositoryExplorer = (function() {
that.statusDeferred = that.displayStatus(repositories[0]);
that.displayCommits(repositories[0]);
that.displayBranches(repositories[0]); //$NON-NLS-0$
+ that.displayStash(repositories[0]);
if (that.showTagsSeparately) {
that.displayTags(repositories[0]);
}
@@ -393,7 +394,7 @@ exports.GitRepositoryExplorer = (function() {
}
});
tagsNavigator.display();
- };
+ }
// Git Config
diff --git a/bundles/org.eclipse.orion.client.git/web/orion/git/logic/gitCommon.js b/bundles/org.eclipse.orion.client.git/web/orion/git/logic/gitCommon.js
index 8b6e215..48194f8 100644
--- a/bundles/org.eclipse.orion.client.git/web/orion/git/logic/gitCommon.js
+++ b/bundles/org.eclipse.orion.client.git/web/orion/git/logic/gitCommon.js
@@ -344,11 +344,39 @@ define(['orion/git/util','orion/i18nUtil','orion/git/gitPreferenceStorage','orio
}
};
+ var displayErrorOnStatus = function(error, serviceRegistry) {
+ var display = {};
+ display.Severity = "Error"; //$NON-NLS-0$
+ display.HTML = false;
+
+ try {
+ var resp = JSON.parse(error.responseText);
+ if (error.status === 401) {
+ display.HTML = true;
+ display.Message = "<span>"; //$NON-NLS-0$
+ display.Message += i18nUtil.formatMessage(messages["Authentication required for: ${0}. ${1} and re-try the request."], resp.label, "<a target=\"_blank\" href=\"" + resp.SignInLocation //$NON-NLS-1$ //$NON-NLS-0$
+ + "\">" + messages["Login"] + "</a>") + "</span>"; //$NON-NLS-3$ //$NON-NLS-2$ //$NON-NLS-1$ //$NON-NLS-0$
+ } else {
+ display.Message = resp.DetailedMessage ? resp.DetailedMessage : (resp.Message ? resp.Message : messages["Problem while performing the action"]);
+ }
+ } catch (Exception) {
+ display.Message = messages["Problem while performing the action"];
+ }
+
+ serviceRegistry.getService("orion.page.message").setProgressResult(display);
+ };
+
+ var displaySuccessOnStatus = function(message, serviceRegistry) {
+ serviceRegistry.getService("orion.page.message").setProgressResult(message);
+ }
+
return {
handleGitServiceResponse : handleGitServiceResponse,
handleProgressServiceResponse : handleProgressServiceResponse,
gatherSshCredentials : gatherSshCredentials,
handleSshAuthenticationError : handleSshAuthenticationError,
- handleKnownHostsError : handleKnownHostsError
+ handleKnownHostsError : handleKnownHostsError,
+ displayErrorOnStatus : displayErrorOnStatus,
+ displaySuccessOnStatus : displaySuccessOnStatus
};
}); \ No newline at end of file
diff --git a/bundles/org.eclipse.orion.client.git/web/orion/git/logic/gitStash.js b/bundles/org.eclipse.orion.client.git/web/orion/git/logic/gitStash.js
new file mode 100644
index 0000000..71c0fa2
--- /dev/null
+++ b/bundles/org.eclipse.orion.client.git/web/orion/git/logic/gitStash.js
@@ -0,0 +1,117 @@
+/**
+ *
+ *//*******************************************************************************
+ * @license
+ * Copyright (c) 2011, 2014 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials are made
+ * available under the terms of the Eclipse Public License v1.0
+ * (http://www.eclipse.org/legal/epl-v10.html), and the Eclipse Distribution
+ * License v1.0 (http://www.eclipse.org/org/documents/edl-v10.html).
+ *
+ * Contributors: IBM Corporation - initial API and implementation
+ ******************************************************************************/
+
+/*eslint-env browser, amd*/
+
+define(['i18n!git/nls/gitmessages','orion/commandRegistry','orion/Deferred','orion/git/widgets/CommitDialog',
+ 'orion/git/logic/gitCommon', 'orion/i18nUtil', 'orion/webui/littlelib'],
+ function(messages,mCommandRegistry,Deferred,mCommit,mGitCommon,i18nUtil, lib) {
+
+ /**
+ * Acts as a factory for stash related functions.
+ * @param dependencies All required objects and values to perform the command
+ */
+ return function(dependencies) {
+
+ var serviceRegistry = dependencies.serviceRegistry;
+ var commandService = dependencies.commandService;
+
+
+ var performStashApply = function(data) {
+ var d = new Deferred();
+
+ var item = data.items.status || data.handler.status || data.items;
+ var location = item.Clone.StashLocation;
+ var gitService = serviceRegistry.getService("orion.git.provider");
+
+ var options = {};
+ options.applyUntracked = true;
+ if(item.stashIndex) options.stashIndex = item.stashIndex;
+
+ gitService.doStashApply(location,options).then(function(data) {
+ d.resolve(data);
+ }, function(err) {
+ d.reject(err);
+ });
+
+ return d;
+ };
+
+ var performStashCreate = function(data) {
+ var d = new Deferred();
+
+ var item = data.items.status || data.handler.status || data.items;
+ var location = item.Clone.StashLocation;
+ var gitService = serviceRegistry.getService("orion.git.provider");
+
+ var options = { includeUntracked: true };
+
+ gitService.doStashCreate(location,options).then(function(data) {
+ d.resolve(data);
+ }, function(err) {
+ d.reject(err);
+ });
+
+ return d;
+ };
+
+ var performStashDrop = function(data) {
+ var d = new Deferred();
+
+ var item = data.items.status || data.handler.status || data.items;
+ var location = item.Clone.StashLocation;
+ var gitService = serviceRegistry.getService("orion.git.provider");
+
+
+ var options = {};
+
+ if (item.stashIndex) {
+ options.stashRef = item.stashIndex;
+ }
+
+ gitService.doStashDrop(location,options).then(function(data) {
+ d.resolve(data);
+ }, function(err) {
+ d.reject(err);
+ });
+
+
+ return d;
+ };
+
+
+ var performStashList = function(data) {
+ var d = new Deferred();
+
+ var item = data.items.status || data.handler.status || data.items;
+ var location = item.Clone.StashLocation;
+ var gitService = serviceRegistry.getService("orion.git.provider");
+
+ gitService.doStashList(location).then(function(data) {
+ d.resolve(data);
+ }, function(err) {
+ d.reject(err);
+ });
+
+
+ return d;
+ };
+
+ return {
+ performStashCreate:performStashCreate,
+ performStashApply:performStashApply,
+ performStashDrop:performStashDrop,
+ performStashList:performStashList
+ };
+ };
+}); \ No newline at end of file
diff --git a/bundles/org.eclipse.orion.client.git/web/orion/git/util.js b/bundles/org.eclipse.orion.client.git/web/orion/git/util.js
index c2588aa..f757b47 100644
--- a/bundles/org.eclipse.orion.client.git/web/orion/git/util.js
+++ b/bundles/org.eclipse.orion.client.git/web/orion/git/util.js
@@ -98,7 +98,7 @@ define([
var splitted = message.split(/\r\n|\n/);
var iterator = 0;
- while(splitted.length > 0 && /^\s*$/.test(splitted[iterator])) {
+ while(splitted.length > 1 && /^\s*$/.test(splitted[iterator])) {
iterator++;
}
var maxMessageLength = 100;
diff --git a/bundles/org.eclipse.orion.client.git/web/orion/git/widgets/gitCommitList.js b/bundles/org.eclipse.orion.client.git/web/orion/git/widgets/gitCommitList.js
index fbdc887..c4a0418 100644
--- a/bundles/org.eclipse.orion.client.git/web/orion/git/widgets/gitCommitList.js
+++ b/bundles/org.eclipse.orion.client.git/web/orion/git/widgets/gitCommitList.js
@@ -98,6 +98,15 @@ define([
return that.incomingCommits = resp.Children;
});
},
+ _getStash: function() {
+ var that = this;
+ var repository = this.root.repository;
+ var stashLocation = repository.StashLocation;
+
+ return that.progressService.progress(that.gitClient.doStashList(stashLocation), messages['Getting git stashed changes...']).then(function(resp) {
+ return that.stashedChanges = resp;
+ });
+ },
getLocalBranch: function() {
var ref = this.log ? this.log.toRef : this.currentBranch;
if (ref && ref.Type === "RemoteTrackingBranch") { //$NON-NLS-0$
@@ -219,6 +228,9 @@ define([
},
{
Type: "Synchronized" //$NON-NLS-0$
+ },
+ {
+ Type: "Stash" //$NON-NLS-0$
}
]));
}
@@ -289,6 +301,23 @@ define([
} else {
onComplete(that.processChildren(parentItem, []));
}
+ } else if (parentItem.Type === "Stash" ) {
+ return Deferred.when(that.stashedChanges || that._getStash(), function(stash) {
+
+ var nextLocation = stash.NextLocation;
+
+ var children = stash.Children;
+
+ children.forEach(function(child,i) {
+ child.stashIndex = i;
+ });
+
+ if (nextLocation) {
+ children.push({Type:"MoreCommits", NextLocation: nextLocation});
+ }
+
+ onComplete(that.processChildren(parentItem,children));
+ });
} else if (parentItem.Type === "Commit") { //$NON-NLS-0$
onComplete(that.processChildren(parentItem, [{Type: "CommitChanges"}])); //$NON-NLS-0$
} else {
@@ -345,6 +374,7 @@ define([
this.incomingActionScope = "IncomingActions"; //$NON-NLS-0$
this.outgoingActionScope = "OutgoingActions"; //$NON-NLS-0$
this.syncActionScope = "SynchronizedActions"; //$NON-NLS-0$
+ this.stashActionScope = "StashActions";
this.createCommands();
}
GitCommitListExplorer.prototype = Object.create(mExplorer.Explorer.prototype);
@@ -487,6 +517,7 @@ define([
} else if (currentBranch && !this.simpleLog) {
var incomingActionScope = this.incomingActionScope;
var outgoingActionScope = this.outgoingActionScope;
+ var stashActionScope = this.stashActionScope;
if (lib.node(actionsNodeScope)) {
commandService.destroy(actionsNodeScope);
@@ -531,6 +562,9 @@ define([
commandService.renderCommands(outgoingActionScope, outgoingActionScope, {LocalBranch: localBranch, RemoteBranch: remoteBranch}, this, "button"); //$NON-NLS-0$
}
+
+ commandService.registerCommandContribution(stashActionScope, "eclipse.orion.git.dropStash", 1000);
+ commandService.renderCommands(stashActionScope, stashActionScope, { Clone: repository, Type:"Stash", stashRef : -1}, this, "button");
}
});
@@ -630,7 +664,7 @@ define([
});
explorer2.display();
}, 0);
- } else if (item.Type !== "Commit") { //$NON-NLS-0$
+ } else if (item.Type !== "Commit") { //$NON-NLS-0$
if (item.Type !== "NoCommits") { //$NON-NLS-0$
sectionItem.className = "gitCommitSectionTableItem"; //$NON-NLS-0$
createExpand();
@@ -662,6 +696,7 @@ define([
slideoutDiv.innerHTML = slideoutFragment;
horizontalBox.appendChild(slideoutDiv);
} else {
+ var repository = explorer.model.root.repository;
createExpand();
sectionItem.className = "sectionTableItem"; //$NON-NLS-0$
detailsView = document.createElement("div"); //$NON-NLS-0$
@@ -685,7 +720,8 @@ define([
actionsArea.className = "layoutRight commandList"; //$NON-NLS-0$
actionsArea.id = itemActionScope;
horizontalBox.appendChild(actionsArea);
- explorer.commandService.renderCommands(itemActionScope, actionsArea, item, explorer, "tool"); //$NON-NLS-0$
+ item.Clone = repository;
+ explorer.commandService.renderCommands(itemActionScope, actionsArea, item, explorer, "button"); //$NON-NLS-0$
}
return td;