Skip to content

Instantly share code, notes, and snippets.

@neilk
Last active July 11, 2017 21:07
Show Gist options
  • Select an option

  • Save neilk/acbcbf83670a29f2937dc487e6677609 to your computer and use it in GitHub Desktop.

Select an option

Save neilk/acbcbf83670a29f2937dc487e6677609 to your computer and use it in GitHub Desktop.

Revisions

  1. neilk revised this gist Jul 11, 2017. 1 changed file with 16 additions and 9 deletions.
    25 changes: 16 additions & 9 deletions sbt-deps-changes
    Original file line number Diff line number Diff line change
    @@ -1,23 +1,31 @@
    #!/bin/bash
    #!/bin/bash

    # Find dependency changes in a branch in a scala project using sbt.
    # You have to have the https://github.com/jrudolph/sbt-dependency-graph plugin installed.

    # if you don't have `gsed`:
    # the standard `sed` on Mac OS X won't work, so make sure you have GNU sed. We assume you want to keep that separate
    # from your system sed, so just `brew install gnu-sed`
    # if you're on a unix with a proper sed:
    # just change the lines below to `sed`
    # the standard `sed` on Mac OS X won't work, so make sure to install GNU sed via brew.


    branch="$1"


    function is_git_clean() {
    [[ $(git status 2> /dev/null | tail -n1) =~ "nothing to commit" ]]
    }

    if ! is_git_clean; then
    echo "your git repo has changes. Commit them first";
    exit 1;
    fi


    git checkout master
    sbt dependencyList > /tmp/deps-master

    git checkout "$branch" # your branch
    sbt dependencyList > /tmp/deps-branch

    # sbt outputs ANSI colors, always. Strip them away
    # sbt outputs ANSI colors, always. Strip them away
    gsed -r "s/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[mGK]//g" /tmp/deps-master > /tmp/deps-master-plain
    gsed -r "s/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[mGK]//g" /tmp/deps-branch > /tmp/deps-branch-plain

    @@ -26,5 +34,4 @@ perl -wlne '/([\w-]+(\.[\w-]+)*:)+\d+(\.\d+)+/ and print $&' /tmp/deps-master-pl
    perl -wlne '/([\w-]+(\.[\w-]+)*:)+\d+(\.\d+)+/ and print $&' /tmp/deps-branch-plain | sort | uniq > /tmp/deps-branch-plain-uniq

    # and diff them
    diff /tmp/deps-{master,branch}-plain-uniq

    diff /tmp/deps-{master,branch}-plain-uniq
  2. neilk revised this gist Jul 6, 2017. 1 changed file with 6 additions and 0 deletions.
    6 changes: 6 additions & 0 deletions sbt-deps-changes
    Original file line number Diff line number Diff line change
    @@ -3,6 +3,12 @@
    # Find dependency changes in a branch in a scala project using sbt.
    # You have to have the https://github.com/jrudolph/sbt-dependency-graph plugin installed.

    # if you don't have `gsed`:
    # the standard `sed` on Mac OS X won't work, so make sure you have GNU sed. We assume you want to keep that separate
    # from your system sed, so just `brew install gnu-sed`
    # if you're on a unix with a proper sed:
    # just change the lines below to `sed`

    branch="$1"

    git checkout master
  3. neilk created this gist Jul 6, 2017.
    24 changes: 24 additions & 0 deletions sbt-deps-changes
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,24 @@
    #!/bin/bash

    # Find dependency changes in a branch in a scala project using sbt.
    # You have to have the https://github.com/jrudolph/sbt-dependency-graph plugin installed.

    branch="$1"

    git checkout master
    sbt dependencyList > /tmp/deps-master

    git checkout "$branch" # your branch
    sbt dependencyList > /tmp/deps-branch

    # sbt outputs ANSI colors, always. Strip them away
    gsed -r "s/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[mGK]//g" /tmp/deps-master > /tmp/deps-master-plain
    gsed -r "s/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[mGK]//g" /tmp/deps-branch > /tmp/deps-branch-plain

    # get just the package names
    perl -wlne '/([\w-]+(\.[\w-]+)*:)+\d+(\.\d+)+/ and print $&' /tmp/deps-master-plain | sort | uniq > /tmp/deps-master-plain-uniq
    perl -wlne '/([\w-]+(\.[\w-]+)*:)+\d+(\.\d+)+/ and print $&' /tmp/deps-branch-plain | sort | uniq > /tmp/deps-branch-plain-uniq

    # and diff them
    diff /tmp/deps-{master,branch}-plain-uniq