update scripts

This commit is contained in:
Rick Olson 2015-05-25 12:30:14 -06:00
parent d678d4bf33
commit 67e13fa433
11 changed files with 14 additions and 158 deletions

3
.gitignore vendored

@ -1,8 +1,5 @@
bin/
benchmark/
.vendor/pkg
servertest
.vendor/src/github.com/github/git-lfs
# only allow man/*.\d.ronn files
man/*

@ -1,14 +1,5 @@
#!/bin/sh
script/fmt
rm -rf `pwd`/bin/*
rm -rf `pwd`/.vendor/pkg
export LOCALSRCDIR=`pwd`/.vendor/src/github.com/github/git-lfs
mkdir -p `dirname $LOCALSRCDIR`
rm -f $LOCALSRCDIR
ln -s `pwd` $LOCALSRCDIR
GOPATH="`pwd`/.vendor" \
go run script/*.go -cmd build "$@"
go run script/*.go -cmd build "$@"

@ -94,15 +94,7 @@ func build(buildos, buildarch string, buildMatrix map[string]Release) error {
dir = filepath.Join(dir, "releases", buildos+"-"+buildarch, name)
}
filepath.Walk("cmd/git-lfs", func(path string, info os.FileInfo, err error) error {
if !strings.HasSuffix(path, ".go") {
return nil
}
cmd := filepath.Base(path)
cmd = cmd[0 : len(cmd)-3]
return buildCommand(path, dir, buildos, buildarch)
})
buildCommand(dir, buildos, buildarch)
if addenv {
err := os.MkdirAll(dir, 0755)
@ -121,18 +113,16 @@ func build(buildos, buildarch string, buildMatrix map[string]Release) error {
return nil
}
func buildCommand(path, dir, buildos, buildarch string) error {
func buildCommand(dir, buildos, buildarch string) error {
addenv := len(buildos) > 0 && len(buildarch) > 0
name := filepath.Base(path)
name = name[0 : len(name)-3]
bin := filepath.Join(dir, name)
bin := filepath.Join(dir, "git-lfs")
if buildos == "windows" {
bin = bin + ".exe"
}
cmd := exec.Command("go", "build", "-o", bin, path)
cmd := exec.Command("go", "build", "-o", bin, ".")
if addenv {
cmd.Env = []string{
"GOOS=" + buildos,

@ -6,7 +6,7 @@ hash goimports 2>/dev/null && {
}
# don't run gofmt in these directories
ignored=(/bin/ /docs/ /log/ /man/ /tmp/ .vendor)
ignored=(/bin/ /docs/ /log/ /man/ /tmp/ /vendor/)
for i in */ ; do
if [[ ! ${ignored[*]} =~ "/$i" ]]; then
$formatter -w -l "$@" "${i%?}"

@ -1,114 +0,0 @@
#!/usr/bin/env bash
# Copied from https://github.com/pote/gpm
#
# The MIT License
#
# Copyright (c) 2013 Pablo Astigarraga
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
#
#
set -eu
## Functions/
usage() {
cat << EOF
SYNOPSIS
gpm leverages the power of the go get command and the underlying version
control systems used by it to set your Go dependencies to desired versions,
thus allowing easily reproducible builds in your Go projects.
A Godeps file in the root of your Go application is expected containing
the import paths of your packages and a specific tag or commit hash
from its version control system, an example Godeps file looks like this:
$ cat Godeps
# This is a comment
github.com/nu7hatch/gotrail v0.0.2
github.com/replicon/fast-archiver v1.02 #This is another comment!
github.com/nu7hatch/gotrail 2eb79d1f03ab24bacbc32b15b75769880629a865
gpm has a companion tool, called [gvp](https://github.com/pote/gvp) which
provides vendoring functionalities, it alters your GOPATH so every project
has its own isolated dependency directory, it's usage is recommended.
USAGE
$ gpm # Same as 'install'.
$ gpm install # Parses the Godeps file, installs dependencies and sets
# them to the appropriate version.
$ gpm version # Outputs version information
$ gpm help # Prints this message
EOF
}
# Iterates over Godep file dependencies and sets
# the specified version on each of them.
set_dependencies() {
deps=$(sed 's/#.*//;/^\s*$/d' < $1) || echo ""
while read package version; do
(
install_path="${GOPATH%%:*}/src/${package%%/...}"
[[ -e "$install_path/.git/index.lock" ||
-e "$install_path/.hg/store/lock" ||
-e "$install_path/.bzr/checkout/lock" ]] && wait
echo ">> Getting package "$package""
go get -u -d "$package"
echo ">> Setting $package to version $version"
cd $install_path
[ -d .hg ] && hg update -q "$version"
[ -d .git ] && git checkout -q "$version"
[ -d .bzr ] && bzr revert -q -r "$version"
[ -d .svn ] && svn update -r "$version"
) &
done < <(echo "$deps")
wait
echo ">> All Done"
}
## /Functions
case "${1:-"install"}" in
"version")
echo ">> gpm v1.2.0"
;;
"install")
deps_file="Godeps"
[[ "$#" -eq 2 ]] && [[ -n "$2" ]] && deps_file="$2"
[[ -f "$deps_file" ]] || (echo ">> $deps_file file does not exist." && exit 1)
(which go > /dev/null) ||
( echo ">> Go is currently not installed or in your PATH" && exit 1)
set_dependencies $deps_file
;;
"help")
usage
;;
*)
## Support for Plugins: if command is unknown search for a gpm-command executable.
if command -v "gpm-$1" > /dev/null
then
plugin=$1 &&
shift &&
gpm-$plugin $@ &&
exit
else
usage && exit 1
fi
;;
esac

@ -1,4 +1,3 @@
#!/bin/sh
script/fmt
GOPATH="`pwd`/.vendor" \
go run script/*.go -cmd release "$@"
go run script/*.go -cmd release "$@"

@ -1,2 +1,3 @@
#!/bin/sh
script/fmt
GOPATH="`pwd`/.vendor" go run cmd/git-lfs/git-lfs.go "$@"
go run ./git-lfs.go "$@"

@ -3,17 +3,8 @@
#/ script/test <subdir> # run just a package's tests
script/fmt
script/bootstrap
export LOCALSRCDIR=`pwd`/.vendor/src/github.com/github/git-lfs
mkdir -p `dirname $LOCALSRCDIR`
rm -f $LOCALSRCDIR
ln -s `pwd` $LOCALSRCDIR
GOPATH="`pwd`/.vendor"
SUITE="./${1:-"lfs ./commands"}"
suite="./${1:-"lfs ./commands"}"
if [ $# -gt 0 ]; then
shift
fi
PATH=$LOCALSRCDIR/bin:$PATH GOPATH=$GOPATH go test $SUITE -i "$@"
PATH=$LOCALSRCDIR/bin:$PATH GOPATH=$GOPATH go test $SUITE "$@"
go test $suite "$@"

@ -1 +1,2 @@
GOPATH="`pwd`/.vendor" script/gpm install
#!/bin/sh
nut install

@ -16,7 +16,7 @@
pflag under the name "flag" then all code should continue to function
with no changes.
import flag "github.com/github/git-lfs/vendor/_nuts/github.com/ogier/pflag"
import flag "github.com/ogier/pflag"
There is one exception to this: if you directly instantiate the Flag struct
there is one more field "Shorthand" that you will need to set.