Re: [Pharo-users] [ANN] Windows support for GitFileTree

2015-10-13 Thread Hernán Morales Durand
2015-10-13 4:29 GMT-03:00 Peter Uhnák :

> On Tue, Oct 13, 2015 at 8:11 AM, Thierry Goubier <
> thierry.goub...@gmail.com> wrote:
>
>> Hi Hernàn,
>>
>> I'm not familiar with the use of ssh-agent. Could it interfere with
>> someone using his own keys (i.e. without ssh-agent)? Would this be
>> necessary for linux or mac use of ssh-agent, or is ssh / git correctly done
>> on those platforms to query ssh-agent on its own if it is already running?
>>
>
> I'm using ssh-agent on both windows and linux, and having aforementioned
> variables (SSH_AGENT_PID, SSH_AUTH_SOCK) in the environment is enough for
> git to automatically use it, no need to prefix it.
>
>
I don't know if I get what you mean with prefix it. But the "set
SSH_AGENT_PID=" is done because the cmd.exe launched by ProcessWrapper
does not detect SSH variables from other environment/term.

I think many platforms (MinGW/MSYS/Cygwin) use something like this to
launch ssh-agent for every term:

echo "#!/bin/bash \
eval `ssh-agent -s` \
ssh-add" >> ~/.bashrc



> In any case I have notes about the implementation:
>
> 1. it assumes that it runs only on windows (it looks like this should be
> generic code)
> 2. it assumes that ssh-agent will be always installed in a specific path,
> it should rely on PATH instead
>

Yes, some time ago I sent some FileSystem extensions to locate path
binaries. I don't know if they are still around but it could be used.


> 3: Windows has its own system for global env variables, so why not use
> that?
> So instead of doing some process lookups you simply get
> $Env:SSH_AUTH_SOCK" (well, I use powershell... but the bat version is I
> think %SSH_AUTH_SOCK%)
>

I guess they could be used, but Git Bash is a MSYS command, so the
environment variables need to be exported.

Hernán


> Peter
>


Re: [Pharo-users] [ANN] Windows support for GitFileTree

2015-10-13 Thread Robert Withers
I just took a quick look. It depends on both LayeredProtocol and SSL, 
but SSL won't load as HierarchicalUrl is missing.


thanks,
Robert

On 10/13/2015 04:02 AM, Thierry Goubier wrote:



2015-10-13 9:46 GMT+02:00 Robert Withers mailto:robert.w.with...@gmail.com>>:

Would the SSH package in Cryptography help you?


I don't know. I just delegate to git for handling the ssh stuff; Pharo
has little to gain by manipulating ssh by itself in that use case (but,
overalll, I believe ssh support to be usefull).

I'll have a look.

Thierry


thanks,
Robert

On 10/13/2015 03:36 AM, Thierry Goubier wrote:



2015-10-13 9:29 GMT+02:00 Peter Uhnák mailto:i.uh...@gmail.com>
>>:

 On Tue, Oct 13, 2015 at 8:11 AM, Thierry Goubier
 mailto:thierry.goub...@gmail.com>
>> wrote:

 Hi Hernàn,

 I'm not familiar with the use of ssh-agent. Could it
interfere
 with someone using his own keys (i.e. without
ssh-agent)? Would
 this be necessary for linux or mac use of ssh-agent, or
is ssh /
 git correctly done on those platforms to query
ssh-agent on its
 own if it is already running?


 I'm using ssh-agent on both windows and linux, and having
 aforementioned variables (SSH_AGENT_PID, SSH_AUTH_SOCK) in the
 environment is enough for git to automatically use it, no
need to
 prefix it.


This is what I expected. Is that different under Windows?


 In any case I have notes about the implementation:

 1. it assumes that it runs only on windows (it looks like this
 should be generic code)


Well, as you said above, the environment under Linux/Mac takes
care of
the interaction with ssh-agent... so there is no need to handle
that on
the Linux/Mac side (OSProcess) versus Windows (ProcessWrapper).

 2. it assumes that ssh-agent will be always installed in a
