Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create simple version command #174

Merged
merged 1 commit into from
Sep 11, 2024
Merged

Conversation

bplunkett-stripe
Copy link
Collaborator

Description

Create simple version command to help with debugging

Motivation

None

Testing

It says "(devel)" beecause it is the version of the locally build command (which has no version). This code should print out the same info as go version -m (binary path)

New command:

 go run ./cmd/pg-schema-diff version                                                                                                   INT х │ 01:01:02
version=(devel)

Example of go version of latest commit sha (it's what's next to the mod). This uses the same go debug info under the hood, so I expect the version command on the installed binary to mirror its output

go version -m $(where pg-schema-diff)                                                                                                ✔ │ 4s │ 01:01:55
/Users/bplunkett/go/bin/pg-schema-diff: go1.22.0
        path    github.com/stripe/pg-schema-diff/cmd/pg-schema-diff
        mod     github.com/stripe/pg-schema-diff        v0.7.1-0.20240909221644-5fe8259b82bd    h1:jF5uaAlsiU0Txzf+7kviuIyqdLcwuAWAJALDH92kXkU=

@bplunkett-stripe bplunkett-stripe added the enhancement New feature or request label Sep 11, 2024
@@ -91,12 +91,12 @@ $ pg-schema-diff plan --dsn "postgres://postgres:postgres@localhost:5432/postgre
# Install
## CLI
```bash
go install github.com/stripe/pg-schema-diff/cmd/pg-schema-diff
go install github.com/stripe/pg-schema-diff/cmd/pg-schema-diff@latest
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The command will error if @latest is not provided

Short: "Get the version of pg-schema-diff",
}
cmd.RunE = func(_ *cobra.Command, _ []string) error {
buildInfo, ok := debug.ReadBuildInfo()
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because we don't build the binary in our CI/CD pipeline, this is the best way to retrieve debug information for the binary.

@bplunkett-stripe bplunkett-stripe merged commit bc41f09 into main Sep 11, 2024
8 checks passed
@bplunkett-stripe bplunkett-stripe deleted the bplunkett/version-cmd branch September 11, 2024 17:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants