Source code management/es: Difference between revisions

From FreeCAD Documentation
(Updating to match new version of source page)
(Updating to match new version of source page)
Line 1: Line 1:
Our main source code management tool is [http://en.wikipedia.org/wiki/Git_%28software%29 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.
Our main source code management tool is [http://en.wikipedia.org/wiki/Git_%28software%29 git]. This article explains how to use it and how some general rules apply in the case of FreeCAD. You are highly advised to learn how git works first (there are a lot of tutorials and docs available for git on the internet) before working with the FreeCAD source code.


There are also many good graphical clients to git, such as [http://github.com/git-cola/git-cola git-cola], that make the whole process of managing git repositories easier.
There are also many good graphical clients to git, such as [http://github.com/git-cola/git-cola git-cola], that make the whole process of managing git repositories easier.


== Access ==
== Source Code 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 [http://forum.freecadweb.org/viewforum.php?f=17 pull requests] section of the FreeCAD forum.
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 [http://forum.freecadweb.org/viewforum.php?f=17 pull requests] section of the FreeCAD forum.


=== Official GitHub Repo ===
The procedure below show how to get a copy of the FreeCAD source code, from one of our two official repositories:
An easy way to start with the FreeCAD source code is using the official FreeCAD repository at
https://github.com/FreeCAD/FreeCAD


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:
=== From Github ===
# [https://github.com/join Sign up] for a GitHub account
An easy way to start with the FreeCAD source code is using [http://www.github.com 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
# Go to the FreeCAD repo: https://github.com/FreeCAD/FreeCAD
# Press the "Fork" button

# On your machine, clone your newly created FreeCAD fork:
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:
#: <pre>git clone https://github.com/<GitHubusername>/FreeCAD.git</pre>
# Create yourself a github account
# Make your specific changes to the source code
# Go to https://github.com/FreeCAD/FreeCAD_sf_master
# Pres the "fork" button
# On your machine, clone your newly created freecad fork
# Do your changes to the code
# Create a new branch
# Create a new branch
# Checkout to that new branch
# Checkout that new branch
# Commit your changes to that new branch
# Commit your changes to that new branch
# Push that new branch to your github repo
# Push that new branch to your GitHub repo


You can also start normally, without using the "fork" button:
You can also start normally, without using the "fork" button:
# clone the FreeCAD code with git
# Clone the FreeCAD code with git:
#: <pre>git clone https://github.com/FreeCAD/FreeCAD.git</pre>
# Do your changes to the code
# Make your specific changes to the code
# create a new branch
# Checkout to that new branch
# Create a new branch
# Checkout that new branch
# Commit your changes to that new branch
# Commit your changes to that new branch
# Create yourself an account on a public git server (github, gitorious, sourceforge or any other)
# Create an account on a public git server (GitHub, GitLab, etc...)
# Push your branch to that server
# Push your branch to that server


'''important Note''': If you have code you wish to see merged into the FreeCAD source code, please post a note in the [http://forum.freecadweb.org/viewforum.php?f=17 pull requests] section of the FreeCAD forum.
''Important Note''': If you have code you wish to see merged into the FreeCAD source code, please post a note in the [http://forum.freecadweb.org/viewforum.php?f=17 Pull Requests] section of the FreeCAD forum.

=== 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 ===
=== Reglas de acceso ===
Line 45: Line 38:
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).
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 ===
=== Authentication ===
The read-only access does not prompt for a password.

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.
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.
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 ===
=== Configurando tu nombre de usuario en Git ===
Line 69: Line 49:
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í:
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.name "YOUR NAME"
git config user.email "USERNAME@users.sourceforge.net"
git config user.email "USERNAME@users.noreply.github.com"
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.
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 ===
=== 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.
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.
Be warned, though, that this is at your own risk, and only the official repository above is 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.
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.
Line 102: Line 82:
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''.
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
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 [https://github.com/ github] o [http://gitorious.org/ gitorious] y decirle a otras personas que puedes obtener tus cambios de allí.


=== Escribiendo buenos mensajes de envío ===
=== Escribiendo buenos mensajes de envío ===

Revision as of 21:43, 6 February 2017

Our main source code management tool is git. This article explains how to use it and how some general rules apply in the case of FreeCAD. You are highly advised to learn how git works first (there are a lot of tutorials and docs available for 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.

Source Code 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.

Official GitHub Repo

An easy way to start with the FreeCAD source code is using the official FreeCAD repository at https://github.com/FreeCAD/FreeCAD

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. Sign up for a GitHub account
  2. Go to the FreeCAD repo: https://github.com/FreeCAD/FreeCAD
  3. Press the "Fork" button
  4. On your machine, clone your newly created FreeCAD fork:
    git clone https://github.com/<GitHubusername>/FreeCAD.git
  5. Make your specific changes to the source code
  6. Create a new branch
  7. Checkout 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:
    git clone https://github.com/FreeCAD/FreeCAD.git
  2. Make your specific changes to the code
  3. Create a new branch
  4. Checkout that new branch
  5. Commit your changes to that new branch
  6. Create an account on a public git server (GitHub, GitLab, etc...)
  7. Push your branch to that server

Important Note': 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.

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).

Authentication

The read-only access does not prompt for a password.

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.

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.noreply.github.com"

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.

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 official repository above is 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

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

Si estas haciendo un montón de trabajo relacionado, se sugiere aquí que deberías hacer tantos envíos grandes o pequeños como sea necesario para que tengan sentido en lo que estés trabajando utilizado los mensajes cortos de envío. Cuando quieras fusionarlos, haz un registro master..BRANCH y utiliza el resultado para tu mensaje de envío. Cuando fusionas con el principal utiliza la opción --squash y envía con tu mensaje de envío. Esto te permitirá ser muy liberal con tus envíos y ayudar a proporcionar un buen nivel de detalle en los mensajes de envío sin demasiadas descripciones distintas.

Otras lecturas