specific
 path, it should rely on PATH instead


Noted.

 3: Windows has its own system for global env variables, so
why not
 use that?
 So instead of doing some process lookups you simply get
 $Env:SSH_AUTH_SOCK" (well, I use powershell... but the bat
version
 is I think %SSH_AUTH_SOCK%)


But the thing is: if I can query for environment variables in
Windows,
then so can the git command as well, which would mean it would
pick-up
the use of ssh-agent, no? Or should I try to manipulate the process

Anyway, I appreciate you're having a look at it. Thanks!

Thierry


 Peter








Re: [Pharo-users] [ANN] Windows support for GitFileTree

2015-10-13 Thread Thierry Goubier
2015-10-13 9:46 GMT+02:00 Robert Withers :

> Would the SSH package in Cryptography help you?
>

I don't know. I just delegate to git for handling the ssh stuff; Pharo has
little to gain by manipulating ssh by itself in that use case (but,
overalll, I believe ssh support to be usefull).

I'll have a look.

Thierry


>
> thanks,
> Robert
>
> On 10/13/2015 03:36 AM, Thierry Goubier wrote:
>
>>
>>
>> 2015-10-13 9:29 GMT+02:00 Peter Uhnák > >:
>>
>> On Tue, Oct 13, 2015 at 8:11 AM, Thierry Goubier
>> mailto:thierry.goub...@gmail.com>> wrote:
>>
>> Hi Hernàn,
>>
>> I'm not familiar with the use of ssh-agent. Could it interfere
>> with someone using his own keys (i.e. without ssh-agent)? Would
>> this be necessary for linux or mac use of ssh-agent, or is ssh /
>> git correctly done on those platforms to query ssh-agent on its
>> own if it is already running?
>>
>>
>> I'm using ssh-agent on both windows and linux, and having
>> aforementioned variables (SSH_AGENT_PID, SSH_AUTH_SOCK) in the
>> environment is enough for git to automatically use it, no need to
>> prefix it.
>>
>>
>> This is what I expected. Is that different under Windows?
>>
>>
>> In any case I have notes about the implementation:
>>
>> 1. it assumes that it runs only on windows (it looks like this
>> should be generic code)
>>
>>
>> Well, as you said above, the environment under Linux/Mac takes care of
>> the interaction with ssh-agent... so there is no need to handle that on
>> the Linux/Mac side (OSProcess) versus Windows (ProcessWrapper).
>>
>> 2. it assumes that ssh-agent will be always installed in a specific
>> path, it should rely on PATH instead
>>
>>
>> Noted.
>>
>> 3: Windows has its own system for global env variables, so why not
>> use that?
>> So instead of doing some process lookups you simply get
>> $Env:SSH_AUTH_SOCK" (well, I use powershell... but the bat version
>> is I think %SSH_AUTH_SOCK%)
>>
>>
>> But the thing is: if I can query for environment variables in Windows,
>> then so can the git command as well, which would mean it would pick-up
>> the use of ssh-agent, no? Or should I try to manipulate the process
>>
>> Anyway, I appreciate you're having a look at it. Thanks!
>>
>> Thierry
>>
>>
>> Peter
>>
>>
>>
>


Re: [Pharo-users] [ANN] Windows support for GitFileTree

2015-10-13 Thread Peter Uhnák
On Tue, Oct 13, 2015 at 9:36 AM, Thierry Goubier 
wrote:

>
>
> 2015-10-13 9:29 GMT+02:00 Peter Uhnák :
>
>> On Tue, Oct 13, 2015 at 8:11 AM, Thierry Goubier <
>> thierry.goub...@gmail.com> wrote:
>>
>>> Hi Hernàn,
>>>
>>> I'm not familiar with the use of ssh-agent. Could it interfere with
>>> someone using his own keys (i.e. without ssh-agent)? Would this be
>>> necessary for linux or mac use of ssh-agent, or is ssh / git correctly done
>>> on those platforms to query ssh-agent on its own if it is already running?
>>>
>>
>> I'm using ssh-agent on both windows and linux, and having aforementioned
>> variables (SSH_AGENT_PID, SSH_AUTH_SOCK) in the environment is enough for
>> git to automatically use it, no need to prefix it.
>>
>
> This is what I expected. Is that different under Windows?
>

