Skip to content

Conversation

LinZhihao-723
Copy link
Member

@LinZhihao-723 LinZhihao-723 commented Sep 24, 2025

Description

As we will introduce linting configs for Rust, symlink_config will be reused in another script called symlink-rust-lint-configs.sh. This PR extracts the helper into a single helper shell script for code sharing.

Checklist

  • The PR satisfies the contribution guidelines.
  • This is a breaking change and that has been indicated in the PR title, OR this isn't a
    breaking change.
  • Necessary docs have been updated, OR no docs need to be updated.

Validation performed

Did the following tests:

☁  yscope-dev-utils [symlink-rust-lint-configs] ⚡  ./exports/lint-configs/symlink-cpp-lint-configs.sh
Symlinked '/home/lzh/yscope-dev-utils//exports/lint-configs/.clang-format' to '/home/lzh/yscope-dev-utils//.clang-format'.
Symlinked '/home/lzh/yscope-dev-utils//exports/lint-configs/.clang-tidy' to '/home/lzh/yscope-dev-utils//.clang-tidy'.
☁  yscope-dev-utils [symlink-rust-lint-configs] ⚡  echo $?
0
☁  yscope-dev-utils [symlink-rust-lint-configs] ⚡  rm -rf .clang-*
☁  yscope-dev-utils [symlink-rust-lint-configs] ⚡  cat README.md > .clang-tidy
☁  yscope-dev-utils [symlink-rust-lint-configs] ⚡  ./exports/lint-configs/symlink-cpp-lint-configs.sh
Symlinked '/home/lzh/yscope-dev-utils//exports/lint-configs/.clang-format' to '/home/lzh/yscope-dev-utils//.clang-format'.
Unknown config file exists at '/home/lzh/yscope-dev-utils//.clang-tidy'. Remove it before running this script.
☁  yscope-dev-utils [symlink-rust-lint-configs] ⚡  echo $?
1
☁  yscope-dev-utils [symlink-rust-lint-configs] ⚡  rm -rf .clang-*
☁  yscope-dev-utils [symlink-rust-lint-configs] ⚡  ./exports/lint-configs/symlink-cpp-lint-configs.sh
Symlinked '/home/lzh/yscope-dev-utils//exports/lint-configs/.clang-format' to '/home/lzh/yscope-dev-utils//.clang-format'.
Symlinked '/home/lzh/yscope-dev-utils//exports/lint-configs/.clang-tidy' to '/home/lzh/yscope-dev-utils//.clang-tidy'.
☁  yscope-dev-utils [symlink-rust-lint-configs] ⚡  ./exports/lint-configs/symlink-cpp-lint-configs.sh
Already symlinked '/home/lzh/yscope-dev-utils//exports/lint-configs/.clang-format' to '/home/lzh/yscope-dev-utils//.clang-format'.
Already symlinked '/home/lzh/yscope-dev-utils//exports/lint-configs/.clang-tidy' to '/home/lzh/yscope-dev-utils//.clang-tidy'.
☁  yscope-dev-utils [symlink-rust-lint-configs] ⚡  echo $?
0
☁  yscope-dev-utils [symlink-rust-lint-configs] ⚡  ./exports/lint-configs/symlink-config.sh hi.txt
symlink-config.sh: Config file doesn't exist: 'hi.txt'.
☁  yscope-dev-utils [symlink-rust-lint-configs] ⚡  echo $?
1
  • Creating symlinks for C++ lint-configs will succeed.
  • If a file with the linking name already exists, it will fail by returning 1.
  • If running the script twice, it won't fail and will properly notify that the symlink has been created.
  • If the config to link doesn't exist, it will fail by returning 1.

Summary by CodeRabbit

  • New Features
    • Added a CLI utility to create relative symlinks for linter/formatter configs at the repository root, with validation, conflict checks, idempotent behaviour, and clear messages.
  • Refactor
    • Updated existing tooling to delegate symlink creation to the new utility, reducing duplication and centralising logic.
  • Chores
    • Improved robustness with strict error handling and path normalisation.

