• Aiden Benner's avatar
    Add non --full support to python git cl format · c08566e6
    Aiden Benner authored
    Parses git diff for changed python files in a method similar to
    clang-diff and feeds the resulting line ranges into yapf.
    
    Also sets the default style to the yapf file included in depot tools
    by searching parent directories of each changed file to find a yapf
    style config (.style.yapf). If none is found the default style
    file will be the chromium .style.yapf included in depot tools.
    
    Note: Even if line ranges are specified, yapf will fix indentation
    issues for the entire file.
    This is intended see https://github.com/google/yapf/issues/499
    This may cause some issues if git cl format is run on a file
    with lots of indentation issues or on a file or when run on a
    third_party file that is formatted with pep8 and does not include
    a .style.yapf and may make many more changes then the user expects.
    
    Still undecided on whether this should be turned on by default but
    if not I think the non --full support is a positive change anyways.
    
    Bug:846432
    Change-Id: Ib85797f4a8e1021870901ff465ec10f7e70deb87
    Reviewed-on: https://chromium-review.googlesource.com/1249642
    Commit-Queue: Aiden Benner <abenner@google.com>
    Reviewed-by: 's avatarNodir Turakulov <nodir@chromium.org>
    Reviewed-by: 's avataragrieve <agrieve@chromium.org>
    c08566e6
git_cl.py 230 KB