this is the same under windows.


> But the thing is: if I can query for environment variables in Windows,
> then so can the git command as well, which would mean it would pick-up the
> use of ssh-agent, no? Or should I try to manipulate the process
>
> Anyway, I appreciate you're having a look at it. Thanks!
>

I was setting up ssh-agent under windows couple years ago so I don't quite
remember what was the problem exactly,
but iirc the problem was that ssh-agent was setting the variables only
locally (maybe because it didn't understand windows env system).

So the way I forced it to work was that I manually created a permanent
record for SSH_AUTH_SOCK with some predefined path,
and then I was starting the agent with "ssh-agent -a "$Env:SSH_AUTH_SOCK"

this way the agent was bound the the socket specified by the global
variable.

Git itself was then able to correctly read the value from the environment,
so I didn't have to change anything for git, it worked out of the box (as
long as the env was correct).

Interestingly I never needed SSH_AGENT_PID, but maybe git just needs the
socket.

Peter


Re: [Pharo-users] [ANN] Windows support for GitFileTree

2015-10-13 Thread Robert Withers

Would the SSH package in Cryptography help you?

thanks,
Robert

On 10/13/2015 03:36 AM, Thierry Goubier wrote:



2015-10-13 9:29 GMT+02:00 Peter Uhnák mailto:i.uh...@gmail.com>>:

On Tue, Oct 13, 2015 at 8:11 AM, Thierry Goubier
mailto:thierry.goub...@gmail.com>> wrote:

Hi Hernàn,

I'm not familiar with the use of ssh-agent. Could it interfere
with someone using his own keys (i.e. without ssh-agent)? Would
this be necessary for linux or mac use of ssh-agent, or is ssh /
git correctly done on those platforms to query ssh-agent on its
own if it is already running?


I'm using ssh-agent on both windows and linux, and having
aforementioned variables (SSH_AGENT_PID, SSH_AUTH_SOCK) in the
environment is enough for git to automatically use it, no need to
prefix it.


This is what I expected. Is that different under Windows?


In any case I have notes about the implementation:

1. it assumes that it runs only on windows (it looks like this
should be generic code)


Well, as you said above, the environment under Linux/Mac takes care of
the interaction with ssh-agent... so there is no need to handle that on
the Linux/Mac side (OSProcess) versus Windows (ProcessWrapper).

2. it assumes that ssh-agent will be always installed in a specific
path, it should rely on PATH instead


Noted.

3: Windows has its own system for global env variables, so why not
use that?
So instead of doing some process lookups you simply get
$Env:SSH_AUTH_SOCK" (well, I use powershell... but the bat version
is I think %SSH_AUTH_SOCK%)


But the thing is: if I can query for environment variables in Windows,
then so can the git command as well, which would mean it would pick-up
the use of ssh-agent, no? Or should I try to manipulate the process

Anyway, I appreciate you're having a look at it. Thanks!

Thierry


Peter






Re: [Pharo-users] [ANN] Windows support for GitFileTree

2015-10-13 Thread Thierry Goubier
2015-10-13 9:29 GMT+02:00 Peter Uhnák :

> On Tue, Oct 13, 2015 at 8:11 AM, Thierry Goubier <
> thierry.goub...@gmail.com> wrote:
>
>> Hi Hernàn,
>>
>> I'm not familiar with the use of ssh-agent. Could it interfere with
>> someone using his own keys (i.e. without ssh-agent)? Would this be
>> necessary for linux or mac use of ssh-agent, or is ssh / git correctly done
>> on those platforms to query ssh-agent on its own if it is already running?
>>
>
> I'm using ssh-agent on both windows and linux, and having aforementioned
> variables (SSH_AGENT_PID, SSH_AUTH_SOCK) in the environment is enough for
> git to automatically use it, no need to prefix it.
>

This is what I expected. Is that different under Windows?


