Skip to content

feat: version string from git describe + fork banner#21

Open
rophy wants to merge 2 commits intomasterfrom
feat/version-string
Open

feat: version string from git describe + fork banner#21
rophy wants to merge 2 commits intomasterfrom
feat/version-string

Conversation

@rophy
Copy link
Copy Markdown
Owner

@rophy rophy commented Apr 11, 2026

Summary

  • Use git describe --tags --always for both CLI version string and Docker image tag
  • Replace per-component MAJOR.MINOR.PATCH assembly with single OLR_VERSION string
  • Add fork attribution banner in welcome message
  • Add make build-release target for production images
  • Fix missing ca-certificates in Dockerfile.release builder (--no-install-recommends broke HTTPS)

Version output

OpenLogReplicator v1.9.0.1-1-gc9f587ad
Forked by rophy from https://github.com/bersler/OpenLogReplicator, all credits to the original author Adam Leszczynski.
arch: x86_64, build-arch: , system: Linux, release: 6.8.0-101-generic, build: Debug, compiled: 2026-04-11 10:17, modules: Kafka OCI Prometheus Protobuf

Test plan

  • Redo log regression tests: 161 passed
  • SQL e2e tests (free-23): 36 passed, 20 skipped
  • Dev image build (make build) verified version output
  • Release image build (make build-release) verified version output

Summary by CodeRabbit

  • New Features

    • Git tag-based versioning for the app and Docker images; added a release build target producing version-tagged images.
  • Documentation

    • Startup banner now displays the consolidated version string and fork attribution with credit to the original author.
  • Chores

    • Automated propagation of derived version information across build tooling, Docker builds, and generated configuration.

- Use OLR_VERSION from `git describe --tags --always` for both the
  CLI version string and Docker image tag
- Replace MAJOR.MINOR.PATCH assembly with single OLR_VERSION string
- Add fork attribution banner in welcome message
- Add build-release Makefile target
- Fix missing ca-certificates in Dockerfile.release builder
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 11, 2026

📝 Walkthrough

Walkthrough

Derive OLR_VERSION from Git tags at configure time and propagate it through CMake, Docker builds, Make targets, and runtime banners; replace numeric major/minor/patch macros with a single string OpenLogReplicator_OLR_VERSION.

Changes

Cohort / File(s) Summary
CMake / Config
CMakeLists.txt, config.h.in
Populate OLR_VERSION from git describe when unset, fall back to PROJECT_VERSION; replace numeric version macros with OpenLogReplicator_OLR_VERSION string macro (@OLR_VERSION@).
Dockerfiles
Dockerfile.dev, Dockerfile.release
Add ARG OLR_VERSION; conditionally pass -DOLR_VERSION=<value> into CMake; release Dockerfile also adds ca-certificates and uses OLR_VERSION for image tag in docs/command.
Make automation
Makefile
Add OLR_VERSION ?= $(shell git describe --tags --always --dirty ...) and pass it to docker buildx build --build-arg OLR_VERSION=$(OLR_VERSION); add build-release target and update .PHONY.
Runtime messages
src/main.cpp, src/StreamClient.cpp
Replace startup banners to use OpenLogReplicator_OLR_VERSION and add fork/attribution lines pointing to rophy/upstream.

Sequence Diagram(s)

sequenceDiagram
    participant Dev as "Developer / CI (git)"
    participant Make as "Make / docker buildx"
    participant Docker as "Docker build (Dockerfile)"
    participant CMake as "CMake configure"
    participant Build as "Compiler / Build"
    participant App as "Runtime (binary)"

    Dev->>Make: run build / build-release (OLR_VERSION=$(git describe))
    Note right of Make: --build-arg OLR_VERSION
    Make->>Docker: docker buildx build (with OLR_VERSION)
    Docker->>CMake: cmake ... -DOLR_VERSION=<value> (conditional)
    CMake->>Build: configure files (populate config.h with OLR_VERSION)
    Build->>App: binary contains OpenLogReplicator_OLR_VERSION
    App->>Developer: startup banner prints OLR_VERSION
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

Possibly related PRs

Poem

🐰 I nibbled tags and found a name,
Poked it into CMake's game,
Docker holds the version tight,
Binaries wake and print it right.
Hooray—a tiny hopping fame! 🥕

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately and concisely summarizes the main changes: using git describe to generate a version string and adding a fork attribution banner.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/version-string

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
Makefile (1)

4-4: Consider avoiding hardcoded unknown for OLR_VERSION passed to CMake.

At Line 4, fallbacking to unknown means Docker builds always pass a non-empty version (Line 32), which bypasses CMake’s fallback to PROJECT_VERSION. Prefer keeping OLR_VERSION empty on git failure and using a separate tag fallback for image naming (Line 39).

Suggested refactor
-OLR_VERSION ?= $(shell git describe --tags --always --dirty 2>/dev/null || echo unknown)
+OLR_VERSION ?= $(shell git describe --tags --always --dirty 2>/dev/null)
+OLR_IMAGE_TAG ?= $(if $(OLR_VERSION),$(OLR_VERSION),unknown)
@@
-		-t rophy/openlogreplicator:$(OLR_VERSION) \
+		-t rophy/openlogreplicator:$(OLR_IMAGE_TAG) \

