Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix check_go_path when it has spaces in it #5261

Merged
merged 5 commits into from
Jul 23, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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