Skip to content

Commit

Permalink
Merge pull request #158 from line-o/feat/package-list-commit-info
Browse files Browse the repository at this point in the history
feat(package): add commit info to raw list output
  • Loading branch information
windauer authored Oct 17, 2023
2 parents f1beb37 + 770aa73 commit 8c54d36
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 1 deletion.
11 changes: 11 additions & 0 deletions modules/list-packages.xq
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ function local:repo($package-uri as xs:string) as map(*) {

return
map {
"commit": local:commit-info($repo/repo:meta),
"website": $repo//repo:website/text(),
"description": $repo//repo:description/text(),
"license": $repo//repo:license/text(),
Expand All @@ -94,6 +95,16 @@ function local:repo($package-uri as xs:string) as map(*) {
}
};

declare
function local:commit-info ($meta as element(repo:meta)) as map(*)? {
if (exists($meta/@commit-id)) then (
map {
"id": $meta/@commit-id/string(),
"time": $meta/@commit-time/string()
}
) else ()
};

declare
function local:get-deployment-date ($expath, $repo) {
let $doc :=
Expand Down
Binary file modified spec/fixtures/test-app.xar
Binary file not shown.
21 changes: 20 additions & 1 deletion spec/tests/package/list.js
Original file line number Diff line number Diff line change
Expand Up @@ -204,14 +204,33 @@ test('with new package', async function (t) {
st.end()
})

t.test('raw output includes commit info', async function (st) {
const { stderr, stdout } = await run('xst', ['package', 'list', '--raw'], asAdmin)
if (stderr) {
st.fail(stderr)
st.end()
return
}
const json = JSON.parse(stdout)
const filtered = json.packages.filter(p => p.abbrev === 'test-app')
st.equal(filtered.length, 1)
const packageInfo = filtered.pop()
st.ok(packageInfo.commit)
st.equal(packageInfo.commit.id, 'e039b2e12f9882375701c7cfd58f5ee32fd7bbd4')
st.equal(packageInfo.commit.time, '1674564361')
st.end()
})

t.teardown(cleanup)
})

test('error', async function (t) {
const { stderr, stdout } = await run('xst', ['pkg', 'ls', '-a', '-l'], asAdmin)
if (stdout) {
t.fail(stdout)
t.end()
return
}
t.ok(stderr, stderr)
t.equal(stderr, 'Arguments a and l are mutually exclusive\n')
t.end()
})

0 comments on commit 8c54d36

Please sign in to comment.