-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsemverUpdGoModToLatest
More file actions
executable file
·49 lines (43 loc) · 1.04 KB
/
semverUpdGoModToLatest
File metadata and controls
executable file
·49 lines (43 loc) · 1.04 KB
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/bin/bash
. $HOME/shell.scripts/YNQ.func
go mod tidy
updates=$(GOPROXY=direct go list -m -u all | grep ']$')
if [ $(echo "$updates" | wc -c) == 1 ]
then
echo "Nothing to update"
exit 0
fi
updates=$(echo "$updates" | sed -e 's/^/ /')
shout.smallHeader "available updates"
echo "$updates" |
perl -ane '
chomp;
print;
@oldParts = split(/\./, "[".$F[1]."]");
@newParts = split(/\./, $F[2]);
if ($oldParts[0] ne $newParts[0]) { print "\t\tBREAKING Change"; }
elsif ($oldParts[1] ne $newParts[1]) { print "\t\tMinor Change"; }
print "\n"
'
ChangesMade=0
for upd in $(echo "$updates" | sed -e 's/^ *//' -e 's/ v.* \[/@/' -e 's/\]$//')
do
if [ "$1" = "-a" ]
then
echo "applying update: $upd"
go mod edit -require $upd
ChangesMade=1
else
YNQ "update module to $upd" go mod edit -require $upd
if [ $? == 0 ] ; then ChangesMade=1 ; fi
fi
done
if [ $ChangesMade == 1 ]
then
shout.short "Tidying..."
go mod tidy
shout.short "Verifying..."
go mod verify
shout.short "Testing..."
go test -cover ./...
fi