Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5109)

Unified Diff: clang_format_merge_driver.py

Issue 2348793003: Introduce git merge driver for the blink reformatting
Patch Set: Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « clang_format_merge_driver.bat ('k') | gclient.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: clang_format_merge_driver.py
diff --git a/clang_format_merge_driver.py b/clang_format_merge_driver.py
new file mode 100755
index 0000000000000000000000000000000000000000..c40a85664b6980d20a045f57b33a9c185b943d96
--- /dev/null
+++ b/clang_format_merge_driver.py
@@ -0,0 +1,36 @@
+#!/usr/bin/env python
+# Copyright 2016 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+"""Clang-format 3-way merge driver.
+
+"""
+
+import subprocess
+import sys
+
+import clang_format
+
+def main():
+ if len(sys.argv) < 6:
+ print('usage: %s <base> <current> <others> <ignored> <path in the tree>' %
+ sys.argv[0])
+ sys.exit(1)
+
+ base, current, others, _, file_name_in_tree = sys.argv[1:6]
+ print '\nRunning clang-format 3-way merge driver on ' + file_name_in_tree
+
+ try:
+ tool = clang_format.FindClangFormatToolInChromiumTree()
+ for fpath in base, current, others:
+ subprocess.call([tool, '-i', '--style=chromium', fpath])
+ except clang_format.NotFoundError, e:
+ print e
+ print 'Failed to find clang-format. Falling-back on standard 3-way merge'
+
+ return subprocess.call(['git', 'merge-file', '-Lcurrent', '-Lbase', '-Lother',
+ current, base, others])
+
+if __name__ == '__main__':
+ sys.exit(main())
« no previous file with comments | « clang_format_merge_driver.bat ('k') | gclient.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698