> In any case I have notes about the implementation:
>
> 1. it assumes that it runs only on windows (it looks like this should be
> generic code)
>

Well, as you said above, the environment under Linux/Mac takes care of the
interaction with ssh-agent... so there is no need to handle that on the
Linux/Mac side (OSProcess) versus Windows (ProcessWrapper).


> 2. it assumes that ssh-agent will be always installed in a specific path,
> it should rely on PATH instead
>

Noted.


> 3: Windows has its own system for global env variables, so why not use
> that?
> So instead of doing some process lookups you simply get
> $Env:SSH_AUTH_SOCK" (well, I use powershell... but the bat version is I
> think %SSH_AUTH_SOCK%)
>

But the thing is: if I can query for environment variables in Windows, then
so can the git command as well, which would mean it would pick-up the use
of ssh-agent, no? Or should I try to manipulate the process

Anyway, I appreciate you're having a look at it. Thanks!

Thierry


>
> Peter
>


Re: [Pharo-users] [ANN] Windows support for GitFileTree

2015-10-13 Thread Peter Uhnák
On Tue, Oct 13, 2015 at 8:11 AM, Thierry Goubier 
wrote:

> Hi Hernàn,
>
> I'm not familiar with the use of ssh-agent. Could it interfere with
> someone using his own keys (i.e. without ssh-agent)? Would this be
> necessary for linux or mac use of ssh-agent, or is ssh / git correctly done
> on those platforms to query ssh-agent on its own if it is already running?
>

I'm using ssh-agent on both windows and linux, and having aforementioned
variables (SSH_AGENT_PID, SSH_AUTH_SOCK) in the environment is enough for
git to automatically use it, no need to prefix it.

In any case I have notes about the implementation:

1. it assumes that it runs only on windows (it looks like this should be
generic code)
2. it assumes that ssh-agent will be always installed in a specific path,
it should rely on PATH instead
3: Windows has its own system for global env variables, so why not use
that?
So instead of doing some process lookups you simply get $Env:SSH_AUTH_SOCK"
(well, I use powershell... but the bat version is I think %SSH_AUTH_SOCK%)

Peter


Re: [Pharo-users] [ANN] Windows support for GitFileTree

2015-10-12 Thread Thierry Goubier

Hi Hernàn,

I'm not familiar with the use of ssh-agent. Could it interfere with 
someone using his own keys (i.e. without ssh-agent)? Would this be 
necessary for linux or mac use of ssh-agent, or is ssh / git correctly 
done on those platforms to query ssh-agent on its own if it is already 
running?


Anyway, I'll integrate that.

Thierry

Le 13/10/2015 06:19, Hernán Morales Durand a écrit :

Hi Thierry,

Providing some feedback here.

I couldn't add a remote repository (image hangs) using Pharo 5. Working
with GitHub Bash and SSH connections I think one needs to re-use
ssh-agent environment variables before launching git commands. For
example if ssh-agent.exe was sucessfully started and MSYS says:

$ env | grep ^SSH
SSH_AGENT_PID=5784
SSH_AUTH_SOCK=/tmp/ssh-Jpgwx10860/agent.10860

then from CMD.exe one could get both values using:

C:\> wmic process where ExecutablePath='c:\\Program Files
(x86)\\Git\\bin\\ssh-agent.exe' get ProcessId

C:\> find /tmp/ssh-* -name agent.\* -uid $(id -u)|head -n 1

I have attached a change set with some refactorings and new methods to
enable setting ssh-agent variables. It is not finished and it needs
review. I do not have too much time but is a start, I hope.

Cheers,

Hernán






2015-10-09 18:35 GMT-03:00 Thierry Goubier mailto:thierry.goub...@gmail.com>>:

Hi all,

thanks to the help of Nicolai and Levente (and others), GitFileTree
has now working support for Windows users through ProcessWrapper (on
the development versions).

A way for it to work is to have git in your path and simply load:

Metacello new
 configuration: 'GitFileTree';
 version: #'development';
 repository:
'https://smalltalkhub.com/mc/Pharo/MetaRepoForPharo50/main';
 load

