fix sync states

pull/5026/head
bunsenstraat 4 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')
.pause(2000)
},
'clone a repo #group1 #group2 #group3': function (browser: NightwatchBrowser) {
'clone a repo #group1 #group2 #group3 #group4': function (browser: NightwatchBrowser) {
browser
.waitForElementVisible('*[data-id="clone-panel"]')
.click('*[data-id="clone-panel"]')
@ -56,7 +56,7 @@ module.exports = {
// GROUP 1
'check file added #group1 #group3': function (browser: NightwatchBrowser) {
'check file added #group1 #group3 #group4': function (browser: NightwatchBrowser) {
browser.
addFile('test.txt', { content: 'hello world' }, 'README.md')
.clickLaunchIcon('dgit')
@ -76,7 +76,7 @@ module.exports = {
.setValue('*[data-id="commitMessage"]', 'testcommit')
.click('*[data-id="commitButton"]')
},
'look at the commit #group1': function (browser: NightwatchBrowser) {
'look at the commit #group1 #group4': function (browser: NightwatchBrowser) {
browser
.click('*[data-id="commits-panel"]')
.waitForElementPresent({
@ -329,24 +329,10 @@ module.exports = {
.clickLaunchIcon('filePanel')
.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) {
browser
.pause(1000)
.click('*[data-id="remotes-panel"]')
.waitForElementVisible('*[data-id="add-manual-remoteurl"]')
.setValue('*[data-id="add-manual-remoteurl"]', 'http://localhost:6868/bare2.git')
.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')]",
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> {

@ -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(() => {
if (context.fileStatusResult) {

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

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

@ -28,7 +28,7 @@ export const CommitDetails = (props: CommitDetailsProps) => {
}, [activePanel])
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) => {

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

Loading…
Cancel
Save