Source code management

From FreeCAD Documentation
Revision as of 22:29, 30 November 2014 by Renatorivo (talk | contribs) (Created page with " Resumen corto (50 caracteres o menos) de cambios Texto de explicación más detallado, si es necesario. En unos 72 caracteres. En algunos contextos, la primera línea es t...")

Our main source code management tool is git. This article explain how to use it and the general rules apply in case of FreeCAD. You are highly advised to learn how git works first (there is a lot of documentation and tutorials about git on the internet) before working with the FreeCAD source code.

There are also many good graphical clients to git, such as git-cola, that make the whole process of managing git repositories easier.

Access

Everybody can access and get a copy of the FreeCAD source code, but only the FreeCAD project managers have write access to it. You can get a copy of the code, study it and modify it as you wish, but if you make a change that you wish to see included in the official source code, you need to ask for a pull request on the pull requests section of the FreeCAD forum.

The procedure below show how to get a copy of the FreeCAD source code, from one of our two official repositories:

From Github

An easy way to start with the FreeCAD source code is using github. While the official FreeCAD Git repository is currently hosted on Sourceforge (see below), we also maintain an automatic mirror of the master branch on this github repository: https://github.com/FreeCAD/FreeCAD_sf_master

You can start simply by using the "fork" button on top of the above page. This will create a copy of the FreeCAD repository on your own github account. The general procedure is as follows:

  1. Create yourself a github account
  2. Go to https://github.com/FreeCAD/FreeCAD_sf_master
  3. Pres the "fork" button
  4. On your machine, clone your newly created freecad fork
  5. Do your changes to the code
  6. Create a new branch
  7. Checkout to that new branch
  8. Commit your changes to that new branch
  9. Push that new branch to your github repo

You can also start normally, without using the "fork" button:

  1. clone the FreeCAD code with git
  2. Do your changes to the code
  3. create a new branch
  4. Checkout to that new branch
  5. Commit your changes to that new branch
  6. Create yourself an account on a public git server (github, gitorious, sourceforge or any other)
  7. Push your branch to that server

important Note: As our github repository is only a mirror, we don't watch it very carefully. Therefore, please don't use it for pull requests. If you have code you wish to see merged into the FreeCAD source code, please post a note in the pull requests section of the FreeCAD forum instead.

Via Sourceforge

Para acceder a un repositorio de Git en sf.net, configura tu cliente de Git como se indica a continuación:

   git://free-cad.git.sourceforge.net/gitroot/free-cad/free-cad  (sólo lectura)
 ssh://USERNAME@free-cad.git.sourceforge.net/gitroot/free-cad/free-cad (lectura/escritura) 

Reglas de acceso

Le daremos a todos los interesados en participar acceso de escritura al repositorio de Git siempre que se mantengan alejados de la rama principal (consejo).

Autentificación

El acceso de sólo lectura no pregunta por una contraseña.

El acceso de lectura/escritura utiliza tu contraseña de ssh o clave de ssh para autorizar tu acceso. Para realizar operaciones de escritura, tu administrador del proyecto debe garantizar que tienes acceso de escritura al repositorio.

Nota: - En todos los ejemplos de abajo, "USERNAME" representa el nombre de usuario de tu cuenta de SourceForge.net.

Cómo clonar un repositorio

Puedes simplemente clonar tu repositorio remoto y ponerte a trabajar:

git clone ssh://USERNAME@git.code.sf.net/p/free-cad/code REPONAME
cd REPONAME

La primera vez que intentes conectar al host free-cad.git.sourceforge.net, deberías ver un mensaje similar al siguiente:

The authenticity of host 'git.code.sf.net (216.34.181.91)' can't be established.
RSA key fingerprint is 86:7b:1b:12:85:35:8a:b7:98:b6:d2:97:5e:96:58:1d.
Are you sure you want to continue connecting (yes/no)? 

Antes de contestar 'yes' para aceptar la huella del host, asegúrate de que la huella es correcta para el host. Puedes encontrar una lista de claves de host SSH en la lista de huellas de claves de host SSH. Si recibes una advertencia de clave del host, por favor contacta con el equipo de SourceForge.net.

