Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to publish to SmalltalkHub from Pharo without always entering your credentials?

Is there a way of setting the SmalltalkHub username and password in an environment variable or an external configuration file as opposed to setting them in every repository in every image? It gets old introducing them always.

like image 698
mircealungu Avatar asked Dec 15 '22 22:12

mircealungu


2 Answers

This is the solution I eventually found.

The MCHTTPRepository>>userAndPasswordFromSettingsDo: already has machinery for using credentials. It looks them up in the MCRepository.Settings class variable where it expects to find a Dictionary. Unfortunately that class variable is never set nor referenced anywhere in the image. There is also no accessor for it.

Thus, we patch the class with an accessor method for Settings and then set the account information in a startup script:

StartupLoader default executeAtomicItems: {
    StartupAction 
        name: 'Accounts'  
        code: [ 
               Author fullName: 'AuthorName'.
               MCRepository class compile: 'settings ^Settings ifNil: [ Settings := Dictionary new.]'.
               MCRepository settings 
                   at: 'account1' 
                   put: '*smalltalkhub.com* username:password'  ]
        runOnce: true
}

As in @Uko's example, the script should be in in ~/Library/Preferences/pharo.

like image 177
mircealungu Avatar answered Feb 15 '23 22:02

mircealungu


Ciao Mircea

So to set your Author name you can use personal.st script from my gist available here.

If you want to set up your credentials, you should create a similar startup action with:

MCRepositoryGroup default repositories
  select: [:each |
    (each isKindOf: MCHttpRepository) and:
    [each location includesSubstring: 'smalltalkhub.com' ]]
  thenDo: [ :repo |
    repo
      user: 'your_user_name';
      password: 'your_secret_password' ]
like image 35
Uko Avatar answered Feb 16 '23 00:02

Uko