If you don't mind, I'll transform your script into a class and commit it
somewhere :)

On Wed, Jul 5, 2017 at 8:30 AM, Pavel Krivanek <[email protected]>
wrote:

> So loading of the PR packages is very simple. Do at the end:
>
> diff := IceDiff from: headCommit to: bootstrapCommit.
> diff changedPackages do: #reload.
>
>
>
> 2017-07-04 17:33 GMT+02:00 Pavel Krivanek <[email protected]>:
>
>> I prepared a script that should help you with the reviews of the pull
>> requests on Pharo 7. We will later convert it into a more fancy tool. It
>> does next steps:
>>
>> - sets the basic information: pull request number, path to your pharo
>> repository clone, name of your fork.
>> - registers the repository into Iceberg and sets pull and push target
>> remotes
>> - switches branch to a particular commit from which the Pharo image was
>> bootstrapped
>> - registers the repository into into Monticello packages to be able to do
>> correct diffs
>> - gets basic information about the pull request from GitHub (original
>> repository, branch name)
>> - registers the PR original repository into remotes if needed and fetches
>> information from it
>> - creates a new local branch to merge the PR
>> - merges the PR branch
>> - displays a simple tool that shows differences in done in this merged
>> branch
>>
>> --------
>>
>> pullRequest := 73.
>> target := '/path/pharo' asFileReference.
>> myForkName := 'myFork'.
>>
>> repository := IceRepositoryCreator new location: target;
>> subdirectory:'src'; createRepository.
>> repository register.
>> fork := repository remotes detect: [ :remote | remote remoteName =
>> myForkName ].
>> repository pushRemote: fork.
>> repository pullRemote: repository origin.
>> repository checkoutBranch: (SystemVersion current commitHash).
>>
>> fileTreeRepository := (MCFileTreeRepository new directory: target /
>> #src; yourself).
>> repositoryGroup := MCRepositoryGroup withRepositories: {
>> fileTreeRepository. MCCacheRepository uniqueInstance. }.
>> MCWorkingCopy allManagers
>> select: [ :wc | (wc repositoryGroup repositories reject: [ :repo | repo
>> isCache ]) isEmpty ]
>> thenDo: [ :wc | wc repositoryGroup: repositoryGroup ].
>>
>> stonString := (ZnEasy get: 'https://api.github.com/repos/
>> pharo-project/pharo/pulls/', pullRequest asString) contents.
>> head := (STONJSON fromString: stonString) at: 'head'.
>> sshUrl := (head at: #repo) at: 'ssh_url'.
>> branchName := head at: #ref.
>> user := (sshUrl withoutPrefix: '[email protected]:') withoutSuffix:
>> '/pharo.git'.
>>
>> fork := repository remotes detect: [ :remote | remote remoteName = user ]
>> ifNone: [
>> | newFork |
>> newFork := (IceRemote name: user url: ('[email protected]:{1}/pharo.git'
>> format: {user})).
>> repository addRemote: newFork.
>> newFork ].
>>
>> repository fetchFrom: fork.
>>
>> prMergedBranchName := 'pr', pullRequest asString.
>> repository createBranch: prMergedBranchName.
>> repository checkoutBranch: prMergedBranchName.
>>
>> commit := repository revparse: user, '/', branchName.
>> bootstrapCommit := repository revparse: (SystemVersion current
>> commitHash).
>> [ repository backend merge: commit id ]
>> on: IceMergeAborted
>> do: [ :error | repository mergeConflictsWith: commit   ] .
>> headCommit := repository revparse: 'HEAD'.
>>
>> browser := GLMTabulator new.
>> browser row: [:row | row column: #commits span: 2; column: #changes span:
>> 3]; row: #diff.
>> browser transmit to: #commits.
>> browser transmit to: #changes; from: #commits; andShow: [ :a :commitInfo
>> |
>> (IceDiffChangeTreeBuilder new entity: commitInfo; diff: (IceDiff from:
>> commitInfo to: bootstrapCommit); buildOn: a) title: 'Changes'. ].
>> browser transmit from: #commits; from: #changes; to: #diff; andShow: [
>> :a |
>> a diff title: 'Left: working copy / Right: incoming updates'; display: [
>> :commitInfo :change |
>> { change theirVersion ifNil: ''. change myVersion ifNil: ''. }]].
>> browser openOn: {headCommit}.
>>
>> --------
>>
>> The merge operation only changes the Git working copy, no code is loaded
>> into the image. If you want to test the PR code, currently you need to open
>> Iceberg and reload all packages in the Pharo repository (Packages tab,
>> Reload all)
>>
>> Expect troubles :-)
>>
>> Cheers,
>> -- Pavel
>>
>>
>>
>


-- 



Guille Polito


Research Engineer

French National Center for Scientific Research - *http://www.cnrs.fr*
<http://www.cnrs.fr>



*Web:* *http://guillep.github.io* <http://guillep.github.io>

*Phone: *+33 06 52 70 66 13

Reply via email to