Skip to content

Commit

Permalink
review suggestions
Browse files Browse the repository at this point in the history
Signed-off-by: Spolti <[email protected]>
  • Loading branch information
spolti committed Mar 12, 2024
1 parent d408f28 commit ce9ef7c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 13 deletions.
3 changes: 2 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@ COPY go.mod go.sum ./
# Install go protoc plugins
# no required module provides package google.golang.org/grpc/cmd/protoc-gen-go-grpc
# to add it run `go get google.golang.org/grpc/cmd/protoc-gen-go-grpc`
ENV PATH $HOME/go/bin:$PATH
ENV GOPATH $HOME/go
ENV PATH $GOPATH/bin:$PATH
RUN true \
&& go get google.golang.org/grpc/cmd/protoc-gen-go-grpc \
&& go install google.golang.org/protobuf/cmd/protoc-gen-go \
Expand Down
27 changes: 15 additions & 12 deletions scripts/add_headers.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,23 @@

if ! hash addlicense 2>/dev/null; then
go install github.com/google/addlicense@latest
# make sure we can actually use the newly install addlicense script
if ! command -v my_command >/dev/null 2>&1; then
echo "Can not find 'addlicense' after running 'go install github.com/google/addlicense'."
echo "GOPATH - $GOPATH"
echo 'Did you forget to export PATH=$PATH:$GOPATH/bin'
exit 1
fi
fi

# adds a new line between the header and the package keyword when it does not exists.
# we use sed to make in-file text replacements, but sed works differently depending on the version
if ! sed -i '1s/^/test/' $(mktemp) 2> /dev/null; then
# macOS (BSD) version of sed
alias gsed="sed -i ''"
else
# POSIX compliant version of sed
alias gsed="sed -i"
fi
export gsed

find . -type f -name "*.go" -exec gsed -e '/\/\/ limitations under the License\.$/{' -e 'N' -e 's/\(\/\/ limitations under the License.\)\n\(package\)/\1\n\n\2/;}' {} \;
for file in $(find . -type f -name "*.go"); do
sed -i.bak \
-e '/\/\/ limitations under the License\.$/{' \
-e 'N' \
-e 's/\(\/\/ limitations under the License.\)\n\(package\)/\1\n\n\2/;}' \
$file
rm -rf ${file}.bak
done

# add license to new files that does not contains it
shopt -s globstar
Expand Down

0 comments on commit ce9ef7c

Please sign in to comment.