Skip to content

Commit

Permalink
Bug 361025 - Simplify switching remotes - second version
Browse files Browse the repository at this point in the history
  • Loading branch information
edytaprzymus committed Jul 3, 2012
1 parent 3ba345d commit 7d81821
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ mBootstrap.startup().then(function(core) {
commandService.registerCommandContribution("itemLevelCommands", "eclipse.git.deleteClone", 1000); //$NON-NLS-1$ //$NON-NLS-0$
commandService.registerCommandContribution("itemLevelCommands", "eclipse.orion.git.fetch", 500); //$NON-NLS-1$ //$NON-NLS-0$
commandService.registerCommandContribution("itemLevelCommands", "eclipse.orion.git.merge", 600); //$NON-NLS-1$ //$NON-NLS-0$
commandService.registerCommandContribution("itemLevelCommands", "eclipse.orion.git.switchRemote", 700); //$NON-NLS-1$ //$NON-NLS-0$
commandService.registerCommandContribution("itemLevelCommands", "eclipse.orion.git.rebase", 700); //$NON-NLS-1$ //$NON-NLS-0$
commandService.registerCommandContribution("itemLevelCommands", "eclipse.orion.git.resetIndex", 800); //$NON-NLS-1$ //$NON-NLS-0$
commandService.registerCommandContribution("itemLevelCommands", "eclipse.removeRemote", 1000); //$NON-NLS-1$ //$NON-NLS-0$
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -336,5 +336,7 @@ define({
"Active Branch Log": "Git Log (Active Branch)",
"Show the log for the active local branch": "Show the log for the active local branch",
"Remote Branch Log": "Git Log (Remote Branch)",
"Show the log for the corresponding remote tracking branch": "Show the log for the corresponding remote tracking branch"
"Show the log for the corresponding remote tracking branch": "Show the log for the corresponding remote tracking branch",
"Switch Remote being tracked by the current branch" : "Switch Remote being tracked by the current branch",
"Switch Remote":"Switch Remote"
});
44 changes: 44 additions & 0 deletions bundles/org.eclipse.orion.client.git/web/orion/git/gitCommands.js
Original file line number Diff line number Diff line change
Expand Up @@ -1379,6 +1379,50 @@ var exports = {};
}
});
commandService.addCommand(pushForceCommand);

var switchRemoteCommand = new mCommands.Command({
name : messages["Switch Remote"],
tooltip: messages["Switch Remote tracked by the current branch"],
imageClass: "git-sprite-merge", //$NON-NLS-0$
spriteClass: "gitCommandSprite", //$NON-NLS-0$
id : "eclipse.orion.git.switchRemote", //$NON-NLS-0$
callback: function(data) {
var item = data.items;
var gitService = serviceRegistry.getService("orion.git.provider");
var remotes = item.RemoteLocation;
var parts = item.CloneLocation.split("/");
var remoteLocation = "/gitapi/remote/file/" + parts[4];
gitService.getGitRemote(remoteLocation).then(
function(resp){
var remotes = resp.Children;
var gitService = serviceRegistry.getService("orion.git.provider");
var dialog = new orion.git.widgets.RemotePrompterDialog({
title: messages["Choose Branch"],
serviceRegistry: serviceRegistry,
gitClient: gitService,
treeRoot: {
Children: remotes
},
hideNewBranch: true,
func: dojo.hitch(this,
function(targetBranch, remote) {
//TODO Send the change of remote to the server
item.RemoteLocation[0] = remote;

}
)
});
dialog.startup();
dialog.show();
}
);
},
visibleWhen: function(item) {
return item.Type === "Branch" && item.Current === true; //$NON-NLS-1$ //$NON-NLS-0$
}
});

commandService.addCommand(switchRemoteCommand);

var previousLogPage = new mCommands.Command({
name : messages["< Previous Page"],
Expand Down

0 comments on commit 7d81821

Please sign in to comment.