Adds version command and Makefile for build info
Provides a `gitlocal version` command to display the application's version, commit hash, and build date. Introduces a `Makefile` to automate builds, installations, and tests. The Makefile dynamically extracts version, commit, and date from git tags, commit hashes, and build timestamps, injecting this metadata into the Go binary via `ldflags`. Updates the `README.md` to document the new command and recommended build process using the Makefile.
This commit is contained in:
35
README.md
35
README.md
@@ -74,6 +74,19 @@ Converted Repositories (2):
|
||||
Branch: master
|
||||
```
|
||||
|
||||
### Show version information
|
||||
|
||||
```bash
|
||||
gitlocal version
|
||||
```
|
||||
|
||||
Example output:
|
||||
```
|
||||
gitlocal version v0.1.0
|
||||
Commit: a1b2c3d
|
||||
Built: 2026-04-11T14:30:00Z
|
||||
```
|
||||
|
||||
## Using git with .gitlocal
|
||||
|
||||
Add this alias to your `.zshrc` or `.bashrc`:
|
||||
@@ -121,11 +134,27 @@ cd gitlocal
|
||||
# Install dependencies
|
||||
go mod download
|
||||
|
||||
# Build the binary
|
||||
# Build with version info (recommended - uses Makefile)
|
||||
make build
|
||||
|
||||
# Or install to $GOPATH/bin with version info
|
||||
make install
|
||||
|
||||
# Build without version info (not recommended)
|
||||
go build -o gitlocal
|
||||
|
||||
# Or install directly to $GOPATH/bin
|
||||
go install
|
||||
# Check version that would be built
|
||||
make version
|
||||
```
|
||||
|
||||
The Makefile automatically injects version information from git tags:
|
||||
- `Version`: Git tag (e.g., `v0.1.0`) or commit hash if no tag exists
|
||||
- `Commit`: Short commit hash
|
||||
- `Date`: Build timestamp
|
||||
|
||||
Check the version after installing:
|
||||
```bash
|
||||
gitlocal version
|
||||
```
|
||||
|
||||
### Running Tests
|
||||
|
||||
Reference in New Issue
Block a user