Skip to content
This repository was archived by the owner on Dec 15, 2022. It is now read-only.

Conversation

@BinaryMuse
Copy link
Contributor

@BinaryMuse BinaryMuse commented Jan 21, 2017

Implements the following flows:

  • Detects all remotes pointing to GH.com
    • If only one, uses that remote
    • If more than one, prompts for selection — saves selection in Git config
  • Detects if we have a token for that remote (currently only GH.com but others will be supported)
    • If not, shows login window
    • If so, shows placeholder

}

async getRemotes() {
const output = await this.exec(['config', '--local', '--get-regexp', '^remote..*.url$']);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kuychaco I couldn't think of a better way to do this. Any thoughts?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, I wonder if we should specifically look at pushUrl here too, in case PRs are opened against pushUrl's repo and not url's

Copy link
Contributor

@smashwilson smashwilson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 Various tiny comments on superficial stuff.

import Resizer from '../views/resizer';
import Tabs from '../views/tabs';
import Commands, {Command} from '../views/commands';
import GithubController from './github-controller';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Structurally, it's a little weird to me that we have a GitController that contains a GitPanelController and a GithubController, especially because the UI consists of a single panel that our registered commands call a "git panel". It'd be nice to have some symmetry between the classnames on each side and between the UI language and the source.

Oh, also, shouldn't the capitalization be GitHub for Branding Reasons ™️?

Maybe instead we could have:

  • GitPanelController
    • GitController
    • GitHubController

Or:

  • GitController
    • GitTabController
    • GitHubTabController

(We could also defer any renaming until after this particular PR ships; I don't want to hold it up for us to decide on that bikeshed color 😉)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree, the naming of these classes needs work. I also agree that we'll do it later ;)

<p>
This repository has multiple remotes hosted at GitHub.com.
Select a remote to see pull requests associated
with this branch ({currentBranch}).
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe something like with the <strong>{currentBranch}</strong> branch to save some parentheticals?

(I always wildly overuse parentheticals myself.)

{remotes.map(remote => (
<li key={remote.name}>
<a href="#" onClick={e => selectRemote(e, remote)}>
{remote.name} ({remote.info.owner}/{remote.info.name})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ooh nice ✨ This will save me so many git remote -v calls 😁


render() {
if (!this.props.repository || !this.props.remotes) {
return <div />;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

React thing - is this better than returning null?

let remote = this.props.remotes.find(r => r.name === this.props.selectedRemote);
let remotesAvailable = false;
if (!remote && this.props.remotes.length === 1) {
remote = this.props.remotes[0];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💯 for defaulting to a single remote with a prompt.

render() {
return (
<div className="github-RemotePrController">
{this.props.token && <span>you gots a token! {this.props.token}</span>}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😆

* // and should return the model to watch; defaults to `props.model`
* getModel: props => props.repository,
* // fetchData takes the model instance and the props passed
* // to the outer component and should an object (or promise
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing the word "return" here I think ☝️

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reminds me of the time I accidentally the whole thing

async getRemotes() {
let output;
try {
output = await this.exec(['config', '--local', '--get-regexp', '^remote..*.url$']);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any way this could be a this.getConfig() call?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought about this, but it would complicate calling getConfig quite a bit so I decided to forego on that effort. I could be convinced.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I lied, this is a great idea 😅

} catch (_e) {
// Nothing
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh wow, this'll be great to have.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The only downside is to make the React devtools work you have to remove the CSP meta tag in static/index.html in your local Atom build (assuming dev mode).

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants