Difference between revisions of "Git asynchronous development"
Line 24: | Line 24: | ||
=== Preparation === | === Preparation === | ||
As an example, we can take the development of the NMRPipe SeriesTab reader: [https://gna.org/support/index.php?3043 sr #3043: Support for NMRPipe seriesTab format *.ser] | As an example, we can take the development of the NMRPipe SeriesTab reader: [https://gna.org/support/index.php?3043 sr #3043: Support for NMRPipe seriesTab format *.ser] | ||
+ | |||
+ | We are going to make a support request '''sr''' branch. In this branch we add the files we would like to track for changes. Then we create a branch '''sr/seriestab''' from '''sr'''. We then track and create patches of the differences between '''sr/seriestab''' and '''sr'''. | ||
+ | |||
+ | Create the support request '''sr''' branch. | ||
+ | git co -b sr master | ||
+ | # See all branches | ||
+ | git br -a | ||
git add lib/software/nmrpipe.py | git add lib/software/nmrpipe.py |
Revision as of 12:39, 25 June 2013
Contents
Motivation
Subversion needs an online repository, to store each commits. Subsequent calls to svn diff > patch will generate the difference according to the last revision. Therefore the development at the moment, require to
- make some lines of code
- make a path file and a commit message
- use the support tracker to upload patch and commit message
- wait for acceptance
- wait for commit to official repository
- then do an svn update
- then return to point 1
This takes time, and require that repository maintainer is online.
If the above scheme is not followed, the patch files will come out of sync.
This can be solved by using git.
Initialization of git
Navigate to the root folder of the branch of relax, you want to develop. Initialize with:
git init
Setup commit information
If you havent set the repository variables for author information and commit message, this is good time. See Git_installation.
Example
Preparation
As an example, we can take the development of the NMRPipe SeriesTab reader: sr #3043: Support for NMRPipe seriesTab format *.ser
We are going to make a support request sr branch. In this branch we add the files we would like to track for changes. Then we create a branch sr/seriestab from sr. We then track and create patches of the differences between sr/seriestab and sr.
Create the support request sr branch.
git co -b sr master # See all branches git br -a git add lib/software/nmrpipe.py git commit
commit message
Added nmrpipe into git
# To see the commit message git log # Or see last changes by git log -p
Checking out a development branch
This section is modified from a how-to for Creating subversion patches with git. We want to be able to create patches and commit messages, which are seamless to patch into the subversion relax repository.
Modification 1
Then we modify, and add following
# Python module imports.
from re import split
# relax module imports.
from lib.errors import RelaxError
Then we make a patch
git diff > nmrpipe1
We add the change to be recorded
git add lib/software/nmrpipe.py
Then we commit
git commit
commit message. See Format_commit_logs.
Imported expected used modules in lib.software.nmrpipe.py.
Progress sr #3043: (https://gna.org/support/index.php?3043) Support for NMRPipe seriesTab format *.ser
Expected modules for use in lib\software\nmrpipe.py is imported.
To see the commit message
git log
If you would like to replace the last commit info
git commit --amend
Or see last changes by
git log -p
Modification 2
Then we modify, and add following
def read_list_intensity_seriestab(file_data=None, int_col=None):
"""Return the peak intensity information from the NMRPipe SeriesTab peak intensity file.
The residue number, heteronucleus and proton names, and peak intensity will be returned.
@keyword file_data: The data extracted from the file converted into a list of lists.
@type file_data: list of lists of str
@keyword int_col: The column containing the peak intensity data (for a non-standard formatted file).
@type int_col: int
@raises RelaxError: When the expected peak intensity is not a float.
@return: The extracted data as a list of lists. The first dimension corresponds to the spin. The second dimension consists of the proton name, heteronucleus name, residue number, the intensity value, and the original line of text.
@rtype: list of lists of str, str, int, float, str
"""
Then we make a patch
git diff > nmrpipe2
We add the change to be recorded
git add lib/software/nmrpipe.py
Then we commit
git commit
commit message. See Format_commit_logs.
Added doc string in lib.software.nmrpipe.py.
Progress sr #3043: (https://gna.org/support/index.php?3043) Support for NMRPipe seriesTab format *.ser
Doc string and variables for read_list_intensity_seriestab() function in lib.software.nmrpipe.py is provided.
To see the commit message
git log
If you would like to replace the last commit info
git commit --amend
Or see last changes by
git log -p -1
Getting an overview
This section is prepared from this site.
Export both commit message and change to last commit to file
git log -p -1 git log -p -1 > nmrpipe2_log
Using a GUI to Visualize History. If you like to use a more graphical tool to visualize your commit history, you may want to take a look at a Tcl/Tk program called gitk that is distributed with Git. Gitk is basically a visual git log tool, and it accepts nearly all the filtering options that git log does. Type gitk on the command line in your project.
gitk