Skip to content

Commit

Permalink
Fix backward compatibility of Buildozer API (#963)
Browse files Browse the repository at this point in the history
  • Loading branch information
vladmos authored Feb 24, 2021
1 parent b08a193 commit c70177b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion buildozer/buildozer_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -1384,7 +1384,7 @@ function test_rule_print_comment() {
in='# Hello
cc_library(name = "a")'
run "$in" 'print_comment' //pkg:a
assert_output 'Hello '
assert_output 'Hello'
}

function test_rule_print_comment_with_suffix_and_after() {
Expand Down
8 changes: 6 additions & 2 deletions edit/buildozer.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,12 @@ func cmdPrintComment(opts *Options, env CmdEnvironment) (*build.File, error) {
case 0: // Print rule comment.
env.output.Fields = []*apipb.Output_Record_Field{
{Value: &apipb.Output_Record_Field_Text{commentsText(env.Rule.Call.Comments.Before)}},
{Value: &apipb.Output_Record_Field_Text{commentsText(env.Rule.Call.Comments.Suffix)}},
{Value: &apipb.Output_Record_Field_Text{commentsText(env.Rule.Call.Comments.After)}},
}
if text := commentsText(env.Rule.Call.Comments.Suffix); text != "" {
env.output.Fields = append(env.output.Fields, &apipb.Output_Record_Field{Value: &apipb.Output_Record_Field_Text{text}})
}
if text := commentsText(env.Rule.Call.Comments.After); text != "" {
env.output.Fields = append(env.output.Fields, &apipb.Output_Record_Field{Value: &apipb.Output_Record_Field_Text{text}})
}
case 1: // Print attribute comment.
attr := env.Rule.AttrDefn(env.Args[0])
Expand Down

0 comments on commit c70177b

Please sign in to comment.