Сегодня Kiln v3 был запущен с Kiln Harmony, который имеет встроенную поддержку Git (фактически, он позволяет и Mercurial, и Git на одних и тех же репозиториях!).
Как фанат Mercurial, я написал скрипт дляпериодически синхронизировать репо с GitHub, чтобы я мог размещать свой код на GitHub, но все равно ежедневно использовать только Mercurial.
Последняя версия функция PowerShell доступна как Gist ,но я вставил здесь и текущую версию для удобства.
<#
.SYNOPSIS
Script to sync a GitHub repo to Kiln to allw GitHub contributions without using Git (use Hg on your Kiln repos!).
.DESCRIPTION
Create a branch repo in Kiln specifically for for the GitHub sync and run this PS script periodically (PoSh v3
scheduled jobs make this easy).
Merge the GitHub branch repo (using Hg!) into your main repo periodically, then push back to the GitHub branch
once done. This will be sync'd back to GitHub when the script next runs.
Avoid simultaneous changes in the GitHub repo and the Kiln GitHub branch repo, as we don't want the automated
script merging (esp. as they could conflict).
.EXAMPLE
Sync-GitRepositories `
"$kilnBase/Misc/Group/NewSyncTest-GitHub.git" `
"$githubBase/NewSyncTest.git" `
"$tempSyncBase\Scripted"
#>
function Sync-GitRepositories
{
param(
[Parameter(Mandatory)]
[string]$gitRepo1,
[Parameter(Mandatory)]
[string]$gitRepo2,
[Parameter(Mandatory)]
[string]$tempSyncPath,
[string]$gitExecutable
)
# If we weren't given a path to git, assume it's in the path.
if (!$gitExecutable)
{ $gitExecutable = "git" }
# Clone the Kiln Github branch repo if we haven't already got a copy.
if (!(Test-Path $tempSyncPath))
{
& $gitExecutable clone $gitRepo1 $tempSyncPath | Out-Default
Push-Location $tempSyncPath
# Add a remote for the GitHub repo that we're syncing with.
& $gitExecutable remote add github $gitRepo2 | Out-Default
}
else
{
Push-Location $tempSyncPath
}
# Fetch changes from the Kiln GitHub branch repo and merge them in.
# Note: Use FastForward-Only to avoid merging (this is automated!), if changes are made to
# both GitHub and Kiln GitHub branch simultaneously, we'll have to manually resolve it.
# Errors from this script should be emailed to the user!
# Note: Always use -q because Git writes progress to STDERR! #WTF
& $gitExecutable fetch origin -q | Out-Default
& $gitExecutable merge origin/master --ff-only -q | Out-Default
# Repeat the process with any changes from GitHub.
& $gitExecutable fetch github -q | Out-Default
& $gitExecutable merge github/master --ff-only -q | Out-Default
# Push changes back to both Kiln GitHub branch repo and GitHub repo.
& $gitExecutable push origin : -q | Out-Default
& $gitExecutable push github : -q | Out-Default
Pop-Location
}