Bug 361025 - Simplify switching remotes
Summary: Simplify switching remotes
Status: RESOLVED FIXED
Alias: None
Product: Orion (Archived)
Classification: ECD
Component: Git (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows 7
: P3 normal (vote)
Target Milestone: 1.0 M1   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard: gsoc2012
Keywords: investigate
Depends on:
Blocks:
 
Reported: 2011-10-14 15:24 EDT by John Arthorne CLA
Modified: 2012-07-17 05:59 EDT (History)
2 users (show)

See Also:


Attachments
Switch remote (164.04 KB, image/png)
2012-07-09 07:15 EDT, Edyta Przymus CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description John Arthorne CLA 2011-10-14 15:24:04 EDT
0.3 RC2

- Start with an existing repository that has various branches, cloned in Orion
- Create a new empty remote repository somewhere
- Attempt to figure out how to push your current branch to the new remote

-> It turns out that you can do this by setting the "branch.<yourbranchname>.remote" property to be the name of your new remote, but this is not obvious. I was looking for either:

1) Some action on my current active branch like "Switch Remote"
2) Some action on the remote like "Make Current" or simply "Switch"

Without thinking about it too much, I think 2) is the simplest. It would change the remote for the local active branch to be the selected remote. Under the covers it would just set the repository configuration property for the active branch.
Comment 1 Tomasz Zarna CLA 2012-02-06 08:07:13 EST
Another option here would be allowing user to select a remote and ref specs to be used when pushing. Currently, the spec is always resolved to something like this: "HEAD:refs/head/{branch name from URL}", remote is also read from the URL requested by POST. This would be a more general solution but not necessarily simpler, comparing to what John suggested.
Comment 3 Szymon Brandys CLA 2012-07-02 11:20:52 EDT
I would add "New branch" to each remote. So far it is just for the first one in the tree. Moreover, as you already noticed, using 'New Branch' text field to push does not work. please fill a separate bug and look at it.
Comment 4 Edyta Przymus CLA 2012-07-03 17:56:24 EDT
Here are two possible solutions for this problem:

https://github.com/edytaprzymus/orion.client/commit/2d3baa416d277859dff2d40e36cb4b45f393ef78 --> when pushing a dialog with possibility to change remote to push

https://github.com/edytaprzymus/orion.client/commit/7d81821afb522f3dfa94549137030ba25b94a3b8 --> new "levelItemCommand", visible for an active branch. Missing server part of this solution, but it's possible to compare workflow of both solution and choose the better one to implement
Comment 5 Szymon Brandys CLA 2012-07-09 06:27:10 EDT
(In reply to comment #4)
> Here are two possible solutions for this problem:
> 
> https://github.com/edytaprzymus/orion.client/commit/2d3baa416d277859dff2d40e36cb4b45f393ef78
> --> when pushing a dialog with possibility to change remote to push

Looks promising. I would change the wording to 'Click More to push to another remote or OK to push to default'
and maybe put 'More' just next to 'OK' e.g. [More][OK] aligned to the right.
> 
> https://github.com/edytaprzymus/orion.client/commit/7d81821afb522f3dfa94549137030ba25b94a3b8
> --> new "levelItemCommand", visible for an active branch. Missing server part of
> this solution, but it's possible to compare workflow of both solution and choose
> the better one to implement

Could you paste a screenshot showing where the icon is? I was not able to see it.
Comment 6 Edyta Przymus CLA 2012-07-09 07:15:18 EDT
Created attachment 218437 [details]
Switch remote
Comment 7 Edyta Przymus CLA 2012-07-10 08:36:25 EDT
I wrote all this code and have the rights to contribute it to Eclipse under the
eclipse.org web site terms of use.
Comment 8 Szymon Brandys CLA 2012-07-10 11:42:55 EDT
(In reply to comment #5)
> (In reply to comment #4)
> > Here are two possible solutions for this problem:
> >
> >
> https://github.com/edytaprzymus/orion.client/commit/2d3baa416d277859dff2d40e36cb4b45f393ef78
> > --> when pushing a dialog with possibility to change remote to push
> 
> Looks promising. I would change the wording to 'Click More to push to another
> remote or OK to push to default'
> and maybe put 'More' just next to 'OK' e.g. [More][OK] aligned to the right.

I think this looks better. Please improve the dialog and make sure that this case works:

Steps:
1) have two remotes e.g. 'origin' and 'test'
2) create a new local branch and make it active
3) push changes to 'origin'
4) try to push to 'test' now and remember that, so the next time you are trying to push it uses 'test/[branch]'
Comment 9 Edyta Przymus CLA 2012-07-11 17:07:36 EDT
The fix: https://github.com/edytaprzymus/orion.client/commit/b587611be44f7bad9e2f945b864b4f479978d6c8

Please notice, that this commit fix also problem with hand-typed new branch name.
Comment 10 Szymon Brandys CLA 2012-07-12 05:42:08 EDT
The latest fix seems to work. Couple comments:
1. Try to not craft locations manually, like:
	var remoteLocation = "/gitapi/remote/file/" + parts[4]; 
	var locationToChange = "/gitapi/config/clone/file/" + parts[4];
I would call GET on CloneLocation and get locations from the response

2. fix indents, for instance see the code around line 1508 in gitCommands.js

3. I would extract the code to edit config property to a separate method.

4. I think that var target; in line 1116 in gitCommands.js should be moved to callback methods

5. I would update configuration also when we push a branch for the first time

and please rebase on top of 'master' branch.
Comment 11 Szymon Brandys CLA 2012-07-12 06:19:09 EDT
(In reply to comment #10)
> 3. I would extract the code to edit config property to a separate method.

Maybe gitClient#editCloneConfigurationProperty method could have 'create' param meaning that if the key doesn't exist, it should be created.
Comment 12 Edyta Przymus CLA 2012-07-13 02:41:38 EDT
https://github.com/edytaprzymus/orion.client/commit/4d461e42f5bef894fc371671127c5df1db722b53

here I fixed almost all remarks. I only didn't get the point 3. Could you please tell me more detailed which code should I extract as a separate method?
Comment 13 Szymon Brandys CLA 2012-07-16 05:33:33 EDT
(In reply to comment #12)
> here I fixed almost all remarks. I only didn't get the point 3. Could you please
> tell me more detailed which code should I extract as a separate method?
Refreshing explorers/pages for instance.

2. indents are not fixed

4. var target is left unused in line 1186
Comment 15 Szymon Brandys CLA 2012-07-17 05:59:44 EDT
Edyta I merged your commit to master on eclipse.org. However I had to simplify the code what is released in a separate commit.