fix sync states

pull/5026/head
bunsenstraat 7 months ago committed by Aniket
parent ae934e4ff4
commit d351f0615f
  1. 73
      apps/remix-ide-e2e/src/tests/dgit_local.test.ts
  2. 2
      libs/remix-ui/git/src/components/branchHeader.tsx
  3. 5
      libs/remix-ui/git/src/components/buttons/sourceControlBase.tsx
  4. 1
      libs/remix-ui/git/src/components/panels/commands/pushpull.tsx
  5. 2
      libs/remix-ui/git/src/components/panels/commits/commitdetails.tsx
  6. 22
      libs/remix-ui/git/src/lib/gitactions.ts

@ -42,7 +42,7 @@ module.exports = {
.modalFooterOKClick('github-credentials-error') .modalFooterOKClick('github-credentials-error')
.pause(2000) .pause(2000)
}, },
'clone a repo #group1 #group2 #group3': function (browser: NightwatchBrowser) { 'clone a repo #group1 #group2 #group3 #group4': function (browser: NightwatchBrowser) {
browser browser
.waitForElementVisible('*[data-id="clone-panel"]') .waitForElementVisible('*[data-id="clone-panel"]')
.click('*[data-id="clone-panel"]') .click('*[data-id="clone-panel"]')
@ -56,7 +56,7 @@ module.exports = {
// GROUP 1 // GROUP 1
'check file added #group1 #group3': function (browser: NightwatchBrowser) { 'check file added #group1 #group3 #group4': function (browser: NightwatchBrowser) {
browser. browser.
addFile('test.txt', { content: 'hello world' }, 'README.md') addFile('test.txt', { content: 'hello world' }, 'README.md')
.clickLaunchIcon('dgit') .clickLaunchIcon('dgit')
@ -76,7 +76,7 @@ module.exports = {
.setValue('*[data-id="commitMessage"]', 'testcommit') .setValue('*[data-id="commitMessage"]', 'testcommit')
.click('*[data-id="commitButton"]') .click('*[data-id="commitButton"]')
}, },
'look at the commit #group1': function (browser: NightwatchBrowser) { 'look at the commit #group1 #group4': function (browser: NightwatchBrowser) {
browser browser
.click('*[data-id="commits-panel"]') .click('*[data-id="commits-panel"]')
.waitForElementPresent({ .waitForElementPresent({
@ -329,24 +329,10 @@ module.exports = {
.clickLaunchIcon('filePanel') .clickLaunchIcon('filePanel')
.waitForElementNotPresent('*[data-id="treeViewLitreeViewItemtest.txt"]') .waitForElementNotPresent('*[data-id="treeViewLitreeViewItemtest.txt"]')
}, },
'clone locally #group4': async function (browser: NightwatchBrowser) {
await cloneOnServer('http://localhost:6868/bare.git', '/tmp/', 'bare')
await cloneOnServer('http://localhost:6868/bare2.git', '/tmp/', 'bare2')
},
'add remote #group4': function (browser: NightwatchBrowser) {
browser
.pause(1000)
.click('*[data-id="remotes-panel"]')
.waitForElementVisible('*[data-id="add-manual-remoteurl"]')
.setValue('*[data-id="add-manual-remoteurl"]', 'http://localhost:6868/bare.git')
.waitForElementVisible('*[data-id="add-manual-remotename"]')
.setValue('*[data-id="add-manual-remotename"]', 'origin')
.waitForElementVisible('*[data-id="add-manual-remotebtn"]')
.click('*[data-id="add-manual-remotebtn"]')
},
'add second remote #group4': function (browser: NightwatchBrowser) { 'add second remote #group4': function (browser: NightwatchBrowser) {
browser browser
.pause(1000) .pause(1000)
.click('*[data-id="remotes-panel"]')
.waitForElementVisible('*[data-id="add-manual-remoteurl"]') .waitForElementVisible('*[data-id="add-manual-remoteurl"]')
.setValue('*[data-id="add-manual-remoteurl"]', 'http://localhost:6868/bare2.git') .setValue('*[data-id="add-manual-remoteurl"]', 'http://localhost:6868/bare2.git')
.waitForElementVisible('*[data-id="add-manual-remotename"]') .waitForElementVisible('*[data-id="add-manual-remotename"]')
@ -380,7 +366,56 @@ module.exports = {
selector: "//div[@id='commands-remote-origin-select']//div[contains(@class, 'singleValue') and contains(text(), 'origin2')]", selector: "//div[@id='commands-remote-origin-select']//div[contains(@class, 'singleValue') and contains(text(), 'origin2')]",
locateStrategy: 'xpath' locateStrategy: 'xpath'
}) })
} },
'sync the commit #group4': function (browser: NightwatchBrowser) {
browser
.pause(1000)
.waitForElementVisible('*[data-id="sourcecontrol-panel"]')
.click('*[data-id="sourcecontrol-panel"]')
.waitForElementVisible('*[data-id="syncButton"]')
.click('*[data-id="syncButton"]')
.waitForElementVisible('*[data-id="commitButton"]')
.click('*[data-id="commits-panel"]')
.waitForElementPresent({
selector: '//*[@data-id="commit-summary-testcommit-"]',
locateStrategy: 'xpath'
})
},
'check the log #group4': async function (browser: NightwatchBrowser) {
const logs = await getGitLog('/tmp/git/bare2.git')
console.log(logs)
browser.assert.ok(logs.includes('testcommit'))
const logs2 = await getGitLog('/tmp/git/bare.git')
console.log(logs2)
browser.assert.fail(logs2.includes('testcommit'))
},
'switch to origin #group4': function (browser: NightwatchBrowser) {
browser
.click('*[data-id="remotes-panel"]')
.waitForElementVisible('*[data-id="set-as-default-origin"]')
.click('*[data-id="set-as-default-origin"]')
},
'check the commands for origin #group4': function (browser: NightwatchBrowser) {
browser
.click('*[data-id="commands-panel"]')
.waitForElementVisible({
selector: "//div[@id='commands-remote-origin-select']//div[contains(@class, 'singleValue') and contains(text(), 'origin')]",
locateStrategy: 'xpath'
})
},
'check the commit ahead #group4': function (browser: NightwatchBrowser) {
browser
.pause(1000)
.waitForElementVisible('*[data-id="sourcecontrol-panel"]')
.click('*[data-id="sourcecontrol-panel"]')
.waitForElementVisible('*[data-id="syncButton"]')
// do not sync
.click('*[data-id="commits-panel"]')
.waitForElementPresent({
selector: '//*[@data-id="commit-summary-testcommit-ahead"]',
locateStrategy: 'xpath'
})
},
} }
async function getBranches(path: string): Promise<string> { async function getBranches(path: string): Promise<string> {

@ -33,7 +33,7 @@ export const BranchHeader = () => {
} }
} }
} }
}, [context.currentBranch, context.commits, context.branches, context.remotes, context.currentHead]) }, [context.currentBranch, context.commits, context.branches, context.remotes, context.currentHead, context.defaultRemote])
useEffect(() => { useEffect(() => {
if (context.fileStatusResult) { if (context.fileStatusResult) {

@ -44,7 +44,10 @@ export const SourceControlBase = (props: SourceControlButtonsProps) => {
}, [context.branchDifferences, context.currentBranch, branch, remote]) }, [context.branchDifferences, context.currentBranch, branch, remote])
const setDefaultRemote = () => { const setDefaultRemote = () => {
if(context.defaultRemote) {
setRemote(context.defaultRemote)
return
}
if (context.remotes.length > 0) { if (context.remotes.length > 0) {
// find remote called origin // find remote called origin
const origin = context.remotes.find(remote => remote.name === 'origin') const origin = context.remotes.find(remote => remote.name === 'origin')

@ -40,7 +40,6 @@ export const PushPull = () => {
}, [context.currentBranch, context.remotes, context.branches]) }, [context.currentBranch, context.remotes, context.branches])
useEffect(() => { useEffect(() => {
console.log('defaultRemote', context.defaultRemote)
if (context.defaultRemote && context.remotes.find(r => r.name === context.defaultRemote.name && r.url === context.defaultRemote.url)) { if (context.defaultRemote && context.remotes.find(r => r.name === context.defaultRemote.name && r.url === context.defaultRemote.url)) {
actions.setUpstreamRemote(context.defaultRemote) actions.setUpstreamRemote(context.defaultRemote)
} }

@ -28,7 +28,7 @@ export const CommitDetails = (props: CommitDetailsProps) => {
}, [activePanel]) }, [activePanel])
const getRemote = (): remote | null => { const getRemote = (): remote | null => {
return branch.remote? branch.remote: context.upstream ? context.upstream : context.defaultRemote ? context.defaultRemote : null return context.upstream ? context.upstream : context.defaultRemote ? context.defaultRemote : branch.remote ? branch.remote : null
} }
const commitsAhead = (remote: remote) => { const commitsAhead = (remote: remote) => {

@ -341,7 +341,7 @@ export const fetch = async (input: fetchInputType) => {
} }
} catch (e: any) { } catch (e: any) {
console.log(e) console.log(e)
await parseError(e) if (!input.quiet) { await parseError(e) }
} }
dispatch(setLoading(false)) dispatch(setLoading(false))
await enableCallBacks() await enableCallBacks()
@ -644,7 +644,7 @@ export const loadGitHubUserFromToken = async () => {
} }
export const statusMatrix = async (filepaths: string[]) => { export const statusMatrix = async (filepaths: string[]) => {
const matrix = await plugin.call('dgitApi', 'status', { ref: "HEAD", filepaths: filepaths || ['.']}); const matrix = await plugin.call('dgitApi', 'status', { ref: "HEAD", filepaths: filepaths || ['.'] });
const result = (matrix || []).map((x) => { const result = (matrix || []).map((x) => {
return { return {
filename: `/${x.shift()}`, filename: `/${x.shift()}`,
@ -784,12 +784,21 @@ export const getBranchDifferences = async (branch: branch, remote: remote, state
remote = state.remotes[0] remote = state.remotes[0]
} }
} }
if (!remote) {
dispatch(resetBranchDifferences())
return
}
try { try {
await fetch({
remote: remote,
singleBranch: true,
ref: branch,
quiet: true,
})
if (!remote) {
dispatch(resetBranchDifferences())
return
}
const branchDifference: branchDifference = await plugin.call('dgitApi', 'compareBranches', { const branchDifference: branchDifference = await plugin.call('dgitApi', 'compareBranches', {
branch, branch,
remote remote
@ -803,6 +812,7 @@ export const getBranchDifferences = async (branch: branch, remote: remote, state
})) }))
} catch (e) { } catch (e) {
// do nothing // do nothing
dispatch(resetBranchDifferences())
} }
} }

Loading…
Cancel
Save