MCPcopy Create free account
hub / github.com/isomorphic-git/isomorphic-git / normalizeAuthorObject

Function normalizeAuthorObject

src/utils/normalizeAuthorObject.js:20–46  ·  view source on GitHub ↗
({ fs, gitdir, author, commit })

Source from the content-addressed store, hash-verified

18 * @returns {Promise<void | {name: string, email: string, timestamp: number, timezoneOffset: number }>}
19 */
20export async function normalizeAuthorObject({ fs, gitdir, author, commit }) {
21 const timestamp = Math.floor(Date.now() / 1000)
22
23 const defaultAuthor = {
24 name: await _getConfig({ fs, gitdir, path: 'user.name' }),
25 email: (await _getConfig({ fs, gitdir, path: 'user.email' })) || '', // author.email is allowed to be empty string
26 timestamp,
27 timezoneOffset: new Date(timestamp * 1000).getTimezoneOffset(),
28 }
29
30 // Populate author object by using properties with this priority:
31 // (1) provided author object
32 // -> (2) author of provided commit object
33 // -> (3) default author
34 const normalizedAuthor = assignDefined(
35 {},
36 defaultAuthor,
37 commit ? commit.author : undefined,
38 author
39 )
40
41 if (normalizedAuthor.name === undefined) {
42 return undefined
43 }
44
45 return normalizedAuthor
46}

Callers 9

_commitFunction · 0.90
getAuthorMethod · 0.90
removeNoteFunction · 0.90
annotatedTagFunction · 0.90
addNoteFunction · 0.90
mergeFunction · 0.90
pullFunction · 0.90

Calls 2

_getConfigFunction · 0.90
assignDefinedFunction · 0.90

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…