Expect this to move into stable GitFileTree if it is reported to work.

Next steps for gitfiletree are a metadata-less mode (for Alexandre
:)) and svn support (aka SVNFileTree ;)).

Regards,

Thierry







Re: [Pharo-users] [ANN] Windows support for GitFileTree

2015-10-12 Thread Hernán Morales Durand
Hi Thierry,

Providing some feedback here.

I couldn't add a remote repository (image hangs) using Pharo 5. Working
with GitHub Bash and SSH connections I think one needs to re-use ssh-agent
environment variables before launching git commands. For example if
ssh-agent.exe was sucessfully started and MSYS says:

$ env | grep ^SSH
SSH_AGENT_PID=5784
SSH_AUTH_SOCK=/tmp/ssh-Jpgwx10860/agent.10860

then from CMD.exe one could get both values using:

C:\> wmic process where ExecutablePath='c:\\Program Files
(x86)\\Git\\bin\\ssh-agent.exe' get ProcessId

C:\> find /tmp/ssh-* -name agent.\* -uid $(id -u)|head -n 1

I have attached a change set with some refactorings and new methods to
enable setting ssh-agent variables. It is not finished and it needs review.
I do not have too much time but is a start, I hope.

Cheers,

Hernán






2015-10-09 18:35 GMT-03:00 Thierry Goubier :

> Hi all,
>
> thanks to the help of Nicolai and Levente (and others), GitFileTree has
> now working support for Windows users through ProcessWrapper (on the
> development versions).
>
> A way for it to work is to have git in your path and simply load:
>
> Metacello new
> configuration: 'GitFileTree';
> version: #'development';
> repository: '
> https://smalltalkhub.com/mc/Pharo/MetaRepoForPharo50/main';
> load
>
> Expect this to move into stable GitFileTree if it is reported to work.
>
> Next steps for gitfiletree are a metadata-less mode (for Alexandre :)) and
> svn support (aka SVNFileTree ;)).
>
> Regards,
>
> Thierry
>
>
'From Pharo5.0 of 16 April 2015 [Latest update: #50380] on 13 October 2015 at 1:16:17.804323 am'!

!MCFileTreeGitRepository class methodsFor: 'accessing' stamp: 'HernanMoralesDurand 10/13/2015 01:13'!
sshAgentPid
	" Answer a  with the pid of a running ssh-agent process 
	ToDo: if exist '%PROGRAMFILES(X86)%' "

	^ self runProcessWrapperCommand: 'wmic process where ExecutablePath=' , '''c:\\Program Files (x86)\\Git\\bin\\ssh-agent.exe ''' , ' get ProcessId'
! !

!MCFileTreeGitRepository class methodsFor: 'accessing' stamp: 'HernanMoralesDurand 10/10/2015 17:05'!
processWrapperClass
	" Answer the ProcessWrapper class or signal an exception if not found "

	^ Smalltalk
		at: #ProcessWrapper
		ifAbsent: [ self error: 'Please load ProcessWrapper' ]! !

!MCFileTreeGitRepository class methodsFor: 'accessing' stamp: 'HernanMoralesDurand 10/13/2015 01:14'!
sshAgentAuthSock
	" Answer a  with the pid of a running ssh-agent process.
	$SSH_AUTH_SOCK contains the path of the unix file socket that the agent uses for communication with other processes. This is essential for ssh-add. "
	"  '/tmp/ssh-Jpgwx10860/agent.10860' -> '10860'  "
	" find.exe and head.exe (MSYS commands) location should be in PATH environment variable "

	^ self runProcessWrapperCommand: 'find /tmp/ssh-* -name agent.\* -uid $(id -u)| head -n 1'! !

!MCFileTreeGitRepository class methodsFor: 'accessing' stamp: 'HernanMoralesDurand 10/13/2015 01:15'!
buildProcessWrapperGitCommand: aCommandString in: aDirectory
	" Answer a  with the git command to be used "
	
	^ self buildSSHAgentEnvVars ,
		' && ' ,
		self gitCommand , ' -C "' , (MCFileTreeFileUtils current directoryPathString: aDirectory) , '" ' , 
		aCommandString! !

