Skip to content

Commit e683f3b

Browse files
committed
Revert unnecessary changes.
1 parent f9d114d commit e683f3b

11 files changed

+59
-69
lines changed

tool/fix_copyright.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/usr/bin/env bash
2-
# Copyright 2025 The Flutter Authors. All rights reserved.
2+
# Copyright 2025 The Flutter Authors.
33
# Use of this source code is governed by a BSD-style license that can be
44
# found in the LICENSE file.
55

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
# Copyright 2025 The Flutter Authors. All rights reserved.
1+
# Copyright 2025 The Flutter Authors.
22
# Use of this source code is governed by a BSD-style license that can be
33
# found in the LICENSE file.
44

55
include: package:dart_flutter_team_lints/analysis_options.yaml
6-

tool/fix_copyright/bin/fix_copyright.dart

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2025 The Flutter Authors. All rights reserved.
1+
// Copyright 2025 The Flutter Authors.
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file.
44

@@ -38,11 +38,6 @@ Future<int> main(List<String> arguments) async {
3838
defaultsTo: '2025',
3939
help: 'Set the year to use for the copyright year.',
4040
);
41-
argParser.addFlag(
42-
'skip-submodules',
43-
defaultsTo: true,
44-
help: 'Skip git submodules when fixing copyrights.',
45-
);
4641
argParser.addFlag(
4742
'help',
4843
negatable: false,
@@ -76,7 +71,6 @@ Future<int> main(List<String> arguments) async {
7671
force: parsedArguments['force'] as bool,
7772
year: parsedArguments['year']! as String,
7873
paths: parsedArguments.rest,
79-
skipSubmodules: parsedArguments['skip-submodules'] as bool,
8074
);
8175
exit(exitCode);
8276
}

tool/fix_copyright/lib/fix_copyright.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2025 The Flutter Authors. All rights reserved.
1+
// Copyright 2025 The Flutter Authors.
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file.
44

tool/fix_copyright/lib/src/fix_copyright.dart

Lines changed: 45 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2025 The Flutter Authors. All rights reserved.
1+
// Copyright 2025 The Flutter Authors.
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file.
44

