Skip to content

Commit

Permalink
Merge pull request #5261 from ipfs/fix/5260
Browse files Browse the repository at this point in the history
fix check_go_path when it has spaces in it
  • Loading branch information
whyrusleeping authored Jul 23, 2018
2 parents 8a29985 + 7a3566b commit 8ae5119
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 13 deletions.
35 changes: 23 additions & 12 deletions bin/check_go_path
Original file line number Diff line number Diff line change
@@ -1,19 +1,30 @@
#!/bin/sh
#!/usr/bin/env bash

PWD=$1
set -e

if [ -z "$PWD" ]; then
echo "must pass in your current working directory"
exit 1
PKG="$1"

DIR="$(pwd -P)"
GOPATH="$(go env GOPATH)"

# The path separator is ; on windows.
if [ "$(go env GOOS)" = "windows" ]; then
PATHSEP=';'
else
PATHSEP=':'
fi

while [ ${#} -gt 1 ]; do
if [ "$PWD" = "$2" ]; then
exit 0
fi
shift
done
while read -r -d "$PATHSEP" p; do
if ! cd "$p/src/$PKG" 2>/dev/null; then
continue
fi

if [ "$DIR" = "$(pwd -P)" ]; then
exit 0
fi
cd "$DIR"
done <<< "$GOPATH$PATHSEP"

echo "go-ipfs must be built from within your \$GOPATH directory."
echo "expected within '$(go env GOPATH)' but got '$PWD'"
echo "expected within '$GOPATH' but got '$DIR'"
exit 1
2 changes: 1 addition & 1 deletion mk/golang.mk
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ check_go_version:
DEPS_GO += check_go_version

check_go_path:
bin/check_go_path $(realpath $(shell pwd)) $(realpath $(addsuffix /src/github.com/ipfs/go-ipfs,$(subst $(PATH_SEP),$(space),$(GOPATH))))
GOPATH="$(GOPATH)" bin/check_go_path github.com/ipfs/go-ipfs
.PHONY: check_go_path
DEPS_GO += check_go_path

Expand Down

0 comments on commit 8ae5119

Please sign in to comment.