@LinZhihao-723 LinZhihao-723 requested a review from a team as a code owner September 24, 2025 20:37
Copy link
Contributor

coderabbitai bot commented Sep 24, 2025

Walkthrough

Adds a new Bash script to create relative symlinks for config files at the repo root and updates the C++ lint symlink script to delegate to this new utility for .clang-format and .clang-tidy.

Changes

Cohort / File(s) Summary
New symlink utility
exports/lint-configs/symlink-config.sh
Introduces a script that validates a single argument, checks source existence, computes repo-relative paths, and creates/validates a relative symlink at the repo root; idempotent with clear messaging; encapsulated in main and invoked via main "$@".
CPP lint symlink refactor
exports/lint-configs/symlink-cpp-lint-configs.sh
Removes inline symlink function and replaces calls with two invocations of symlink-config.sh for .clang-format and .clang-tidy, delegating all error handling and control flow to the new utility.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor Dev as Developer
  participant Cpp as symlink-cpp-lint-configs.sh
  participant Util as symlink-config.sh
  note over Dev,Cpp: Trigger C++ lint config symlinking

  Dev->>Cpp: Run script
  loop For each config (.clang-format, .clang-tidy)
    Cpp->>Util: symlink-config.sh <config-path>
    activate Util
    Util->>Util: Validate args and source file
    Util->>Util: Compute repo root and relative target
    alt Destination missing
      Util->>Util: Create relative symlink
      Util-->>Cpp: Success message
    else Destination exists
      alt Correct symlink
        Util-->>Cpp: Already correctly symlinked
      else Conflict (file/other symlink)
        Util-->>Cpp: Error and non-zero exit
      end
    end
    deactivate Util
  end
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Pre-merge checks and finishing touches

❌ 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%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ 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 summarises the primary change by indicating that the symlink_config functionality has been refactored out into a standalone helper script within the lint-configs area. It follows a clear conventional commit style and directly reflects the core intent of the pull request.
✨ Finishing touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Tip

👮 Agentic pre-merge checks are now available in preview!

Pro plan users can now enable pre-merge checks in their settings to enforce checklists before merging PRs.

  • Built-in checks – Quickly apply ready-made checks to enforce title conventions, require pull request descriptions that follow templates, validate linked issues for compliance, and more.
  • Custom agentic checks – Define your own rules using CodeRabbit’s advanced agentic capabilities to enforce organization-specific policies and workflows. For example, you can instruct CodeRabbit’s agent to verify that API documentation is updated whenever API schema files are modified in a PR. Note: Upto 5 custom checks are currently allowed during the preview period. Pricing for this feature will be announced in a few weeks.

Please see the documentation for more information.

Example:

reviews:
  pre_merge_checks:
    custom_checks:
      - name: "Undocumented Breaking Changes"
        mode: "warning"
        instructions: |
          Pass/fail criteria: All breaking changes to public APIs, CLI flags, environment variables, configuration keys, database schemas, or HTTP/GraphQL endpoints must be documented in the "Breaking Change" section of the PR description and in CHANGELOG.md. Exclude purely internal or private changes (e.g., code not exported from package entry points or explicitly marked as internal).

Please share your feedback with us on this Discord post.


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
Contributor

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

📜 Review details

Configuration used: CodeRabbit UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f1202b9 and 30ea512.

📒 Files selected for processing (2)
  • exports/lint-configs/symlink-config.sh (1 hunks)
  • exports/lint-configs/symlink-cpp-lint-configs.sh (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
exports/lint-configs/symlink-config.sh (1)
exports/lint-configs/symlink-cpp-lint-configs.sh (1)
  • main (11-14)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: unit-tests (ubuntu-24.04)
  • GitHub Check: unit-tests (ubuntu-22.04)
🔇 Additional comments (2)
exports/lint-configs/symlink-config.sh (1)

11-52: Request macOS verification Validate that the script works on macOS (BSD readlink lacks -f) by running the same smoke test there.

exports/lint-configs/symlink-cpp-lint-configs.sh (1)

12-13: Approve changes: helper script is executable Verified that exports/lint-configs/symlink-config.sh exists and has the execute bit set.

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