Skip to content

Commit

Permalink
Buildozer PrintComment now also returns 'Suffix' and 'After' comments…
Browse files Browse the repository at this point in the history
… on rules (#958)
  • Loading branch information
matthewcbrown authored Feb 16, 2021
1 parent 752270c commit e8d5029
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
3 changes: 2 additions & 1 deletion CONTRIBUTORS
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@ Paul Bethe <[email protected]>
Russ Cox <[email protected]>
Laurent Le Brun <[email protected]>
Justine Alexandra Roberts Tunney <[email protected]>
Nilton Volpato <[email protected]>
Nilton Volpato <[email protected]>
Matthew C Brown <[email protected]>
10 changes: 9 additions & 1 deletion buildozer/buildozer_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -1384,7 +1384,15 @@ 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() {
in='# Hello Before
cc_library(name = "a") # Hello Suffix
# Hello After'
run "$in" 'print_comment' //pkg:a
assert_output 'Hello Before Hello Suffix Hello After'
}

function test_attribute_print_comment() {
Expand Down
2 changes: 2 additions & 0 deletions edit/buildozer.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,8 @@ 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)}},
}
case 1: // Print attribute comment.
attr := env.Rule.AttrDefn(env.Args[0])
Expand Down

0 comments on commit e8d5029

Please sign in to comment.