This repository was archived by the owner on Feb 25, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6k
Adds githooks that reminds to run gclient sync -D
#51156
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| // Copyright 2013 The Flutter Authors. All rights reserved. | ||
| // Use of this source code is governed by a BSD-style license that can be | ||
| // found in the LICENSE file. | ||
|
|
||
| import 'dart:io' as io; | ||
|
|
||
| const String _redBoldUnderline = '\x1B[31;1;4m'; | ||
| const String _reset = '\x1B[0m'; | ||
|
|
||
| /// Prints a reminder to stdout to run `gclient sync -D`. Uses colors when | ||
| /// stdout supports ANSI escape codes. | ||
| void printGclientSyncReminder(String command) { | ||
| final String prefix = io.stdout.supportsAnsiEscapes ? _redBoldUnderline : ''; | ||
| final String postfix = io.stdout.supportsAnsiEscapes ? _reset : ''; | ||
| io.stderr.writeln('$command: The engine source tree has been updated.'); | ||
| io.stderr.writeln( | ||
| '\n${prefix}You man need to run "gclient sync -D"$postfix\n', | ||
| ); | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| // Copyright 2013 The Flutter Authors. All rights reserved. | ||
| // Use of this source code is governed by a BSD-style license that can be | ||
| // found in the LICENSE file. | ||
|
|
||
| import 'package:args/command_runner.dart'; | ||
|
|
||
| import 'messages.dart'; | ||
|
|
||
| /// The command that implements the post-checkout githook | ||
| class PostCheckoutCommand extends Command<bool> { | ||
| @override | ||
| final String name = 'post-checkout'; | ||
|
|
||
| @override | ||
| final String description = 'Checks that run after the worktree is updated'; | ||
|
|
||
| @override | ||
| Future<bool> run() async { | ||
| printGclientSyncReminder(name); | ||
| return true; | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| // Copyright 2013 The Flutter Authors. All rights reserved. | ||
| // Use of this source code is governed by a BSD-style license that can be | ||
| // found in the LICENSE file. | ||
|
|
||
| import 'package:args/command_runner.dart'; | ||
|
|
||
| import 'messages.dart'; | ||
|
|
||
| /// The command that implements the post-merge githook | ||
| class PostMergeCommand extends Command<bool> { | ||
| @override | ||
| final String name = 'post-merge'; | ||
|
|
||
| @override | ||
| final String description = 'Checks to run after a "git merge"'; | ||
|
|
||
| @override | ||
| Future<bool> run() async { | ||
| printGclientSyncReminder(name); | ||
| return true; | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| // Copyright 2013 The Flutter Authors. All rights reserved. | ||
| // Use of this source code is governed by a BSD-style license that can be | ||
| // found in the LICENSE file. | ||
|
|
||
| import 'package:args/command_runner.dart'; | ||
|
|
||
| import 'messages.dart'; | ||
|
|
||
| /// The command that implements the pre-rebase githook | ||
| class PreRebaseCommand extends Command<bool> { | ||
| @override | ||
| final String name = 'pre-rebase'; | ||
|
|
||
| @override | ||
| final String description = 'Checks to run before a "git rebase"'; | ||
|
|
||
| @override | ||
| Future<bool> run() async { | ||
| printGclientSyncReminder(name); | ||
| // Returning false here will block the rebase. | ||
| return true; | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| #!/usr/bin/env python3 | ||
| # Copyright 2013 The Flutter Authors. All rights reserved. | ||
| # Use of this source code is governed by a BSD-style license that can be | ||
| # found in the LICENSE file. | ||
|
|
||
| ''' | ||
| Runs the post-checkout githooks. | ||
| ''' | ||
|
|
||
| import os | ||
| import subprocess | ||
| import sys | ||
|
|
||
| SRC_ROOT = os.path.dirname(os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))) | ||
| FLUTTER_DIR = os.path.join(SRC_ROOT, 'flutter') | ||
| DART_BIN = os.path.join(SRC_ROOT, 'third_party', 'dart', 'tools', 'sdks', 'dart-sdk', 'bin') | ||
|
|
||
| def Main(argv): | ||
| githook_args = [ | ||
| '--flutter', | ||
| FLUTTER_DIR, | ||
| ] | ||
|
|
||
| result = subprocess.run([ | ||
| os.path.join(DART_BIN, 'dart'), | ||
| '--disable-dart-dev', | ||
| os.path.join(FLUTTER_DIR, 'tools', 'githooks', 'bin', 'main.dart'), | ||
| ] + githook_args + [ | ||
| 'post-checkout', | ||
| ] + argv[1:], cwd=SRC_ROOT) | ||
| return result.returncode | ||
|
|
||
|
|
||
| if __name__ == '__main__': | ||
| sys.exit(Main(sys.argv)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| #!/usr/bin/env python3 | ||
| # Copyright 2013 The Flutter Authors. All rights reserved. | ||
| # Use of this source code is governed by a BSD-style license that can be | ||
| # found in the LICENSE file. | ||
|
|
||
| ''' | ||
| Runs the post-merge githooks. | ||
| ''' | ||
|
|
||
| import os | ||
| import subprocess | ||
| import sys | ||
|
|
||
| SRC_ROOT = os.path.dirname(os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))) | ||
| FLUTTER_DIR = os.path.join(SRC_ROOT, 'flutter') | ||
| DART_BIN = os.path.join(SRC_ROOT, 'third_party', 'dart', 'tools', 'sdks', 'dart-sdk', 'bin') | ||
|
|
||
| def Main(argv): | ||
| githook_args = [ | ||
| '--flutter', | ||
| FLUTTER_DIR, | ||
| ] | ||
|
|
||
| result = subprocess.run([ | ||
| os.path.join(DART_BIN, 'dart'), | ||
| '--disable-dart-dev', | ||
| os.path.join(FLUTTER_DIR, 'tools', 'githooks', 'bin', 'main.dart'), | ||
| ] + githook_args + [ | ||
| 'post-merge', | ||
| ] + argv[1:], cwd=SRC_ROOT) | ||
| return result.returncode | ||
|
|
||
|
|
||
| if __name__ == '__main__': | ||
| sys.exit(Main(sys.argv)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| #!/usr/bin/env python3 | ||
| # Copyright 2013 The Flutter Authors. All rights reserved. | ||
| # Use of this source code is governed by a BSD-style license that can be | ||
| # found in the LICENSE file. | ||
|
|
||
| ''' | ||
| Runs the pre-rebase githooks. | ||
| ''' | ||
|
|
||
| import os | ||
| import subprocess | ||
| import sys | ||
|
|
||
| SRC_ROOT = os.path.dirname(os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))) | ||
| FLUTTER_DIR = os.path.join(SRC_ROOT, 'flutter') | ||
| DART_BIN = os.path.join(SRC_ROOT, 'third_party', 'dart', 'tools', 'sdks', 'dart-sdk', 'bin') | ||
|
|
||
| def Main(argv): | ||
| githook_args = [ | ||
| '--flutter', | ||
| FLUTTER_DIR, | ||
| ] | ||
|
|
||
| result = subprocess.run([ | ||
| os.path.join(DART_BIN, 'dart'), | ||
| '--disable-dart-dev', | ||
| os.path.join(FLUTTER_DIR, 'tools', 'githooks', 'bin', 'main.dart'), | ||
| ] + githook_args + [ | ||
| 'pre-rebase', | ||
| ] + argv[1:], cwd=SRC_ROOT) | ||
| return result.returncode | ||
|
|
||
|
|
||
| if __name__ == '__main__': | ||
| sys.exit(Main(sys.argv)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo?
'\n${prefix}You may need to run "gclient sync -D"$postfix\n',