Skip to content

Instantly share code, notes, and snippets.

@toomasr
Forked from aslakknutsen/blog.md
Created November 2, 2012 13:26
Show Gist options
  • Select an option

  • Save toomasr/4001366 to your computer and use it in GitHub Desktop.

Select an option

Save toomasr/4001366 to your computer and use it in GitHub Desktop.

Revisions

  1. toomasr revised this gist Nov 2, 2012. 1 changed file with 3 additions and 1 deletion.
    4 changes: 3 additions & 1 deletion blog.md
    Original file line number Diff line number Diff line change
    @@ -18,7 +18,7 @@ REPO=$1
    START_TAG=$2

    MVN_COMMAND="mvn clean install"
    SONAR_COMMAND="mvn sonar:sonar"
    SONAR_COMMAND="mvn sonar:sonar -DskipTests=true -Psonar"

    if [ -z "$REPO" ]; then
    echo "Missing program argument: repository"
    @@ -29,6 +29,7 @@ fi
    pushd $REPO
    TAGS="`hg tags`"

    OLDIFS=$IFS
    IFS="
    "

    @@ -47,6 +48,7 @@ do

    SONAR_PROJECT_COMMAND="$SONAR_COMMAND -Dsonar.projectDate=$TAG_DATE"

    IFS=$OLDIFS
    echo "Executing Maven: $MVN_COMMAND"
    $MVN_COMMAND > /tmp/sonarifying.log 2>&1
    echo "Executing Sonar: $SONAR_PROJECT_COMMAND"
  2. toomasr revised this gist Nov 2, 2012. 1 changed file with 3 additions and 0 deletions.
    3 changes: 3 additions & 0 deletions blog.md
    Original file line number Diff line number Diff line change
    @@ -29,6 +29,9 @@ fi
    pushd $REPO
    TAGS="`hg tags`"

    IFS="
    "

    for tag in $TAGS
    do
    if [[ -n "$START_TAG" && "$START_TAG" > "$tag" ]] ; then
  3. toomasr revised this gist Nov 2, 2012. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion blog.md
    Original file line number Diff line number Diff line change
    @@ -18,7 +18,7 @@ REPO=$1
    START_TAG=$2

    MVN_COMMAND="mvn clean install"
    SONAR_COMMAND="mvn sonar:sonar -DskipTests=true -Psonar"
    SONAR_COMMAND="mvn sonar:sonar"

    if [ -z "$REPO" ]; then
    echo "Missing program argument: repository"
  4. toomasr revised this gist Nov 2, 2012. 1 changed file with 4 additions and 2 deletions.
    6 changes: 4 additions & 2 deletions blog.md
    Original file line number Diff line number Diff line change
    @@ -12,6 +12,8 @@ This little Bash script illustrates the concept. To spell out what it does in hu
    ```bash

    #!/bin/bash

    REPO=$1
    START_TAG=$2

    @@ -43,9 +45,9 @@ do
    SONAR_PROJECT_COMMAND="$SONAR_COMMAND -Dsonar.projectDate=$TAG_DATE"

    echo "Executing Maven: $MVN_COMMAND"
    $MVN_COMMAND
    $MVN_COMMAND > /tmp/sonarifying.log 2>&1
    echo "Executing Sonar: $SONAR_PROJECT_COMMAND"
    $SONAR_PROJECT_COMMAND
    $SONAR_PROJECT_COMMAND > /tmp/sonarifying.log 2>&1
    done
    popd
    ```
  5. toomasr revised this gist Nov 2, 2012. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion blog.md
    Original file line number Diff line number Diff line change
    @@ -35,7 +35,7 @@ do
    fi

    STAG=$(echo $tag | cut -d' ' -f1)
    TAG_DATE=`hg log -rtip --style=compact | head -n1 | cut -d' ' -f7`
    TAG_DATE=`hg log -r$STAG --style=compact | head -n1 | cut -d' ' -f7`

    echo "Checking out source from $TAG_DATE tagged as $tag"
    hg update -r $STAG -C
  6. toomasr revised this gist Nov 2, 2012. 1 changed file with 0 additions and 1 deletion.
    1 change: 0 additions & 1 deletion blog.md
    Original file line number Diff line number Diff line change
    @@ -46,7 +46,6 @@ do
    $MVN_COMMAND
    echo "Executing Sonar: $SONAR_PROJECT_COMMAND"
    $SONAR_PROJECT_COMMAND
    exit
    done
    popd
    ```
  7. toomasr revised this gist Nov 2, 2012. 1 changed file with 0 additions and 3 deletions.
    3 changes: 0 additions & 3 deletions blog.md
    Original file line number Diff line number Diff line change
    @@ -27,9 +27,6 @@ fi
    pushd $REPO
    TAGS="`hg tags`"

    #IFS="
    #"

    for tag in $TAGS
    do
    if [[ -n "$START_TAG" && "$START_TAG" > "$tag" ]] ; then
  8. toomasr revised this gist Nov 2, 2012. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion blog.md
    Original file line number Diff line number Diff line change
    @@ -9,8 +9,8 @@ By combining this property and what your version system does best, track changes
    This little Bash script illustrates the concept. To spell out what it does in human readable form:

    > for each tag in the given Mercurial repository, checkout the source and run sonar, using the tag date as projectDate
    ```bash
    #!/bin/bash

    REPO=$1
    START_TAG=$2
  9. toomasr revised this gist Nov 2, 2012. 1 changed file with 2 additions and 1 deletion.
    3 changes: 2 additions & 1 deletion blog.md
    Original file line number Diff line number Diff line change
    @@ -9,7 +9,7 @@ By combining this property and what your version system does best, track changes
    This little Bash script illustrates the concept. To spell out what it does in human readable form:

    > for each tag in the given Mercurial repository, checkout the source and run sonar, using the tag date as projectDate
    ```bash
    #!/bin/bash

    REPO=$1
    @@ -52,6 +52,7 @@ do
    exit
    done
    popd
    ```

    You can of course modify this script to fit your own need. Maybe you want to checkout the history pr week or pr month instead of using tags. It's up to you.

  10. toomasr revised this gist Nov 2, 2012. 1 changed file with 40 additions and 32 deletions.
    72 changes: 40 additions & 32 deletions blog.md
    Original file line number Diff line number Diff line change
    @@ -1,49 +1,57 @@
    When you do your first [Sonar](http://sonarsource.org) run on your project, you get a lot of new quality numbers to play with, but no trends. You only have one data set for comparison, the now picture.

    Wouldn't it be nice if you could see the current trend of the project without waiting a couple of month for the 'daily/weekly' Sonar runs to fill up the data? Well, you're in luck! And if you're using git as a version system as well, this is your day. :)
    Wouldn't it be nice if you could see the current trend of the project without waiting a couple of month for the 'daily/weekly' Sonar runs to fill up the data? Well, you're in luck! And if you're using Mercurial as a version system as well, this is your day. :)

    In the [Sonar Advanced Parameter](http://docs.codehaus.org/display/SONAR/Advanced+parameters) documentation you will find a System Property called *sonar.projectDate*. The property let you tell Sonar when in time the running analysis was ran.

    By combining this property and what your version system does best, track changes to source, we can now play back the history of the project as far as Sonar is concerned.

    This little Bash script illustrates the concept. To spell out what it does in human readable form:

    > for each tag in the given git repository, checkout the source and run sonar, using the tag date as projectDate
    > for each tag in the given Mercurial repository, checkout the source and run sonar, using the tag date as projectDate
    GIT_REPO=$1
    START_TAG=$2
    #!/bin/bash

    MVN_COMMAND="mvn clean install"
    SONAR_COMMAND="mvn org.codehaus.sonar:sonar-maven3-plugin:3.0:sonar"
    REPO=$1
    START_TAG=$2

    if [ -z "$GIT_REPO" ]; then
    echo "Missing program argument: repository"
    echo "Usage: ./sonar_history.sh git_repository_path [start-tag]"
    exit
    fi
    MVN_COMMAND="mvn clean install"
    SONAR_COMMAND="mvn sonar:sonar -DskipTests=true -Psonar"

    if [ -z "$REPO" ]; then
    echo "Missing program argument: repository"
    echo "Usage: ./sonar_history.sh repository_path [start-tag]"
    exit
    fi

    pushd $GIT_REPO
    for tag in `git tag`
    do
    if [[ -n "$START_TAG" && "$START_TAG" > "$tag" ]] ; then
    echo "Skipping $tag (start tag $START_TAG)"
    continue
    fi

    TAG_DATE=`git show $tag --date=iso | grep Date: -m1 | cut -d' ' -f 4`
    echo "Checking out source from $TAG_DATE tagged as $tag"
    git checkout $tag > /dev/null 2>&1
    git clean -df > /dev/null 2>&1

    SONAR_PROJECT_COMMAND="$SONAR_COMMAND -Dsonar.projectDate=$TAG_DATE"

    echo "Executing Maven: $MVN_COMMAND"
    $MVN_COMMAND > /dev/null 2>&1
    echo "Executing Sonar: $SONAR_PROJECT_COMMAND"
    $SONAR_PROJECT_COMMAND > /dev/null 2>&1
    done
    popd
    pushd $REPO
    TAGS="`hg tags`"

    #IFS="
    #"

    for tag in $TAGS
    do
    if [[ -n "$START_TAG" && "$START_TAG" > "$tag" ]] ; then
    echo "Skipping $tag (start tag $START_TAG)"
    continue
    fi

    STAG=$(echo $tag | cut -d' ' -f1)
    TAG_DATE=`hg log -rtip --style=compact | head -n1 | cut -d' ' -f7`

    echo "Checking out source from $TAG_DATE tagged as $tag"
    hg update -r $STAG -C

    SONAR_PROJECT_COMMAND="$SONAR_COMMAND -Dsonar.projectDate=$TAG_DATE"

    echo "Executing Maven: $MVN_COMMAND"
    $MVN_COMMAND
    echo "Executing Sonar: $SONAR_PROJECT_COMMAND"
    $SONAR_PROJECT_COMMAND
    exit
    done
    popd

    You can of course modify this script to fit your own need. Maybe you want to checkout the history pr week or pr month instead of using tags. It's up to you.

  11. @aslakknutsen aslakknutsen revised this gist Jun 17, 2012. No changes.
  12. @aslakknutsen aslakknutsen revised this gist Jun 17, 2012. 1 changed file with 0 additions and 3 deletions.
    3 changes: 0 additions & 3 deletions blog.md
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,3 @@
    How to import your project's history in Sonar
    ---------------------------------------------

    When you do your first [Sonar](http://sonarsource.org) run on your project, you get a lot of new quality numbers to play with, but no trends. You only have one data set for comparison, the now picture.

    Wouldn't it be nice if you could see the current trend of the project without waiting a couple of month for the 'daily/weekly' Sonar runs to fill up the data? Well, you're in luck! And if you're using git as a version system as well, this is your day. :)
  13. @aslakknutsen aslakknutsen revised this gist May 18, 2012. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion blog.md
    Original file line number Diff line number Diff line change
    @@ -26,7 +26,7 @@ This little Bash script illustrates the concept. To spell out what it does in hu
    fi

    pushd $GIT_REPO
    for tag in `git tag`
    for tag in `git tag`
    do
    if [[ -n "$START_TAG" && "$START_TAG" > "$tag" ]] ; then
    echo "Skipping $tag (start tag $START_TAG)"
  14. @aslakknutsen aslakknutsen revised this gist May 18, 2012. 1 changed file with 33 additions and 34 deletions.
    67 changes: 33 additions & 34 deletions blog.md
    Original file line number Diff line number Diff line change
    @@ -13,41 +13,40 @@ This little Bash script illustrates the concept. To spell out what it does in hu

    > for each tag in the given git repository, checkout the source and run sonar, using the tag date as projectDate
    ```bash
    GIT_REPO=$1
    START_TAG=$2

    MVN_COMMAND="mvn clean install"
    SONAR_COMMAND="mvn org.codehaus.sonar:sonar-maven3-plugin:3.0:sonar"

    if [ -z "$GIT_REPO" ]; then
    echo "Missing program argument: repository"
    echo "Usage: ./sonar_history.sh git_repository_path [start-tag]"
    exit
    fi

    pushd $GIT_REPO
    for tag in `git tag`
    do
    if [[ -n "$START_TAG" && "$START_TAG" > "$tag" ]] ; then
    echo "Skipping $tag (start tag $START_TAG)"
    continue
    fi
    GIT_REPO=$1
    START_TAG=$2

    MVN_COMMAND="mvn clean install"
    SONAR_COMMAND="mvn org.codehaus.sonar:sonar-maven3-plugin:3.0:sonar"

    if [ -z "$GIT_REPO" ]; then
    echo "Missing program argument: repository"
    echo "Usage: ./sonar_history.sh git_repository_path [start-tag]"
    exit
    fi

    pushd $GIT_REPO
    for tag in `git tag`
    do
    if [[ -n "$START_TAG" && "$START_TAG" > "$tag" ]] ; then
    echo "Skipping $tag (start tag $START_TAG)"
    continue
    fi

    TAG_DATE=`git show $tag --date=iso | grep Date: -m1 | cut -d' ' -f 4`
    echo "Checking out source from $TAG_DATE tagged as $tag"
    git checkout $tag > /dev/null 2>&1
    git clean -df > /dev/null 2>&1

    SONAR_PROJECT_COMMAND="$SONAR_COMMAND -Dsonar.projectDate=$TAG_DATE"

    echo "Executing Maven: $MVN_COMMAND"
    $MVN_COMMAND > /dev/null 2>&1
    echo "Executing Sonar: $SONAR_PROJECT_COMMAND"
    $SONAR_PROJECT_COMMAND > /dev/null 2>&1
    done
    popd
    ```
    TAG_DATE=`git show $tag --date=iso | grep Date: -m1 | cut -d' ' -f 4`
    echo "Checking out source from $TAG_DATE tagged as $tag"
    git checkout $tag > /dev/null 2>&1
    git clean -df > /dev/null 2>&1

    SONAR_PROJECT_COMMAND="$SONAR_COMMAND -Dsonar.projectDate=$TAG_DATE"

    echo "Executing Maven: $MVN_COMMAND"
    $MVN_COMMAND > /dev/null 2>&1
    echo "Executing Sonar: $SONAR_PROJECT_COMMAND"
    $SONAR_PROJECT_COMMAND > /dev/null 2>&1
    done
    popd


    You can of course modify this script to fit your own need. Maybe you want to checkout the history pr week or pr month instead of using tags. It's up to you.

  15. @aslakknutsen aslakknutsen renamed this gist May 18, 2012. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  16. @aslakknutsen aslakknutsen revised this gist Apr 19, 2012. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion sonar_history.md
    Original file line number Diff line number Diff line change
    @@ -11,7 +11,7 @@ By combining this property and what your version system does best, track changes

    This little Bash script illustrates the concept. To spell out what it does in human readable form:

    > for each tag in the given git repository, check out the source and run sonar, using the tag date as projectDate
    > for each tag in the given git repository, checkout the source and run sonar, using the tag date as projectDate
    ```bash
    GIT_REPO=$1
  17. @aslakknutsen aslakknutsen revised this gist Apr 19, 2012. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions sonar_history.md
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,5 @@
    How to import your project version history in Sonar
    ---------------------------------------------------
    How to import your project's history in Sonar
    ---------------------------------------------

    When you do your first [Sonar](http://sonarsource.org) run on your project, you get a lot of new quality numbers to play with, but no trends. You only have one data set for comparison, the now picture.

  18. @aslakknutsen aslakknutsen revised this gist Apr 19, 2012. 1 changed file with 5 additions and 1 deletion.
    6 changes: 5 additions & 1 deletion sonar_history.md
    Original file line number Diff line number Diff line change
    @@ -47,4 +47,8 @@ do
    $SONAR_PROJECT_COMMAND > /dev/null 2>&1
    done
    popd
    ```
    ```

    You can of course modify this script to fit your own need. Maybe you want to checkout the history pr week or pr month instead of using tags. It's up to you.

    Have fun! :)
  19. @aslakknutsen aslakknutsen revised this gist Apr 19, 2012. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion sonar_history.md
    Original file line number Diff line number Diff line change
    @@ -5,7 +5,7 @@ When you do your first [Sonar](http://sonarsource.org) run on your project, you

    Wouldn't it be nice if you could see the current trend of the project without waiting a couple of month for the 'daily/weekly' Sonar runs to fill up the data? Well, you're in luck! And if you're using git as a version system as well, this is your day. :)

    In the [Sonar Advanced Parameter](http://docs.codehaus.org/display/SONAR/Advanced+parameters) documentation you will find a System Property called @sonar.projectDate@. The property let you tell Sonar when in time the running analysis was ran.
    In the [Sonar Advanced Parameter](http://docs.codehaus.org/display/SONAR/Advanced+parameters) documentation you will find a System Property called *sonar.projectDate*. The property let you tell Sonar when in time the running analysis was ran.

    By combining this property and what your version system does best, track changes to source, we can now play back the history of the project as far as Sonar is concerned.

  20. @aslakknutsen aslakknutsen revised this gist Apr 19, 2012. 1 changed file with 3 additions and 0 deletions.
    3 changes: 3 additions & 0 deletions sonar_history.md
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,6 @@
    How to import your project version history in Sonar
    ---------------------------------------------------

    When you do your first [Sonar](http://sonarsource.org) run on your project, you get a lot of new quality numbers to play with, but no trends. You only have one data set for comparison, the now picture.

    Wouldn't it be nice if you could see the current trend of the project without waiting a couple of month for the 'daily/weekly' Sonar runs to fill up the data? Well, you're in luck! And if you're using git as a version system as well, this is your day. :)
  21. @aslakknutsen aslakknutsen revised this gist Apr 19, 2012. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions sonar_history.md
    Original file line number Diff line number Diff line change
    @@ -1,8 +1,8 @@
    When you do your first Sonar:sonarsource.org run on your project, you get a lot of new quality numbers to play with, but no trends. You only have one data set for comparison, the now picture.
    When you do your first [Sonar](http://sonarsource.org) run on your project, you get a lot of new quality numbers to play with, but no trends. You only have one data set for comparison, the now picture.

    Wouldn't it be nice if you could see the current trend of the project without waiting a couple of month for the 'daily/weekly' Sonar runs to fill up the data? Well, you're in luck! And if you're using git as a version system as well, this is your day. :)

    In the "Sonar Advanced Parameter":http://docs.codehaus.org/display/SONAR/Advanced+parameters documentation you will find a System Property called @sonar.projectDate@. The property let you tell Sonar when in time the running analysis was ran.
    In the [Sonar Advanced Parameter](http://docs.codehaus.org/display/SONAR/Advanced+parameters) documentation you will find a System Property called @sonar.projectDate@. The property let you tell Sonar when in time the running analysis was ran.

    By combining this property and what your version system does best, track changes to source, we can now play back the history of the project as far as Sonar is concerned.

  22. @aslakknutsen aslakknutsen revised this gist Apr 19, 2012. 1 changed file with 11 additions and 0 deletions.
    11 changes: 11 additions & 0 deletions sonar_history.md
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,14 @@
    When you do your first Sonar:sonarsource.org run on your project, you get a lot of new quality numbers to play with, but no trends. You only have one data set for comparison, the now picture.

    Wouldn't it be nice if you could see the current trend of the project without waiting a couple of month for the 'daily/weekly' Sonar runs to fill up the data? Well, you're in luck! And if you're using git as a version system as well, this is your day. :)

    In the "Sonar Advanced Parameter":http://docs.codehaus.org/display/SONAR/Advanced+parameters documentation you will find a System Property called @sonar.projectDate@. The property let you tell Sonar when in time the running analysis was ran.

    By combining this property and what your version system does best, track changes to source, we can now play back the history of the project as far as Sonar is concerned.

    This little Bash script illustrates the concept. To spell out what it does in human readable form:

    > for each tag in the given git repository, check out the source and run sonar, using the tag date as projectDate
    ```bash
    GIT_REPO=$1
  23. @aslakknutsen aslakknutsen revised this gist Apr 19, 2012. 1 changed file with 1 addition and 2 deletions.
    3 changes: 1 addition & 2 deletions sonar_history.md
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,5 @@


    ```
    ```bash
    GIT_REPO=$1
    START_TAG=$2

  24. @aslakknutsen aslakknutsen created this gist Apr 19, 2012.
    37 changes: 37 additions & 0 deletions sonar_history.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,37 @@


    ```
    GIT_REPO=$1
    START_TAG=$2
    MVN_COMMAND="mvn clean install"
    SONAR_COMMAND="mvn org.codehaus.sonar:sonar-maven3-plugin:3.0:sonar"
    if [ -z "$GIT_REPO" ]; then
    echo "Missing program argument: repository"
    echo "Usage: ./sonar_history.sh git_repository_path [start-tag]"
    exit
    fi
    pushd $GIT_REPO
    for tag in `git tag`
    do
    if [[ -n "$START_TAG" && "$START_TAG" > "$tag" ]] ; then
    echo "Skipping $tag (start tag $START_TAG)"
    continue
    fi
    TAG_DATE=`git show $tag --date=iso | grep Date: -m1 | cut -d' ' -f 4`
    echo "Checking out source from $TAG_DATE tagged as $tag"
    git checkout $tag > /dev/null 2>&1
    git clean -df > /dev/null 2>&1
    SONAR_PROJECT_COMMAND="$SONAR_COMMAND -Dsonar.projectDate=$TAG_DATE"
    echo "Executing Maven: $MVN_COMMAND"
    $MVN_COMMAND > /dev/null 2>&1
    echo "Executing Sonar: $SONAR_PROJECT_COMMAND"
    $SONAR_PROJECT_COMMAND > /dev/null 2>&1
    done
    popd
    ```