Skip to content

Commit

Permalink
Release v1.3.0 (#567)
Browse files Browse the repository at this point in the history
This release contains the following changes:
- AddTemplate template option.
- thriftbreak: support for changed types, new files, and optional JSON output.
- String() performance improvements for string type definitions.
  • Loading branch information
r-hang authored Apr 4, 2023
2 parents ceb8018 + 8837a25 commit 51abcb3
Show file tree
Hide file tree
Showing 214 changed files with 2,718 additions and 1,725 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
go: ["1.15.x", "1.16.x"]
go: ["1.17.x", "1.18.x"]
include:
- go: 1.16.x
- go: 1.18.x
latest: true

steps:
Expand Down
9 changes: 0 additions & 9 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,3 @@ cover.full.out
cover.html
.idea/

# We will explicitly whitelist vendored libraries that we want to check in.
vendor/*
!vendor/github.com/

/vendor/github.com/*
!vendor/github.com/fatih/

vendor/github.com/fatih/*
!vendor/github.com/fatih/structtag
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## [1.30.0] - 2023-04-04
### Added
- AddTemplate template option.
- thriftbreak: support for changed types, new files, and optional JSON output.
### Changed
- String() performance improvements for string type definitions.

## [1.29.2] - 2021-09-09
### Fixed
- Streaming now handles unrecongized fields and non-matching field types when
Expand Down Expand Up @@ -427,6 +434,7 @@ this release.
### Added
- Initial release.

[1.30.0]: https://github.com/thriftrw/thriftrw-go/compare/v1.29.2...v1.30.0
[1.29.2]: https://github.com/thriftrw/thriftrw-go/compare/v1.29.1...v1.29.2
[1.29.1]: https://github.com/thriftrw/thriftrw-go/compare/v1.29.0...v1.29.1
[1.29.0]: https://github.com/thriftrw/thriftrw-go/compare/v1.28.0...v1.29.0
Expand Down
19 changes: 9 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ LINT_EXCLUDES = \
plugin/api/plugin.go \
plugin/api/plugin_client.go \
plugin/api/servicegenerator.go \
plugin/api/servicegenerator_client.go \
vendor/
plugin/api/servicegenerator_client.go

# For tests on generated code, ignore deprecated warnings.
LINT_EXCLUDES += gen/.*_test.go:.*deprecated
Expand All @@ -33,20 +32,20 @@ LINT_EXCLUDES += unknown.*JSON.*option.*required
RAGEL_TAR = $(BUILD_DIR)/src/ragel-$(RAGEL_VERSION).tar.gz

GO_FILES := $(shell \
find . '(' -path '*/.*' -o -path './vendor' ')' -prune \
find . -path '*/.*' -prune \
-o -name '*.go' -print | cut -b3-)

# Installs dependencies listed in tools_test.go.
.PHONY: tools
tools:
go list -json tools_test.go | jq -r '.TestImports | .[]' | xargs -n1 go install

.PHONY: build
build: $(THRIFTRW)

.PHONY: ragel
ragel: $(RAGEL)

# Installs dependencies listed in tools_test.go.
.PHONY: tools
tools:
go list -json tools_test.go | jq -r '.TestImports | .[]' | xargs -n1 go install

$(THRIFTRW): $(GO_FILES)
go install .

Expand Down Expand Up @@ -122,8 +121,7 @@ COVER_IGNORE_FILES = \
$(wildcard plugin/api/*.go)

# literal space
space :=
space +=
space := $(subst ,, )

.PHONY: cover
cover:
Expand All @@ -133,4 +131,5 @@ cover:

.PHONY: clean
clean:
rm $(THRIFTRW)
go clean
2 changes: 1 addition & 1 deletion ast/annotation.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2021 Uber Technologies, Inc.
// Copyright (c) 2023 Uber Technologies, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
Expand Down
2 changes: 1 addition & 1 deletion ast/basetypeid_string.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion ast/constant.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2021 Uber Technologies, Inc.
// Copyright (c) 2023 Uber Technologies, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
Expand Down
2 changes: 1 addition & 1 deletion ast/definition.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2021 Uber Technologies, Inc.
// Copyright (c) 2023 Uber Technologies, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
Expand Down
2 changes: 1 addition & 1 deletion ast/doc.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2021 Uber Technologies, Inc.
// Copyright (c) 2023 Uber Technologies, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
Expand Down
2 changes: 1 addition & 1 deletion ast/header.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2021 Uber Technologies, Inc.
// Copyright (c) 2023 Uber Technologies, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
Expand Down
15 changes: 8 additions & 7 deletions ast/mock_visitor_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion ast/node.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2021 Uber Technologies, Inc.
// Copyright (c) 2023 Uber Technologies, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
Expand Down
2 changes: 1 addition & 1 deletion ast/position.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2021 Uber Technologies, Inc.
// Copyright (c) 2023 Uber Technologies, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
Expand Down
2 changes: 1 addition & 1 deletion ast/program.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2021 Uber Technologies, Inc.
// Copyright (c) 2023 Uber Technologies, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
Expand Down
2 changes: 1 addition & 1 deletion ast/type.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2021 Uber Technologies, Inc.
// Copyright (c) 2023 Uber Technologies, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
Expand Down
2 changes: 1 addition & 1 deletion ast/visitor.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2021 Uber Technologies, Inc.
// Copyright (c) 2023 Uber Technologies, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
Expand Down
2 changes: 1 addition & 1 deletion ast/walk.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2021 Uber Technologies, Inc.
// Copyright (c) 2023 Uber Technologies, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
Expand Down
109 changes: 109 additions & 0 deletions cmd/thriftbreak/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
// Copyright (c) 2023 Uber Technologies, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.

package main

import (
"encoding/json"
"errors"
"flag"
"fmt"
"io"
"log"
"os"

"go.uber.org/thriftrw/internal/compare"
"go.uber.org/thriftrw/internal/git"
)

func main() {
if err := run(os.Args[1:]); err != nil && !errors.Is(err, flag.ErrHelp) {
log.Fatalf("%+v", err)
}
}

// readableOutput prints every lint error on a separate line.
func readableOutput(w io.Writer) func(compare.Diagnostic) error {
return func(diagnostic compare.Diagnostic) error {
if _, err := fmt.Fprintln(w, &diagnostic); err != nil {
return fmt.Errorf("failed to output a lint error: %v", err)
}

return nil
}
}

// jsonOutput prints out every lint error in JSON format.
func jsonOutput(w io.Writer) func(compare.Diagnostic) error {
enc := json.NewEncoder(w)

return func(diagnostic compare.Diagnostic) error {
// Encode adds a trailing newline.
if err := enc.Encode(diagnostic); err != nil {
return fmt.Errorf("encode as JSON: %v", err)
}

return nil
}
}

func run(args []string) error {
flag := flag.NewFlagSet("thriftbreak", flag.ContinueOnError)
gitRepo := flag.String("C", "",
"location of git repository. Defaults to current directory.")
jsonOut := flag.Bool("json", false,
"output as a list of newline-delimited JSON objects with the following fields: FilePath and Message")
if err := flag.Parse(args); err != nil {
return err
}

if *gitRepo == "" {
cwd, err := os.Getwd()
if err != nil {
return fmt.Errorf("cannot determine current directory: %v", err)
}
*gitRepo = cwd
}

pass, err := git.Compare(*gitRepo)
// Errors in compiling phase, but not in backwards compatibility.
if err != nil {
return err
}

var write func(compare.Diagnostic) error
if *jsonOut {
write = jsonOutput(os.Stdout)
} else {
write = readableOutput(os.Stdout)
}
lints := pass.Lints()
for _, l := range lints {
if err := write(l); err != nil {
return fmt.Errorf("failed to output error: %v", err)
}
}

if len(lints) > 0 {
return fmt.Errorf("found %d issues", len(lints))
}

return nil
}
Loading

0 comments on commit 51abcb3

Please sign in to comment.