Publish to Monticello and mirror to git

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Publish to Monticello and mirror to git

hernanmd
Is it possible right now in Pharo 4 or 5 on any platform?

Cheers,

Hernán

Reply | Threaded
Open this post in threaded view
|

Re: Publish to Monticello and mirror to git

EstebanLM
This does not have anything to do with Pharo so no matter the version :)

I keep in sync the VMMaker repositories using a jenkins job with this script (from squeaksource to github):

#! /bin/bash

set -e

eval `ssh-agent`
ssh-add $HOME/.ssh/id_rsa_estebanlm

PACKAGES="'VMMaker.oscog'"
REPOSITORY=cog

# Clone
git clone -b spur64 [hidden email]:estebanlm/pharo-vm.git $REPOSITORY
cd $REPOSITORY
git config --local user.email "[hidden email]"
git config --local user.name "Esteban Lorenzano"
cd -


# Get Pharo (and prepare it)
wget -O- get.pharo.org/50+vm | bash
./pharo Pharo.image get OSProcess

# Execute sync script
./pharo Pharo.image eval "
| origin destination |

origin := (MCHttpRepository location: 'http://source.squeak.org/VMMaker')
        instVarNamed: 'cacheFileNames' put: true;
        yourself.
destination := MCFileTreeRepository new
        directory: '$REPOSITORY/mc' asFileReference ensureCreateDirectory;
        instVarNamed: 'cacheFileNames' put: true;
        yourself.
 
#($PACKAGES) do: [ :eachPackageName |
        | infoOrigin infoDest versionNumber newer |
       
        VTermOutputDriver stdout black: 'Updating ', eachPackageName; lf.
       
        infoOrigin := origin versionInfoFromVersionNamed: eachPackageName.
        infoDest := destination versionInfoFromVersionNamed: eachPackageName.
        versionNumber := infoDest versionNumber.
       
        newer := (({infoOrigin}, (infoOrigin allAncestors))
                select: [ :each |
                        each versionNumber > versionNumber
                                or: [
                                        each versionNumber = versionNumber
                                        and: [ each id ~= infoDest id ] ] ])
                sorted: [ :a :b | a timeStamp < b timeStamp ].
               
        newer do: [ :each | | summary |
                [
                        VTermOutputDriver stdout green: ('New version: ', each name); lf.
                       
                        VTermOutputDriver stdout << 'Store ' << each name << ' in ' << destination description; cr.
                        destination storeVersion: (origin versionFromFileNamed: (each name, '.mcz')).
                       
                        VTermOutputDriver stdout << 'Commit ' << each name; cr.
                        summary := each summary copyReplaceTokens: String cr with: String crlf.
  OSProcess waitForCommand: '(cd $REPOSITORY; git add -A ; git commit -m \"', summary, '\")' ]
                on: Error do: [ :e |
                        VTermOutputDriver stdout yellow: ('Warning: ', e messageText); lf ] ] ].

VTermOutputDriver stdout << 'OK'; cr.
"

cd $REPOSITORY
git push --force origin spur64
git branch --verbose
cd -

git stuff is to add my credentials, that’s because I use one of our structure servers. One of your own shouldn’t need that part.

basically, script does:

1) clone mirrored repo
2) run a script comparing PACKAGES and versions, generate a new export+commit for each new version.
3) does a push with all new commits

cheers,
Esteban


> On 30 Aug 2015, at 21:23, Hernán Morales Durand <[hidden email]> wrote:
>
> Is it possible right now in Pharo 4 or 5 on any platform?
>
> Cheers,
>
> Hernán
>


Reply | Threaded
Open this post in threaded view
|

Re: Publish to Monticello and mirror to git

hernanmd
Thank you for this Esteban.
I dreamed about a magic button in MC :)
cheers,

Hernán


2015-08-31 6:10 GMT-03:00 Esteban Lorenzano <[hidden email]>:
This does not have anything to do with Pharo so no matter the version :)

I keep in sync the VMMaker repositories using a jenkins job with this script (from squeaksource to github):

#! /bin/bash

set -e

eval `ssh-agent`
ssh-add $HOME/.ssh/id_rsa_estebanlm

PACKAGES="'VMMaker.oscog'"
REPOSITORY=cog

