Commit 79d284b8 authored by Jesse McKenna's avatar Jesse McKenna Committed by Commit Bot

Reland "boilerplate.py: Ignore current-dir prefixes .\, ./"

This reverts commit f909a6a2.

Reason for revert: _RemoveCurrentDirectoryPrefix was missing a
line to return the original argument if it was not modified,
i.e. the function was returning None if no modification took
place. This reland adds the missing return statement.

Original change's description:
> Revert "boilerplate.py: Ignore current-dir prefixes .\, ./"
>
> This reverts commit 9d14b9ec.
>
> Reason for revert: Change is breaking calls without .\ prefix.
>
> Original change's description:
> > boilerplate.py: Ignore current-dir prefixes .\, ./
> >
> > This change makes boilerplate.py trim a leading ".\" (Windows's
> > current-directory prefix) or "./" (Unix's current-directory prefix)
> > from the filename argument, if present.
> >
> > This is a convenience change for cases where the current-directory
> > prefix is prepended. For example, Windows PowerShell automatically
> > prepends ".\" to a path when tab completion is used (e.g., typing
> > "chrome/b" and pressing tab results in ".\chrome\browser"). This
> > change will remove artifacts of this for users who use tab completion
> > while typing the filename argument.
> >
> > Currently:
> > `tools/boilerplate.py .\test.h` produces include guard `__TEST_H_`
> > `tools/boilerplate.py ./test.cc` or `.mm` produces `#include "./test.h"`
> >
> > With this change:
> > `tools/boilerplate.py .\test.h` produces include guard `TEST_H_`
> > `tools/boilerplate.py ./test.cc` or `.mm` produces `#include "test.h"`
> >
> > Change-Id: I19fd2e72c58135b5e87d4a1e22ec8bc76ef326aa
> > Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2157876
> > Commit-Queue: Jesse McKenna <jessemckenna@google.com>
> > Reviewed-by: Robert Sesek <rsesek@chromium.org>
> > Cr-Commit-Position: refs/heads/master@{#761085}
>
> TBR=rsesek@chromium.org,jessemckenna@google.com
>
> Change-Id: Ic02537133fd1548f5279ead83abb0492d6657aaa
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2159993
> Reviewed-by: Jesse McKenna <jessemckenna@google.com>
> Commit-Queue: Jesse McKenna <jessemckenna@google.com>
> Cr-Commit-Position: refs/heads/master@{#761185}

Change-Id: Iaef7fdecaff8ae205fd0c242777676bbffb788a0
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2161895
Auto-Submit: Jesse McKenna <jessemckenna@google.com>
Reviewed-by: default avatarRobert Sesek <rsesek@chromium.org>
Commit-Queue: Robert Sesek <rsesek@chromium.org>
Cr-Commit-Position: refs/heads/master@{#761923}
parent c71eaf36
......@@ -55,6 +55,16 @@ def _CppHeader(filename):
])
def _RemoveCurrentDirectoryPrefix(filename):
current_dir_prefixes = [os.curdir + os.sep]
if os.altsep is not None:
current_dir_prefixes.append(os.curdir + os.altsep)
for prefix in current_dir_prefixes:
if filename.startswith(prefix):
return filename[len(prefix):]
return filename
def _RemoveTestSuffix(filename):
base, _ = os.path.splitext(filename)
suffixes = [ '_test', '_unittest', '_browsertest' ]
......@@ -94,6 +104,8 @@ def _ObjCppImplementation(filename):
def _CreateFile(filename):
filename = _RemoveCurrentDirectoryPrefix(filename)
contents = _GetHeader(filename) + '\n'
if filename.endswith('.h'):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment