Unverified Commit 86dc5db5 authored by Russell Cohen's avatar Russell Cohen Committed by GitHub
Browse files

Add pre-commit hooks (#17)

* Setup pre-commit

* Run precommit hook across all files

* Update README.md
parent 1d30ad06
Loading
Loading
Loading
Loading
+14 −0
Original line number Diff line number Diff line
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
  rev: v2.3.0
  hooks:
  - id: check-yaml
  - id: end-of-file-fixer
  - id: trailing-whitespace
- repo: https://github.com/macisamuele/language-formatters-pre-commit-hooks
  rev: v1.6.1
  hooks:
  - id: pretty-format-kotlin
    args: [--autofix, --ktlint-version, 0.39.0]
  - id: pretty-format-yaml
    args: [--autofix, --indent, '2']
+10 −3
Original line number Diff line number Diff line
@@ -10,3 +10,10 @@ installation instructions on your platform.
```./tesh.sh```

This will run all the unit tests, codegen an example model end-to-end and validates that the generated code compiles.

## Development
For development, pre-commit hooks may be useful. Setup:
```
brew install pre-commit # (or appropriate for your platform: https://pre-commit.com/)
pre-commit install
```
+1 −1
Original line number Diff line number Diff line
@@ -5,7 +5,6 @@

package software.amazon.smithy.rust.codegen.lang

import java.util.function.BiFunction
import software.amazon.smithy.codegen.core.CodegenException
import software.amazon.smithy.codegen.core.Symbol
import software.amazon.smithy.codegen.core.writer.CodegenWriter
@@ -17,6 +16,7 @@ import software.amazon.smithy.rust.codegen.smithy.RuntimeType
import software.amazon.smithy.rust.codegen.smithy.isOptional
import software.amazon.smithy.rust.codegen.smithy.rustType
import software.amazon.smithy.utils.CodeWriter
import java.util.function.BiFunction

fun <T : CodeWriter> T.withBlock(
    textBeforeNewLine: String,
+1 −1
Original line number Diff line number Diff line
@@ -5,7 +5,6 @@

package software.amazon.smithy.rust.codegen.smithy

import java.util.logging.Logger
import software.amazon.smithy.build.PluginContext
import software.amazon.smithy.codegen.core.SymbolProvider
import software.amazon.smithy.codegen.core.writer.CodegenWriterDelegator
@@ -29,6 +28,7 @@ import software.amazon.smithy.rust.codegen.smithy.generators.UnionGenerator
import software.amazon.smithy.rust.codegen.smithy.transformers.OperationNormalizer
import software.amazon.smithy.rust.codegen.util.CommandFailed
import software.amazon.smithy.rust.codegen.util.runCommand
import java.util.logging.Logger

private val PublicModules = listOf("error", "operation", "model")

+2 −2
Original line number Diff line number Diff line
@@ -5,13 +5,13 @@

package software.amazon.smithy.rust.codegen.smithy

import java.io.File
import java.util.Optional
import software.amazon.smithy.codegen.core.Symbol
import software.amazon.smithy.model.node.ObjectNode
import software.amazon.smithy.model.traits.TimestampFormatTrait
import software.amazon.smithy.rust.codegen.lang.RustDependency
import software.amazon.smithy.rust.codegen.lang.RustType
import java.io.File
import java.util.Optional

data class RuntimeConfig(val cratePrefix: String = "smithy", val relativePath: String = "../") {
    companion object {
Loading