# Clone
git clone -b spur64 [hidden email]:estebanlm/pharo-vm.git $REPOSITORY
cd $REPOSITORY
git config --local user.email "[hidden email]"
git config --local user.name "Esteban Lorenzano"
cd -


# Get Pharo (and prepare it)
wget -O- get.pharo.org/50+vm | bash
./pharo Pharo.image get OSProcess

# Execute sync script
./pharo Pharo.image eval "
| origin destination |

origin := (MCHttpRepository location: 'http://source.squeak.org/VMMaker')
        instVarNamed: 'cacheFileNames' put: true;
        yourself.
destination := MCFileTreeRepository new
        directory: '$REPOSITORY/mc' asFileReference ensureCreateDirectory;
        instVarNamed: 'cacheFileNames' put: true;
        yourself.

#($PACKAGES) do: [ :eachPackageName |
        | infoOrigin infoDest versionNumber newer |

        VTermOutputDriver stdout black: 'Updating ', eachPackageName; lf.

        infoOrigin := origin versionInfoFromVersionNamed: eachPackageName.
        infoDest := destination versionInfoFromVersionNamed: eachPackageName.
        versionNumber := infoDest versionNumber.

        newer := (({infoOrigin}, (infoOrigin allAncestors))
                select: [ :each |
                        each versionNumber > versionNumber
                                or: [
                                        each versionNumber = versionNumber
                                        and: [ each id ~= infoDest id ] ] ])
                sorted: [ :a :b | a timeStamp < b timeStamp ].

        newer do: [ :each | | summary |
                [
                        VTermOutputDriver stdout green: ('New version: ', each name); lf.

                        VTermOutputDriver stdout << 'Store ' << each name << ' in ' << destination description; cr.
                        destination storeVersion: (origin versionFromFileNamed: (each name, '.mcz')).

                        VTermOutputDriver stdout << 'Commit ' << each name; cr.
                        summary := each summary copyReplaceTokens: String cr with: String crlf.
                        OSProcess waitForCommand: '(cd $REPOSITORY; git add -A ; git commit -m \"', summary, '\")' ]
                on: Error do: [ :e |
                        VTermOutputDriver stdout yellow: ('Warning: ', e messageText); lf ] ] ].

VTermOutputDriver stdout << 'OK'; cr.
"

cd $REPOSITORY
git push --force origin spur64
git branch --verbose
cd -

git stuff is to add my credentials, that’s because I use one of our structure servers. One of your own shouldn’t need that part.

basically, script does:

1) clone mirrored repo
2) run a script comparing PACKAGES and versions, generate a new export+commit for each new version.
3) does a push with all new commits

cheers,
Esteban


> On 30 Aug 2015, at 21:23, Hernán Morales Durand <[hidden email]> wrote:
>
> Is it possible right now in Pharo 4 or 5 on any platform?
>
> Cheers,
>
> Hernán
>



Reply | Threaded
Open this post in threaded view
|

Re: Publish to Monticello and mirror to git

Sean P. DeNigris
Administrator
In reply to this post by EstebanLM
EstebanLM wrote
with this script (from squeaksource to github):
For a Smalltalk solution, I've wrapped and tweaked the original MC script that was floating around on the lists. It needs a cleanup and won't work on Windows because I used NBMacShell, but could easily be cleaned up if others find it helpful. In Pharo 4.0 (may work in 5.0):
    Metacello new
        repository: 'github://seandenigris/MonticelloProjectMigrate/repository';
        baseline: 'McProjectMigrate';
        load.

See the class comment for a usage example:

        | source destination files |
        source := MCHttpRepository allSubInstances detect: [ :e | e location includesSubstring: 'Playground' ].
        destination := MCHttpRepository allSubInstances detect: [ :e | e location includesSubstring: 'Engelbart' ].

        files := source allVersionNames select: [ :e | e includesSubstring: 'Chord' ].
       
        McProjectMigrate new
                source: source;
                destination: destination;
                versionFilenames: files;
                execute.

For git, just specify a filetree repo as the destination, and you'll want to replace the final send of #execute with #executeBitbucket (nothing BitBucket-specific; as I said it needs a cleanup!).

N.B. The only part that is not handled is filtering existing versions. I wasn't sure how to compare mcz versions with their git counterparts, so it pushes them all by default.
Cheers,
Sean