resulgit 1.0.8 → 1.0.9
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/package.json +1 -1
- package/resulgit.js +8 -0
package/package.json
CHANGED
package/resulgit.js
CHANGED
|
@@ -991,6 +991,14 @@ async function fetchRemoteSnapshot(server, repo, branch, token) {
|
|
|
991
991
|
if (branch) url.searchParams.set('branch', branch)
|
|
992
992
|
const res = await fetch(url.toString(), { headers })
|
|
993
993
|
if (!res.ok) {
|
|
994
|
+
// For new/empty repos, return empty snapshot instead of throwing
|
|
995
|
+
if (res.status === 404 || res.status === 500) {
|
|
996
|
+
// Check if this is a "new repo" scenario
|
|
997
|
+
const text = await res.text()
|
|
998
|
+
if (text.includes('not found') || text.includes('empty') || text.includes('no commits') || res.status === 500) {
|
|
999
|
+
return { files: {}, commitId: '' }
|
|
1000
|
+
}
|
|
1001
|
+
}
|
|
994
1002
|
const text = await res.text()
|
|
995
1003
|
throw new Error(text || 'snapshot failed')
|
|
996
1004
|
}
|