diff --git a/atom/browser/atom_permission_manager.h b/atom/browser/atom_permission_manager.h index 605db56bedcc8..f1ae69aff7075 100644 --- a/atom/browser/atom_permission_manager.h +++ b/atom/browser/atom_permission_manager.h @@ -49,13 +49,12 @@ class AtomPermissionManager : public content::PermissionControllerDelegate { bool user_gesture, const base::Callback& callback) override; - int RequestPermissionWithDetails( - content::PermissionType permission, - content::RenderFrameHost* render_frame_host, - const GURL& requesting_origin, - bool user_gesture, - const base::DictionaryValue* details, - const StatusCallback& callback); + int RequestPermissionWithDetails(content::PermissionType permission, + content::RenderFrameHost* render_frame_host, + const GURL& requesting_origin, + bool user_gesture, + const base::DictionaryValue* details, + const StatusCallback& callback); int RequestPermissions( const std::vector& permissions, content::RenderFrameHost* render_frame_host, diff --git a/atom/browser/web_contents_permission_helper.h b/atom/browser/web_contents_permission_helper.h index d0ad5266dadf6..012a012711c70 100644 --- a/atom/browser/web_contents_permission_helper.h +++ b/atom/browser/web_contents_permission_helper.h @@ -25,9 +25,8 @@ class WebContentsPermissionHelper // Asynchronous Requests void RequestFullscreenPermission(const base::Callback& callback); - void RequestMediaAccessPermission( - const content::MediaStreamRequest& request, - content::MediaResponseCallback callback); + void RequestMediaAccessPermission(const content::MediaStreamRequest& request, + content::MediaResponseCallback callback); void RequestWebNotificationPermission( const base::Callback& callback); void RequestPointerLockPermission(bool user_gesture); diff --git a/script/lint.js b/script/lint.js index a06305d17f3af..372e46efa9316 100755 --- a/script/lint.js +++ b/script/lint.js @@ -51,6 +51,11 @@ const LINTERS = [ { roots: ['atom', 'brightray'], test: filename => filename.endsWith('.cc') || filename.endsWith('.h'), run: (opts, filenames) => { + if (opts.fix) { + spawnAndCheckExitCode('python', ['script/run-clang-format.py', '--fix', ...filenames]) + } else { + spawnAndCheckExitCode('python', ['script/run-clang-format.py', ...filenames]) + } const result = childProcess.spawnSync('cpplint.py', filenames, { encoding: 'utf8' }) // cpplint.py writes EVERYTHING to stderr, including status messages if (result.stderr) { @@ -61,7 +66,6 @@ const LINTERS = [ { } } if (result.status) { - if (opts.fix) spawnAndCheckExitCode('python', ['script/run-clang-format.py', ...filenames]) process.exit(result.status) } } @@ -157,7 +161,7 @@ async function findFiles (args, linter) { if (args.changed) { whitelist = await findChangedFiles(SOURCE_ROOT) if (!whitelist.size) { - return filenames + return [] } } @@ -183,7 +187,10 @@ async function findFiles (args, linter) { filenames = filenames.filter(x => whitelist.has(x)) } - return filenames + // it's important that filenames be relative otherwise clang-format will + // produce patches with absolute paths in them, which `git apply` will refuse + // to apply. + return filenames.map(x => path.relative(SOURCE_ROOT, x)) } async function main () { diff --git a/script/run-clang-format.py b/script/run-clang-format.py index 2cb17a59085b6..bcd3f99ae3a6e 100644 --- a/script/run-clang-format.py +++ b/script/run-clang-format.py @@ -105,6 +105,8 @@ def run_clang_format_diff(args, file_name): except IOError as exc: raise DiffError(str(exc)) invocation = [args.clang_format_executable, file_name] + if args.fix: + invocation.append('-i') try: proc = subprocess.Popen( ' '.join(invocation), @@ -129,6 +131,8 @@ def run_clang_format_diff(args, file_name): if proc.returncode: raise DiffError("clang-format exited with status {}: '{}'".format( proc.returncode, file_name), errs) + if args.fix: + return None, errs return make_diff(file_name, original, outs), errs @@ -190,6 +194,10 @@ def main(): help='comma separated list of file extensions (default: {})'.format( DEFAULT_EXTENSIONS), default=DEFAULT_EXTENSIONS) + parser.add_argument( + '--fix', + help='if specified, reformat files in-place', + action='store_true') parser.add_argument( '-r', '--recursive', @@ -281,8 +289,9 @@ def main(): njobs = multiprocessing.cpu_count() + 1 njobs = min(len(files), njobs) - patch_file = tempfile.NamedTemporaryFile(delete=False, - prefix='electron-format-') + if not args.fix: + patch_file = tempfile.NamedTemporaryFile(delete=False, + prefix='electron-format-') if njobs == 1: # execute directly instead of in a pool, @@ -316,20 +325,22 @@ def main(): sys.stderr.writelines(errs) if outs == []: continue - if not args.quiet: - print_diff(outs, use_color=colored_stdout) - for line in outs: - patch_file.write(line) - patch_file.write('\n') - if retcode == ExitStatus.SUCCESS: - retcode = ExitStatus.DIFF - - if patch_file.tell() == 0: - patch_file.close() - os.unlink(patch_file.name) - else: - print("\nTo patch these files, run:\n$ git apply {}\n" - .format(patch_file.name)) + if not args.fix: + if not args.quiet: + print_diff(outs, use_color=colored_stdout) + for line in outs: + patch_file.write(line) + patch_file.write('\n') + if retcode == ExitStatus.SUCCESS: + retcode = ExitStatus.DIFF + + if not args.fix: + if patch_file.tell() == 0: + patch_file.close() + os.unlink(patch_file.name) + else: + print("\nTo patch these files, run:\n$ git apply {}\n" + .format(patch_file.name)) return retcode