Log changed files
This commit is contained in:
parent
4517f174bb
commit
7d553e5a8e
|
@ -1,8 +1,11 @@
|
||||||
import argparse
|
import argparse
|
||||||
import pathlib
|
import pathlib
|
||||||
|
import logging
|
||||||
|
|
||||||
from . import Config, NamingScheme, standardize_java_text
|
from . import Config, NamingScheme, standardize_java_text
|
||||||
|
|
||||||
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
def test_files(repo: pathlib.Path) -> list[pathlib.Path]:
|
def test_files(repo: pathlib.Path) -> list[pathlib.Path]:
|
||||||
return list(repo.rglob('*.java'))
|
return list(repo.rglob('*.java'))
|
||||||
|
@ -21,13 +24,14 @@ def standardize_in_file(
|
||||||
config,
|
config,
|
||||||
)
|
)
|
||||||
if text_updated == text:
|
if text_updated == text:
|
||||||
return
|
return False
|
||||||
|
|
||||||
if inline:
|
if inline:
|
||||||
with open(path, 'w') as f:
|
with open(path, 'w') as f:
|
||||||
f.write(text_updated)
|
f.write(text_updated)
|
||||||
else:
|
else:
|
||||||
print(text_updated)
|
print(text_updated)
|
||||||
|
return True
|
||||||
|
|
||||||
|
|
||||||
def argument_parser():
|
def argument_parser():
|
||||||
|
@ -65,6 +69,7 @@ def argument_parser():
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
logging.basicConfig(level='INFO')
|
||||||
args = argument_parser().parse_args()
|
args = argument_parser().parse_args()
|
||||||
|
|
||||||
config = Config(
|
config = Config(
|
||||||
|
@ -75,12 +80,21 @@ def main():
|
||||||
naming_scheme=args.naming,
|
naming_scheme=args.naming,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
num_modified = 0
|
||||||
for path in test_files(args.repo):
|
for path in test_files(args.repo):
|
||||||
standardize_in_file(
|
was_modified = standardize_in_file(
|
||||||
path,
|
path,
|
||||||
inline=args.i,
|
inline=args.i,
|
||||||
config=config,
|
config=config,
|
||||||
)
|
)
|
||||||
|
if was_modified:
|
||||||
|
num_modified += 1
|
||||||
|
logger.info('Standardized %s', path)
|
||||||
|
|
||||||
|
logger.info('Standardized %d files', num_modified)
|
||||||
|
if not args.i:
|
||||||
|
logger.warning('This was a dry run')
|
||||||
|
logger.warning('Use -i to replace in files!')
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|
Loading…
Reference in New Issue
Block a user