diff --git a/modules/list-packages.xq b/modules/list-packages.xq index 0edd1d7..e8baf16 100644 --- a/modules/list-packages.xq +++ b/modules/list-packages.xq @@ -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(), @@ -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 := diff --git a/spec/fixtures/test-app.xar b/spec/fixtures/test-app.xar index cfeed26..b0bb456 100644 Binary files a/spec/fixtures/test-app.xar and b/spec/fixtures/test-app.xar differ diff --git a/spec/tests/package/list.js b/spec/tests/package/list.js index d1b34bb..17265b9 100644 --- a/spec/tests/package/list.js +++ b/spec/tests/package/list.js @@ -204,6 +204,23 @@ 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) }) @@ -211,7 +228,9 @@ 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() })