Skip to content

refactor: derive bundle runtime paths from source_dir - #820

Open
AlexanderLanin wants to merge 1 commit into
mainfrom
source-dir
Open

AlexanderLanin wants to merge 1 commit into
mainfrom
source-dir

Conversation

@AlexanderLanin

@AlexanderLanin AlexanderLanin commented Sep 14, 2026

Copy link
Copy Markdown
Member

What this achieves

Passes the original source_dir into bundle creation so the internal bundle rule can derive the source runtime path from the owning package and repository.

Why this is needed

The current bundle setup passes a precomputed strip_prefix and infers external-repository paths from the first globbed file. Keeping the source-directory value until the rule boundary makes path ownership explicit and handles package-root and nested source directories consistently.

Changes

  • Replace the internal strip_prefix attribute and argument with source_dir.
  • Derive local and external runtime paths from the bundle label and source_dir.
  • Keep explicit-source and execroot conversion behavior unchanged.

@AlexanderLanin
AlexanderLanin added this pull request to stack #821 September 14, 2026 12:39
@AlexanderLanin AlexanderLanin changed the title source dir refactor: derive bundle runtime paths from source_dir Sep 14, 2026
@AlexanderLanin
AlexanderLanin requested a balanced review from Copilot September 14, 2026 12:40

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟢 Approval recommended

The focused refactor preserves existing explicit-source behavior and is covered by relevant package-root, nested-package, and cross-module scenarios.

Pull request overview

Refactors bundle path derivation to retain source_dir until rule evaluation.

Changes:

  • Pass source_dir directly into bundle creation.
  • Derive local and external runtime paths from the bundle label.
File summaries
File Description
docs.bzl Forwards and documents source_dir.
bzl/bundle_rules.bzl Derives runtime paths within the bundle rule.
Review details
  • Files reviewed: 2/2 changed files
  • Comments generated: 0
  • Review effort level: Balanced

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@github-actions

Copy link
Copy Markdown
Contributor

Documentation preview for this pull request is available at:
pr-820: https://eclipse-score.github.io/docs-as-code/pr-820/

Comment thread bzl/bundle_rules.bzl
Comment on lines 442 to +459
@@ -453,7 +456,7 @@ def create_bundle(
source_dir_globbed = source_dir_globbed,
source_targets = source_targets,
sourcelinks_json = sourcelinks_json,
strip_prefix = strip_prefix,
source_dir = source_dir if source_dir != None else "",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

But since you put source_dir in default above as "" would the source_dir if in 459 not always be true then, caues it's never the default None?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

when a user calls docs or docs_bundle the source_dir defaults to None. This place is exactly where None is transformed to "". Maybe it makes more sense to store None instead of empty strings, but that would be the next refactoring starting from this point.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

That default "" is exactly what is being set here

Base automatically changed from one-rename to main September 14, 2026 14:19
@AlexanderLanin

Copy link
Copy Markdown
Member Author

FYI stacked PRs can apparently only be force pushed, not merged with main

Comment thread bzl/bundle_rules.bzl
"source_dir_globbed": attr.label_list(allow_files = True),
"source_targets": attr.label_list(allow_files = True),
"sourcelinks_json": attr.label(allow_single_file = True),
"strip_prefix": attr.string(default = ""),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why remove strip_prefix?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Strip_prefix was a missnamed argument. It never actually stripped a prefix.
That's why now it has been removed and actuall source_dir has been added.

@MaximilianSoerenPollak

Copy link
Copy Markdown
Contributor

FYI stacked PRs can apparently only be force pushed, not merged with main

Yes once ,one is approved it will get merged onto the next PR in the stack and rebased.
That way you ave then one main PR at the end that will get merged.

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

Labels

None yet

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

4 participants