Skip to content

Instantly share code, notes, and snippets.

@jpeak5
Last active October 27, 2017 14:46
Show Gist options
  • Select an option

  • Save jpeak5/920a966b3b8247ee0d7dd9ad3322cda9 to your computer and use it in GitHub Desktop.

Select an option

Save jpeak5/920a966b3b8247ee0d7dd9ad3322cda9 to your computer and use it in GitHub Desktop.

Revisions

  1. Jason Peak revised this gist Oct 27, 2017. 1 changed file with 15 additions and 8 deletions.
    23 changes: 15 additions & 8 deletions git-versions
    Original file line number Diff line number Diff line change
    @@ -11,11 +11,18 @@

    root=${1%%/}

    for d in $(find $1 -type d -name '.git'); do
    if [ -d $d ]
    then
    cd $d/..
    wkdir=$(pwd)/
    echo ${wkdir#$root} $(git -C $wkdir rev-parse HEAD) $(git -C $wkdir config --get remote.origin.url)
    fi
    done
    if [ -z $2 ]
    then
    for d in $(find $1 -type d -name '.git'); do
    if [ -d $d ]
    then
    cd $d/..
    wkdir=$(pwd)/
    echo ${wkdir#$root} $(git -C $wkdir rev-parse HEAD) $(git -C $wkdir config --get remote.origin.url)
    fi
    done
    else
    while IFS=' ' read dir rev branch remote; do
    git -C $root$dir fetch $branch
    done < $2
    fi
  2. Jason Peak revised this gist Oct 25, 2017. 1 changed file with 4 additions and 3 deletions.
    7 changes: 4 additions & 3 deletions git-versions
    Original file line number Diff line number Diff line change
    @@ -7,14 +7,15 @@
    # https://stackoverflow.com/questions/949314/how-to-retrieve-the-hash-for-the-current-commit-in-git
    # https://stackoverflow.com/questions/171550/find-out-which-remote-branch-a-local-branch-is-tracking
    # https://stackoverflow.com/questions/4089430/how-can-i-determine-the-url-that-a-local-git-repository-was-originally-cloned-fr
    # excellent - https://opensource.com/article/17/6/bash-parameter-expansion

    root=$1
    root=${1%%/}

    for d in $(find $root -type d -name '.git'); do
    for d in $(find $1 -type d -name '.git'); do
    if [ -d $d ]
    then
    cd $d/..
    wkdir=$(pwd)
    wkdir=$(pwd)/
    echo ${wkdir#$root} $(git -C $wkdir rev-parse HEAD) $(git -C $wkdir config --get remote.origin.url)
    fi
    done
  3. Jason Peak revised this gist Oct 25, 2017. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions git-versions
    Original file line number Diff line number Diff line change
    @@ -5,6 +5,8 @@
    # https://stackoverflow.com/questions/11981716/how-to-quickly-find-all-git-repos-under-a-directory
    # https://stackoverflow.com/questions/9612090/how-to-loop-through-file-names-returned-by-find
    # https://stackoverflow.com/questions/949314/how-to-retrieve-the-hash-for-the-current-commit-in-git
    # https://stackoverflow.com/questions/171550/find-out-which-remote-branch-a-local-branch-is-tracking
    # https://stackoverflow.com/questions/4089430/how-can-i-determine-the-url-that-a-local-git-repository-was-originally-cloned-fr

    root=$1

  4. Jason Peak revised this gist Oct 25, 2017. 1 changed file with 8 additions and 8 deletions.
    16 changes: 8 additions & 8 deletions git-versions
    Original file line number Diff line number Diff line change
    @@ -1,10 +1,10 @@
    #!/bin/bash
    ## thanks to
    # https://askubuntu.com/questions/429229/how-to-check-in-a-bash-script-if-passed-argument-is-file-or-directory
    # https://stackoverflow.com/questions/5311956/bash-remove-first-directory-component-from-variable-path-of-file
    # https://stackoverflow.com/questions/11981716/how-to-quickly-find-all-git-repos-under-a-directory
    # https://stackoverflow.com/questions/9612090/how-to-loop-through-file-names-returned-by-find
    # https://stackoverflow.com/questions/949314/how-to-retrieve-the-hash-for-the-current-commit-in-git
    #!/bin/bash
    ## thanks to
    # https://askubuntu.com/questions/429229/how-to-check-in-a-bash-script-if-passed-argument-is-file-or-directory
    # https://stackoverflow.com/questions/5311956/bash-remove-first-directory-component-from-variable-path-of-file
    # https://stackoverflow.com/questions/11981716/how-to-quickly-find-all-git-repos-under-a-directory
    # https://stackoverflow.com/questions/9612090/how-to-loop-through-file-names-returned-by-find
    # https://stackoverflow.com/questions/949314/how-to-retrieve-the-hash-for-the-current-commit-in-git

    root=$1

    @@ -13,6 +13,6 @@ for d in $(find $root -type d -name '.git'); do
    then
    cd $d/..
    wkdir=$(pwd)
    echo ${wkdir#$root} $(git -C $d rev-parse HEAD)
    echo ${wkdir#$root} $(git -C $wkdir rev-parse HEAD) $(git -C $wkdir config --get remote.origin.url)
    fi
    done
  5. Jason Peak created this gist Oct 25, 2017.
    18 changes: 18 additions & 0 deletions git-versions
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,18 @@
    #!/bin/bash
    ## thanks to
    # https://askubuntu.com/questions/429229/how-to-check-in-a-bash-script-if-passed-argument-is-file-or-directory
    # https://stackoverflow.com/questions/5311956/bash-remove-first-directory-component-from-variable-path-of-file
    # https://stackoverflow.com/questions/11981716/how-to-quickly-find-all-git-repos-under-a-directory
    # https://stackoverflow.com/questions/9612090/how-to-loop-through-file-names-returned-by-find
    # https://stackoverflow.com/questions/949314/how-to-retrieve-the-hash-for-the-current-commit-in-git

    root=$1

    for d in $(find $root -type d -name '.git'); do
    if [ -d $d ]
    then
    cd $d/..
    wkdir=$(pwd)
    echo ${wkdir#$root} $(git -C $d rev-parse HEAD)
    fi
    done