forked from ipfs/go-ds-s3
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathset-target.sh
executable file
·35 lines (27 loc) · 889 Bytes
/
set-target.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#!/bin/bash
GOCC="${GOCC:-go}"
set -eo pipefail
GOPATH="$($GOCC env GOPATH)"
VERSION="$1"
PKG=github.com/ipfs/go-ipfs
if [[ "$VERSION" == /* ]]; then
# Build against a local repo
MODFILE="$VERSION/go.mod"
$GOCC mod edit -replace "github.com/ipfs/go-ipfs=$VERSION"
else
$GOCC mod edit -dropreplace=github.com/ipfs/go-ipfs
# Resolve the exact version/package name
MODFILE="$(go list -f '{{.GoMod}}' -m "$PKG@$VERSION")"
resolvedver="$(go list -f '{{.Version}}' -m "$PKG@$VERSION")"
# Update to that version.
$GOCC get $PKG@$resolvedver
fi
TMP="$(mktemp -d)"
trap "$(printf 'rm -rf "%q"' "$TMP")" EXIT
(
cd "$TMP"
cp "$MODFILE" "go.mod"
go list -mod=mod -f '-require={{.Path}}@{{.Version}}{{if .Replace}} -replace={{.Path}}@{{.Version}}={{.Replace}}{{end}}' -m all | tail -n+2 > args
)
$GOCC mod edit $(cat "$TMP/args")
$GOCC mod tidy