Also applies to: 32-32, 39-39

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@Makefile` at line 4, Change the OLR_VERSION assignment so it does not default
to the literal "unknown" when git describe fails (e.g., make OLR_VERSION empty
on failure) so CMake can fall back to PROJECT_VERSION; then introduce or use a
separate Docker image tag fallback for image naming (the tag used on the docker
build/push step referenced around line 39) so image naming still gets a
non-empty tag when needed. Specifically, update the OLR_VERSION variable
assignment (the OLR_VERSION ?= ... shell invocation) to return an empty string
on git failure, and update the docker tag logic (the variable used at the docker
build/push step) to explicitly fallback to a tag value when OLR_VERSION is
empty.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@Makefile`:
- Around line 33-34: The build argument for GIDOLR is incorrectly sourced from
the user ID; update the Makefile so GIDOLR uses the group ID command instead of
the user ID. Specifically, in the build-release invocation where --build-arg
GIDOLR and --build-arg UIDOLR are set, change the GIDOLR value to use id -g
(leaving UIDOLR using id -u) so GIDOLR and UIDOLR correctly reflect group and
user IDs respectively.

---

Nitpick comments:
In `@Makefile`:
- Line 4: Change the OLR_VERSION assignment so it does not default to the
literal "unknown" when git describe fails (e.g., make OLR_VERSION empty on
failure) so CMake can fall back to PROJECT_VERSION; then introduce or use a
separate Docker image tag fallback for image naming (the tag used on the docker
build/push step referenced around line 39) so image naming still gets a
non-empty tag when needed. Specifically, update the OLR_VERSION variable
assignment (the OLR_VERSION ?= ... shell invocation) to return an empty string
on git failure, and update the docker tag logic (the variable used at the docker
build/push step) to explicitly fallback to a tag value when OLR_VERSION is
empty.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: ec1d36c0-279d-4d73-b305-24e2beb239af

📥 Commits

Reviewing files that changed from the base of the PR and between da2d6d8 and c9f587a.

📒 Files selected for processing (7)
  • CMakeLists.txt
  • Dockerfile.dev
  • Dockerfile.release
  • Makefile
  • config.h.in
  • src/StreamClient.cpp
  • src/main.cpp

Comment thread Makefile Outdated
Fix GIDOLR using id -g instead of id -u in build-release target.
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (2)
Makefile (2)

30-30: Parameterize the release image repository.

Hardcoding rophy/openlogreplicator makes reuse in other forks/CI less flexible. Prefer a variable (for example OLR_RELEASE_IMAGE) and keep the target generic.

Also applies to: 39-39

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@Makefile` at line 30, Replace the hardcoded release image repository in the
Makefile targets that reference "rophy/openlogreplicator" by introducing a
variable (e.g., OLR_RELEASE_IMAGE) and use that variable inside the
build-release target (and the other target at line ~39); add a sensible default
assignment like OLR_RELEASE_IMAGE ?= rophy/openlogreplicator at the top of the
Makefile so callers/CI can override it, and update any docker build/tag or push
commands in the build-release and the related target to reference
$(OLR_RELEASE_IMAGE) instead of the fixed string.

4-4: Add defensive sanitization for Docker tag format safety.

While the repository currently uses safe version strings, OLR_VERSION should be sanitized before use as a Docker tag to handle potential edge cases where git describe output (e.g., from future annotated tags) contains characters invalid in Docker tags.

Suggested fix
 OLR_IMAGE ?= olr-dev:latest
+OLR_RELEASE_IMAGE ?= rophy/openlogreplicator
 CACHE_IMAGE ?= ghcr.io/bersler/openlogreplicator:ci
 BUILD_TYPE ?= Debug
 OLR_VERSION ?= $(shell git describe --tags --always --dirty 2>/dev/null || echo unknown)
+OLR_VERSION_TAG ?= $(shell printf '%s' '$(OLR_VERSION)' | sed 's/[^A-Za-z0-9_.-]/-/g')

@@
 build-release: ## Build OLR release image (minimal, multi-stage)
 	docker buildx build \
 		--build-arg OLR_VERSION=$(OLR_VERSION) \
@@
-		-t rophy/openlogreplicator:$(OLR_VERSION) \
+		-t $(OLR_RELEASE_IMAGE):$(OLR_VERSION_TAG) \
 		--load \
 		-f Dockerfile.release .

Also applies to: 39-39

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@Makefile` at line 4, Sanitize OLR_VERSION before using it as a Docker tag:
add a sanitized variable (e.g., SAFE_OLR_VERSION) derived from OLR_VERSION that
lowercases the string and replaces any character not allowed in Docker tags
(allow only [a-z0-9_.-]) with a safe substitute like '-' (or strip them), and
then use SAFE_OLR_VERSION wherever OLR_VERSION is used for Docker tagging (refer
to the OLR_VERSION variable and the Docker tag usage at the second occurrence
around line 39) so all docker tag operations use the cleaned value.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@Makefile`:
- Line 30: Replace the hardcoded release image repository in the Makefile
targets that reference "rophy/openlogreplicator" by introducing a variable
(e.g., OLR_RELEASE_IMAGE) and use that variable inside the build-release target
(and the other target at line ~39); add a sensible default assignment like
OLR_RELEASE_IMAGE ?= rophy/openlogreplicator at the top of the Makefile so
callers/CI can override it, and update any docker build/tag or push commands in
the build-release and the related target to reference $(OLR_RELEASE_IMAGE)
instead of the fixed string.
- Line 4: Sanitize OLR_VERSION before using it as a Docker tag: add a sanitized
variable (e.g., SAFE_OLR_VERSION) derived from OLR_VERSION that lowercases the
string and replaces any character not allowed in Docker tags (allow only
[a-z0-9_.-]) with a safe substitute like '-' (or strip them), and then use
SAFE_OLR_VERSION wherever OLR_VERSION is used for Docker tagging (refer to the
OLR_VERSION variable and the Docker tag usage at the second occurrence around
line 39) so all docker tag operations use the cleaned value.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 169453ba-de46-4c05-afb7-eb5922b21e44

📥 Commits

Reviewing files that changed from the base of the PR and between c9f587a and de2b2a4.

📒 Files selected for processing (1)
  • Makefile

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant