Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 370978 - Fetch from remote now always prompts for SSH information
Summary: Fetch from remote now always prompts for SSH information
Status: RESOLVED FIXED
Alias: None
Product: Orion
Classification: ECD
Component: Git (show other bugs)
Version: 0.4   Edit
Hardware: PC Mac OS X - Carbon (unsup.)
: P3 major (vote)
Target Milestone: 0.4 RC3   Edit
Assignee: Szymon Brandys CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on: 365982
Blocks:
  Show dependency tree
 
Reported: 2012-02-08 11:59 EST by Ken Walker CLA
Modified: 2012-02-22 04:38 EST (History)
3 users (show)

See Also:
malgorzata.tomczyk: review+
ken_walker: review+


Attachments
Screen shot of forced SSH authentication (41.74 KB, image/jpeg)
2012-02-08 11:59 EST, Ken Walker CLA
no flags Details
Proposal v1 (9.88 KB, patch)
2012-02-20 08:56 EST, Szymon Brandys CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Ken Walker CLA 2012-02-08 11:59:36 EST
Created attachment 210743 [details]
Screen shot of forced SSH authentication

Within the last couple of days something has changed with regards to using the "Fetch from remote" button at the bottom of a repository page.  The public, non-committer git site (http://git.eclipse.org/gitroot/orion/org.eclipse.orion.client.git) does not need authentication.

Attaching a screen shot
Comment 1 Ken Walker CLA 2012-02-08 12:00:28 EST
just hitting the checkmark does fetch the remote
Comment 2 Szymon Brandys CLA 2012-02-08 12:36:20 EST
We collect credentials via slideouts which do not know whether the repo needs credentials or not. Either we need to disable it and go back to the old dialog (doable for .4) or let the command control when the slideout should be opened (Susan?).
Comment 3 Susan McCourt CLA 2012-02-08 12:50:51 EST
letting the command control the slideout content is bug 365982 which I was hoping to defer to 0.5

I think there is a middle ground where we could keep the slideout.
The code that associates the repo with the command (renderCommands) could check the repo and set the required parameters on the fly.  

Admittedly this is a hack.  bug 365982 is basically the same thing, but it's the command framework triggering the call.
Comment 4 Susan McCourt CLA 2012-02-08 13:14:15 EST
Discussed with Szymon, i'll investigate a contained fix for bug 365982
Comment 5 Susan McCourt CLA 2012-02-09 01:00:48 EST
I fixed the dependent bug.

I think it may still be awkward given the structure of the git commands (which is why we had bug 370255).  From what i recall, you had to try to authenticate before you really knew what you might have in the way of credentials.  In bug 365982 you said that the parameters have to be collected during the callback, but of course parameters are something you specify that are a "prereq" to your callback being called.  The callback needs to assume the parameters are already there.  

So...if the default values and/or the parameters themselves depend on something like the repository, then you need a hook to know what repository is involved before the callback is called.  This is what I added in bug 365982.

So...

Where you had:
var gitAuthParameters = new mCommands.ParametersDescription([new mCommands.CommandParameter("sshuser", "text", "SSH User Name:"), new mCommands.CommandParameter("sshpassword", "password", "SSH Password:")], true);

you can now say
var gitAuthParameters = new mCommands.ParametersDescription([new mCommands.CommandParameter("sshuser", "text", "SSH User Name:"), new mCommands.CommandParameter("sshpassword", "password", "SSH Password:")], true, function(data) {
   if (data.items.... means no need to authenticate) {
     return null;
   } else if (data.items.....means we know the user but not password) {
     return [new mCommands.CommandParameter("sshpassword", password", "SSH Password:"];
   } else { // we really need both
     reutrn [new mCommands.CommandParameter("sshuser", "text", "SSH User Name:"), new mCommands.CommandParameter("sshpassword", "password", "SSH Password:")]
   }
});

If you need to hang some kind of state on the parameters so that the callback can get to it, you could hang some properties on the "data" in the callback.  That is the same data that will be sent to the callback.  This isn't really documented, but it sounds like your case is a bit awkward, where you have to try to authenticate before you can know what you need.  So if that try will get some state that you need, you can store it there. 

Such as function(data)
   if (data.items...means no authentication) {
     data.secretStashOfCachedInfo = ...;
     return null;  // no slideout
   } else {...

Then in the callback
  callback: function(data) {
    mySecretStuff = data.secretStashOfCachedInfo...

If the problem is that the only way to find out what credentials you need is to actually ask the server to do something, then you need to have some kind of server-side request that asks the server to validate credentials.  You could call that request in the parameter callback (but please do not return a deferred as we don't assume most clients have such complex requirements...if you must call the server to determine what parameters are needed then wait for the response...
Comment 6 Szymon Brandys CLA 2012-02-20 08:56:40 EST
Created attachment 211273 [details]
Proposal v1

This patch changes just the Fetch command.
Comment 7 Szymon Brandys CLA 2012-02-20 08:56:56 EST
Gosia what do you think?
Comment 8 Malgorzata Janczarska CLA 2012-02-20 10:44:26 EST
(In reply to comment #7)
> Gosia what do you think?

1. Errors are not displayed
2. Even if we know user name we still ask for it
3. handleProgressServiceResponse2 has errCallback - name suggests that it will be called on error, but it's called only when it's ssh error
4. Git log is not refreshed after successful Fetch, this is something we have in logs: "could not find table row gitapiremoteoriginmasterfile3". Force fetch that wasn't changed doesn't have this error.
Comment 9 Szymon Brandys CLA 2012-02-20 10:57:43 EST
(In reply to comment #8)

> 1. Errors are not displayed
Hmm. Right. They are not displayed if you switched to the old dialog using 'More'.
I missed that.

> 2. Even if we know user name we still ask for it
There is a separate bug for that in the slideout. For the old dialog, the same issue as in 1)

> 3. handleProgressServiceResponse2 has errCallback - name suggests that it will
> be called on error, but it's called only when it's ssh error
Sure. The name can be changed.

> 4. Git log is not refreshed after successful Fetch, this is something we have in
> logs: "could not find table row gitapiremoteoriginmasterfile3". Force fetch that
> wasn't changed doesn't have this error.
Please raise a separate bug for that. It works this way without the patch too.

Thanks.
Comment 10 Malgorzata Janczarska CLA 2012-02-20 11:04:10 EST
(In reply to comment #9)
> > 4. Git log is not refreshed after successful Fetch, this is something we have in
> > logs: "could not find table row gitapiremoteoriginmasterfile3". Force fetch that
> > wasn't changed doesn't have this error.
> Please raise a separate bug for that. It works this way without the patch too.
> 
I opened Bug 372040, but my comment is still valid. Without your patch the error is still shown in logs, but the log *does* refresh.
It seems that this error is not related to the not refreshing problem.
Comment 11 Malgorzata Janczarska CLA 2012-02-21 10:36:25 EST
I reviewed code you pushed to branch bug370978, those are my comments:
* pull command doesn't use slideout at all (it never did). I think we should unify that, if it's too late now we could wait until 0.5, but we should do it.
* The slideout still asks for the user name, but I understand that it's Bug 370255
* You added handleProgressServiceResponse2 function in addition to currently used handleProgressServiceResponse. I understand that you wanted to limit the number of changes because it's late in development cycle, but for 0.5 we should merge them
* (Nitpicking) There are some places where you added 4 empty lines and nothing more.
* While testing I also came across Bug 371882, but it's reproducable without your patch as well
Comment 12 Szymon Brandys CLA 2012-02-21 10:39:34 EST
(In reply to comment #11)
> I reviewed code you pushed to branch bug370978, those are my comments:
> * pull command doesn't use slideout at all (it never did). I think we should
> unify that, if it's too late now we could wait until 0.5, but we should do it.

I would say it is too late. I decided to fix places where Susan already added slideouts. I would wait wit other places till .5 and Bug 372127 is fixed.

> * The slideout still asks for the user name, but I understand that it's Bug
> 370255

Yup.

> * You added handleProgressServiceResponse2 function in addition to currently
> used handleProgressServiceResponse. I understand that you wanted to limit the
> number of changes because it's late in development cycle, but for 0.5 we should
> merge them

Yup.

> * (Nitpicking) There are some places where you added 4 empty lines and nothing
> more.

Really? I will fix that before pushing.

> * While testing I also came across Bug 371882, but it's reproducable without
> your patch as well

Right.
Comment 13 Szymon Brandys CLA 2012-02-21 10:45:52 EST
You may review the fix at branch bug370978 on orion.client repo.
Comment 14 Ken Walker CLA 2012-02-21 12:19:23 EST
As project lead I +1 this for RC3
Comment 15 Szymon Brandys CLA 2012-02-22 04:38:28 EST
Fixed with 5dbac688df2e1fe958c541704d94df5544a589fc.