Skip to content

Commit a69a901

Browse files
committed
update index.js
1 parent a47ca21 commit a69a901

File tree

2 files changed

+44
-27
lines changed

2 files changed

+44
-27
lines changed

dist/index.js

Lines changed: 30 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -72836,6 +72836,7 @@ const exec_1 = __nccwpck_require__(5236);
7283672836
const io = __nccwpck_require__(4994);
7283772837
const os = __nccwpck_require__(857);
7283872838
const path = __nccwpck_require__(6928);
72839+
const semver_1 = __nccwpck_require__(2088);
7283972840
function makeOpt(ref) {
7284072841
return { cwd: path.join(os.tmpdir(), `xmake-git-${ref}`) };
7284172842
}
@@ -72850,25 +72851,38 @@ async function lsRemote(repo) {
7285072851
});
7285172852
const data = { heads: {}, tags: {}, pull: {} };
7285272853
out.split('\n').forEach((line) => {
72853-
const [ref, tag] = line.trim().split('\t');
72854-
if (ref && (tag === null || tag === void 0 ? void 0 : tag.startsWith('refs/'))) {
72855-
const tagPath = tag.split('/').splice(1);
72856-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
72857-
let ldata = data; // eslint-disable-line @typescript-eslint/no-unsafe-assignment
72858-
for (let i = 0; i < tagPath.length - 1; i++) {
72859-
const seg = tagPath[i];
72860-
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
72861-
if (typeof ldata[seg] === 'object') {
72862-
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
72863-
ldata = ldata[seg]; // eslint-disable-line @typescript-eslint/no-unsafe-assignment
72854+
const [ref, path] = line.trim().split('\t');
72855+
if (ref && (path === null || path === void 0 ? void 0 : path.startsWith('refs/'))) {
72856+
const tagPath = path.split('/').splice(1);
72857+
switch (tagPath[0]) {
72858+
case 'heads': {
72859+
// refs/heads/copilot/fix-6807
72860+
const head = tagPath.slice(1).join('/');
72861+
data.heads[head] = ref;
72862+
break;
7286472863
}
72865-
else {
72866-
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
72867-
ldata = ldata[seg] = {};
72864+
case 'pull': {
72865+
// refs/pull/11/head
72866+
// refs/pull/11/merge
72867+
const pr = Number(tagPath[1]);
72868+
if (!data.pull[pr]) {
72869+
data.pull[pr] = {};
72870+
}
72871+
data.pull[pr][tagPath[2]] = ref;
72872+
break;
7286872873
}
72874+
case 'tags': {
72875+
// refs/tags/preview
72876+
// refs/tags/v3.0.3
72877+
const tag = tagPath.slice(1).join('/');
72878+
if ((0, semver_1.valid)(tag)) {
72879+
data.tags[tag] = ref;
72880+
}
72881+
break;
72882+
}
72883+
default:
72884+
break;
7286972885
}
72870-
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
72871-
ldata[tagPath[tagPath.length - 1]] = ref;
7287272886
}
7287372887
});
7287472888
return data;

src/git.ts

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -25,28 +25,31 @@ export async function lsRemote(repo: Repo): Promise<RefDic> {
2525
if (ref && path?.startsWith('refs/')) {
2626
const tagPath = path.split('/').splice(1);
2727
switch (tagPath[0]) {
28-
case 'heads':
28+
case 'heads': {
2929
// refs/heads/copilot/fix-6807
30-
const head = tagPath.slice(1).join('/')
31-
data.heads[head] = ref
32-
break
33-
case 'pull':
30+
const head = tagPath.slice(1).join('/');
31+
data.heads[head] = ref;
32+
break;
33+
}
34+
case 'pull': {
3435
// refs/pull/11/head
3536
// refs/pull/11/merge
36-
const pr = Number(tagPath[1])
37+
const pr = Number(tagPath[1]);
3738
if (!data.pull[pr]) {
38-
data.pull[pr] = {} as RefDic['pull'][number]
39+
data.pull[pr] = {} as RefDic['pull'][number];
3940
}
40-
data.pull[pr][tagPath[2] as 'head' | 'merge'] = ref
41+
data.pull[pr][tagPath[2] as 'head' | 'merge'] = ref;
4142
break;
42-
case 'tags':
43+
}
44+
case 'tags': {
4345
// refs/tags/preview
4446
// refs/tags/v3.0.3
45-
const tag = tagPath.slice(1).join('/')
47+
const tag = tagPath.slice(1).join('/');
4648
if (isValidSemver(tag)) {
47-
data.tags[tag] = ref
49+
data.tags[tag] = ref;
4850
}
4951
break;
52+
}
5053
default:
5154
break;
5255
}

0 commit comments

Comments
 (0)