angular-docs-cn/.ng-dev/config.ts

120 lines
2.8 KiB
TypeScript
Raw Normal View History

import {MergeConfig} from '../dev-infra/pr/merge/config';
// The configuration for `ng-dev commit-message` commands.
const commitMessage = {
'maxLength': 120,
ci: decrease the minBodyLength commit message limit to 20 chars (#37949) The motivation behind this change is to improve the productivity in the angular/angular repo without sacrificing the original goal of having better understanding of changes within the repo. When the minBodyLength limit was originally introduced the goal was simple: force committers to provide more contextual information for each change coming into the repo. Too often we found ourselves in a situation where nobody understood what motivated some of the changes and we needed more contextual info to know if the change was correct, desirable, and still relevant (at a later point in time). When the limit was introduced, we needed to pick a minimum body length - given no data, and frustration with even big changes being committed with just a words in the subject (along the lines of "fix(core): fixing a bug"), we overcompensated and started off with a really high bar of minBodyLength set to 100 chars. This turned out to be impractical and created a big friction point in making valid changes in the angular/angular repo, and in fact caused some of the refactorings and smaller changes to be either skipped or combined into other commits which increased the burden for code reviewers. The evidence in the friction points can be seen in the number of PRs that fail to pass the current lint check on the first try, but more importantly also in the "creative" writing that some of the committers are forced to resort to in order to satisfy the current checks. Examples: - https://github.com/angular/angular/commit/286fbf42c65a02e6da7420cd19a2c5baff3f2656 - https://github.com/angular/angular/commit/b2816a1536075397d876ba27ce2b7dcd785d4a39 Given that we primarily care to document the motivation behind each change (the answer to the ultimate question: WHY?), I've collected several *common* & *valid* commit messages that are minimalistic and capture the WHY sufficiently: ``` Refactoring for readability. => 28 chars Improving variable naming. => 26 chars Additional test coverage. => 25 chars Cleaning up the code. => 21 chars Simplified the code. => 20 chars ``` These commit message bodies in addition to the commit message subject should sufficiently satisfy the need to capture the context and motivation behind each change without creating an undue burden on committers. Example minimalistic commit message: ------ refactor(core): cleanup the expression parser Simplifying the code. ---- Given this research, I'm decreasing the minBodyLenth in angular/angular to 20 chars. The commit message quality can be additionally improved by implementing a commit message template via `.gitmessage` that will guide the committers in following our commit message guidelines via instructions provided in the form of in-the-flow help rather than as an after the fact lint check. More info: https://thoughtbot.com/blog/better-commit-messages-with-a-gitmessage-template I'm intentionally deferring such change for a separate PR as not to complicate or delay the minBodyLength limit decrease. PR Close #37949
2020-07-06 17:27:19 -04:00
'minBodyLength': 20,
'minBodyLengthTypeExcludes': ['docs'],
'types': [
'build',
'ci',
'docs',
'feat',
'fix',
'perf',
'refactor',
'release',
'style',
'test',
],
'scopes': [
'animations',
'bazel',
'benchpress',
'changelog',
'common',
'compiler',
'compiler-cli',
'core',
'dev-infra',
'docs-infra',
'elements',
'forms',
'http',
'language-service',
'localize',
'migrations',
'ngcc',
'packaging',
'platform-browser',
'platform-browser-dynamic',
'platform-server',
'platform-webworker',
'platform-webworker-dynamic',
'router',
'service-worker',
'upgrade',
've',
'zone.js',
]
};
// The configuration for `ng-dev format` commands.
const format = {
'clang-format': {
'matchers': [
'**/*.{js,ts}',
// TODO: burn down format failures and remove aio and integration exceptions.
'!aio/**',
'!integration/**',
// Both third_party and .yarn are directories containing copied code which should
// not be modified.
'!third_party/**',
'!.yarn/**',
// Do not format d.ts files as they are generated
'!**/*.d.ts',
]
},
'buildifier': true
};
/** Github metadata information for `ng-dev` commands. */
const github = {
owner: 'angular',
name: 'angular',
};
// Configuration for the `ng-dev pr merge` command. The command can be used
// for merging upstream pull requests into branches based on a PR target label.
const merge = () => {
// TODO: resume dynamically determining patch branch
const patch = '10.0.x';
const config: MergeConfig = {
githubApiMerge: false,
claSignedLabel: 'cla: yes',
mergeReadyLabel: /^PR action: merge(-assistance)?/,
caretakerNoteLabel: 'PR action: merge-assistance',
commitMessageFixupLabel: 'commit message fixup',
labels: [
{
pattern: 'PR target: master-only',
branches: ['master'],
},
{
pattern: 'PR target: patch-only',
branches: [patch],
},
{
pattern: 'PR target: master & patch',
branches: ['master', patch],
},
],
requiredBaseCommits: {
// PRs that target either `master` or the patch branch, need to be rebased
// on top of the latest commit message validation fix.
// These SHAs are the commits that update the required license text in the header.
'master': '5aeb9a4124922d8ac08eb73b8f322905a32b0b3a',
[patch]: '27b95ba64a5d99757f4042073fd1860e20e3ed24'
},
};
return config;
};
// Export function to build ng-dev configuration object.
module.exports = {
commitMessage,
format,
github,
merge,
};