2012-08-15 10 views

Respuesta

5

no he utilizado dulwich, pero a partir de these doc's, posiblemente algo como:

from dulwich.repo import Repo 
from dulwich.client import HttpGitClient 
local = Repo.init("local", mkdir=True) 
client = HttpGitClient('http://github.com/adammorris/') 
remote_refs = client.fetch("history.js.git",local) 
local["HEAD"] = remote_refs["refs/heads/master"] 

En este punto, no cargar los archivos, pero yo podía hacer "git checkout" de la ruta local y actualizó los archivos.

también para mirar a estos:

+0

Sí, la función de búsqueda insertará un archivo de paquete en el directorio '.git'. Y simplemente no sé cómo fusionarlo en la rama principal. – Determinant

+0

Parece que fetch() debería importar el paquete en la misma rama que el repositorio. ¿Es posible usar do_commit() para fusionarlo en la rama principal? http://stackoverflow.com/questions/6904734/in-dulwich-how-do-i-commit-to-a-branch-instead-of-to-head –

+0

Me temo que no ... – Determinant

1

Ejemplo completo. Funciona con Bitbucket.

from dulwich import index 
from dulwich.client import HttpGitClient 
from dulwich.repo import Repo 

local_repo = Repo.init(LOCAL_FOLDER, mkdir=True) 
remote_repo = HttpGitClient(REMOTE_URL, username=USERNAME, password=PASSWORD) 
remote_refs = remote_repo.fetch(REMOTE_URL, local_repo) 
local_repo[b"HEAD"] = remote_refs[b"refs/heads/master"] 

index_file = local_repo.index_path() 
tree = local_repo[b"HEAD"].tree 
index.build_index_from_tree(local_repo.path, index_file, local_repo.object_store, tree) 

Reemplace LOCAL_FOLDER, REMOTE_URL, NOMBRE DE USUARIO, CONTRASEÑA con sus datos.

Cuestiones relacionadas