Skip to content

Commit

Permalink
[web] - fix push; small fixes (#615)
Browse files Browse the repository at this point in the history
Roman Matusevich authored Oct 19, 2023
1 parent 39706f7 commit 10616fa
Showing 3 changed files with 42 additions and 15 deletions.
25 changes: 21 additions & 4 deletions react-gosh/src/gosh/6.1.0/adapter.ts
Original file line number Diff line number Diff line change
@@ -3800,6 +3800,8 @@ class GoshRepositoryAdapter implements IGoshRepositoryAdapter {
}
const { tags, branchParent, callback } = options

const daoname = await (await this._getDao()).getName()
const reponame = await this.getName()
const taglist = tags ? tags.split(' ') : []
const cb: IPushCallback = (params) => callback && callback(params)

@@ -3844,6 +3846,23 @@ class GoshRepositoryAdapter implements IGoshRepositoryAdapter {
branchParent,
)

// Get branch to commit time
let branchto_commit = branchTo.commit
let adapter = this as IGoshRepositoryAdapter
while (true) {
if (branchto_commit.initupgrade) {
const parent = branchto_commit.parents[0]
if (parent.version !== this.getVersion()) {
const gosh = GoshAdapterFactory.create(parent.version)
adapter = await gosh.getRepository({ path: `${daoname}/${reponame}` })
}

branchto_commit = await adapter.getCommit({ address: parent.address })
continue
}
break
}

// Update tree items with commit, update blob items with address
for (const key of Object.keys(updatedTree0.tree)) {
for (const treeitem of updatedTree0.tree[key]) {
@@ -3873,7 +3892,7 @@ class GoshRepositoryAdapter implements IGoshRepositoryAdapter {
name: snapshot.onchain.tmpcommit,
})

if ((commit.time ?? 0) > (branchTo.commit.time ?? 0)) {
if ((commit.time ?? 0) > (branchto_commit.time ?? 0)) {
console.debug('Deploy new snapshot with content')
treeitem.commit = commitHash
blob.patch = ''
@@ -3966,7 +3985,7 @@ class GoshRepositoryAdapter implements IGoshRepositoryAdapter {
let tagsCounter = 0
await this._runMultiwallet(taglist, async (wallet, tag) => {
await this.createCommitTag({
repository: await this.getName(),
repository: reponame,
commit: commitHash,
tag,
wallet,
@@ -3976,8 +3995,6 @@ class GoshRepositoryAdapter implements IGoshRepositoryAdapter {

// Set commit or start PR proposal
const signer = this.auth.wallet0.account.signer as any
const daoname = await (await this._getDao()).getName()
const reponame = await this.getName()
const patched = blobsData.filter(({ data }) => !!data.patch)
if (!isPullRequest) {
await this._setCommit(branch, commitHash, patched.length, false, task)
2 changes: 1 addition & 1 deletion web/src/blockchain/contract.ts
Original file line number Diff line number Diff line change
@@ -222,7 +222,7 @@ class BaseContract {
}
} catch (e: any) {
if (e.code === 414 && e.data?.exit_code === 60) {
throw new GoshError(e.message)
throw new GoshError('Blockchain error', e.message)
} else {
throw e
}
30 changes: 20 additions & 10 deletions web/src/components/Toast/ToastError.tsx
Original file line number Diff line number Diff line change
@@ -9,31 +9,41 @@ const ToastError = (props: TToastErrorProps) => {
const { error } = props

if (error instanceof GoshError) {
let data: string | null = null
if (error.data) {
data =
typeof error.data === 'string'
? error.data
: JSON.stringify(error.data, undefined, 1)
}

return (
<>
<h3 className="font-semibold">{error.title || 'Something went wrong'}</h3>
{error.data && (
<p className="text-sm">
{typeof error.data === 'string'
? error.data
: JSON.stringify(error.data, undefined, 1)}
</p>
{data && (
<>
<p className="text-sm">{data}</p>
<CopyClipboard
label="Copy error message"
className="mt-3 text-xs"
componentProps={{ text: data }}
/>
</>
)}
</>
)
}

const data = error.data ? JSON.stringify(error, undefined, 1) : null
return (
<>
<h3 className="font-semibold">{error.name || 'Internal error'}</h3>
<p className="text-sm">{error.message}</p>
<p className="text-xs">{JSON.stringify(error)}</p>
{data && <p className="text-xs">{data}</p>}
<CopyClipboard
label="Copy error message"
className="mt-3 text-xs"
componentProps={{
text: JSON.stringify(error),
}}
componentProps={{ text: data || error.message }}
/>
</>
)

0 comments on commit 10616fa

Please sign in to comment.