Source code management/fr

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
Pour accéder à un dépôt Git, configurez votre client Git comme suit :

git://free-cad.git.sourceforge.net/gitroot/free-cad/free-cad (read-only) ssh://USERNAME@free-cad.git.sourceforge.net/gitroot/free-cad/free-cad (read/write)

Règles d'accès
A ceux qui veulent participer : nous donnerons, à toutes personnes intéressées, un accès en écriture sur le dépôt git aussi longtemps que vous restez loin de la branche principale (conseil).

Authentification
L'accès en lecture seule ne demande pas de mot de passe.

L'accès lecture/écriture, utilise votre mot de passe SSH, ou une clé SSH, pour autoriser votre accès. Pour effectuer des opérations d'écriture, votre administrateur de projet, doit vous accorder l'accès en écrivez au référentiel.

Remarque : Dans tous les exemples ci-dessous, USERNAME représente votre compte utilisateur chez SourceForge.net.

Comment cloner le dépôt
Vous pouvez simplement cloner votre dépôt distant, et, vous mettre au travail : git clone ssh://USERNAME@git.code.sf.net/p/free-cad/code REPONAME cd REPONAME La première fois que vous essayez de vous connecter à l'hôte de free-cad.git.sourceforge.net, vous devriez voir un message similaire à celui-ci : 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)? Avant de taper «oui» et accepter la signature d'accueil, assurez vous que la signature digitale est correct pour l'hôte. Vous pouvez trouver une liste de clés d'hôtes SSH dans la liste des clés SSH, des signatures hôte. Si vous recevez un avertissement de clé d'hôte, s'il vous plaît contacter l'équipe SourceForge.net.

Configuration de votre nom d'utilisateur git
Les utilisateurs doivent s'engager à leur référentiel de projet, en utilisant leur nom d'utilisateur SourceForge.net. Si ce n'est pas déjà fait globalement, vous pouvez le régler au niveau local pour le dépôt Git actuel comme ceci : git config user.name "YOUR NAME" git config user.email "USERNAME@users.sourceforge.net" Vous pouvez maintenant utiliser une combinaison de commandes "git add" et "git commit" pour créer un, ou plusieurs commits dans votre dépôt 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.

Développement
Tout d'abord, ne jamais développer sur la branche principale ! Créer une branche locale de développement. Vous pouvez apprendre comment la faire ici.

Ramifications
Une caractéristique importante de Git, est qu'il est extrêmement facile de travailler avec des branches, et, les fusionner. La meilleure pratique recommande de créer une nouvelle branche à chaque fois que vous voulez travailler sur une nouvelle fonctionnalité.

Création d'une branche se fait avec : git branch myNewBranch git checkout myNewBranch or, both operation in one: git checkout -b myNewBranch you can always check in which branch you are with: git branch

Committing
Once you did some work, you commit them with: git commit -a Unlike SVN, you need to specifically tell which files to commit (or all with the -a option). Your text editor will open to allow you to write a commit message.

Publishing your work on the sourceforge repository
After done some changes on your local branch and commit it (this means commit locally) you can push your repository to the server. This opens your branch to the public and allows the main developers to review and integrate your branch into master. git push my-branch

Publishing on another repository
Git also allows you to merge branches from more than one repository. If you don't have write access to the sourceforge hosted FreeCAD Git repository, you can also setup an account on any other free Git host such as github or gitorious and tell other people to get your changes from there.

Writing good commit messages
You should try to work in small chunks. If you cannot summarize your changes in one sentence, then it has probably been too long since you have made a commit. It is also important that you have helpful and useful descriptions of your work. For commit messages, FreeCAD has adopted a format mentioned in book Pro Git (see ).

Short (50 chars or less) summary of changes More detailed explanatory text, if necessary. Wrap it to about 72 characters or so. In some contexts, the first line is treated as the subject of an email and the rest of the text as the body. The blank line separating the summary from the body is critical (unless you omit the body entirely); tools like rebase can get confused if you run the two together. Further paragraphs come after blank lines. - Bullet points are okay, too - Typically a hyphen or asterisk is used for the bullet, preceded by a   single space, with blank lines in between, but conventions vary here

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.