!MCFileTreeGitRepository class methodsFor: 'accessing' stamp: 'HernanMoralesDurand 10/10/2015 17:23'!
buildSSHAgentEnvVars
	" Answer a  with DOS environment commands for connecting a runnning ssh-agent "

	^ String streamContents: [ : stream | 
		stream
			nextPutAll: 'set SSH_AGENT_PID=';
			nextPutAll: self sshAgentPid;
			cr;
			nextPutAll: 	'SSH_AUTH_SOCK=';
			nextPutAll: self sshAgentAuthSock
			cr ]
! !

!MCFileTreeGitRepository class methodsFor: 'accessing' stamp: 'HernanMoralesDurand 10/10/2015 16:55'!
runProcessWrapperGitCommand: anArrayOfStrings in: aDirectory
	"Enclose all parameters with double quotes to protect."

	| r aCommandString |
	aCommandString := String
		streamContents:
			[ :stream | 
			anArrayOfStrings
do:
	[ :e | 
	stream
		nextPut: $";
		nextPutAll: e;
		nextPutAll: '" ' ] ].
	r := self
		runProcessWrapperGitCommandString: aCommandString
		in: aDirectory.
	^ r! !

!MCFileTreeGitRepository class methodsFor: 'accessing' stamp: 'HernanMoralesDurand 10/10/2015 17:18'!
runProcessWrapperGitCommandString: aCommandString in: aDirectory

	| r command |

	command := self processWrapperClass new
useStdout;
useStderr;
startWithCommand: (self buildProcessWrapperGitCommand: aCommandString in: aDirectory);
yourself.
	command waitForExit.
	self assert: command isRunning not.
	r := command upToEnd.
	command exitCode > 0
		ifTrue: [ 
			self signalGitCommandError: command.
			r := '' ].
	^ r! !

!MCFileTreeGitRepository class methodsFor: 'accessing' stamp: 'HernanMoralesDurand 10/10/2015 17:00'!
signalGitCommandError: command
	| errorString |
	errorString := command errorUpToEnd.
	errorString notEmpty
		ifTrue:
			[ MCFileTreeGitError new signal: 'Git error: ' , errorStr

Re: [Pharo-users] [ANN] Windows support for GitFileTree

2015-10-09 Thread Alexandre Bergel
:-)

Excellent!

Alexandre


> On Oct 9, 2015, at 6:35 PM, Thierry Goubier  wrote:
> 
> Hi all,
> 
> thanks to the help of Nicolai and Levente (and others), GitFileTree has now 
> working support for Windows users through ProcessWrapper (on the development 
> versions).
> 
> A way for it to work is to have git in your path and simply load:
> 
> Metacello new
>   configuration: 'GitFileTree';
>   version: #'development';
>   repository: 'https://smalltalkhub.com/mc/Pharo/MetaRepoForPharo50/main';
>   load
> 
> Expect this to move into stable GitFileTree if it is reported to work.
> 
> Next steps for gitfiletree are a metadata-less mode (for Alexandre :)) and 
> svn support (aka SVNFileTree ;)).
> 
> Regards,
> 
> Thierry
> 

-- 
_,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:
Alexandre Bergel  http://www.bergel.eu
^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;.






[Pharo-users] [ANN] Windows support for GitFileTree

2015-10-09 Thread Thierry Goubier

Hi all,

thanks to the help of Nicolai and Levente (and others), GitFileTree has 
now working support for Windows users through ProcessWrapper (on the 
development versions).


A way for it to work is to have git in your path and simply load:

Metacello new
configuration: 'GitFileTree';
version: #'development';
repository: 'https://smalltalkhub.com/mc/Pharo/MetaRepoForPharo50/main';
load

Expect this to move into stable GitFileTree if it is reported to work.

Next steps for gitfiletree are a metadata-less mode (for Alexandre :)) 
and svn support (aka SVNFileTree ;)).


Regards,

Thierry