isomorphic-git 1.27.2 → 1.28.0
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 +5 -3
- package/browser-tests.json +3 -1
- package/index.cjs +791 -30
- package/index.d.ts +72 -0
- package/index.js +791 -31
- package/index.umd.min.d.ts +72 -0
- 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/index.d.ts
CHANGED
|
@@ -641,6 +641,14 @@ export type HeadStatus = 0 | 1;
|
|
|
641
641
|
export type WorkdirStatus = 0 | 1 | 2;
|
|
642
642
|
export type StageStatus = 0 | 1 | 2 | 3;
|
|
643
643
|
export type StatusRow = [string, 0 | 1, 0 | 1 | 2, 0 | 1 | 2 | 3];
|
|
644
|
+
/**
|
|
645
|
+
* the type of stash ops
|
|
646
|
+
*/
|
|
647
|
+
export type StashOp = "push" | "drop" | "pop" | "apply" | "list" | "clear";
|
|
648
|
+
/**
|
|
649
|
+
* - when compare WORDIR to HEAD, 'remove' could mean 'untracked'
|
|
650
|
+
*/
|
|
651
|
+
export type StashChangeType = "add" | "unknown" | "remove" | "equal" | "modify";
|
|
644
652
|
export type ClientRef = {
|
|
645
653
|
/**
|
|
646
654
|
* The name of the ref
|
|
@@ -755,6 +763,7 @@ declare namespace index {
|
|
|
755
763
|
export { writeRef };
|
|
756
764
|
export { writeTag };
|
|
757
765
|
export { writeTree };
|
|
766
|
+
export { stash };
|
|
758
767
|
}
|
|
759
768
|
export var Errors: Readonly<{
|
|
760
769
|
__proto__: null;
|
|
@@ -3059,6 +3068,65 @@ export function setConfig({ fs: _fs, dir, gitdir, path, value, append, }: {
|
|
|
3059
3068
|
value: string | number | boolean | void;
|
|
3060
3069
|
append?: boolean;
|
|
3061
3070
|
}): Promise<void>;
|
|
3071
|
+
/**
|
|
3072
|
+
* stash api, supports {'push' | 'pop' | 'apply' | 'drop' | 'list' | 'clear'} StashOp
|
|
3073
|
+
* _note_,
|
|
3074
|
+
* - all stash operations are done on tracked files only with loose objects, no packed objects
|
|
3075
|
+
* - when op === 'push', both working directory and index (staged) changes will be stashed, tracked files only
|
|
3076
|
+
* - when op === 'push', message is optional, and only applicable when op === 'push'
|
|
3077
|
+
* - when op === 'apply | pop', the stashed changes will overwrite the working directory, no abort when conflicts
|
|
3078
|
+
*
|
|
3079
|
+
* @param {object} args
|
|
3080
|
+
* @param {FsClient} args.fs - [required] a file system client
|
|
3081
|
+
* @param {string} [args.dir] - [required] The [working tree](dir-vs-gitdir.md) directory path
|
|
3082
|
+
* @param {string} [args.gitdir=join(dir,'.git')] - [optional] The [git directory](dir-vs-gitdir.md) path
|
|
3083
|
+
* @param {'push' | 'pop' | 'apply' | 'drop' | 'list' | 'clear'} [args.op = 'push'] - [optional] name of stash operation, default to 'push'
|
|
3084
|
+
* @param {string} [args.message = ''] - [optional] message to be used for the stash entry, only applicable when op === 'push'
|
|
3085
|
+
* @param {number} [args.refIdx = 0] - [optional - Number] stash ref index of entry, only applicable when op === ['apply' | 'drop' | 'pop'], refIdx >= 0 and < num of stash pushed
|
|
3086
|
+
* @returns {Promise<string | void>} Resolves successfully when stash operations are complete
|
|
3087
|
+
*
|
|
3088
|
+
* @example
|
|
3089
|
+
* // stash changes in the working directory and index
|
|
3090
|
+
* let dir = '/tutorial'
|
|
3091
|
+
* await fs.promises.writeFile(`${dir}/a.txt`, 'original content - a')
|
|
3092
|
+
* await fs.promises.writeFile(`${dir}/b.js`, 'original content - b')
|
|
3093
|
+
* await git.add({ fs, dir, filepath: [`a.txt`,`b.txt`] })
|
|
3094
|
+
* let sha = await git.commit({
|
|
3095
|
+
* fs,
|
|
3096
|
+
* dir,
|
|
3097
|
+
* author: {
|
|
3098
|
+
* name: 'Mr. Stash',
|
|
3099
|
+
* email: 'mstasher@stash.com',
|
|
3100
|
+
* },
|
|
3101
|
+
* message: 'add a.txt and b.txt to test stash'
|
|
3102
|
+
* })
|
|
3103
|
+
* console.log(sha)
|
|
3104
|
+
*
|
|
3105
|
+
* await fs.promises.writeFile(`${dir}/a.txt`, 'stashed chang- a')
|
|
3106
|
+
* await git.add({ fs, dir, filepath: `${dir}/a.txt` })
|
|
3107
|
+
* await fs.promises.writeFile(`${dir}/b.js`, 'work dir change. not stashed - b')
|
|
3108
|
+
*
|
|
3109
|
+
* await git.stash({ fs, dir }) // default gitdir and op
|
|
3110
|
+
*
|
|
3111
|
+
* console.log(await git.status({ fs, dir, filepath: 'a.txt' })) // 'unmodified'
|
|
3112
|
+
* console.log(await git.status({ fs, dir, filepath: 'b.txt' })) // 'unmodified'
|
|
3113
|
+
*
|
|
3114
|
+
* const refLog = await git.stash({ fs, dir, op: 'list' })
|
|
3115
|
+
* console.log(refLog) // [{stash{#} message}]
|
|
3116
|
+
*
|
|
3117
|
+
* await git.stash({ fs, dir, op: 'apply' }) // apply the stash
|
|
3118
|
+
*
|
|
3119
|
+
* console.log(await git.status({ fs, dir, filepath: 'a.txt' })) // 'modified'
|
|
3120
|
+
* console.log(await git.status({ fs, dir, filepath: 'b.txt' })) // '*modified'
|
|
3121
|
+
*/
|
|
3122
|
+
export function stash({ fs, dir, gitdir, op, message, refIdx, }: {
|
|
3123
|
+
fs: CallbackFsClient | PromiseFsClient;
|
|
3124
|
+
dir?: string;
|
|
3125
|
+
gitdir?: string;
|
|
3126
|
+
op?: "push" | "drop" | "pop" | "apply" | "list" | "clear";
|
|
3127
|
+
message?: string;
|
|
3128
|
+
refIdx?: number;
|
|
3129
|
+
}): Promise<string | void>;
|
|
3062
3130
|
/**
|
|
3063
3131
|
* Tell whether a file has been changed
|
|
3064
3132
|
*
|
|
@@ -4581,6 +4649,10 @@ declare namespace NoCommitError {
|
|
|
4581
4649
|
* @typedef {[string, HeadStatus, WorkdirStatus, StageStatus]} StatusRow
|
|
4582
4650
|
*/
|
|
4583
4651
|
/**
|
|
4652
|
+
* @typedef {'push' | 'pop' | 'apply' | 'drop' | 'list' | 'clear'} StashOp the type of stash ops
|
|
4653
|
+
*/
|
|
4654
|
+
/**
|
|
4655
|
+
* @typedef {'equal' | 'modify' | 'add' | 'remove' | 'unknown'} StashChangeType - when compare WORDIR to HEAD, 'remove' could mean 'untracked'
|
|
4584
4656
|
* @typedef {Object} ClientRef
|
|
4585
4657
|
* @property {string} ref The name of the ref
|
|
4586
4658
|
* @property {string} oid The SHA-1 object id the ref points to
|