DoozyX / clang-format-lint-action

This action checks if the source code matches the .clang-format file.
MIT License
134 stars 51 forks source link

inplace=False option doesn't work #18

Closed werat closed 3 years ago

werat commented 4 years ago

Setting inplace: False doesn't work and the action still works as if inplace: True.

- uses: DoozyX/clang-format-lint-action@0.10
  with:
    inplace: False

This is because --inplace argument is defined as type=bool -- https://github.com/DoozyX/clang-format-lint-action/blob/v0.10/run-clang-format.py#L303

Everything is parsed as bool, expect for the empty string:

In [1]: import argparse
   ...: parser = argparse.ArgumentParser()
   ...: parser.add_argument('-i', '--inplace', type=bool, default=False)
Out[1]: <...>

In [2]: parser.parse_args(['--inplace', 'True'])
Out[2]: Namespace(inplace=True)

In [3]: parser.parse_args(['--inplace', 'False'])
Out[3]: Namespace(inplace=True)

In [4]: parser.parse_args(['--inplace', '0'])
Out[4]: Namespace(inplace=True)

In [5]: parser.parse_args(['--inplace', ''])
Out[5]: Namespace(inplace=False)

So as a workaround one can set inplace: "":

- uses: DoozyX/clang-format-lint-action@0.10
  with:
    inplace: ""
ladislas commented 3 years ago

I can confirm the issue!