Skip to content
Tamir Duberstein edited this page Mar 29, 2016 · 5 revisions
  • Get a PR locally, or create a PR from the current branch. Courtesy of @tamird. TODO: refuse to create a PR if the current branch diverged from the tracker.
#!/usr/bin/env sh

set -eu

error_message() {
  ret=$?
  if [ $ret -ne 0 ]; then
    echo "Something went wrong. Did you push your branch? Did you set a remote tracking branch?"
  fi
  exit $ret
}

trap error_message EXIT

if [ $# == 0 ]; then
  branch_name=$(git rev-parse --abbrev-ref HEAD)
  remote_name=$(git config branch."$branch_name".remote)

  github_forked_org_name=$(git config remote."$remote_name".url | sed -E -e 's,^(https://|git@)github.com[:/]([^\./]+)/[^\./]+(\.git)?,\2,')
  github_origin_proj_url=$(git config remote.origin.url         | sed -E -e 's,^(https://|git@)github.com[:/]([^\./]+/[^\./]+)(\.git)?,\2,')

  url="https://github.com/$github_origin_proj_url/compare/master...$github_forked_org_name:$branch_name?expand="

  open "$url"
else
  hub fetch origin refs/pull/"$1"/head:pr/"$1" && hub checkout pr/"$1"
fi
  • Determine the variables which are escaping to the heap for a given file. Courtesy of @nvanbenschoten.
#!/usr/bin/env bash

set -eu

if [ $# -eq 0 ]
then
        echo "usage: goescape <filename>"
        exit 1
fi

FILEPATH="$1"
DIR=$(dirname "$FILEPATH")
FILE=$(basename "$FILEPATH")

pushd "$DIR"
touch "$FILE"

go build -gcflags='-m' 2>&1 | \
        grep 'moved to heap' | \
        grep "$FILE"

popd
  • Home
  • Beta Dashboard
  • Release Process
  • [Building and running tests](Building and running tests)
    • [Using musl to get a completely static binary](Using musl to get a completely static binary)
  • Productivity
    • [Multiple GOPATHs](Multiple GOPATHs)
    • [Ben's Go Emacs setup](Ben's Go Emacs setup)
    • [Radu's vim setup](Radu's vim setup)
    • [Speeding up cgo builds](Speeding up cgo builds)
    • [Rando scripts](Rando scripts)
  • [Life of a transaction](Life of a transaction)
  • Readings
Clone this wiki locally