Skip to content

Commit a6c0d89

Browse files
authored
feat: add fetch input
Ref #386
1 parent 4893421 commit a6c0d89

File tree

4 files changed

+33
-3
lines changed

4 files changed

+33
-3
lines changed

Diff for: action.yml

+4
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@ inputs:
2929
description: How the action should fill missing author name or email.
3030
required: false
3131
default: 'github_actor'
32+
fetch:
33+
description: Arguments for the git fetch command (if 'false', the action won't fetch the repo)
34+
required: false
35+
default: --tags --force
3236
message:
3337
description: The message for the commit
3438
required: false

Diff for: lib/index.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: src/io.ts

+15
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ interface InputTypes {
1010
committer_email: string
1111
cwd: string
1212
default_author: 'github_actor' | 'user_info' | 'github_actions'
13+
fetch: string
1314
message: string
1415
new_branch: string | undefined
1516
pathspec_error_handling: 'ignore' | 'exitImmediately' | 'exitAtEnd'
@@ -124,6 +125,20 @@ export async function checkInputs() {
124125
)
125126
// #endregion
126127

128+
// #region fetch
129+
if (getInput('fetch')) {
130+
let value: string | boolean
131+
132+
try {
133+
value = getInput('fetch', true)
134+
} catch {
135+
value = getInput('fetch')
136+
}
137+
138+
core.debug(`Currrent fetch option: '${value}' (parsed as ${typeof value})`)
139+
}
140+
// #endregion
141+
127142
// #region author_name, author_email
128143
let name, email
129144
switch (getInput('default_author')) {

Diff for: src/main.ts

+13-2
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,19 @@ core.info(`Running in ${baseDir}`)
5555
JSON.stringify((await git.listConfig()).all, null, 2)
5656
)
5757

58-
core.info('> Fetching repo...')
59-
await git.fetch(['--tags', '--force'], log)
58+
let fetchOption: string | boolean
59+
try {
60+
fetchOption = getInput('fetch', true)
61+
} catch {
62+
fetchOption = getInput('fetch')
63+
}
64+
if (fetchOption) {
65+
core.info('> Fetching repo...')
66+
await git.fetch(
67+
matchGitArgs(fetchOption === true ? '' : fetchOption),
68+
log
69+
)
70+
} else core.info('> Not fetching repo.')
6071

6172
const targetBranch = getInput('new_branch')
6273
if (targetBranch) {

0 commit comments

Comments
 (0)