@@ -19,7 +19,6 @@ Future<int> fixCopyrights(
1919
required bool force,
2020
required String year,
2121
required List<String> paths,
22-
bool skipSubmodules = true,
2322
ProcessManager processManager = const LocalProcessManager(),
2423
LogFunction? log,
2524
LogFunction? error,
@@ -32,47 +31,43 @@ Future<int> fixCopyrights(
3231
(error ?? stderr.writeln as LogFunction).call(message);
3332

3433
final Set<String> submodulePaths;
35-
if (skipSubmodules) {
36-
final gitRootResult = await processManager.run([
34+
final gitRootResult = await processManager.run([
35+
'git',
36+
'rev-parse',
37+
'--show-toplevel',
38+
]);
39+
if (gitRootResult.exitCode != 0) {
40+
stdErr('Warning: not a git repository. Cannot check for submodules.');
41+
submodulePaths = <String>{};
42+
} else {
43+
final repoRoot = gitRootResult.stdout.toString().trim();
44+
final result = await processManager.run([
3745
'git',
38-
'rev-parse',
39-
'--show-toplevel',
40-
]);
41-
if (gitRootResult.exitCode != 0) {
42-
stdErr('Warning: not a git repository. Cannot check for submodules.');
43-
submodulePaths = <String>{};
46+
'submodule',
47+
'status',
48+
'--recursive',
49+
], workingDirectory: repoRoot);
50+
if (result.exitCode == 0) {
51+
submodulePaths = result.stdout
52+
.toString()
53+
.split('\n')
54+
.where((line) => line.trim().isNotEmpty)
55+
.map((line) {
56+
final parts = line.trim().split(RegExp(r'\s+'));
57+
if (parts.length > 1) {
58+
return path.canonicalize(path.join(repoRoot, parts[1]));
59+
}
60+
return null;
61+
})
62+
.whereType<String>()
63+
.toSet();
4464
} else {
45-
final repoRoot = gitRootResult.stdout.toString().trim();
46-
final result = await processManager.run([
47-
'git',
48-
'submodule',
49-
'status',
50-
'--recursive',
51-
], workingDirectory: repoRoot);
52-
if (result.exitCode == 0) {
53-
submodulePaths = result.stdout
54-
.toString()
55-
.split('\n')
56-
.where((line) => line.trim().isNotEmpty)
57-
.map((line) {
58-
final parts = line.trim().split(RegExp(r'\s+'));
59-
if (parts.length > 1) {
60-
return path.canonicalize(path.join(repoRoot, parts[1]));
61-
}
62-
return null;
63-
})
64-
.whereType<String>()
65-
.toSet();
66-
} else {
67-
submodulePaths = <String>{};
68-
stdErr(
69-
'Warning: could not get submodule status. '
70-
'Not skipping any submodules.',
71-
);
72-
}
65+
submodulePaths = <String>{};
66+
stdErr(
67+
'Warning: could not get submodule status. '
68+
'Not skipping any submodules.',
69+
);
7370
}
74-
} else {
75-
submodulePaths = <String>{};
7671
}
7772

7873
String getExtension(File file) {
@@ -85,8 +80,7 @@ Future<int> fixCopyrights(
8580
final directories = <Directory>[dir];
8681
while (directories.isNotEmpty) {
8782
final currentDir = directories.removeAt(0);
88-
if (skipSubmodules &&
89-
submodulePaths.contains(path.canonicalize(currentDir.path))) {
83+
if (submodulePaths.contains(path.canonicalize(currentDir.path))) {
9084
stdLog('Skipping submodule: ${currentDir.path}');
9185
continue;
9286
}
@@ -161,6 +155,8 @@ Future<int> fixCopyrights(
161155
}
162156
}
163157

158+
contents = contents.trimLeft();
159+
164160
// If a sort-of correct copyright is there, but just doesn't have the
165161
// right case, date, spacing, license type or trailing newline, then
166162
// remove it.
@@ -171,7 +167,7 @@ Future<int> fixCopyrights(
171167
contents = contents.trimLeft();
172168
var newContents = '';
173169
if (fileHeader != null) {
174-
final String copyrightBlock =
170+
final copyrightBlock =
175171
'${info.copyright}${info.trailingBlank ? '\n\n' : '\n'}';
176172
newContents = '$fileHeader$copyrightBlock$contents';
177173
} else {
@@ -226,6 +222,7 @@ class CopyrightInfo {
226222
return RegExp(
227223
'^(?:${headerPattern ?? (header != null ? RegExp.escape(header!) : '')})?'
228224
'${RegExp.escape(copyright)}\n${trailingBlank ? r'\n' : ''}',
225+
multiLine: true,
229226
);
230227
}
231228

@@ -254,7 +251,7 @@ Map<String, CopyrightInfo> _generateExtensionMap(String year) {
254251
String suffix = '',
255252
required bool isParagraph,
256253
}) {
257-
return '''${prefix}Copyright $year The Flutter Authors. All rights reserved.${isParagraph ? '' : suffix}
254+
return '''${prefix}Copyright $year The Flutter Authors.${isParagraph ? '' : suffix}
258255
${isParagraph ? '' : prefix}Use of this source code is governed by a BSD-style license that can be${isParagraph ? '' : suffix}
259256
${isParagraph ? '' : prefix}found in the LICENSE file.$suffix''';
260257
}
@@ -267,7 +264,7 @@ ${isParagraph ? '' : prefix}found in the LICENSE file.$suffix''';
267264
final escapedSuffix = RegExp.escape(suffix);
268265

269266
return '($escapedPrefix'
270-
r'Copyright (\d+) ([\w ]+)\.?\s+All rights reserved.'
267+
r'Copyright (\d+) ([\w ]+)\.?(?:\s*All rights reserved.)?'
271268
'(?:$escapedSuffix)?\\n'
272269
'(?:$escapedPrefix)?'
273270
r'Use of this source code is governed by a [-\w]+ license that can be'
@@ -311,7 +308,7 @@ ${isParagraph ? '' : prefix}found in the LICENSE file.$suffix''';
311308
'cc': generateInfo(prefix: '// '),
312309
'cmake': generateInfo(prefix: '# '),
313310
'cpp': generateInfo(prefix: '// '),
314-
'dart': generateInfo(prefix: '// '),
311+
'dart': generateInfo(prefix: '// ', headerPattern: r'(?<header>#!.*\n?)'),
315312
'gn': generateInfo(prefix: '# '),
316313
'gradle': generateInfo(prefix: '// '),
317314
'h': generateInfo(prefix: '// '),
@@ -321,7 +318,7 @@ ${isParagraph ? '' : prefix}found in the LICENSE file.$suffix''';
321318
isParagraph: true,
322319
trailingBlank: false,
323320
header: '<!DOCTYPE HTML>\n',
324-
headerPattern: r'(?<header><!DOCTYPE\s+HTML[^>]*>\n)?',
321+
headerPattern: r'(?<header><!DOCTYPE\s+HTML[^>]*>\n?)?',
325322
),
326323
'js': generateInfo(prefix: '// '),
327324
'java': generateInfo(prefix: '// '),
@@ -336,7 +333,7 @@ ${isParagraph ? '' : prefix}found in the LICENSE file.$suffix''';
336333
suffix: ' -->',
337334
isParagraph: true,
338335
headerPattern:
339-
r'''(?<header><\?xml\s+(?:version="1.0"\s+encoding="utf-8"|encoding="utf-8"\s+version="1.0")[^>]*\?>\n|)''',
336+
r'''(?<header><\?xml\s+(?:version="1.0"\s+encoding="utf-8"|encoding="utf-8"\s+version="1.0")[^>]*\?>\n?|)''',
340337
),
341338
'yaml': generateInfo(prefix: '# '),
342339
};

tool/fix_copyright/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright 2025 The Flutter Authors. All rights reserved.
1+
# Copyright 2025 The Flutter Authors.
22
# Use of this source code is governed by a BSD-style license that can be
33
# found in the LICENSE file.
44

tool/fix_copyright/test/fix_copyright_test.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2025 The Flutter Authors. All rights reserved.
1+
// Copyright 2025 The Flutter Authors.
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file.
44

@@ -15,7 +15,7 @@ void main() {
1515
const year = '2025';
1616
const copyright =
1717
'''
18-
// Copyright $year The Flutter Authors. All rights reserved.
18+
// Copyright $year The Flutter Authors.
1919
// Use of this source code is governed by a BSD-style license that can be
2020
// found in the LICENSE file.''';
2121
String getBadCopyright({String prefix = '//'}) =>
@@ -278,7 +278,7 @@ $prefix found in the LICENSE file.''';
278278
test('updates an xml file', () async {
279279
const xmlPreamble = '<?xml version="1.0" encoding="utf-8"?>\n<root/>';
280280
const xmlCopyright = '''
281-
<!-- Copyright 2025 The Flutter Authors. All rights reserved.
281+
<!-- Copyright 2025 The Flutter Authors.
282282
Use of this source code is governed by a BSD-style license that can be
283283
found in the LICENSE file. -->''';
284284
final testFile = fileSystem.file('test.xml')

tool/refresh_firebase_template.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/bin/bash
2-
# Copyright 2025 The Flutter Authors. All rights reserved.
2+
# Copyright 2025 The Flutter Authors.
33
# Use of this source code is governed by a BSD-style license that can be
44
# found in the LICENSE file.
55

tool/refresh_packages.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/usr/bin/env bash
2-
# Copyright 2025 The Flutter Authors. All rights reserved.
2+
# Copyright 2025 The Flutter Authors.
33
# Use of this source code is governed by a BSD-style license that can be
44
# found in the LICENSE file.
55

tool/run_all_tests_and_fixes.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/bin/bash
2-
# Copyright 2025 The Flutter Authors. All rights reserved.
2+
# Copyright 2025 The Flutter Authors.
33
# Use of this source code is governed by a BSD-style license that can be
44
# found in the LICENSE file.
55

@@ -46,7 +46,7 @@ run_project_step() {
4646
echo ""
4747
echo "### [$step_num/$PROJECT_TOTAL_STEPS] $description"
4848
echo "> To rerun this command:"
49-
echo ">
49+
echo ">
5050
> (cd \"$project_dir\" && $cmd_str_for_display)
5151
> "
5252
if ! "${cmd_to_run[@]}"; then
@@ -87,7 +87,7 @@ echo "---"
8787
if [ -f "tool/fix_copyright/bin/fix_copyright.dart" ]; then
8888
echo "### Running copyright fix"
8989
echo "> To rerun this command:"
90-
echo ">
90+
echo ">
9191
> dart run tool/fix_copyright/bin/fix_copyright.dart --force
9292
> "
9393
# Log failures without stopping the script.

0 commit comments

Comments
 (0)