2011-03-30 8 views
9

Soy un diseñador de frontend y no tengo un gran conocimiento de programación. Hago CSS/html y un poco de JavaScript. El equipo de tecnología de nuestra empresa ha trasladado nuestro control de versiones de Git (github) a Mercurial (Kiln). La única razón para ellos es obtener la función de revisión de código de Kiln (utilizamos Fogbugz y nos encanta).Sincronización automatizada entre Github y Kiln

El problema es que los frontendistas y los no desarrolladores que trabajan en nuestro control de versiones se divierten todo el tiempo. Usamos hg-git para implementar en Heroku y se usan para git (nunca funcionó con otros sistemas de control de versiones). Estoy seguro de que Mercurial es una gran herramienta, pero debo concluir que dedicamos demasiado tiempo a problemas y errores.

Mi pensamiento era: ¿Hay alguna forma de usar git en github y luego sincronizar todas las confirmaciones, etc., con Mercurial (horno)? Entonces podríamos usar git y seguir teniendo las características de revisión de código de Kiln.

Espero que pueda ayudar. Me encantaría volver a nuestro equipo de tecnología con una solución;)

Respuesta

8

Cualquier sincronización que configure será más propensa a errores que simplemente aprender Mercurial. Git y Mercurial son excelentes herramientas, y muy similares, por lo que si en lugar de ir por tareas poco a poco pasas una buena hora leyendo sobre las diferencias, podrás cambiar de un lado a otro sin ningún problema.

No-grandes opciones para la sincronización son: git-hg, hgit, y la extensión de conversión de Mercurial, y el apoyo de Mercurial para subrepositories git, pero te arrepentirás de cualquiera de ellos, ya que a requerir una mayor comprensión de tanto herramientas que usar cualquiera de ellas solo lo haría.

Haga que los desarrolladores vuelvan a cambiar o haga que reescriban sus instrucciones de implementación, pero no se moleste en instalarse dentro de la misma empresa.

2

¿Quizás podría usar un gancho post-commit de git para enviar/sincronizar sus cambios al horno usando git-hg?

+0

Gracias, lo investigaré :) – nikstep

+1

Interesante. No me importa nada votar, pero no me importaría una explicación :) ¡Estoy aquí para aprender también! –

+1

Tengo curiosidad por el voto negativo también. Parece que fue una respuesta más útil que la "correcta" desde mi punto de vista ingenuo. ¿Alguien tiene una explicación? He votado recientemente ... –

3

Hoy Kiln v3 se lanzó con Kiln Harmony que tiene soporte nativo Git (de hecho, ¡permite tanto a Mercurial como a Git en los mismos repositorios).

Como admirador de Mercurial, escribí un script para sincronizar un horno Repo periódicamente con GitHub, así que puedo alojar mi código en GitHub pero aún usar solo Mercurial a diario.

La última versión de the PowerShell function is available as a Gist, pero también he pegado la versión actual para su comodidad.

<# 
.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 
}