Skip to content

Instantly share code, notes, and snippets.

@burtlo
Last active October 18, 2017 16:22
Show Gist options
  • Select an option

  • Save burtlo/8424cf6f841a523121ac54516b28376c to your computer and use it in GitHub Desktop.

Select an option

Save burtlo/8424cf6f841a523121ac54516b28376c to your computer and use it in GitHub Desktop.

Revisions

  1. @lynnvfrank lynnvfrank revised this gist Oct 18, 2017. 1 changed file with 20 additions and 13 deletions.
    33 changes: 20 additions & 13 deletions .studiorc
    Original file line number Diff line number Diff line change
    @@ -1,7 +1,9 @@
    # Usage:
    # Usage
    #
    # $ run pkg_name HEAD
    # $ run pkg_name HEAD~1
    # run pkg_name # Run the latest
    # run pkg_name HEAD # Run the latest
    # run pkg_name HEAD~1 # Run the second to last
    # run pkg_name ~1 # Run the second to last
    #
    function run() {
    local pkg_name=$1
    @@ -15,21 +17,26 @@ function run() {
    for i in ${!found_pkgs[@]}; do
    current_count=$((pkg_count-1-i))
    if [ $current_count == 0 ] ; then
    head_offset="HEAD"
    indexed_pkgs+=([HEAD]=${found_pkgs[$i]})
    else
    head_offset="HEAD~$current_count"
    indexed_pkgs+=([HEAD~$current_count]=${found_pkgs[$i]})
    indexed_pkgs+=([~$current_count]=${found_pkgs[$i]})
    fi

    indexed_pkgs+=([$head_offset]=${found_pkgs[$i]})
    done

    local pkg_to_run=${indexed_pkgs[$pkg_position]}
    # Run the latest package if no pkg_position has been specified.
    local pkg_to_run=${indexed_pkgs[HEAD]}

    # If there is a pkg_position then find that package. Stop if it cannot.
    if ! [ -z "$pkg_position" ] ; then
    pkg_to_run=${indexed_pkgs[$pkg_position]}

    if [ -z "$pkg_to_run" ] ; then
    echo "Could not find a package at $pkg_position. There are $pkg_count total package(s)."
    return
    if [ -z "$pkg_to_run" ] ; then
    echo "Could not find a package at $pkg_position. There are $pkg_count total package(s)."
    return
    fi
    fi

    echo "Running $pkg_to_run"
    hab sup start $pkg_to_run
    }
    }
  2. @lynnvfrank lynnvfrank revised this gist Oct 18, 2017. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions .studiorc
    Original file line number Diff line number Diff line change
    @@ -13,7 +13,7 @@ function run() {
    declare -A indexed_pkgs

    for i in ${!found_pkgs[@]}; do
    ((current_count=pkg_count-1-i))
    current_count=$((pkg_count-1-i))
    if [ $current_count == 0 ] ; then
    head_offset="HEAD"
    else
    @@ -32,4 +32,4 @@ function run() {

    echo "Running $pkg_to_run"
    hab sup start $pkg_to_run
    }
    }
  3. @lynnvfrank lynnvfrank revised this gist Oct 18, 2017. 1 changed file with 5 additions and 2 deletions.
    7 changes: 5 additions & 2 deletions .studiorc
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,8 @@
    # run pkg_name HEAD
    # run pkg_name HEAD~1
    # Usage:
    #
    # $ run pkg_name HEAD
    # $ run pkg_name HEAD~1
    #
    function run() {
    local pkg_name=$1
    local pkg_position=$2
  4. @lynnvfrank lynnvfrank renamed this gist Oct 18, 2017. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  5. @lynnvfrank lynnvfrank created this gist Oct 18, 2017.
    32 changes: 32 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,32 @@
    # run pkg_name HEAD
    # run pkg_name HEAD~1
    function run() {
    local pkg_name=$1
    local pkg_position=$2

    local found_pkgs=( ./results/$HAB_ORIGIN-$pkg_name-*.hart )
    local pkg_count=${#found_pkgs[@]}

    declare -A indexed_pkgs

    for i in ${!found_pkgs[@]}; do
    ((current_count=pkg_count-1-i))
    if [ $current_count == 0 ] ; then
    head_offset="HEAD"
    else
    head_offset="HEAD~$current_count"
    fi

    indexed_pkgs+=([$head_offset]=${found_pkgs[$i]})
    done

    local pkg_to_run=${indexed_pkgs[$pkg_position]}

    if [ -z "$pkg_to_run" ] ; then
    echo "Could not find a package at $pkg_position. There are $pkg_count total package(s)."
    return
    fi

    echo "Running $pkg_to_run"
    hab sup start $pkg_to_run
    }