Configurando tu nombre de usuario en Git

Los usuarios deberían enviar a sus repositorios de proyecto utilizando sus nombres de usuario de SourceForge.net. Si no está definido globalmente, lo puedes definir localmente para el repositorio de Gir actual así:

git config user.name "YOUR NAME"
git config user.email "USERNAME@users.sourceforge.net"

Ahora puedes utilizar alguna combinación de los comandos "git add" y "git commit" para crear uno o más envíos en tu repositorio local.

From alternative repositories

The beauty of git is that everybody can clone a project, and start modifying the code. Several frequent collaborators of the FreeCAD project have their own git repository, where they build up their work before it is ready to be included in the official source code, or simply where they experiment new ideas. In certain cases, you might want to clone your FreeCAD code from one of these, instead of the official repos, to benefit from the changes their users did.

Be warned, though, that this is at your own risk, and only the two official repositories above are fully guaranteed to work and contain clean code.

It is also possible to attach several remote repositories to a same local FreeCAD git code, using the "git remote" command. This is useful to keep in sync with the master code branch, but keep an eye on the work of different developers.

En desarrollo

Antes de nada nunca desarrolles en el ramal principal! Crea un ramal local para el desarrollo. Puedes aprender a hacer esto aquí.

Ramificado

Una importante característica de Git es que es extremadamente sencillo trabajar con ramas y fusionarlas. La mejor forma de trabajar recomienda crear una nueva rama siempre que quieras trabajar en una nueva característica. La creación de una rama se hace con:

git branch myNewBranch
git checkout myNewBranch

o, ambas operaciones en una:

git checkout -b myNewBranch

siempre puedes comprobar con que rama estas:

git branch

Envío

Una vez que hagas algo de trabajo, envíalo con:

git commit -a

A diferencia de SVN, tienes que especificar los archivos que quieres enviar (o todos con la opción -a). Tu editor de texto se abrirá para permitirte escribir un mensaje de envío.

Publicación de tu trabajo en el repositorio de sourceforge

Después de hacer algunos cambios en tu ramal local y enviarlos (es decir, enviarlos "localmente") puedes enviar tu repositorio al servidor. Esto abre tu ramal al público y permite que los desarrolladores principales revisen e integren tu ramal en el principal.

git push my-branch

Publicación en otro repositorio

Git también te permite fusionar ramas de más de un repositorio. Si no tienes acceso de escritura al repositorio de Git de FreeCAD que ofrece sourceforge, también puedes definir una cuenta o cualquier huésped gratuito de Git como github o gitorious y decirle a otras personas que puedes obtener tus cambios de allí.

Escribiendo buenos mensajes de envío

Deberías tratar de trabajar en pedazos pequeños. Si no puedes resumir tus cambios en una frase, entonces posiblemente ha pasado pasado demasiado tiempo desde que hiciste un envío. También es importante que ofrezcas descripciones de tu trabajo que sean útiles y ayuden. Para los mensajes de envío, FreeCAD ha adoptado un formato mencionado en el libro Pro Git (mira #Otras lecturas).

 Resumen corto (50 caracteres o menos) de cambios
Texto de explicación más detallado, si es necesario. En unos 72 caracteres.
En algunos contextos, la primera línea es tratada como el tema
de un email y el resto del texto como el cuerpo. La línea en blanco
separando el tema del cuerpo es crítica (a menos que omitas el cuerpo por
completo); las herramientas de recálculo se pueden confundir si pones los
dos juntos.

Más párrafos van después de líneas en blanco. 

 - Las listas con viñetas también están bien

 - Tipicamente un guión o asterisco se utiliza para la viñeta, precedido 
   por un espacio en blanco, con líneas en blanco en medio, pero las 
   convenciones aquí varían

If you are doing a lot of related work, it has been suggested here that one should make as many commits large or small as makes sense for what you are working on using the short one sentence commit messages. When you want to merge, do a git log master..BRANCH and use the output as a basis for your quality commit message. Then when you merge to master use the --squash option and commit with your quality commit message. This will allow you to be very liberal with your commits and help to provide a good level of detail in commit messages without so many distinct descriptions.

Further reading