MCPcopy Index your code
hub / github.com/isomorphic-git/isomorphic-git / _commit

Function _commit

src/commands/commit.js:46–184  ·  view source on GitHub ↗
({
  fs,
  cache,
  onSign,
  gitdir,
  message,
  author: _author,
  committer: _committer,
  signingKey,
  amend = false,
  dryRun = false,
  noUpdateBranch = false,
  ref,
  parent,
  tree,
})

Source from the content-addressed store, hash-verified

44 * @returns {Promise<string>} Resolves successfully with the SHA-1 object id of the newly created commit.
45 */
46export async function _commit({
47 fs,
48 cache,
49 onSign,
50 gitdir,
51 message,
52 author: _author,
53 committer: _committer,
54 signingKey,
55 amend = false,
56 dryRun = false,
57 noUpdateBranch = false,
58 ref,
59 parent,
60 tree,
61}) {
62 // Determine ref and the commit pointed to by ref, and if it is the initial commit
63 let initialCommit = false
64 let detachedHead = false
65 if (!ref) {
66 const headContent = await fs.read(`${gitdir}/HEAD`, { encoding: 'utf8' })
67 detachedHead = !headContent.startsWith('ref:')
68 ref = await GitRefManager.resolve({
69 fs,
70 gitdir,
71 ref: 'HEAD',
72 depth: 2,
73 })
74 }
75
76 let refOid, refCommit
77 try {
78 refOid = await GitRefManager.resolve({
79 fs,
80 gitdir,
81 ref,
82 })
83 refCommit = await readCommit({ fs, gitdir, oid: refOid, cache: {} })
84 } catch {
85 // We assume that there's no commit and this is the initial commit
86 initialCommit = true
87 }
88
89 if (amend && initialCommit) {
90 throw new NoCommitError(ref)
91 }
92
93 // Determine author and committer information
94 const author = !amend
95 ? await normalizeAuthorObject({ fs, gitdir, author: _author })
96 : await normalizeAuthorObject({
97 fs,
98 gitdir,
99 author: _author,
100 commit: refCommit.commit,
101 })
102 if (!author) throw new MissingNameError('author')
103

Callers 5

_removeNoteFunction · 0.90
_addNoteFunction · 0.90
_mergeFunction · 0.90
_cherryPickFunction · 0.90
commitFunction · 0.90

Calls 14

normalizeAuthorObjectFunction · 0.90
normalizeCommitterObjectFunction · 0.90
readCommitFunction · 0.85
constructTreeFunction · 0.85
resolveMethod · 0.80
acquireMethod · 0.80
writeRefMethod · 0.80
writeObjectFunction · 0.70
readMethod · 0.45
getMethod · 0.45
fromMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…