-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcommit.task.ts
More file actions
34 lines (29 loc) 路 888 Bytes
/
Copy pathcommit.task.ts
File metadata and controls
34 lines (29 loc) 路 888 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import { spawn } from '@fuzdev/fuz_util/process.ts';
import { z } from 'zod';
import { GitOrigin, git_current_branch_name, git_push } from '@fuzdev/fuz_util/git.ts';
import type { Task } from './task.ts';
/** @nodocs */
export const Args = z.strictObject({
_: z
.array(z.string())
.meta({
description: 'the git commit message, the same as git commit -m or --message'
})
.default([]),
origin: GitOrigin.meta({ description: 'git origin to commit to' }).default('origin')
});
export type Args = z.infer<typeof Args>;
/** @nodocs */
export const task: Task<Args> = {
summary: 'commit and push to a new branch',
Args,
run: async ({ args }): Promise<void> => {
const {
_: [message],
origin
} = args;
const branch = await git_current_branch_name();
await spawn('git', ['commit', '-a', '-m', message!]);
await git_push(origin, branch, undefined, true);
}
};