isomorphic-git 1.26.5 → 1.27.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -0
- package/browser-tests.json +4 -7
- package/index.cjs +280 -153
- package/index.d.ts +21 -3
- package/index.js +280 -153
- package/index.umd.min.d.ts +21 -3
- package/index.umd.min.js +2 -2
- package/index.umd.min.js.map +1 -1
- package/package.json +1 -1
- package/size_report.html +1 -1
package/README.md
CHANGED
|
@@ -377,6 +377,7 @@ Thanks goes to these wonderful people ([emoji key](https://github.com/kentcdodds
|
|
|
377
377
|
<td align="center"><a href="https://github.com/limond"><img src="https://avatars.githubusercontent.com/u/1025682?v=4?s=60" width="60px;" alt=""/><br /><sub><b>Leon Kaucher</b></sub></a><br /><a href="https://github.com/isomorphic-git/isomorphic-git/commits?author=limond" title="Code">💻</a> <a href="https://github.com/isomorphic-git/isomorphic-git/commits?author=limond" title="Tests">⚠️</a></td>
|
|
378
378
|
<td align="center"><a href="https://github.com/gilisho"><img src="https://avatars.githubusercontent.com/u/40733156?v=4?s=60" width="60px;" alt=""/><br /><sub><b>Gili Shohat</b></sub></a><br /><a href="https://github.com/isomorphic-git/isomorphic-git/commits?author=gilisho" title="Code">💻</a> <a href="https://github.com/isomorphic-git/isomorphic-git/commits?author=gilisho" title="Documentation">📖</a> <a href="https://github.com/isomorphic-git/isomorphic-git/commits?author=gilisho" title="Tests">⚠️</a></td>
|
|
379
379
|
<td align="center"><a href="https://github.com/hhourani27"><img src="https://avatars.githubusercontent.com/u/61935766?v=4?s=60" width="60px;" alt=""/><br /><sub><b>Habib</b></sub></a><br /><a href="https://github.com/isomorphic-git/isomorphic-git/commits?author=hhourani27" title="Code">💻</a> <a href="https://github.com/isomorphic-git/isomorphic-git/commits?author=hhourani27" title="Documentation">📖</a> <a href="https://github.com/isomorphic-git/isomorphic-git/commits?author=hhourani27" title="Tests">⚠️</a></td>
|
|
380
|
+
<td align="center"><a href="https://github.com/Vinzent03"><img src="https://avatars.githubusercontent.com/u/63981639?v=4?s=60" width="60px;" alt=""/><br /><sub><b>Vinzent</b></sub></a><br /><a href="https://github.com/isomorphic-git/isomorphic-git/commits?author=Vinzent03" title="Code">💻</a></td>
|
|
380
381
|
</tr>
|
|
381
382
|
</table>
|
|
382
383
|
|
package/browser-tests.json
CHANGED
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
[
|
|
2
|
-
"X Chrome Headless 79.0.3945.0 (Linux x86_64)",
|
|
3
|
-
"Firefox 126.0 (Ubuntu 0.0.0)",
|
|
4
|
-
"X Chrome 123.0.0.0 (Android 10)",
|
|
5
|
-
"Edge 79.0.309.65 (Windows 10)",
|
|
6
|
-
"Safari 13.1 (Mac OS 10.15.4)",
|
|
7
|
-
"Mobile Safari 13.0 (iOS 13.0)",
|
|
8
2
|
"Chrome Headless 79.0.3945.0 (Linux x86_64)",
|
|
3
|
+
"Firefox 127.0 (Ubuntu 0.0.0)",
|
|
9
4
|
"Chrome 123.0.0.0 (Android 10)",
|
|
10
|
-
"Edge 79.0.309.65 (Windows 10)"
|
|
5
|
+
"Edge 79.0.309.65 (Windows 10)",
|
|
6
|
+
"Mobile Safari 13.0 (iOS 13.0)",
|
|
7
|
+
"Safari 13.1 (Mac OS 10.15.4)"
|
|
11
8
|
]
|
package/index.cjs
CHANGED
|
@@ -3579,6 +3579,21 @@ class IndexResetError extends BaseError {
|
|
|
3579
3579
|
/** @type {'IndexResetError'} */
|
|
3580
3580
|
IndexResetError.code = 'IndexResetError';
|
|
3581
3581
|
|
|
3582
|
+
class NoCommitError extends BaseError {
|
|
3583
|
+
/**
|
|
3584
|
+
* @param {string} ref
|
|
3585
|
+
*/
|
|
3586
|
+
constructor(ref) {
|
|
3587
|
+
super(
|
|
3588
|
+
`"${ref}" does not point to any commit. You're maybe working on a repository with no commits yet. `
|
|
3589
|
+
);
|
|
3590
|
+
this.code = this.name = NoCommitError.code;
|
|
3591
|
+
this.data = { ref };
|
|
3592
|
+
}
|
|
3593
|
+
}
|
|
3594
|
+
/** @type {'NoCommitError'} */
|
|
3595
|
+
NoCommitError.code = 'NoCommitError';
|
|
3596
|
+
|
|
3582
3597
|
|
|
3583
3598
|
|
|
3584
3599
|
var Errors = /*#__PURE__*/Object.freeze({
|
|
@@ -3613,7 +3628,8 @@ var Errors = /*#__PURE__*/Object.freeze({
|
|
|
3613
3628
|
UrlParseError: UrlParseError,
|
|
3614
3629
|
UserCanceledError: UserCanceledError,
|
|
3615
3630
|
UnmergedPathsError: UnmergedPathsError,
|
|
3616
|
-
IndexResetError: IndexResetError
|
|
3631
|
+
IndexResetError: IndexResetError,
|
|
3632
|
+
NoCommitError: NoCommitError
|
|
3617
3633
|
});
|
|
3618
3634
|
|
|
3619
3635
|
function formatAuthor({ name, email, timestamp, timezoneOffset }) {
|
|
@@ -4248,7 +4264,10 @@ class GitWalkerFs {
|
|
|
4248
4264
|
const stats = await entry.stat();
|
|
4249
4265
|
const config = await GitConfigManager.get({ fs, gitdir });
|
|
4250
4266
|
const filemode = await config.get('core.filemode');
|
|
4251
|
-
const trustino =
|
|
4267
|
+
const trustino =
|
|
4268
|
+
typeof process !== 'undefined'
|
|
4269
|
+
? !(process.platform === 'win32')
|
|
4270
|
+
: true;
|
|
4252
4271
|
if (!stage || compareStats(stats, stage, filemode, trustino)) {
|
|
4253
4272
|
const content = await entry.content();
|
|
4254
4273
|
if (content === undefined) {
|
|
@@ -5171,6 +5190,177 @@ async function addToIndex({
|
|
|
5171
5190
|
|
|
5172
5191
|
// @ts-check
|
|
5173
5192
|
|
|
5193
|
+
/**
|
|
5194
|
+
* @param {Object} args
|
|
5195
|
+
* @param {import('../models/FileSystem.js').FileSystem} args.fs
|
|
5196
|
+
* @param {string} args.gitdir
|
|
5197
|
+
* @param {string} args.path
|
|
5198
|
+
*
|
|
5199
|
+
* @returns {Promise<any>} Resolves with the config value
|
|
5200
|
+
*
|
|
5201
|
+
* @example
|
|
5202
|
+
* // Read config value
|
|
5203
|
+
* let value = await git.getConfig({
|
|
5204
|
+
* dir: '$input((/))',
|
|
5205
|
+
* path: '$input((user.name))'
|
|
5206
|
+
* })
|
|
5207
|
+
* console.log(value)
|
|
5208
|
+
*
|
|
5209
|
+
*/
|
|
5210
|
+
async function _getConfig({ fs, gitdir, path }) {
|
|
5211
|
+
const config = await GitConfigManager.get({ fs, gitdir });
|
|
5212
|
+
return config.get(path)
|
|
5213
|
+
}
|
|
5214
|
+
|
|
5215
|
+
// Like Object.assign but ignore properties with undefined values
|
|
5216
|
+
// ref: https://stackoverflow.com/q/39513815
|
|
5217
|
+
function assignDefined(target, ...sources) {
|
|
5218
|
+
for (const source of sources) {
|
|
5219
|
+
if (source) {
|
|
5220
|
+
for (const key of Object.keys(source)) {
|
|
5221
|
+
const val = source[key];
|
|
5222
|
+
if (val !== undefined) {
|
|
5223
|
+
target[key] = val;
|
|
5224
|
+
}
|
|
5225
|
+
}
|
|
5226
|
+
}
|
|
5227
|
+
}
|
|
5228
|
+
return target
|
|
5229
|
+
}
|
|
5230
|
+
|
|
5231
|
+
/**
|
|
5232
|
+
* Return author object by using properties following this priority:
|
|
5233
|
+
* (1) provided author object
|
|
5234
|
+
* -> (2) author of provided commit object
|
|
5235
|
+
* -> (3) Config and current date/time
|
|
5236
|
+
*
|
|
5237
|
+
* @param {Object} args
|
|
5238
|
+
* @param {FsClient} args.fs - a file system implementation
|
|
5239
|
+
* @param {string} [args.gitdir] - The [git directory](dir-vs-gitdir.md) path
|
|
5240
|
+
* @param {Object} [args.author] - The author object.
|
|
5241
|
+
* @param {CommitObject} [args.commit] - A commit object.
|
|
5242
|
+
*
|
|
5243
|
+
* @returns {Promise<void | {name: string, email: string, timestamp: number, timezoneOffset: number }>}
|
|
5244
|
+
*/
|
|
5245
|
+
async function normalizeAuthorObject({ fs, gitdir, author, commit }) {
|
|
5246
|
+
const timestamp = Math.floor(Date.now() / 1000);
|
|
5247
|
+
|
|
5248
|
+
const defaultAuthor = {
|
|
5249
|
+
name: await _getConfig({ fs, gitdir, path: 'user.name' }),
|
|
5250
|
+
email: (await _getConfig({ fs, gitdir, path: 'user.email' })) || '', // author.email is allowed to be empty string
|
|
5251
|
+
timestamp,
|
|
5252
|
+
timezoneOffset: new Date(timestamp * 1000).getTimezoneOffset(),
|
|
5253
|
+
};
|
|
5254
|
+
|
|
5255
|
+
// Populate author object by using properties with this priority:
|
|
5256
|
+
// (1) provided author object
|
|
5257
|
+
// -> (2) author of provided commit object
|
|
5258
|
+
// -> (3) default author
|
|
5259
|
+
const normalizedAuthor = assignDefined(
|
|
5260
|
+
{},
|
|
5261
|
+
defaultAuthor,
|
|
5262
|
+
commit ? commit.author : undefined,
|
|
5263
|
+
author
|
|
5264
|
+
);
|
|
5265
|
+
|
|
5266
|
+
if (normalizedAuthor.name === undefined) {
|
|
5267
|
+
return undefined
|
|
5268
|
+
}
|
|
5269
|
+
|
|
5270
|
+
return normalizedAuthor
|
|
5271
|
+
}
|
|
5272
|
+
|
|
5273
|
+
/**
|
|
5274
|
+
* Return committer object by using properties with this priority:
|
|
5275
|
+
* (1) provided committer object
|
|
5276
|
+
* -> (2) provided author object
|
|
5277
|
+
* -> (3) committer of provided commit object
|
|
5278
|
+
* -> (4) Config and current date/time
|
|
5279
|
+
*
|
|
5280
|
+
* @param {Object} args
|
|
5281
|
+
* @param {FsClient} args.fs - a file system implementation
|
|
5282
|
+
* @param {string} [args.gitdir] - The [git directory](dir-vs-gitdir.md) path
|
|
5283
|
+
* @param {Object} [args.author] - The author object.
|
|
5284
|
+
* @param {Object} [args.committer] - The committer object.
|
|
5285
|
+
* @param {CommitObject} [args.commit] - A commit object.
|
|
5286
|
+
*
|
|
5287
|
+
* @returns {Promise<void | {name: string, email: string, timestamp: number, timezoneOffset: number }>}
|
|
5288
|
+
*/
|
|
5289
|
+
async function normalizeCommitterObject({
|
|
5290
|
+
fs,
|
|
5291
|
+
gitdir,
|
|
5292
|
+
author,
|
|
5293
|
+
committer,
|
|
5294
|
+
commit,
|
|
5295
|
+
}) {
|
|
5296
|
+
const timestamp = Math.floor(Date.now() / 1000);
|
|
5297
|
+
|
|
5298
|
+
const defaultCommitter = {
|
|
5299
|
+
name: await _getConfig({ fs, gitdir, path: 'user.name' }),
|
|
5300
|
+
email: (await _getConfig({ fs, gitdir, path: 'user.email' })) || '', // committer.email is allowed to be empty string
|
|
5301
|
+
timestamp,
|
|
5302
|
+
timezoneOffset: new Date(timestamp * 1000).getTimezoneOffset(),
|
|
5303
|
+
};
|
|
5304
|
+
|
|
5305
|
+
const normalizedCommitter = assignDefined(
|
|
5306
|
+
{},
|
|
5307
|
+
defaultCommitter,
|
|
5308
|
+
commit ? commit.committer : undefined,
|
|
5309
|
+
author,
|
|
5310
|
+
committer
|
|
5311
|
+
);
|
|
5312
|
+
|
|
5313
|
+
if (normalizedCommitter.name === undefined) {
|
|
5314
|
+
return undefined
|
|
5315
|
+
}
|
|
5316
|
+
return normalizedCommitter
|
|
5317
|
+
}
|
|
5318
|
+
|
|
5319
|
+
async function resolveCommit({ fs, cache, gitdir, oid }) {
|
|
5320
|
+
const { type, object } = await _readObject({ fs, cache, gitdir, oid });
|
|
5321
|
+
// Resolve annotated tag objects to whatever
|
|
5322
|
+
if (type === 'tag') {
|
|
5323
|
+
oid = GitAnnotatedTag.from(object).parse().object;
|
|
5324
|
+
return resolveCommit({ fs, cache, gitdir, oid })
|
|
5325
|
+
}
|
|
5326
|
+
if (type !== 'commit') {
|
|
5327
|
+
throw new ObjectTypeError(oid, type, 'commit')
|
|
5328
|
+
}
|
|
5329
|
+
return { commit: GitCommit.from(object), oid }
|
|
5330
|
+
}
|
|
5331
|
+
|
|
5332
|
+
// @ts-check
|
|
5333
|
+
|
|
5334
|
+
/**
|
|
5335
|
+
* @param {object} args
|
|
5336
|
+
* @param {import('../models/FileSystem.js').FileSystem} args.fs
|
|
5337
|
+
* @param {any} args.cache
|
|
5338
|
+
* @param {string} args.gitdir
|
|
5339
|
+
* @param {string} args.oid
|
|
5340
|
+
*
|
|
5341
|
+
* @returns {Promise<ReadCommitResult>} Resolves successfully with a git commit object
|
|
5342
|
+
* @see ReadCommitResult
|
|
5343
|
+
* @see CommitObject
|
|
5344
|
+
*
|
|
5345
|
+
*/
|
|
5346
|
+
async function _readCommit({ fs, cache, gitdir, oid }) {
|
|
5347
|
+
const { commit, oid: commitOid } = await resolveCommit({
|
|
5348
|
+
fs,
|
|
5349
|
+
cache,
|
|
5350
|
+
gitdir,
|
|
5351
|
+
oid,
|
|
5352
|
+
});
|
|
5353
|
+
const result = {
|
|
5354
|
+
oid: commitOid,
|
|
5355
|
+
commit: commit.parse(),
|
|
5356
|
+
payload: commit.withoutSignature(),
|
|
5357
|
+
};
|
|
5358
|
+
// @ts-ignore
|
|
5359
|
+
return result
|
|
5360
|
+
}
|
|
5361
|
+
|
|
5362
|
+
// @ts-check
|
|
5363
|
+
|
|
5174
5364
|
/**
|
|
5175
5365
|
*
|
|
5176
5366
|
* @param {Object} args
|
|
@@ -5178,18 +5368,19 @@ async function addToIndex({
|
|
|
5178
5368
|
* @param {object} args.cache
|
|
5179
5369
|
* @param {SignCallback} [args.onSign]
|
|
5180
5370
|
* @param {string} args.gitdir
|
|
5181
|
-
* @param {string} args.message
|
|
5182
|
-
* @param {Object} args.author
|
|
5183
|
-
* @param {string} args.author.name
|
|
5184
|
-
* @param {string} args.author.email
|
|
5185
|
-
* @param {number} args.author.timestamp
|
|
5186
|
-
* @param {number} args.author.timezoneOffset
|
|
5187
|
-
* @param {Object} args.committer
|
|
5188
|
-
* @param {string} args.committer.name
|
|
5189
|
-
* @param {string} args.committer.email
|
|
5190
|
-
* @param {number} args.committer.timestamp
|
|
5191
|
-
* @param {number} args.committer.timezoneOffset
|
|
5371
|
+
* @param {string} [args.message]
|
|
5372
|
+
* @param {Object} [args.author]
|
|
5373
|
+
* @param {string} [args.author.name]
|
|
5374
|
+
* @param {string} [args.author.email]
|
|
5375
|
+
* @param {number} [args.author.timestamp]
|
|
5376
|
+
* @param {number} [args.author.timezoneOffset]
|
|
5377
|
+
* @param {Object} [args.committer]
|
|
5378
|
+
* @param {string} [args.committer.name]
|
|
5379
|
+
* @param {string} [args.committer.email]
|
|
5380
|
+
* @param {number} [args.committer.timestamp]
|
|
5381
|
+
* @param {number} [args.committer.timezoneOffset]
|
|
5192
5382
|
* @param {string} [args.signingKey]
|
|
5383
|
+
* @param {boolean} [args.amend = false]
|
|
5193
5384
|
* @param {boolean} [args.dryRun = false]
|
|
5194
5385
|
* @param {boolean} [args.noUpdateBranch = false]
|
|
5195
5386
|
* @param {string} [args.ref]
|
|
@@ -5204,15 +5395,18 @@ async function _commit({
|
|
|
5204
5395
|
onSign,
|
|
5205
5396
|
gitdir,
|
|
5206
5397
|
message,
|
|
5207
|
-
author,
|
|
5208
|
-
committer,
|
|
5398
|
+
author: _author,
|
|
5399
|
+
committer: _committer,
|
|
5209
5400
|
signingKey,
|
|
5401
|
+
amend = false,
|
|
5210
5402
|
dryRun = false,
|
|
5211
5403
|
noUpdateBranch = false,
|
|
5212
5404
|
ref,
|
|
5213
5405
|
parent,
|
|
5214
5406
|
tree,
|
|
5215
5407
|
}) {
|
|
5408
|
+
// Determine ref and the commit pointed to by ref, and if it is the initial commit
|
|
5409
|
+
let initialCommit = false;
|
|
5216
5410
|
if (!ref) {
|
|
5217
5411
|
ref = await GitRefManager.resolve({
|
|
5218
5412
|
fs,
|
|
@@ -5222,6 +5416,50 @@ async function _commit({
|
|
|
5222
5416
|
});
|
|
5223
5417
|
}
|
|
5224
5418
|
|
|
5419
|
+
let refOid, refCommit;
|
|
5420
|
+
try {
|
|
5421
|
+
refOid = await GitRefManager.resolve({
|
|
5422
|
+
fs,
|
|
5423
|
+
gitdir,
|
|
5424
|
+
ref,
|
|
5425
|
+
});
|
|
5426
|
+
refCommit = await _readCommit({ fs, gitdir, oid: refOid, cache: {} });
|
|
5427
|
+
} catch {
|
|
5428
|
+
// We assume that there's no commit and this is the initial commit
|
|
5429
|
+
initialCommit = true;
|
|
5430
|
+
}
|
|
5431
|
+
|
|
5432
|
+
if (amend && initialCommit) {
|
|
5433
|
+
throw new NoCommitError(ref)
|
|
5434
|
+
}
|
|
5435
|
+
|
|
5436
|
+
// Determine author and committer information
|
|
5437
|
+
const author = !amend
|
|
5438
|
+
? await normalizeAuthorObject({ fs, gitdir, author: _author })
|
|
5439
|
+
: await normalizeAuthorObject({
|
|
5440
|
+
fs,
|
|
5441
|
+
gitdir,
|
|
5442
|
+
author: _author,
|
|
5443
|
+
commit: refCommit.commit,
|
|
5444
|
+
});
|
|
5445
|
+
if (!author) throw new MissingNameError('author')
|
|
5446
|
+
|
|
5447
|
+
const committer = !amend
|
|
5448
|
+
? await normalizeCommitterObject({
|
|
5449
|
+
fs,
|
|
5450
|
+
gitdir,
|
|
5451
|
+
author,
|
|
5452
|
+
committer: _committer,
|
|
5453
|
+
})
|
|
5454
|
+
: await normalizeCommitterObject({
|
|
5455
|
+
fs,
|
|
5456
|
+
gitdir,
|
|
5457
|
+
author,
|
|
5458
|
+
committer: _committer,
|
|
5459
|
+
commit: refCommit.commit,
|
|
5460
|
+
});
|
|
5461
|
+
if (!committer) throw new MissingNameError('committer')
|
|
5462
|
+
|
|
5225
5463
|
return GitIndexManager.acquire(
|
|
5226
5464
|
{ fs, gitdir, cache, allowUnmerged: false },
|
|
5227
5465
|
async function(index) {
|
|
@@ -5230,18 +5468,13 @@ async function _commit({
|
|
|
5230
5468
|
if (!tree) {
|
|
5231
5469
|
tree = await constructTree({ fs, gitdir, inode, dryRun });
|
|
5232
5470
|
}
|
|
5471
|
+
|
|
5472
|
+
// Determine parents of this commit
|
|
5233
5473
|
if (!parent) {
|
|
5234
|
-
|
|
5235
|
-
parent = [
|
|
5236
|
-
|
|
5237
|
-
|
|
5238
|
-
gitdir,
|
|
5239
|
-
ref,
|
|
5240
|
-
}),
|
|
5241
|
-
];
|
|
5242
|
-
} catch (err) {
|
|
5243
|
-
// Probably an initial commit
|
|
5244
|
-
parent = [];
|
|
5474
|
+
if (!amend) {
|
|
5475
|
+
parent = refOid ? [refOid] : [];
|
|
5476
|
+
} else {
|
|
5477
|
+
parent = refCommit.commit.parent;
|
|
5245
5478
|
}
|
|
5246
5479
|
} else {
|
|
5247
5480
|
// ensure that the parents are oids, not refs
|
|
@@ -5252,6 +5485,16 @@ async function _commit({
|
|
|
5252
5485
|
);
|
|
5253
5486
|
}
|
|
5254
5487
|
|
|
5488
|
+
// Determine message of this commit
|
|
5489
|
+
if (!message) {
|
|
5490
|
+
if (!amend) {
|
|
5491
|
+
throw new MissingParameterError('message')
|
|
5492
|
+
} else {
|
|
5493
|
+
message = refCommit.commit.message;
|
|
5494
|
+
}
|
|
5495
|
+
}
|
|
5496
|
+
|
|
5497
|
+
// Create and write new Commit object
|
|
5255
5498
|
let comm = GitCommit.from({
|
|
5256
5499
|
tree,
|
|
5257
5500
|
parent,
|
|
@@ -5551,72 +5794,6 @@ async function _addNote({
|
|
|
5551
5794
|
|
|
5552
5795
|
// @ts-check
|
|
5553
5796
|
|
|
5554
|
-
/**
|
|
5555
|
-
* @param {Object} args
|
|
5556
|
-
* @param {import('../models/FileSystem.js').FileSystem} args.fs
|
|
5557
|
-
* @param {string} args.gitdir
|
|
5558
|
-
* @param {string} args.path
|
|
5559
|
-
*
|
|
5560
|
-
* @returns {Promise<any>} Resolves with the config value
|
|
5561
|
-
*
|
|
5562
|
-
* @example
|
|
5563
|
-
* // Read config value
|
|
5564
|
-
* let value = await git.getConfig({
|
|
5565
|
-
* dir: '$input((/))',
|
|
5566
|
-
* path: '$input((user.name))'
|
|
5567
|
-
* })
|
|
5568
|
-
* console.log(value)
|
|
5569
|
-
*
|
|
5570
|
-
*/
|
|
5571
|
-
async function _getConfig({ fs, gitdir, path }) {
|
|
5572
|
-
const config = await GitConfigManager.get({ fs, gitdir });
|
|
5573
|
-
return config.get(path)
|
|
5574
|
-
}
|
|
5575
|
-
|
|
5576
|
-
/**
|
|
5577
|
-
*
|
|
5578
|
-
* @returns {Promise<void | {name: string, email: string, date: Date, timestamp: number, timezoneOffset: number }>}
|
|
5579
|
-
*/
|
|
5580
|
-
async function normalizeAuthorObject({ fs, gitdir, author = {} }) {
|
|
5581
|
-
let { name, email, timestamp, timezoneOffset } = author;
|
|
5582
|
-
name = name || (await _getConfig({ fs, gitdir, path: 'user.name' }));
|
|
5583
|
-
email = email || (await _getConfig({ fs, gitdir, path: 'user.email' })) || '';
|
|
5584
|
-
|
|
5585
|
-
if (name === undefined) {
|
|
5586
|
-
return undefined
|
|
5587
|
-
}
|
|
5588
|
-
|
|
5589
|
-
timestamp = timestamp != null ? timestamp : Math.floor(Date.now() / 1000);
|
|
5590
|
-
timezoneOffset =
|
|
5591
|
-
timezoneOffset != null
|
|
5592
|
-
? timezoneOffset
|
|
5593
|
-
: new Date(timestamp * 1000).getTimezoneOffset();
|
|
5594
|
-
|
|
5595
|
-
return { name, email, timestamp, timezoneOffset }
|
|
5596
|
-
}
|
|
5597
|
-
|
|
5598
|
-
/**
|
|
5599
|
-
*
|
|
5600
|
-
* @returns {Promise<void | {name: string, email: string, timestamp: number, timezoneOffset: number }>}
|
|
5601
|
-
*/
|
|
5602
|
-
async function normalizeCommitterObject({
|
|
5603
|
-
fs,
|
|
5604
|
-
gitdir,
|
|
5605
|
-
author,
|
|
5606
|
-
committer,
|
|
5607
|
-
}) {
|
|
5608
|
-
committer = Object.assign({}, committer || author);
|
|
5609
|
-
// Match committer's date to author's one, if omitted
|
|
5610
|
-
if (author) {
|
|
5611
|
-
committer.timestamp = committer.timestamp || author.timestamp;
|
|
5612
|
-
committer.timezoneOffset = committer.timezoneOffset || author.timezoneOffset;
|
|
5613
|
-
}
|
|
5614
|
-
committer = await normalizeAuthorObject({ fs, gitdir, author: committer });
|
|
5615
|
-
return committer
|
|
5616
|
-
}
|
|
5617
|
-
|
|
5618
|
-
// @ts-check
|
|
5619
|
-
|
|
5620
5797
|
/**
|
|
5621
5798
|
* Add or update an object note
|
|
5622
5799
|
*
|
|
@@ -7452,8 +7629,8 @@ function filterCapabilities(server, client) {
|
|
|
7452
7629
|
|
|
7453
7630
|
const pkg = {
|
|
7454
7631
|
name: 'isomorphic-git',
|
|
7455
|
-
version: '1.
|
|
7456
|
-
agent: 'git/isomorphic-git@1.
|
|
7632
|
+
version: '1.27.1',
|
|
7633
|
+
agent: 'git/isomorphic-git@1.27.1',
|
|
7457
7634
|
};
|
|
7458
7635
|
|
|
7459
7636
|
class FIFO {
|
|
@@ -8403,7 +8580,6 @@ async function clone({
|
|
|
8403
8580
|
}
|
|
8404
8581
|
|
|
8405
8582
|
// @ts-check
|
|
8406
|
-
|
|
8407
8583
|
/**
|
|
8408
8584
|
* Create a new commit
|
|
8409
8585
|
*
|
|
@@ -8412,7 +8588,7 @@ async function clone({
|
|
|
8412
8588
|
* @param {SignCallback} [args.onSign] - a PGP signing implementation
|
|
8413
8589
|
* @param {string} [args.dir] - The [working tree](dir-vs-gitdir.md) directory path
|
|
8414
8590
|
* @param {string} [args.gitdir=join(dir,'.git')] - [required] The [git directory](dir-vs-gitdir.md) path
|
|
8415
|
-
* @param {string} args.message - The commit message to use.
|
|
8591
|
+
* @param {string} [args.message] - The commit message to use. Required, unless `amend === true`
|
|
8416
8592
|
* @param {Object} [args.author] - The details about the author.
|
|
8417
8593
|
* @param {string} [args.author.name] - Default is `user.name` config.
|
|
8418
8594
|
* @param {string} [args.author.email] - Default is `user.email` config.
|
|
@@ -8424,6 +8600,7 @@ async function clone({
|
|
|
8424
8600
|
* @param {number} [args.committer.timestamp=Math.floor(Date.now()/1000)] - Set the committer timestamp field. This is the integer number of seconds since the Unix epoch (1970-01-01 00:00:00).
|
|
8425
8601
|
* @param {number} [args.committer.timezoneOffset] - Set the committer timezone offset field. This is the difference, in minutes, from the current timezone to UTC. Default is `(new Date()).getTimezoneOffset()`.
|
|
8426
8602
|
* @param {string} [args.signingKey] - Sign the tag object using this private PGP key.
|
|
8603
|
+
* @param {boolean} [args.amend = false] - If true, replaces the last commit pointed to by `ref` with a new commit.
|
|
8427
8604
|
* @param {boolean} [args.dryRun = false] - If true, simulates making a commit so you can test whether it would succeed. Implies `noUpdateBranch`.
|
|
8428
8605
|
* @param {boolean} [args.noUpdateBranch = false] - If true, does not update the branch pointer after creating the commit.
|
|
8429
8606
|
* @param {string} [args.ref] - The fully expanded name of the branch to commit to. Default is the current branch pointed to by HEAD. (TODO: fix it so it can expand branch names without throwing if the branch doesn't exist yet.)
|
|
@@ -8452,9 +8629,10 @@ async function commit({
|
|
|
8452
8629
|
dir,
|
|
8453
8630
|
gitdir = join(dir, '.git'),
|
|
8454
8631
|
message,
|
|
8455
|
-
author
|
|
8456
|
-
committer
|
|
8632
|
+
author,
|
|
8633
|
+
committer,
|
|
8457
8634
|
signingKey,
|
|
8635
|
+
amend = false,
|
|
8458
8636
|
dryRun = false,
|
|
8459
8637
|
noUpdateBranch = false,
|
|
8460
8638
|
ref,
|
|
@@ -8464,23 +8642,14 @@ async function commit({
|
|
|
8464
8642
|
}) {
|
|
8465
8643
|
try {
|
|
8466
8644
|
assertParameter('fs', _fs);
|
|
8467
|
-
|
|
8645
|
+
if (!amend) {
|
|
8646
|
+
assertParameter('message', message);
|
|
8647
|
+
}
|
|
8468
8648
|
if (signingKey) {
|
|
8469
8649
|
assertParameter('onSign', onSign);
|
|
8470
8650
|
}
|
|
8471
8651
|
const fs = new FileSystem(_fs);
|
|
8472
8652
|
|
|
8473
|
-
const author = await normalizeAuthorObject({ fs, gitdir, author: _author });
|
|
8474
|
-
if (!author) throw new MissingNameError('author')
|
|
8475
|
-
|
|
8476
|
-
const committer = await normalizeCommitterObject({
|
|
8477
|
-
fs,
|
|
8478
|
-
gitdir,
|
|
8479
|
-
author,
|
|
8480
|
-
committer: _committer,
|
|
8481
|
-
});
|
|
8482
|
-
if (!committer) throw new MissingNameError('committer')
|
|
8483
|
-
|
|
8484
8653
|
return await _commit({
|
|
8485
8654
|
fs,
|
|
8486
8655
|
cache,
|
|
@@ -8490,6 +8659,7 @@ async function commit({
|
|
|
8490
8659
|
author,
|
|
8491
8660
|
committer,
|
|
8492
8661
|
signingKey,
|
|
8662
|
+
amend,
|
|
8493
8663
|
dryRun,
|
|
8494
8664
|
noUpdateBranch,
|
|
8495
8665
|
ref,
|
|
@@ -11215,49 +11385,6 @@ async function listTags({ fs, dir, gitdir = join(dir, '.git') }) {
|
|
|
11215
11385
|
}
|
|
11216
11386
|
}
|
|
11217
11387
|
|
|
11218
|
-
async function resolveCommit({ fs, cache, gitdir, oid }) {
|
|
11219
|
-
const { type, object } = await _readObject({ fs, cache, gitdir, oid });
|
|
11220
|
-
// Resolve annotated tag objects to whatever
|
|
11221
|
-
if (type === 'tag') {
|
|
11222
|
-
oid = GitAnnotatedTag.from(object).parse().object;
|
|
11223
|
-
return resolveCommit({ fs, cache, gitdir, oid })
|
|
11224
|
-
}
|
|
11225
|
-
if (type !== 'commit') {
|
|
11226
|
-
throw new ObjectTypeError(oid, type, 'commit')
|
|
11227
|
-
}
|
|
11228
|
-
return { commit: GitCommit.from(object), oid }
|
|
11229
|
-
}
|
|
11230
|
-
|
|
11231
|
-
// @ts-check
|
|
11232
|
-
|
|
11233
|
-
/**
|
|
11234
|
-
* @param {object} args
|
|
11235
|
-
* @param {import('../models/FileSystem.js').FileSystem} args.fs
|
|
11236
|
-
* @param {any} args.cache
|
|
11237
|
-
* @param {string} args.gitdir
|
|
11238
|
-
* @param {string} args.oid
|
|
11239
|
-
*
|
|
11240
|
-
* @returns {Promise<ReadCommitResult>} Resolves successfully with a git commit object
|
|
11241
|
-
* @see ReadCommitResult
|
|
11242
|
-
* @see CommitObject
|
|
11243
|
-
*
|
|
11244
|
-
*/
|
|
11245
|
-
async function _readCommit({ fs, cache, gitdir, oid }) {
|
|
11246
|
-
const { commit, oid: commitOid } = await resolveCommit({
|
|
11247
|
-
fs,
|
|
11248
|
-
cache,
|
|
11249
|
-
gitdir,
|
|
11250
|
-
oid,
|
|
11251
|
-
});
|
|
11252
|
-
const result = {
|
|
11253
|
-
oid: commitOid,
|
|
11254
|
-
commit: commit.parse(),
|
|
11255
|
-
payload: commit.withoutSignature(),
|
|
11256
|
-
};
|
|
11257
|
-
// @ts-ignore
|
|
11258
|
-
return result
|
|
11259
|
-
}
|
|
11260
|
-
|
|
11261
11388
|
function compareAge(a, b) {
|
|
11262
11389
|
return a.committer.timestamp - b.committer.timestamp
|
|
11263
11390
|
}
|
package/index.d.ts
CHANGED
|
@@ -789,6 +789,7 @@ export var Errors: Readonly<{
|
|
|
789
789
|
UserCanceledError: typeof UserCanceledError;
|
|
790
790
|
UnmergedPathsError: typeof UnmergedPathsError;
|
|
791
791
|
IndexResetError: typeof IndexResetError;
|
|
792
|
+
NoCommitError: typeof NoCommitError;
|
|
792
793
|
}>;
|
|
793
794
|
/**
|
|
794
795
|
* @returns {Walker}
|
|
@@ -1180,7 +1181,7 @@ export function clone({ fs, http, onProgress, onMessage, onAuth, onAuthSuccess,
|
|
|
1180
1181
|
* @param {SignCallback} [args.onSign] - a PGP signing implementation
|
|
1181
1182
|
* @param {string} [args.dir] - The [working tree](dir-vs-gitdir.md) directory path
|
|
1182
1183
|
* @param {string} [args.gitdir=join(dir,'.git')] - [required] The [git directory](dir-vs-gitdir.md) path
|
|
1183
|
-
* @param {string} args.message - The commit message to use.
|
|
1184
|
+
* @param {string} [args.message] - The commit message to use. Required, unless `amend === true`
|
|
1184
1185
|
* @param {Object} [args.author] - The details about the author.
|
|
1185
1186
|
* @param {string} [args.author.name] - Default is `user.name` config.
|
|
1186
1187
|
* @param {string} [args.author.email] - Default is `user.email` config.
|
|
@@ -1192,6 +1193,7 @@ export function clone({ fs, http, onProgress, onMessage, onAuth, onAuthSuccess,
|
|
|
1192
1193
|
* @param {number} [args.committer.timestamp=Math.floor(Date.now()/1000)] - Set the committer timestamp field. This is the integer number of seconds since the Unix epoch (1970-01-01 00:00:00).
|
|
1193
1194
|
* @param {number} [args.committer.timezoneOffset] - Set the committer timezone offset field. This is the difference, in minutes, from the current timezone to UTC. Default is `(new Date()).getTimezoneOffset()`.
|
|
1194
1195
|
* @param {string} [args.signingKey] - Sign the tag object using this private PGP key.
|
|
1196
|
+
* @param {boolean} [args.amend = false] - If true, replaces the last commit pointed to by `ref` with a new commit.
|
|
1195
1197
|
* @param {boolean} [args.dryRun = false] - If true, simulates making a commit so you can test whether it would succeed. Implies `noUpdateBranch`.
|
|
1196
1198
|
* @param {boolean} [args.noUpdateBranch = false] - If true, does not update the branch pointer after creating the commit.
|
|
1197
1199
|
* @param {string} [args.ref] - The fully expanded name of the branch to commit to. Default is the current branch pointed to by HEAD. (TODO: fix it so it can expand branch names without throwing if the branch doesn't exist yet.)
|
|
@@ -1214,12 +1216,12 @@ export function clone({ fs, http, onProgress, onMessage, onAuth, onAuthSuccess,
|
|
|
1214
1216
|
* console.log(sha)
|
|
1215
1217
|
*
|
|
1216
1218
|
*/
|
|
1217
|
-
export function commit({ fs: _fs, onSign, dir, gitdir, message, author
|
|
1219
|
+
export function commit({ fs: _fs, onSign, dir, gitdir, message, author, committer, signingKey, amend, dryRun, noUpdateBranch, ref, parent, tree, cache, }: {
|
|
1218
1220
|
fs: CallbackFsClient | PromiseFsClient;
|
|
1219
1221
|
onSign?: SignCallback;
|
|
1220
1222
|
dir?: string;
|
|
1221
1223
|
gitdir?: string;
|
|
1222
|
-
message
|
|
1224
|
+
message?: string;
|
|
1223
1225
|
author?: {
|
|
1224
1226
|
name?: string;
|
|
1225
1227
|
email?: string;
|
|
@@ -1233,6 +1235,7 @@ export function commit({ fs: _fs, onSign, dir, gitdir, message, author: _author,
|
|
|
1233
1235
|
timezoneOffset?: number;
|
|
1234
1236
|
};
|
|
1235
1237
|
signingKey?: string;
|
|
1238
|
+
amend?: boolean;
|
|
1236
1239
|
dryRun?: boolean;
|
|
1237
1240
|
noUpdateBranch?: boolean;
|
|
1238
1241
|
ref?: string;
|
|
@@ -4303,6 +4306,21 @@ declare namespace IndexResetError {
|
|
|
4303
4306
|
const code_30: 'IndexResetError';
|
|
4304
4307
|
export { code_30 as code };
|
|
4305
4308
|
}
|
|
4309
|
+
declare class NoCommitError extends BaseError {
|
|
4310
|
+
/**
|
|
4311
|
+
* @param {string} ref
|
|
4312
|
+
*/
|
|
4313
|
+
constructor(ref: string);
|
|
4314
|
+
code: "NoCommitError";
|
|
4315
|
+
name: "NoCommitError";
|
|
4316
|
+
data: {
|
|
4317
|
+
ref: string;
|
|
4318
|
+
};
|
|
4319
|
+
}
|
|
4320
|
+
declare namespace NoCommitError {
|
|
4321
|
+
const code_31: 'NoCommitError';
|
|
4322
|
+
export { code_31 as code };
|
|
4323
|
+
}
|
|
4306
4324
|
/**
|
|
4307
4325
|
* @typedef {Object} GitProgressEvent
|
|
4308
4326
|
* @property {string} phase
|