@able-autonomy/able 0.0.8 → 0.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/config.ts +6 -0
- package/package.json +1 -1
- package/src/commit.ts +4 -3
- package/src/workspaces/new.ts +2 -2
package/config.ts
CHANGED
|
@@ -37,6 +37,9 @@ export interface AbleConfig {
|
|
|
37
37
|
* touches; kept fast. `merge`: run from the root after those, at `able ws merge` only (the cross-package checks).
|
|
38
38
|
* Any failure stops it. Release checks (builds, tests) come with the Release module (98). */
|
|
39
39
|
checks?: { commit?: Record<string, Command[]>; merge?: Command[] }
|
|
40
|
+
/** `trailers`: lines such as `Co-Authored-By: …`, added to every commit Able makes with `able commit` and
|
|
41
|
+
* `able ws new --brief` (and so `able sync`'s); a message that already ends with one is not given it twice. */
|
|
42
|
+
commit?: { trailers?: string[] }
|
|
40
43
|
workspaces?: WorkspacesConfig
|
|
41
44
|
/** The branch workspaces are cut from and merged into. */
|
|
42
45
|
trunk: string
|
|
@@ -46,6 +49,9 @@ export interface AbleConfig {
|
|
|
46
49
|
knowledge?: string
|
|
47
50
|
}
|
|
48
51
|
|
|
52
|
+
/** The `git commit` flags for the host's trailers. */
|
|
53
|
+
export const trailerArgs = (config: AbleConfig) => (config.commit?.trailers ?? []).flatMap((t) => ['--trailer', t])
|
|
54
|
+
|
|
49
55
|
/** Types and editor help for `able.config.ts`; returns the config unchanged. */
|
|
50
56
|
export const defineConfig = (config: AbleConfig): AbleConfig => config
|
|
51
57
|
|
package/package.json
CHANGED
package/src/commit.ts
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
|
|
10
10
|
import { existsSync } from 'node:fs'
|
|
11
11
|
import { join, relative, resolve } from 'node:path'
|
|
12
|
-
import { loadConfig } from '../config.ts'
|
|
12
|
+
import { loadConfig, trailerArgs } from '../config.ts'
|
|
13
13
|
import { runChecks } from './checks.ts'
|
|
14
14
|
import { failOnMerge, git, gitLoud } from './git.ts'
|
|
15
15
|
import { bold, confirm, dim, fail, green } from './ui.ts'
|
|
@@ -45,11 +45,12 @@ for (const f of before) console.log(dim(` ${f}`))
|
|
|
45
45
|
if (argv.includes('--dry')) process.exit(0)
|
|
46
46
|
if (!argv.includes('--yes') && !confirm(`Run the checks and commit as "${msg}"?`)) fail('aborted; nothing committed')
|
|
47
47
|
|
|
48
|
-
|
|
48
|
+
const config = await loadConfig(root)
|
|
49
|
+
if (!runChecks(config, before, at)) fail('a check failed; nothing committed')
|
|
49
50
|
|
|
50
51
|
// The checks may have formatted files, so the list is read again.
|
|
51
52
|
const paths = changed()
|
|
52
53
|
// A path that is gone (a deletion, a rename's old name) has nothing to add, but still goes into the commit.
|
|
53
54
|
const present = paths.filter((p) => existsSync(join(root, p)))
|
|
54
|
-
if ((present.length && !gitLoud(root, 'add', '--', ...present)) || !gitLoud(root, 'commit', '--quiet', '-m', msg, '--', ...paths)) fail('git commit failed')
|
|
55
|
+
if ((present.length && !gitLoud(root, 'add', '--', ...present)) || !gitLoud(root, 'commit', '--quiet', '-m', msg, ...trailerArgs(config), '--', ...paths)) fail('git commit failed')
|
|
55
56
|
console.log(`\n ${green('✓')} ${git(root, 'log', '--oneline', '-1')}\n`)
|
package/src/workspaces/new.ts
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
|
|
9
9
|
import { copyFileSync, existsSync, mkdirSync } from 'node:fs'
|
|
10
10
|
import { dirname, join, relative, resolve } from 'node:path'
|
|
11
|
-
import { loadConfig } from '../../config.ts'
|
|
11
|
+
import { loadConfig, trailerArgs } from '../../config.ts'
|
|
12
12
|
import { runChecks } from '../checks.ts'
|
|
13
13
|
import { count, failOnMerge, fetchTrunk, git, gitLoud, mainRoot } from '../git.ts'
|
|
14
14
|
import { runCommand } from '../run.ts'
|
|
@@ -49,7 +49,7 @@ if (args.includes('--brief')) {
|
|
|
49
49
|
if (git(main, 'status', '--porcelain', '--', file)) {
|
|
50
50
|
const at = { slug: 'main', path: main, portOffset: 0, main }
|
|
51
51
|
if (!runChecks(config, [file], at)) fail('a check failed; nothing committed')
|
|
52
|
-
if (!gitLoud(main, 'add', '--', file) || !gitLoud(main, 'commit', '--quiet', '-m', `journal: ${slug} brief`, '--', file)) fail('commit of the brief failed')
|
|
52
|
+
if (!gitLoud(main, 'add', '--', file) || !gitLoud(main, 'commit', '--quiet', '-m', `journal: ${slug} brief`, ...trailerArgs(config), '--', file)) fail('commit of the brief failed')
|
|
53
53
|
}
|
|
54
54
|
if (count(main, `origin/${trunk}..${trunk}`) && !gitLoud(main, 'push', '--quiet', 'origin', trunk)) fail(`push of ${trunk} failed`)
|
|
55
55
|
}
|