Skip to content

Commit 16447ce

Browse files
committed
chore(build): improve messaging when using clang-format
1 parent 15f1eb2 commit 16447ce

File tree

5 files changed

+24
-10
lines changed

5 files changed

+24
-10
lines changed

DEVELOPER.md

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -197,21 +197,34 @@ Angular specific command line options when running protractor (e.g. force gc, ..
197197

198198
## Formatting
199199

200-
We use [clang-format](http://clang.llvm.org/docs/ClangFormat.html) to automatically enforce code style for our TypeScript code. This allows us to focus our code reviews more on the content, and less on style nit-picking. It also lets us encode our style guide in the `.clang-format` file in the repository, allowing many tools and editors to share our settings.
200+
We use [clang-format](http://clang.llvm.org/docs/ClangFormat.html) to automatically enforce code style for our TypeScript code.
201+
This allows us to focus our code reviews more on the content, and less on style nit-picking.
202+
It also lets us encode our style guide in the `.clang-format` file in the repository,
203+
allowing many tools and editors to share our settings.
201204

202205
To check the formatting of your code, run
203206

204207
gulp check-format
205208

206-
Note that the continuous build on Travis runs `gulp enforce-format`. Unlike the `check-format` task, this will actually fail the build if files aren't formatted according to the style guide.
209+
Note that the continuous build on Travis runs `gulp enforce-format`.
210+
Unlike the `check-format` task, this will actually fail the build if files aren't formatted according to the style guide.
207211

208-
Your life will be easier if you include the formatter in your standard workflow. Otherwise, you'll likely forget to check the formatting, and waste time waiting for a build on Travis that fails due to some whitespace difference.
212+
Your life will be easier if you include the formatter in your standard workflow.
213+
Otherwise, you'll likely forget to check the formatting,
214+
and waste time waiting for a build on Travis that fails due to some whitespace difference.
215+
216+
* **git pre-commit hook** is available at
217+
[llvm.org](https://llvm.org/svn/llvm-project/cfe/trunk/tools/clang-format/git-clang-format).
218+
This will automatically format your delta regions when you commit a change.
219+
To install, first patch this file to add `.ts` to the `default_extensions` section.
220+
Then copy the file somewhere in your path, for example, `/usr/local/git/current/bin/git-clang-format`.
221+
Make sure it is executable. Then, in the angular repo, run
209222

210-
* **git pre-commit hook** is available at [llvm.org](https://llvm.org/svn/llvm-project/cfe/trunk/tools/clang-format/git-clang-format). This will automatically format your delta regions when you commit a change. To install, first patch this file to add `.ts` to the `default_extensions` section. Then copy the file somewhere in your path, for example, `/usr/local/git/current/bin/git-clang-format`. Make sure it is executable. Then, in the angular repo, run
211223
```
212224
$ echo -e '#!/bin/sh\nexec git clang-format' > .git/hooks/pre-commit
213225
$ chmod u+x !$
214226
```
227+
215228
* **WebStorm** can run clang-format on the current file.
216229
1. Under Preferences, open Tools > External Tools.
217230
1. Plus icon to Create Tool

gulpfile.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,8 @@ gulp.task('check-format', function() {
227227

228228
gulp.task('enforce-format', function() {
229229
return doCheckFormat().on('warning', function(e) {
230-
console.log("ERROR: Some files need formatting");
230+
console.log("ERROR: You forgot to run clang-format on your change.");
231+
console.log("See https://github.com/angular/angular/blob/master/DEVELOPER.md#formatting");
231232
process.exit(1);
232233
});
233234
});

npm-shrinkwrap.clean.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3934,7 +3934,7 @@
39343934
}
39353935
},
39363936
"gulp-clang-format": {
3937-
"version": "1.0.13",
3937+
"version": "1.0.14",
39383938
"dependencies": {
39393939
"gulp-util": {
39403940
"version": "3.0.4",

npm-shrinkwrap.json

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@
6464
"gulp": "^3.8.8",
6565
"gulp-autoprefixer": "^2.1.0",
6666
"gulp-changed": "^1.0.0",
67-
"gulp-clang-format": "^1.0.13",
67+
"gulp-clang-format": "^1.0.14",
6868
"gulp-concat": "^2.5.2",
6969
"gulp-connect": "~1.0.5",
7070
"gulp-load-plugins": "^0.7.1",

0 commit comments

Comments
 (0)