From 0936e029bd0c23b72ea6a6d1f824c31cca6688bb Mon Sep 17 00:00:00 2001 From: Michelle Tilley Date: Fri, 24 Feb 2017 12:11:31 -0800 Subject: [PATCH 01/14] Add yubikiri as a dep --- package.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index c853dfd5fb..1063f89a93 100644 --- a/package.json +++ b/package.json @@ -60,7 +60,8 @@ "recursive-readdir": "^2.0.0", "semver": "^5.3.0", "tree-kill": "^1.1.0", - "what-the-diff": "^0.3.0" + "what-the-diff": "^0.3.0", + "yubikiri": "0.0.2" }, "devDependencies": { "atom-mocha-test-runner": "^1.0.0", From 09a4f9df2af96fcb275f120ae47350d3ce289fc8 Mon Sep 17 00:00:00 2001 From: Michelle Tilley Date: Fri, 24 Feb 2017 12:11:48 -0800 Subject: [PATCH 02/14] Migrate StatusBarTileController data fetching to yubikiri --- lib/controllers/status-bar-tile-controller.js | 26 +++++-------------- 1 file changed, 7 insertions(+), 19 deletions(-) diff --git a/lib/controllers/status-bar-tile-controller.js b/lib/controllers/status-bar-tile-controller.js index 7502dd5f64..70f8f4046a 100644 --- a/lib/controllers/status-bar-tile-controller.js +++ b/lib/controllers/status-bar-tile-controller.js @@ -8,12 +8,13 @@ import PushPullMenuView from '../views/push-pull-menu-view'; import ChangedFilesCountView from '../views/changed-files-count-view'; import Tooltip from '../views/tooltip'; import Commands, {Command} from '../views/commands'; +import yubikiri from 'yubikiri'; import {autobind} from 'core-decorators'; @ObserveModel({ getModel: props => props.repository, fetchData: async repository => { - const promises = { + return yubikiri({ branchName: repository.getCurrentBranch(), branches: repository.getBranches(), changedFilesCount: repository.getStatusesForChangedFiles().then(statuses => { @@ -32,24 +33,11 @@ import {autobind} from 'core-decorators'; return changedFiles.size; }), - }; - - const branchName = await promises.branchName; - const branchPromises = { - remoteName: repository.getRemoteForBranch(branchName), - aheadCount: repository.getAheadCount(branchName), - behindCount: repository.getBehindCount(branchName), - }; - - return { - branchName, - changedFilesCount: await promises.changedFilesCount, - branches: await promises.branches, - remoteName: await branchPromises.remoteName, - aheadCount: await branchPromises.aheadCount, - behindCount: await branchPromises.behindCount, - pullDisabled: (await promises.changedFilesCount) > 0, - }; + remoteName: async query => repository.getRemoteForBranch(await query.branchName), + aheadCount: async query => repository.getAheadCount(await query.branchName), + behindCount: async query => repository.getBehindCount(await query.branchName), + pullDisabled: async query => (await query.changedFilesCount) > 0, + }); }, }) export default class StatusBarTileController extends React.Component { From a25205db0e289a9fa895eda86a9ce6fddec8084c Mon Sep 17 00:00:00 2001 From: Michelle Tilley Date: Sat, 25 Feb 2017 14:53:00 -0800 Subject: [PATCH 03/14] Use yubikiri in GitPanelController data fetching --- lib/controllers/git-panel-controller.js | 44 +++++++++---------------- 1 file changed, 16 insertions(+), 28 deletions(-) diff --git a/lib/controllers/git-panel-controller.js b/lib/controllers/git-panel-controller.js index bd06c673ad..fdad4d9e3e 100644 --- a/lib/controllers/git-panel-controller.js +++ b/lib/controllers/git-panel-controller.js @@ -7,6 +7,7 @@ import etch from 'etch'; import GitPanelView from '../views/git-panel-view'; import ModelObserver from '../models/model-observer'; import {autobind} from 'core-decorators'; +import yubikiri from 'yubikiri'; export default class GitPanelController { constructor(props) { @@ -91,8 +92,8 @@ export default class GitPanelController { } @autobind - async fetchRepositoryData(repository) { - const dataPromises = { + fetchRepositoryData(repository) { + return yubikiri({ mergeConflicts: repository.getMergeConflicts(), lastCommit: repository.getLastCommit(), isMerging: repository.isMerging(), @@ -102,33 +103,20 @@ export default class GitPanelController { remoteName: repository.getRemoteForBranch(this.branchName), unstagedChanges: repository.getUnstagedChanges(), stagedChanges: this.fetchStagedChanges(repository), - }; - const data = { - unstagedChanges: await dataPromises.unstagedChanges, - stagedChanges: await dataPromises.stagedChanges, - mergeConflicts: await dataPromises.mergeConflicts, - lastCommit: await dataPromises.lastCommit, - isMerging: await dataPromises.isMerging, - isRebasing: await dataPromises.isRebasing, - branchName: await dataPromises.branchName, - branches: await dataPromises.branches, - mergeMessage: null, - aheadCount: null, - behindCount: null, - remoteName: await dataPromises.remoteName, workingDirectoryPath: repository.getWorkingDirectoryPath(), - }; - - if (data.remoteName) { - data.aheadCount = await repository.getAheadCount(data.branchName); - data.behindCount = await repository.getBehindCount(this.branchName); - } - - if (data.isMerging) { - data.mergeMessage = await repository.getMergeMessage(); - } - - return data; + aheadCount: async query => { + const remoteName = await query.remoteName; + return remoteName ? repository.getAheadCount(await query.branchName) : null; + }, + behindCount: async query => { + const remoteName = await query.remoteName; + return remoteName ? repository.getAheadCount(this.branchName) : null; + }, + mergeMessage: async query => { + const isMerging = await query.isMerging; + return isMerging ? repository.getMergeMessage() : null; + }, + }); } fetchStagedChanges(repository) { From c72499e3e9b9ff7dff89e29c1699f0efa20881cc Mon Sep 17 00:00:00 2001 From: Michelle Tilley Date: Sat, 25 Feb 2017 14:57:12 -0800 Subject: [PATCH 04/14] Use yubikiri in GithubController data fetching --- lib/controllers/github-controller.js | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/lib/controllers/github-controller.js b/lib/controllers/github-controller.js index b8556eaaa7..1d953e6241 100644 --- a/lib/controllers/github-controller.js +++ b/lib/controllers/github-controller.js @@ -1,5 +1,6 @@ import React from 'react'; import {autobind} from 'core-decorators'; +import yubikiri from 'yubikiri'; import RemotePrController from './remote-pr-controller'; import Repository from '../models/repository'; @@ -41,12 +42,14 @@ class RemoteSelector extends React.Component { @ObserveModel({ getModel: props => props.repository, fetchData: async repo => { - let remotes = await repo.getRemotes(); - const currentBranch = await repo.getCurrentBranch(); - const selectedRemote = await repo.getConfig('atomGithub.currentRemote'); - remotes = remotes.map(({name, url}) => ({name, url, info: Repository.githubInfoFromRemote(url)})) - .filter(remote => remote.info.githubRepo); - return {remotes, currentBranch, selectedRemote}; + return yubikiri({ + remotes: repo.getRemotes().then(remotes => { + return remotes.map(({name, url}) => ({name, url, info: Repository.githubInfoFromRemote(url)})) + .filter(remote => remote.info.githubRepo); + }), + currentBranch: repo.getCurrentBranch(), + selectedRemote: repo.getConfig('atomGithub.currentRemote'), + }); }, }) export default class GithubController extends React.Component { From de8dfb2911deb1bf6b0ce6e034144c21f78f7f61 Mon Sep 17 00:00:00 2001 From: Michelle Tilley Date: Sat, 25 Feb 2017 15:32:26 -0800 Subject: [PATCH 05/14] Use yubikiri in RemotePrController data fetching --- lib/controllers/remote-pr-controller.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/controllers/remote-pr-controller.js b/lib/controllers/remote-pr-controller.js index a4dd968c64..dec723969d 100644 --- a/lib/controllers/remote-pr-controller.js +++ b/lib/controllers/remote-pr-controller.js @@ -1,5 +1,6 @@ import React from 'react'; import {autobind} from 'core-decorators'; +import yubikiri from 'yubikiri'; import {RemotePropType} from '../prop-types'; import ObserveModel from '../decorators/observe-model'; @@ -8,10 +9,10 @@ import PrInfoController from './pr-info-controller'; @ObserveModel({ getModel: props => props.loginModel, - fetchData: async (loginModel, {instance}) => { - return { - token: await loginModel.getToken(instance), - }; + fetchData: (loginModel, {instance}) => { + return yubikiri({ + token: loginModel.getToken(instance), + }); }, }) export default class RemotePrController extends React.Component { From f7604bcb2f36130d35fa83ba1ae0d7786e1a915d Mon Sep 17 00:00:00 2001 From: Michelle Tilley Date: Sat, 25 Feb 2017 15:32:52 -0800 Subject: [PATCH 06/14] Use yubiriki in RepositoryConflictController data fetching --- lib/controllers/repository-conflict-controller.js | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/lib/controllers/repository-conflict-controller.js b/lib/controllers/repository-conflict-controller.js index 228a653dc7..c3816cdbf2 100644 --- a/lib/controllers/repository-conflict-controller.js +++ b/lib/controllers/repository-conflict-controller.js @@ -1,5 +1,6 @@ import path from 'path'; import React from 'react'; +import yubikiri from 'yubikiri'; import {CompositeDisposable} from 'atom'; import ObserveModel from '../decorators/observe-model'; @@ -12,16 +13,11 @@ import EditorConflictController from './editor-conflict-controller'; @ObserveModel({ getModel: props => props.repository, fetchData: async (r, props) => { - const promises = { - mergeConflicts: r.getMergeConflicts(), - isRebasing: r.isRebasing(), - }; - - return { + return yubikiri({ workingDirectoryPath: r.getWorkingDirectoryPath(), - mergeConflictPaths: (await promises.mergeConflicts).map(conflict => conflict.filePath), - isRebasing: await promises.isRebasing, - }; + mergeConflictPaths: r.getMergeConflicts().then(conflicts => conflicts.map(conflict => conflict.filePath)), + isRebasing: r.isRebasing(), + }); }, }) export default class RepositoryConflictController extends React.Component { From c1d54ab486c43ffc2257aa37febc495135d6fe30 Mon Sep 17 00:00:00 2001 From: Michelle Tilley Date: Sat, 25 Feb 2017 15:34:00 -0800 Subject: [PATCH 07/14] :shirt: --- lib/controllers/github-controller.js | 2 +- lib/controllers/repository-conflict-controller.js | 2 +- lib/controllers/status-bar-tile-controller.js | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/controllers/github-controller.js b/lib/controllers/github-controller.js index 1d953e6241..9a6ff88709 100644 --- a/lib/controllers/github-controller.js +++ b/lib/controllers/github-controller.js @@ -41,7 +41,7 @@ class RemoteSelector extends React.Component { @ObserveModel({ getModel: props => props.repository, - fetchData: async repo => { + fetchData: repo => { return yubikiri({ remotes: repo.getRemotes().then(remotes => { return remotes.map(({name, url}) => ({name, url, info: Repository.githubInfoFromRemote(url)})) diff --git a/lib/controllers/repository-conflict-controller.js b/lib/controllers/repository-conflict-controller.js index c3816cdbf2..6e4a122133 100644 --- a/lib/controllers/repository-conflict-controller.js +++ b/lib/controllers/repository-conflict-controller.js @@ -12,7 +12,7 @@ import EditorConflictController from './editor-conflict-controller'; */ @ObserveModel({ getModel: props => props.repository, - fetchData: async (r, props) => { + fetchData: (r, props) => { return yubikiri({ workingDirectoryPath: r.getWorkingDirectoryPath(), mergeConflictPaths: r.getMergeConflicts().then(conflicts => conflicts.map(conflict => conflict.filePath)), diff --git a/lib/controllers/status-bar-tile-controller.js b/lib/controllers/status-bar-tile-controller.js index 70f8f4046a..beacb74012 100644 --- a/lib/controllers/status-bar-tile-controller.js +++ b/lib/controllers/status-bar-tile-controller.js @@ -13,7 +13,7 @@ import {autobind} from 'core-decorators'; @ObserveModel({ getModel: props => props.repository, - fetchData: async repository => { + fetchData: repository => { return yubikiri({ branchName: repository.getCurrentBranch(), branches: repository.getBranches(), From 9c12ce88ec7011ca95762e82380c4912c1ea94d7 Mon Sep 17 00:00:00 2001 From: Michelle Tilley Date: Sat, 25 Feb 2017 15:36:28 -0800 Subject: [PATCH 08/14] Fix random propType warning --- test/controllers/git-controller.test.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/test/controllers/git-controller.test.js b/test/controllers/git-controller.test.js index bbd2725db8..39050dd2b6 100644 --- a/test/controllers/git-controller.test.js +++ b/test/controllers/git-controller.test.js @@ -9,13 +9,14 @@ import {cloneRepository, buildRepository} from '../helpers'; import GitController from '../../lib/controllers/git-controller'; describe('GitController', function() { - let atomEnv, workspace, commandRegistry, notificationManager, confirm, app; + let atomEnv, workspace, commandRegistry, notificationManager, tooltips, confirm, app; beforeEach(function() { atomEnv = global.buildAtomEnvironment(); workspace = atomEnv.workspace; commandRegistry = atomEnv.commands; notificationManager = atomEnv.notifications; + tooltips = atomEnv.tooltips; confirm = sinon.stub(atomEnv, 'confirm'); app = ( @@ -24,6 +25,7 @@ describe('GitController', function() { commandRegistry={commandRegistry} notificationManager={notificationManager} confirm={confirm} + tooltips={tooltips} /> ); }); From 014a8aa746e1d3cc4228ee04087a2affc199683c Mon Sep 17 00:00:00 2001 From: Michelle Tilley Date: Sat, 25 Feb 2017 15:39:20 -0800 Subject: [PATCH 09/14] :shirt: Add some propType validations --- lib/views/push-pull-menu-view.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/views/push-pull-menu-view.js b/lib/views/push-pull-menu-view.js index 4d3fc11d61..e7d0f72c97 100644 --- a/lib/views/push-pull-menu-view.js +++ b/lib/views/push-pull-menu-view.js @@ -11,6 +11,11 @@ export default class PushPullMenuView extends React.Component { remoteName: React.PropTypes.string, aheadCount: React.PropTypes.number, behindCount: React.PropTypes.number, + + notificationManager: React.PropTypes.object.isRequired, + fetch: React.PropTypes.func.isRequired, + pull: React.PropTypes.func.isRequired, + push: React.PropTypes.func.isRequired, } static defaultProps = { From cb758477f029ce25a802ecf686f26c7186621ea1 Mon Sep 17 00:00:00 2001 From: Michelle Tilley Date: Sat, 25 Feb 2017 15:42:02 -0800 Subject: [PATCH 10/14] Remove staging view elem at end of tests --- test/views/staging-view.test.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/test/views/staging-view.test.js b/test/views/staging-view.test.js index 8123650f74..753109f106 100644 --- a/test/views/staging-view.test.js +++ b/test/views/staging-view.test.js @@ -398,6 +398,7 @@ describe('StagingView', function() { view.mouseup(); assertEqualSets(view.selection.getSelectedItems(), new Set(unstagedChanges.slice(0, 2))); assert.equal(view.props.didSelectFilePath.callCount, 0); + view.element.remove(); }); }); @@ -542,6 +543,7 @@ describe('StagingView', function() { await view.mousedownOnItem({button: 0}, unstagedChanges[2]); assertEqualSets(view.selection.getSelectedItems(), new Set([unstagedChanges[2]])); + view.element.remove(); }); if (process.platform !== 'win32') { @@ -565,6 +567,7 @@ describe('StagingView', function() { assert.isFalse(view.selection.addOrSubtractSelection.called); assert.isFalse(view.selection.selectItem.called); assert.isFalse(view.mouseSelectionInProgress); + view.element.remove(); }); }); } From 160e059dfe7df5ae23432d91d816bac8a63b2f1c Mon Sep 17 00:00:00 2001 From: Michelle Tilley Date: Mon, 27 Feb 2017 15:22:41 -0800 Subject: [PATCH 11/14] Revert ":shirt: Add some propType validations" This reverts commit 014a8aa746e1d3cc4228ee04087a2affc199683c. --- lib/views/push-pull-menu-view.js | 5 ----- 1 file changed, 5 deletions(-) diff --git a/lib/views/push-pull-menu-view.js b/lib/views/push-pull-menu-view.js index e7d0f72c97..4d3fc11d61 100644 --- a/lib/views/push-pull-menu-view.js +++ b/lib/views/push-pull-menu-view.js @@ -11,11 +11,6 @@ export default class PushPullMenuView extends React.Component { remoteName: React.PropTypes.string, aheadCount: React.PropTypes.number, behindCount: React.PropTypes.number, - - notificationManager: React.PropTypes.object.isRequired, - fetch: React.PropTypes.func.isRequired, - pull: React.PropTypes.func.isRequired, - push: React.PropTypes.func.isRequired, } static defaultProps = { From ebfdbbd1c6b249e6e9dcc15545e6619c3bee801c Mon Sep 17 00:00:00 2001 From: Michelle Tilley Date: Mon, 27 Feb 2017 15:22:42 -0800 Subject: [PATCH 12/14] Revert "Fix random propType warning" This reverts commit 9c12ce88ec7011ca95762e82380c4912c1ea94d7. --- test/controllers/git-controller.test.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/test/controllers/git-controller.test.js b/test/controllers/git-controller.test.js index 39050dd2b6..bbd2725db8 100644 --- a/test/controllers/git-controller.test.js +++ b/test/controllers/git-controller.test.js @@ -9,14 +9,13 @@ import {cloneRepository, buildRepository} from '../helpers'; import GitController from '../../lib/controllers/git-controller'; describe('GitController', function() { - let atomEnv, workspace, commandRegistry, notificationManager, tooltips, confirm, app; + let atomEnv, workspace, commandRegistry, notificationManager, confirm, app; beforeEach(function() { atomEnv = global.buildAtomEnvironment(); workspace = atomEnv.workspace; commandRegistry = atomEnv.commands; notificationManager = atomEnv.notifications; - tooltips = atomEnv.tooltips; confirm = sinon.stub(atomEnv, 'confirm'); app = ( @@ -25,7 +24,6 @@ describe('GitController', function() { commandRegistry={commandRegistry} notificationManager={notificationManager} confirm={confirm} - tooltips={tooltips} /> ); }); From 1d5df1ebb0d9bba2f57afd1fccc0f633f89b699f Mon Sep 17 00:00:00 2001 From: Michelle Tilley Date: Mon, 27 Feb 2017 15:36:30 -0800 Subject: [PATCH 13/14] this.branchName -> query.branchName --- lib/controllers/git-tab-controller.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/controllers/git-tab-controller.js b/lib/controllers/git-tab-controller.js index fb8a123b7e..00b7797620 100644 --- a/lib/controllers/git-tab-controller.js +++ b/lib/controllers/git-tab-controller.js @@ -110,7 +110,7 @@ export default class GitTabController { }, behindCount: async query => { const remoteName = await query.remoteName; - return remoteName ? repository.getAheadCount(this.branchName) : null; + return remoteName ? repository.getAheadCount(await query.branchName) : null; }, mergeMessage: async query => { const isMerging = await query.isMerging; From 37c2b69a85861148c800727a8680dc90e2694399 Mon Sep 17 00:00:00 2001 From: Michelle Tilley Date: Mon, 27 Feb 2017 15:38:48 -0800 Subject: [PATCH 14/14] Oops! :keyboard: --- lib/controllers/git-tab-controller.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/controllers/git-tab-controller.js b/lib/controllers/git-tab-controller.js index 00b7797620..1cdde65f9a 100644 --- a/lib/controllers/git-tab-controller.js +++ b/lib/controllers/git-tab-controller.js @@ -110,7 +110,7 @@ export default class GitTabController { }, behindCount: async query => { const remoteName = await query.remoteName; - return remoteName ? repository.getAheadCount(await query.branchName) : null; + return remoteName ? repository.getBehindCount(await query.branchName) : null; }, mergeMessage: async query => { const isMerging = await query.isMerging;