Skip to content

Conversation

koudis
Copy link
Member

@koudis koudis commented Jul 6, 2025

Summary by CodeRabbit

  • New Features

    • Introduced a utility to normalize Git repository URIs between SSH and HTTP(S) formats.
  • Documentation

    • Updated documentation to describe the new Git URI normalization utility.
  • Tests

    • Added comprehensive tests to verify correct normalization of Git URIs for both SSH and HTTP(S) formats.
    • Added tests to validate error handling for invalid URIs and unsupported target types.
  • Chores

    • Expanded test coverage to additional Linux distributions in CI workflows.

Copy link

coderabbitai bot commented Jul 6, 2025

"""

Walkthrough

A new CMake module, CMUTIL_NORMALIZE_GIT_URI.cmake, is introduced to normalize Git repository URIs between SSH and HTTP(S) formats. The build system is updated to include this module, and comprehensive tests—covering valid and invalid use cases—are added. Documentation in the README is updated to reflect the new functionality. The GitHub Actions workflow is extended to test on additional Linux distributions.

Changes

File(s) Change Summary
system_modules/CMUTIL_NORMALIZE_GIT_URI.cmake New module for normalizing Git URIs between SSH and HTTP(S) formats, with main and helper functions.
FindCMUTIL.cmake Includes the new CMUTIL_NORMALIZE_GIT_URI.cmake module.
README.md Documents the new normalization module and updates references.
test/CMakeLists.txt Adds the NORMALIZE_GIT_URI/ test directory to the test suite.
test/NORMALIZE_GIT_URI/CMakeLists.txt Adds tests for normalizing Git URIs to SSH and HTTP formats.
test/NORMALIZE_GIT_URI/fail/CMakeLists.txt Adds failure case tests for invalid URIs and target types.
test/NORMALIZE_GIT_URI/fail/invalid_http_uri/CMakeLists.txt Test for invalid HTTP URI input to normalization function.
test/NORMALIZE_GIT_URI/fail/invalid_ssh_uri/CMakeLists.txt Test for invalid SSH URI input to normalization function.
test/NORMALIZE_GIT_URI/fail/invalid_target_type/CMakeLists.txt Test for invalid target type input to normalization function.
.github/workflows/tests.yml Expanded test matrix to include additional Debian and Fedora container images; upgraded checkout action.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant CMake
    participant CMUTIL_NORMALIZE_GIT_URI

    User->>CMake: Call CMUTIL_NORMALIZE_GIT_URI(URI, TARGET_TYPE, OUT_VAR)
    CMake->>CMUTIL_NORMALIZE_GIT_URI: Parse arguments
    alt TARGET_TYPE is SSH
        CMUTIL_NORMALIZE_GIT_URI->>CMUTIL_NORMALIZE_GIT_URI: _CMUTIL_NORMALIZE_GIT_URI_SSH(URI, OUT_VAR)
    else TARGET_TYPE is HTTP
        CMUTIL_NORMALIZE_GIT_URI->>CMUTIL_NORMALIZE_GIT_URI: _CMUTIL_NORMALIZE_GIT_URI_HTTP(URI, OUT_VAR)
    else Invalid TARGET_TYPE
        CMUTIL_NORMALIZE_GIT_URI->>CMake: Fatal error
    end
    CMUTIL_NORMALIZE_GIT_URI->>CMake: Set OUT_VAR in parent scope
Loading

Poem

A bunny hops through lines of code,
Normalizing URIs on the yellow brick road.
SSH or HTTP, it knows the way—
No more confusion, come what may!
With tests and docs now up to date,
This module’s fate is truly great!
🐇✨
"""


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b261845 and 389f020.

📒 Files selected for processing (1)
  • .github/workflows/tests.yml (3 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • .github/workflows/tests.yml
✨ Finishing Touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch jan_kubalek/normalize_gituri

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai auto-generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@koudis
Copy link
Member Author

koudis commented Jul 6, 2025

Depends on
cmakelib/cmakelib#32

Copy link

@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: 9

🧹 Nitpick comments (5)
FindCMUTIL.cmake (1)

21-21: Good addition – remember to keep includes alphabetised

The extra include is correct; however, consider keeping the list alphabetically sorted for quick scanning (NORMALIZE comes after PLATFORM).

README.md (2)

10-10: Bullet order drift

The new entry is on top, breaking the pre-existing alphabetical order (N, P, T, V). Re-ordering keeps the list predictable.


25-30: Link table mis-alignment

Column spacing of the reference links is now uneven; run a formatter or align by hand for readability.

test/NORMALIZE_GIT_URI/fail/invalid_http_uri/CMakeLists.txt (1)

10-16: Fail test could silently succeed if CMUTIL is missing

Add REQUIRED to the find_package to guarantee the test actually fails on missing CMUTIL instead of passing:

-FIND_PACKAGE(CMUTIL)
+FIND_PACKAGE(CMUTIL REQUIRED)

Minor, but avoids false-positive green builds when the module is not found.

test/NORMALIZE_GIT_URI/fail/CMakeLists.txt (1)

10-12: Regexes: tighten or anchor to avoid accidental matches

The failure-expectation regexes are very generic; e.g. "Invalid TARGET_TYPE" would match any message containing those words. Consider anchoring or using full error text to prevent false positives if unrelated diagnostics include the same fragment.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between fcd1387 and b0281f9.

📒 Files selected for processing (9)
  • FindCMUTIL.cmake (1 hunks)
  • README.md (2 hunks)
  • system_modules/CMUTIL_NORMALIZE_GIT_URI.cmake (1 hunks)
  • test/CMakeLists.txt (1 hunks)
  • test/NORMALIZE_GIT_URI/CMakeLists.txt (1 hunks)
  • test/NORMALIZE_GIT_URI/fail/CMakeLists.txt (1 hunks)
  • test/NORMALIZE_GIT_URI/fail/invalid_http_uri/CMakeLists.txt (1 hunks)
  • test/NORMALIZE_GIT_URI/fail/invalid_ssh_uri/CMakeLists.txt (1 hunks)
  • test/NORMALIZE_GIT_URI/fail/invalid_target_type/CMakeLists.txt (1 hunks)
🧰 Additional context used
🪛 GitHub Actions: Tests
test/NORMALIZE_GIT_URI/fail/invalid_http_uri/CMakeLists.txt

[error] 20-20: Unknown CMake command "TEST_VAR_EQUALS_LITERAL". Called from TEST_SSH_TARGET_TYPE at line 118 and TEST_RUN at line 12.

test/NORMALIZE_GIT_URI/fail/invalid_target_type/CMakeLists.txt

[error] 20-20: Unknown CMake command "TEST_VAR_EQUALS_LITERAL". Called from TEST_SSH_TARGET_TYPE at line 118 and TEST_RUN at line 12.

test/CMakeLists.txt

[error] 20-20: Unknown CMake command "TEST_VAR_EQUALS_LITERAL". Called from TEST_SSH_TARGET_TYPE at line 118 and TEST_RUN at line 12.

test/NORMALIZE_GIT_URI/fail/CMakeLists.txt

[error] 20-20: Unknown CMake command "TEST_VAR_EQUALS_LITERAL". Called from TEST_SSH_TARGET_TYPE at line 118 and TEST_RUN at line 12.

test/NORMALIZE_GIT_URI/fail/invalid_ssh_uri/CMakeLists.txt

[error] 20-20: Unknown CMake command "TEST_VAR_EQUALS_LITERAL". Called from TEST_SSH_TARGET_TYPE at line 118 and TEST_RUN at line 12.

test/NORMALIZE_GIT_URI/CMakeLists.txt

[error] 20-20: Unknown CMake command "TEST_VAR_EQUALS_LITERAL". Called from TEST_SSH_TARGET_TYPE at line 118 and TEST_RUN at line 12.

🔇 Additional comments (4)
test/NORMALIZE_GIT_URI/CMakeLists.txt (1)

118-121: Approve comprehensive test coverage.

The test functions provide excellent coverage of different URI formats including custom domains, ports, subgroups, and repositories with/without .git extensions. The test structure is well-organized.

system_modules/CMUTIL_NORMALIZE_GIT_URI.cmake (3)

1-15: Excellent documentation and module structure.

The documentation clearly explains the purpose, formats, and functionality of the module. The examples are helpful and the structure is well-organized.


41-72: Well-structured main function with proper error handling.

The main function correctly delegates to helper functions based on the target type and provides clear error messages for invalid target types.


120-124: Fix port handling in SSH URI conversion.

The current implementation doesn't properly handle ports in HTTP URIs when converting to SSH format. URLs with ports like https://host:8080/path should preserve the port information correctly.

-    STRING(REGEX REPLACE "^https?://([^/]+)/(.+)$" "\\1" hostname "${uri}")
-    STRING(REGEX REPLACE "^https?://([^/]+)/(.+)$" "\\2" path "${uri}")
+    STRING(REGEX REPLACE "^https?://([^/]+)(:[0-9]+)?/(.+)$" "\\1\\2" hostname "${uri}")
+    STRING(REGEX REPLACE "^https?://([^/]+)(:[0-9]+)?/(.+)$" "\\3" path "${uri}")

Note: The resulting SSH URI format with ports (git@host:port:path) is non-standard. Consider if this is the intended behavior.

Likely an incorrect or invalid review comment.

@koudis koudis merged commit 77e2ba9 into master Jul 16, 2025
21 checks passed
@koudis koudis deleted the jan_kubalek/normalize_gituri branch August 9, 2025 18:48
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