Merge branch 'master' of github.com:cyhhao/git-remote-git3

master
cyhhao 2 years ago
commit b47a4a254c

@ -27,12 +27,17 @@ export async function callContractMethod ({
const pathBuffer = path ? Buffer.from(path) : '' const pathBuffer = path ? Buffer.from(path) : ''
if (method === 'upload') { if (method === 'upload') {
await contract.upload(pathBuffer, file) const uploadResult = await contract.upload(pathBuffer, file)
console.error(`=== upload file ${path} result ===`)
console.error(uploadResult)
} }
if (method === 'download') { if (method === 'download') {
const res = await contract.download(pathBuffer) const res = await contract.download(pathBuffer)
const buf = Buffer.from(res[0].slice(2), 'hex') const buf = Buffer.from(res[0].slice(2), 'hex')
console.error(`=== download file ${path} result ===`)
console.error(buf.toString('utf-8'))
return buf return buf
} }
@ -42,10 +47,12 @@ export async function callContractMethod ({
if (method === 'listRefs') { if (method === 'listRefs') {
const res = await contract.listRefs() const res = await contract.listRefs()
const refs = res.map(i => ({ let refs = res.map(i => ({
ref: i[1], ref: i[1],
sha: i[0].slice(2) sha: i[0].slice(2)
})) }))
refs = refs.concat([{ ref: 'HEAD', sha: 'refs/heads/main' }])
return refs return refs
} }
} }

Loading…
Cancel
Save