Skip to content
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
2 changes: 1 addition & 1 deletion DEVELOPMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ You can link that script into a directory within your search `$PATH`. This allow
* `build.sh` - Compile, test, generate docs and format source code
* `build.sh -f` - Compile only
* `build.sh -f -t` - Compile & test
* `build.sh -u` - Update dependencies before compiling
* `build.sh -c` - Update dependencies, regenerate documentation and format source files
* `build.sh -w` - Enter watch mode for automatic recompilation
* `build.sh -w -t` - Enter watch mode for automatic recompilation & running tests

Expand Down
1 change: 0 additions & 1 deletion docs/cmd/kn.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ Manage your Knative building blocks:

### SEE ALSO

* [kn completion](kn_completion.md) - Output shell completion code (default Bash)
* [kn revision](kn_revision.md) - Revision command group
* [kn route](kn_route.md) - Route command group
* [kn service](kn_service.md) - Service command group
Expand Down
30 changes: 0 additions & 30 deletions docs/cmd/kn_completion.md

This file was deleted.

1 change: 1 addition & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,7 @@ golang.org/x/time v0.0.0-20190308202827-9d24e82272b4 h1:SvFZT6jyqRaOeXpc5h/JSfZe
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/tools v0.0.0-20180221164845-07fd8470d635/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20180828015842-6cd1fcedba52/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20181011042414-1f849cf54d09 h1:6Cq5LXQ/D2J5E7sYJemWSQApczOzY1rxSp8TWloyxIY=
golang.org/x/tools v0.0.0-20181011042414-1f849cf54d09/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY=
Expand Down
33 changes: 22 additions & 11 deletions hack/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -47,16 +47,17 @@ run() {
fi

if $(has_flag --watch -w); then
# Build and test first
go_build
go_test

# Go in endless loop, to be stopped with CTRL-C
watch
# No exit, needs to be stopped with CTRL-C anyways
fi

if $(has_flag -u --update); then
if ! $(has_flag --fast -f) || $(has_flag --codegen -c); then
# Update dependencies
update_deps
fi

if ! $(has_flag --fast -f); then

# Format source code and cleanup imports
source_format
Expand All @@ -69,6 +70,11 @@ run() {
generate_docs
fi

# Stop when only codegen is requested
if $(has_flag --codegen -c); then
exit 0
fi

# Run build
go_build

Expand All @@ -91,7 +97,7 @@ source_format() {
which goimports >/dev/null 2>&1
if [ $? -ne 0 ]; then
echo "✋ No 'goimports' found. Please use"
echo "✋ go get golang.org/x/tools/cmd/goimports"
echo "✋ go install golang.org/x/tools/cmd/goimports"
echo "✋ to enable import cleanup. Import cleanup skipped."

# Run go fmt instead
Expand All @@ -112,8 +118,14 @@ go_build() {

go_test() {
local test_output=$(mktemp /tmp/kn-client-test-output.XXXXXX)
local red=""
local reset=""

local red=""
local reset=""
# Use color only when a terminal is set
if [ -t 1 ]; then
red=""
reset=""
fi

echo "🧪 ${S}Test"
set +e
Expand Down Expand Up @@ -240,10 +252,9 @@ Usage: $(basename $BASH_SOURCE) [... options ...]

with the following options:

-f --fast Only compile (without formatting, testing, doc generation)
-f --fast Only compile (without dep update, formatting, testing, doc gen)
-t --test Run tests when used with --fast or --watch
-i --imports Organize and cleanup imports
-u --update Update dependencies before compiling
-c --codegen Runs formatting, doc gen and update without compiling/testing
-w --watch Watch for source changes and recompile in fast mode
-h --help Display this help message
--verbose More output
Expand Down
23 changes: 0 additions & 23 deletions hack/update-deps.sh

This file was deleted.

36 changes: 10 additions & 26 deletions hack/verify-codegen.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,33 +20,17 @@ set -o pipefail

source $(dirname $0)/../vendor/github.com/knative/test-infra/scripts/library.sh

readonly TMP_DIFFROOT="$(mktemp -d ${REPO_ROOT_DIR}/tmpdiffroot.XXXXXX)"
# Needed later
go install golang.org/x/tools/cmd/goimports

cleanup() {
rm -rf "${TMP_DIFFROOT}"
}

trap "cleanup" EXIT SIGINT

cleanup

# Save working tree state
mkdir -p "${TMP_DIFFROOT}/vendor"
cp -aR "${REPO_ROOT_DIR}/go.sum" "${REPO_ROOT_DIR}/vendor" "${TMP_DIFFROOT}"

"${REPO_ROOT_DIR}/hack/update-deps.sh"
echo "Diffing ${REPO_ROOT_DIR} against freshly update dependencies"
ret=0
diff -Naupr --no-dereference "${REPO_ROOT_DIR}/vendor" "${TMP_DIFFROOT}/vendor" || ret=1

# Restore working tree state
rm -fr "${REPO_ROOT_DIR}/go.sum" "${REPO_ROOT_DIR}/vendor"
cp -aR "${TMP_DIFFROOT}"/* "${REPO_ROOT_DIR}"

if [[ $ret -eq 0 ]]
then
echo "${REPO_ROOT_DIR} up to date."
"${REPO_ROOT_DIR}"/hack/build.sh --codegen
if output="$(git status --porcelain)" && [ -z "$output" ]; then
echo "${REPO_ROOT_DIR} is up to date."
else
echo "ERROR: ${REPO_ROOT_DIR} is out of date. Please run ./hack/update-deps.sh"
echo "ERROR: Modified files found:"
git status --porcelain
echo "ERROR: Diff"
git diff
echo "ERROR: ${REPO_ROOT_DIR} is out of date. Please run ./hack/build.sh -u and commit."
exit 1
fi
6 changes: 3 additions & 3 deletions pkg/kn/commands/completion.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ func NewCompletionCommand(p *KnParams) *cobra.Command {
var completionFlags CompletionFlags

completionCmd := &cobra.Command{
Use: "completion",
Short: "Output shell completion code (default Bash)",
Hidden: true, // Don't show this in help listing.
Use: "completion",
Short: "Output shell completion code (default Bash)",
Hidden: true, // Don't show this in help listing.
Run: func(cmd *cobra.Command, args []string) {
if completionFlags.Zsh {
cmd.Root().GenZshCompletion(os.Stdout)
Expand Down