git

Git, Gits or GIT may refer to: read more at WikiPedia

  • Display the short GIT version hash as build identifier in TeamCity

    TeamCity is a Continuous integration and build management server from JetBrains.

    As the first build step, create a custom script that reads %build.number%, and uses service messages to append the short GIT hash programmatically.

    image

    Here’s an example using a bash script pasted right into the TeamCity GUI (Runner type: Command Line, Run: Custom Script):

    GIT_HASH=%build.vcs.number%
    GIT_HASH_SHORT=${GIT_HASH:0:7}
    echo "##teamcity[buildNumber '#${GIT_HASH_SHORT}']"
     
  • Enjoy Fighting regressions with git bisect

    As Git Bisect is not clear a lot of people, here is a nice PDF to look at Enjoy Fighting regressions with git bisect, LinuxCon EU 2013.pdf

    it is about "Linux" combinational explosion... Bug software have the following properties (not desired):

    • has many different "configurations"
    • may fail under one configuration but not another

    N configurations, T tests and C new commits means that a release needs:

    C * N * T tests performed

    where N and T, at least, are growing with the size of the software.

    Git Bisect help find a first bad commit and use a binary search algorithm for efficiency if possible.

  • git-branch-renamer-maven-plugin

    When working with many feature/release/bugix/hotfix branches, it is a bad idea to start changing the pom version as this will create merge conflicts using pull request. this plugin allow you to keep in ALL branches the same pom version for all your projects, for example MASTER-SNAPSHOT the version will be derived from branch name automagically :-)

    You may want to read more first these 2 short articles

    git-branch-renamer-maven-plugin allow you to keep in ALL branches the same pom version for all your projects: for example MASTER-SNAPSHOT and never change it again.

    the project version will be derived from branch name automatically when running in your continuous integration server.

    branch name feature/xxxx

    • <version>xxxx-SNAPSHOT</version> (default)
    • <version>xxxx</version> (release = true)
    • <version>0-xxxx-SNAPSHOT</version> (forceNumericalVersion = true)
    • <version>feature-xxxx-SNAPSHOT</version> (filterOutBranchQualifier = false)

    The project is hosted at Github https://github.com/cedricwalter/git-branch-renamer-maven-plugin 

  • Merging Two Git Repositories Into One Repository Without Losing File History

    There seems to be a lot of way to merge two #git repositories into one repository without losing file history. Here is another straightforward method.

    This method do not use #submodules or #subtree merges. it uses regular merge operations.

    1. Create a new empty repository New.
    2. Make an initial commit because we need one before we do a merge.
    3. Add a remote to old repository A.
    4. Merge A/master to New/master.
    5. Make a subdirectory folderA.
    6. Move all files into subdirectory folderA.
    7. Commit all of the file moves.
    8. Repeat 3-6 for another repository.
    mkdir result
    cd result
    git init
    touch README.MD
    git add .
    git commit -m "added readme.md"
    
    Step 3 to 6
    git remote add -f A https://github.com/A.git
    git fetch --all
    git merge --allow-unrelated-histories  A/master
    mkdir folderA
    git mv -k * folderA
    git commit -m “moved A files into subdir folderA”
    
  • Stitching several git repositories into a git fast-import stream

    git-stitch-repo

    Stitch several git repositories (merging git repository) into a git fast-import stream from Git-FastExport

    Installation

    $ perl -MCPAN -e shell
      
    cpan[6]> i /fastexport/
    	Distribution    BOOK/Git-FastExport-0.107.tar.gz
    	Module  < Git::FastExport        (BOOK/Git-FastExport-0.107.tar.gz)
    	Module  < Git::FastExport::Block (BOOK/Git-FastExport-0.107.tar.gz)
    	Module  < Git::FastExport::Stitch (BOOK/Git-FastExport-0.107.tar.gz)
    	4 items found
    
    cpan[6]> install BOOK/Git-FastExport-0.107.tar.gz
    
    cpan[6]> CTRL-D
    

    Usage

    git-stitch-repo will process the output of git fast-export --all --date-order on the git repositories given on the command-line, and create a stream suitable for git fast-import that will create a new repository containing all the commits in a new commit tree that respects the history of all the source repositories. Typical usage is like this:
    git clone https://github.com/xxxx/A.git
    git clone https://github.com/xxxxx/B.git
    
    $ ls
    A B
    
    mkdir result
    cd result
    git init
    git-stitch-repo ../A:folderA ../B:folderB | git fast-import
    
    # pull both repository in a new branch for examples
    git checkout -b newBranch
    git pull . master-A
    git pull . master-B
    
    # when finished delete unused branches
    git branch -d master-A 
    git branch -d master-B 
    
  • Update Maven pom version on GIT checkout in TeamCity

    Here is a solution to the following problems

    • Deriving #Maven artifact version from #GIT branch,
    • Update pom version on GIT checkout automatically,
    • Add the ability to use Pull request with Apache #Maven.

    You have a workflow requirement that require you to have the artifact version of a module externally defined from the current branch in GIT.

    For example

    You want to start working on a new feature branch “feature-memory-improvement”, so you branch from master a new branch named feature/feature-memory-improvement

    Having unique snapshot is a something you need to share your code using a #Maven repository, so you may want to have into the branch all pom.xml version changed to

    <version>FEATURE-MEMORY-IMPROVEMENT-SNAPHOTS</version>

    changing all your pom.xml and doing a technical commit  will create merge conflicts when using pull request!

    One solution, while not perfect is to do the following:  You can add a separate execution to run a goal which will change the version of the POM automatically in the #Maven reactor. This small script will do it¨