Add tests
This commit is contained in:
Vendored
+17
-5
@@ -5,21 +5,33 @@ const io = require("@actions/io");
|
||||
const os = require("os");
|
||||
const path = require("path");
|
||||
function makeOpt(ref) {
|
||||
return { cwd: path.join(os.tmpdir(), `xmake-${ref}`) };
|
||||
return { cwd: path.join(os.tmpdir(), `xmake-git-${ref}`) };
|
||||
}
|
||||
async function lsRemote() {
|
||||
let out = '';
|
||||
await exec_1.exec('git', ['ls-remote', '--tags', 'https://github.com/xmake-io/xmake.git'], {
|
||||
await exec_1.exec('git', ['ls-remote', 'https://github.com/xmake-io/xmake.git'], {
|
||||
silent: true,
|
||||
listeners: {
|
||||
stdout: d => (out += d.toString()),
|
||||
},
|
||||
});
|
||||
const data = {};
|
||||
const data = { heads: {}, tags: {}, pull: {} };
|
||||
out.split('\n').forEach(line => {
|
||||
const [ref, tag] = line.trim().split('\t');
|
||||
if (ref && tag && tag.startsWith('refs/tags/v')) {
|
||||
data[tag.substring('refs/tags/v'.length)] = ref;
|
||||
if (ref && tag && tag.startsWith('refs/')) {
|
||||
const tagPath = tag.split('/').splice(1);
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
let ldata = data;
|
||||
for (let i = 0; i < tagPath.length - 1; i++) {
|
||||
const seg = tagPath[i];
|
||||
if (typeof ldata[seg] === 'object') {
|
||||
ldata = ldata[seg];
|
||||
}
|
||||
else {
|
||||
ldata = ldata[seg] = {};
|
||||
}
|
||||
}
|
||||
ldata[tagPath[tagPath.length - 1]] = ref;
|
||||
}
|
||||
});
|
||||
return data;
|
||||
|
||||
Reference in New Issue
Block a user