update index.js

This commit is contained in:
Redbeanw44602
2025-10-02 12:41:16 +08:00
Unverified
parent a47ca21d88
commit a69a9011c5
2 changed files with 44 additions and 27 deletions
+30 -16
View File
@@ -72836,6 +72836,7 @@ const exec_1 = __nccwpck_require__(5236);
const io = __nccwpck_require__(4994); const io = __nccwpck_require__(4994);
const os = __nccwpck_require__(857); const os = __nccwpck_require__(857);
const path = __nccwpck_require__(6928); const path = __nccwpck_require__(6928);
const semver_1 = __nccwpck_require__(2088);
function makeOpt(ref) { function makeOpt(ref) {
return { cwd: path.join(os.tmpdir(), `xmake-git-${ref}`) }; return { cwd: path.join(os.tmpdir(), `xmake-git-${ref}`) };
} }
@@ -72850,25 +72851,38 @@ async function lsRemote(repo) {
}); });
const data = { heads: {}, tags: {}, pull: {} }; const data = { heads: {}, tags: {}, pull: {} };
out.split('\n').forEach((line) => { out.split('\n').forEach((line) => {
const [ref, tag] = line.trim().split('\t'); const [ref, path] = line.trim().split('\t');
if (ref && (tag === null || tag === void 0 ? void 0 : tag.startsWith('refs/'))) { if (ref && (path === null || path === void 0 ? void 0 : path.startsWith('refs/'))) {
const tagPath = tag.split('/').splice(1); const tagPath = path.split('/').splice(1);
// eslint-disable-next-line @typescript-eslint/no-explicit-any switch (tagPath[0]) {
let ldata = data; // eslint-disable-line @typescript-eslint/no-unsafe-assignment case 'heads': {
for (let i = 0; i < tagPath.length - 1; i++) { // refs/heads/copilot/fix-6807
const seg = tagPath[i]; const head = tagPath.slice(1).join('/');
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access data.heads[head] = ref;
if (typeof ldata[seg] === 'object') { break;
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
ldata = ldata[seg]; // eslint-disable-line @typescript-eslint/no-unsafe-assignment
} }
else { case 'pull': {
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access // refs/pull/11/head
ldata = ldata[seg] = {}; // refs/pull/11/merge
const pr = Number(tagPath[1]);
if (!data.pull[pr]) {
data.pull[pr] = {};
}
data.pull[pr][tagPath[2]] = ref;
break;
} }
case 'tags': {
// refs/tags/preview
// refs/tags/v3.0.3
const tag = tagPath.slice(1).join('/');
if ((0, semver_1.valid)(tag)) {
data.tags[tag] = ref;
}
break;
}
default:
break;
} }
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
ldata[tagPath[tagPath.length - 1]] = ref;
} }
}); });
return data; return data;
+14 -11
View File
@@ -25,28 +25,31 @@ export async function lsRemote(repo: Repo): Promise<RefDic> {
if (ref && path?.startsWith('refs/')) { if (ref && path?.startsWith('refs/')) {
const tagPath = path.split('/').splice(1); const tagPath = path.split('/').splice(1);
switch (tagPath[0]) { switch (tagPath[0]) {
case 'heads': case 'heads': {
// refs/heads/copilot/fix-6807 // refs/heads/copilot/fix-6807
const head = tagPath.slice(1).join('/') const head = tagPath.slice(1).join('/');
data.heads[head] = ref data.heads[head] = ref;
break break;
case 'pull': }
case 'pull': {
// refs/pull/11/head // refs/pull/11/head
// refs/pull/11/merge // refs/pull/11/merge
const pr = Number(tagPath[1]) const pr = Number(tagPath[1]);
if (!data.pull[pr]) { if (!data.pull[pr]) {
data.pull[pr] = {} as RefDic['pull'][number] data.pull[pr] = {} as RefDic['pull'][number];
} }
data.pull[pr][tagPath[2] as 'head' | 'merge'] = ref data.pull[pr][tagPath[2] as 'head' | 'merge'] = ref;
break; break;
case 'tags': }
case 'tags': {
// refs/tags/preview // refs/tags/preview
// refs/tags/v3.0.3 // refs/tags/v3.0.3
const tag = tagPath.slice(1).join('/') const tag = tagPath.slice(1).join('/');
if (isValidSemver(tag)) { if (isValidSemver(tag)) {
data.tags[tag] = ref data.tags[tag] = ref;
} }
break; break;
}
default: default:
break; break;
} }