@dotinc/ogre 0.12.0 → 0.13.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/.tap/processinfo/{bbd7b150-cdcb-4e65-8d6e-4b099c5f0973.json → 3003312e-d9e5-465c-902a-2eadb56849eb.json} +95 -95
- package/.tap/processinfo/{7cf26ceb-246e-4df7-b06f-b91a9c2c90f2.json → 3e08f97b-0be1-4778-9b9e-b41cf6f87d61.json} +136 -136
- package/.tap/processinfo/{6e780462-6547-4d6f-900d-1a52bb32630a.json → 57aa81ef-6dc3-43de-bcb6-25365a014208.json} +38 -38
- package/.tap/processinfo/{1254b0cd-57e8-429b-aa96-c4cde45e11e0.json → 5eb04f8d-6954-44bf-b674-832101e7a830.json} +34 -34
- package/.tap/processinfo/{25fcbba3-c883-4827-8eab-904fa6bbcc11.json → 68ecb6dd-6146-473b-b616-b806d753c8e1.json} +72 -72
- package/.tap/processinfo/{6394c505-e5e8-46f7-a635-0721603d4f26.json → ba0144f8-5625-48a3-8eec-6ded9941ba75.json} +101 -101
- package/.tap/processinfo/{cca32a98-41e4-499b-9a82-20f3854d47ef.json → cab7b2a6-8937-4071-a93e-0a367160d4b9.json} +101 -101
- package/.tap/test-results/src/branch.test.ts.tap +6 -6
- package/.tap/test-results/src/checkout.test.ts.tap +9 -9
- package/.tap/test-results/src/commit.test.ts.tap +18 -18
- package/.tap/test-results/src/merge.test.ts.tap +2 -2
- package/.tap/test-results/src/repository.test.ts.tap +35 -35
- package/.tap/test-results/src/tag.test.ts.tap +3 -3
- package/.tap/test-results/src/utils.test.ts.tap +12 -12
- package/CHANGELOG.md +16 -0
- package/lib/repository.d.ts +8 -2
- package/lib/repository.js +17 -7
- package/package.json +2 -2
- package/src/repository.ts +25 -8
package/src/repository.ts
CHANGED
|
@@ -107,6 +107,11 @@ export interface RepositoryObject<T extends { [k: string]: any }> {
|
|
|
107
107
|
* Cherry returns the commits that are missing from upstream and the refs that have been moved since remote
|
|
108
108
|
*/
|
|
109
109
|
cherry(): { commits: Array<Commit>; refs: Map<string, Reference> };
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Runs an arbitrary backend push command and after success advances the locally stored remote state
|
|
113
|
+
*/
|
|
114
|
+
push(pushToBackendFn: () => Promise<boolean>): Promise<boolean>
|
|
110
115
|
}
|
|
111
116
|
|
|
112
117
|
/**
|
|
@@ -119,12 +124,7 @@ export class Repository<T extends { [k: PropertyKey]: any }>
|
|
|
119
124
|
this.hashFn = options.overrides?.calculateCommitHashFn;
|
|
120
125
|
this.serializeObjectFn = options.overrides?.serializeObjectFn;
|
|
121
126
|
this.deserializeObjectFn = options.overrides?.deserializeObjectFn;
|
|
122
|
-
|
|
123
|
-
this.remoteRefs = immutableMapCopy(options.history?.refs);
|
|
124
|
-
this.remoteCommits = immutableArrayCopy<Commit, string>(
|
|
125
|
-
options.history?.commits,
|
|
126
|
-
(c) => c.hash,
|
|
127
|
-
);
|
|
127
|
+
options.history && this.storeRemoteState(options.history);
|
|
128
128
|
this.original = deepClone(obj);
|
|
129
129
|
// store js ref, so obj can still be modified without going through repo.data
|
|
130
130
|
this.data = obj as T;
|
|
@@ -159,6 +159,15 @@ export class Repository<T extends { [k: PropertyKey]: any }>
|
|
|
159
159
|
});
|
|
160
160
|
}
|
|
161
161
|
|
|
162
|
+
private storeRemoteState(history: History) {
|
|
163
|
+
// FIXME: move this to refs/remote as git would do?
|
|
164
|
+
this.remoteRefs = immutableMapCopy(history.refs);
|
|
165
|
+
this.remoteCommits = immutableArrayCopy<Commit, string>(
|
|
166
|
+
history.commits,
|
|
167
|
+
(c) => c.hash,
|
|
168
|
+
);
|
|
169
|
+
}
|
|
170
|
+
|
|
162
171
|
private readonly original: T;
|
|
163
172
|
private _isReady = false;
|
|
164
173
|
|
|
@@ -192,18 +201,26 @@ export class Repository<T extends { [k: PropertyKey]: any }>
|
|
|
192
201
|
| undefined;
|
|
193
202
|
|
|
194
203
|
// stores the remote state upon initialization
|
|
195
|
-
private
|
|
204
|
+
private remoteRefs:
|
|
196
205
|
| ReadonlyMap<string, Readonly<Reference>>
|
|
197
206
|
| undefined;
|
|
198
207
|
|
|
199
208
|
// stores the remote state upon initialization
|
|
200
|
-
private
|
|
209
|
+
private remoteCommits: ReadonlyArray<Readonly<string>> | undefined;
|
|
201
210
|
|
|
202
211
|
private observer: Observer<T>;
|
|
203
212
|
|
|
204
213
|
private readonly refs: Map<string, Reference>;
|
|
205
214
|
private readonly commits: Array<Commit>;
|
|
206
215
|
|
|
216
|
+
async push(pushToBackendFn: () => Promise<boolean>): Promise<boolean> {
|
|
217
|
+
const success = await pushToBackendFn()
|
|
218
|
+
if (success) {
|
|
219
|
+
this.storeRemoteState(this.getHistory())
|
|
220
|
+
}
|
|
221
|
+
return success
|
|
222
|
+
}
|
|
223
|
+
|
|
207
224
|
cherry(): { commits: Array<Commit>; refs: Map<string, Reference> } {
|
|
208
225
|
const commits: Array<Commit> = [];
|
|
209
226
|
const refs = new Map<string, Reference>();
|