Skip to content

Updating set kind to remember starting line of the rule#1342

Merged
oreflow merged 1 commit intomainfrom
oreflow-patch-2
Mar 6, 2025
Merged

Updating set kind to remember starting line of the rule#1342
oreflow merged 1 commit intomainfrom
oreflow-patch-2

Conversation

@oreflow
Copy link
Collaborator

@oreflow oreflow commented Mar 6, 2025

Prior to this change, if a user were to run multiple consecutive commands, including one set kind command.
Any command including a line number would fail if referring to the rule with the changed kind.

Example

$ cat package/BUILD
foo_lib(
    name = "unknown",
    deps = [
        "path/to/some:dep",
    ],
)

$ cat commands
set kind bar_lib|package:%1
rename deps new_deps|package:%1

Before this change

$ buildozer -f ./commands 
.../package/BUILD: error while executing commands [{[rename deps new_deps]}] on target package:%1: rule '%1' not found

Including change

$buildozer -f ./commands 
fixed .../package/BUILD

$ cat package/BUILD 
bar_lib(
    name = "unknown",
    new_deps = [
        "path/to/some:dep",
    ],
)

@oreflow oreflow merged commit 931d76d into main Mar 6, 2025
5 checks passed
@oreflow oreflow deleted the oreflow-patch-2 branch March 6, 2025 16:11
names := strings.Split(kind, ".")
var expr Expr
expr = &Ident{Name: names[0]}
startPos, _ := r.Call.X.Span()
Copy link
Member

Choose a reason for hiding this comment

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

if x := r.Call.X; x != nil {
	startPos, _ = x.Span()
}

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.

2 participants