Custom committer support (#264)
* feat: add support for a custom committer * chore: update build * chore: remove redundant code The author is correctly set by the git config (line 40) * docs: add new feature docs * docs(README): add example use of committer info Closes #265
This commit is contained in:
28
src/main.ts
28
src/main.ts
@@ -40,6 +40,10 @@ core.info(`Running in ${baseDir}`)
|
||||
await git
|
||||
.addConfig('user.email', getInput('author_email'), undefined, log)
|
||||
.addConfig('user.name', getInput('author_name'), undefined, log)
|
||||
.addConfig('author.email', getInput('author_email'), undefined, log)
|
||||
.addConfig('author.name', getInput('author_name'), undefined, log)
|
||||
.addConfig('committer.email', getInput('committer_email'), undefined, log)
|
||||
.addConfig('committer.name', getInput('committer_name'), undefined, log)
|
||||
core.debug(
|
||||
'> Current git config\n' +
|
||||
JSON.stringify((await git.listConfig()).all, null, 2)
|
||||
@@ -75,9 +79,6 @@ core.info(`Running in ${baseDir}`)
|
||||
getInput('message'),
|
||||
undefined,
|
||||
{
|
||||
'--author': `"${getInput('author_name')} <${getInput(
|
||||
'author_email'
|
||||
)}>"`,
|
||||
...(getInput('signoff')
|
||||
? {
|
||||
'--signoff': null
|
||||
@@ -238,6 +239,7 @@ async function checkInputs() {
|
||||
', '
|
||||
)}`
|
||||
)
|
||||
// #endregion
|
||||
|
||||
// #region author_name, author_email
|
||||
let name, email
|
||||
@@ -289,6 +291,25 @@ async function checkInputs() {
|
||||
)
|
||||
// #endregion
|
||||
|
||||
// #region committer_name, committer_email
|
||||
if (getInput('committer_name') || getInput('committer_email'))
|
||||
core.info(
|
||||
`> Using custom committer info: ${
|
||||
getInput('committer_name') ||
|
||||
getInput('author_name') + ' [from author info]'
|
||||
} <${
|
||||
getInput('committer_email') ||
|
||||
getInput('author_email') + ' [from author info]'
|
||||
}>`
|
||||
)
|
||||
|
||||
setDefault('committer_name', getInput('author_name'))
|
||||
setDefault('committer_email', getInput('author_email'))
|
||||
core.debug(
|
||||
`Committer: ${getInput('committer_name')} <${getInput('committer_email')}>`
|
||||
)
|
||||
// #endregion
|
||||
|
||||
// #region message
|
||||
setDefault(
|
||||
'message',
|
||||
@@ -349,6 +370,7 @@ async function checkInputs() {
|
||||
core.warning(
|
||||
'No github_token has been detected, the action may fail if it needs to use the API'
|
||||
)
|
||||
// #endregion
|
||||
}
|
||||
|
||||
async function add({ logWarning = true, ignoreErrors = false } = {}): Promise<
|
||||
|
||||
@@ -8,6 +8,8 @@ export type Input =
|
||||
| 'author_name'
|
||||
| 'author_email'
|
||||
| 'branch'
|
||||
| 'committer_name'
|
||||
| 'committer_email'
|
||||
| 'cwd'
|
||||
| 'default_author'
|
||||
| 'message'
|
||||
|
||||
Reference in New Issue
Block a user