FAQ Récupérer, mettre à jour les sources GIT du projet: Difference between revisions

Jump to navigation Jump to search
no edit summary
No edit summary
No edit summary
Line 1: Line 1:
[[Category:FAQ FR]]
[[Category:FAQ FR]]
{{TemplateDocDev}}
{{TemplateDocDevFr}}
{{ToTranslate}}
{{ToTranslate}}
This is informations on how you can get sources of Dolibarr project. This tutorial explains steps to follow using Eclipse IDE.
This is informations on how you can get sources of Dolibarr project.


= Prerequisite =  
=Get last version of sources by download=
First you must have a working install of Eclipse. '''EGit''' plugin must also have been installed.
This method allows you to get sources of main development branch (called HEAD): This operation consist to get last version of Dolibarr files that are packaged each night into a tgz file.
For this, use the '''Find And Install process''' into Eclipse menu, add the GIT update URL:
For this, go on page with [http://www.dolibarr.org/downloads/cat_view/64-development-version last source version of the day].


http://download.eclipse.org/egit/updates
New files overwrite old ones.
The inconvenient of this method is that you must download and uncompress package each time you want to get updates.


=Get last version of sources using a GIT anonymous access=
== Prerequisite ==
First you must have a working install of Eclipse. '''EGit''' plugin must also have been installed.
For this, use the '''Find And Install process''' into Eclipse menu, add the GIT update URL:
http://download.eclipse.org/egit/updates
Then choose to install '''EGit'''.
Then choose to install '''EGit'''.


=Get last version of sources using a GIT anonymous access=
To get sources with goal to edit them, you need a GitHub write access to the GIT remote repository, and a GIT client (GIT command line tool with Linux, or the GIT client in Eclipse). See next chapter for this.
 
To get sources with goal to edit them, you need a GitHub write access to the GIT remote repository, and a GIT client (GIT command line tool with Linux, or the GIT client in Eclipse).


First, enter value of the repository with reference sources into your GIT client tool.
First, enter value of the repository with reference sources into your GIT client tool.
Line 26: Line 30:


* With GIT on Command Line Interface:
* With GIT on Command Line Interface:
First setup your git client:
<source lang="bash">
git config --global user.name "Your Name"
git config --global user.email "user@domain.com"
git config --list
</source>
Then clone repository locally:
<source lang="bash">
<source lang="bash">
git clone git://github.com/Dolibarr/dolibarr.git dolibarr
git clone git://github.com/Dolibarr/dolibarr.git dolibarr
</source>
And, if you are behind a firewall, you can user the alternate URL:
<source lang="bash">
git config --global http.proxy http://proxyuser:proxypass@proxyserver:proxyport
git clone https://gitlogin:gitpassword@github.com/Dolibarr/dolibarr.git dolibarr
</source>
</source>


Line 33: Line 49:


Once download is finished, go into GIT view - Branches - Local. In most cases, the branch you choosed should be already available.
Once download is finished, go into GIT view - Branches - Local. In most cases, the branch you choosed should be already available.
If not, right click on "Branches - Remotes - The branch you want to duplicate locally".
 
If not:
* With Eclipse, right click on "Branches - Remotes - The branch you want to duplicate locally".
If you choose "Create Branch", this will duplicate content of branch to work on it locally.
If you choose "Create Branch", this will duplicate content of branch to work on it locally.
If you Choose "Checkout", this will update the view "Working Directory".
If you Choose "Checkout", this will update the view "Working Directory".
* With GIT on Command Line Interface;
<source lang="bash">
git checkout develop
git checkout x.y
</source>
This will create local branch and make checkout automatically.


Once your branch is created locally, create a PHP project from your Eclipse assistant by choosing "'''Create from existing project'''" and select directory that is your GIT local repository (Do not choose to create a PHP project from scratch).


If using Eclipse, once your branch is created locally, create a PHP project from assistant by choosing "'''Create from existing project'''" and select directory that is your GIT local repository (Do not choose to create a PHP project from scratch).
Then right click on project from your Eclipse workspace and Choose "'''Team - Share'''". Select GIT and click on option "'''Use or create repository in parent folder of project'''".
Then right click on project from your Eclipse workspace and Choose "'''Team - Share'''". Select GIT and click on option "'''Use or create repository in parent folder of project'''".
An alternate method is File->Import, Git->Project from Git, Select the Git repository and Next, Use New project Wizard -> Php project, enter the folder of you GIT local repository.
Then, you can setup Eclipse to avoid it to scan all project files for its build tools (Outline scanner, TODO scanner, syntax scanner...). This will avoid Eclipse to be too slow. For this, right click on project, choose Build Path and setup it like into following screenshot.
[[File:Eclipse php build path.png|240px]]


=Get last version of sources using a full GIT access=
=Get last version of sources using a full GIT access=
== Prerequisite ==
First you must have a working install of Eclipse. '''EGit''' plugin must also have been installed.
For this, use the '''Find And Install process''' into Eclipse menu, add the GIT update URL:
http://download.eclipse.org/egit/updates
Then choose to install '''EGit'''.
You must before create an account on GitHub (https://github.com/) and upload a public RSA or DSA certificate into your account profile.
You must before create an account on GitHub (https://github.com/) and upload a public RSA or DSA certificate into your account profile.


Line 67: Line 103:


= Commit and publish your changes =
= Commit and publish your changes =
To commit changes you made into your local repository, right click on file or directory to commit. This will validate changes into your local repository.
To see all changes you made into your working directory and waiting to be added into Git:
* With GIT Command Line Interface:
<source lang="bash">
git status
git diff subdir/filename
</source>


To upload them on the remote GIT repository, right click on project and choose "'''Team - Push to Upstream'''".
To add changes made into your local repository into the GIT index, then commit this index :
* With Eclipse: Right click on file or directory to commit. Select file to add/remove/update into commit.
* With GIT Command Line Interface:
<source lang="bash">
git commit -a -m "Commit text"
</source>
This will save add and changes into your local branch.
 
To push them on the GIT repository server,
* With Eclipse: right click on project and choose "'''Team - Push to Upstream'''".
* With GIT Command Line Interface:
<source lang="bash">
git push
</source>
 
To cancel a commit:
* With GIT Command Line Interface:
<source lang="bash">
git revert IdCommit  or  git revert HEAD  (for last commit)
</source>


= Add an external commit into current repository =
= Add an external commit into current repository =
Line 98: Line 158:
</source>
</source>


More information in GIT usage is available [http://wiki.eclipse.org/EGit/User_Guide here].
=Tagging sources=
To add a tag to a current version:
<source lang="bash">
git tag -m "Tag for x.y.z_YYYYMMDD" "x.y.z_YYYYMMDD"
git push --tags
</source>
 
=Creating a new branch=
This is command used to start a new branch from a clean develop cloned repository:
<source lang="bash">
git branch x.y
git push origin x.y
</source>
 
=Statistics=
To count number of changes developers have made between a version x and y:
* First, run git merge-base to know the id of last common commit between x and y
<source lang="bash">
git merge-base origin/3.1 origin/develop
</source>
* Then run git log to have list of all changes from last common commit to last commit
<source lang="bash">
git log id_found_at_previous_step..HEAD
</source>
* To get total number of added/deleted lines:
<source lang="bash">
git log --ancestry-path --numstat --pretty="%H" id_found_at_previous_step..HEAD | awk 'NF==3 {plus+=$1; minus+=$2} END {printf("+%d, -%d\n", plus, minus)}'
</source>
 


=Get last version of sources by download=
To count number of changes finally between a version x and y (it differs from previous count because in previous count, a change can be done 2 times at two different moment to change differently. With second method, you count change finally found if changes were ok at first try):
* Use same method than previously but instead of running git log, run git diff.
<source lang="bash">
git diff -b -M --numstat --pretty="%H" id_found_at_previous_step..HEAD | awk 'NF==3 {plus+=$1; minus+=$2} END {printf("+%d, -%d\n", plus, minus)}'
</source>


This method allows you to get sources of main development branch (called HEAD): This operation consist to get last version of Dolibarr files that are packaged each night into a tgz file.
For this, go on page with [http://www.dolibarr.org/downloads/cat_view/64-development-version last source version of the day].


New files overwrite old ones.
More information in GIT usage is available [http://wiki.eclipse.org/EGit/User_Guide here].
The inconvenient of this method is that you must download and uncompress package each time you want to get updates.

Navigation menu