Skip to content
This repository was archived by the owner on Nov 16, 2023. It is now read-only.

Support host name(fix #25)#27

Merged
chrmarti merged 5 commits intomicrosoft:masterfrom
Ikuyadeu:GHE
Nov 8, 2017
Merged

Support host name(fix #25)#27
chrmarti merged 5 commits intomicrosoft:masterfrom
Ikuyadeu:GHE

Conversation

@Ikuyadeu
Copy link
Contributor

It's one idea to fix #25.
And, If you use GitHubAPI, this change has no effect.

"default": [],
"description": "A list of repositories to query for issues."
},
"github.host": {
Copy link
Contributor

Choose a reason for hiding this comment

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

Would it be difficult to support multiple hosts?

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 think, if you set multiple hosts, you need to set multiple user names and passwords for each hosts.

Copy link
Contributor

Choose a reason for hiding this comment

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

Sounds good.

private children: Promise<TreeItem[]> | undefined;

private username: string | undefined;
private host: string | undefined;
Copy link
Contributor

Choose a reason for hiding this comment

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

getGitHubRemotes() has two references to "github.com". I guess that needs to be updated too. Do you have access to a GitHub Enterprise install?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, I'll fix.
But, I don't have GHE. How should I test for GHE environment?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK fixed!

for (const url of new Set(allMatches(/^[^\s]+\s+([^\s]+)/gm, stdout, 1))) {
const m = /[^\s]*github\.com[/:]([^/]+)\/([^ ]+)[^\s]*/.exec(url);
// const m = /[^\s]*github\.com[/:]([^/]+)\/([^ ]+)[^\s]*/.exec(url);
const m = new RegExp(`[^\s]*${this.getURL()}[/:]([^/]+)\/([^ ]+)[^\s]*`).exec(url);
Copy link
Contributor

Choose a reason for hiding this comment

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

Backslashes need escaping in the string. Slashes don't. The URL might need some escaping too. Maybe (please check):

const m = new RegExp(`[^\\s]*${this.getURL().replace(/\./g, '\\.')}[/:]([^/]+)/([^ ]+)[^\\s]*`).exec(url);

}

private getURL() {
if(this.host === undefined){
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't that always be defined?

let remote = remotes[`${owner}/${repo}`];
if (!remote) {
const url = `https://github.com/${owner}/${repo}.git`;
const url = `${this.host}/${owner}/${repo}.git`;
Copy link
Contributor

Choose a reason for hiding this comment

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

Should that keep the https?

@Ikuyadeu
Copy link
Contributor Author

Ikuyadeu commented Nov 4, 2017

@chrmarti Thank you for review.
How is this?

@chrmarti chrmarti added this to the October 2017 milestone Nov 6, 2017
Copy link
Contributor

@chrmarti chrmarti left a comment

Choose a reason for hiding this comment

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

Thanks for the update. I've added a few more comments.

const item = issue.item;
const assignee = issue.query.assignee;
const url = `https://github.com/${issue.query.remote.owner}/${issue.query.remote.repo}/issues?q=is%3Aopen+milestone%3A%22${item.milestone.title}%22${assignee ? '+assignee%3A' + assignee : ''}`;
const url = `https://${this.getURL}/${issue.query.remote.owner}/${issue.query.remote.repo}/issues?q=is%3Aopen+milestone%3A%22${item.milestone.title}%22${assignee ? '+assignee%3A' + assignee : ''}`;
Copy link
Contributor

Choose a reason for hiding this comment

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

getURL is missing ().

}

private getAPIOption() {
if (this.host === "github.com") {
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you use single quotes ' instead of double quotes? Just for consistency with the rest of the code.

const { stdout } = await exec('git remote -v', { cwd: folder.uri.fsPath });
for (const url of new Set(allMatches(/^[^\s]+\s+([^\s]+)/gm, stdout, 1))) {
const m = /[^\s]*github\.com[/:]([^/]+)\/([^ ]+)[^\s]*/.exec(url);
const m = new RegExp(`[^\s]*${this.getURL().replace(/\./g, '\\.')}[/:]([^/]+)\/([^ ]+)[^\s]*`).exec(url);
Copy link
Contributor

Choose a reason for hiding this comment

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

I think the \s still need escaping as \\s, don't they? That's because it is in a string and not in a regex anymore.

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 missed it. Thank you

let remote = remotes[`${owner}/${repo}`];
if (!remote) {
const url = `https://github.com/${owner}/${repo}.git`;
const url = `https://${this.host}/${owner}/${repo}.git`;
Copy link
Contributor

Choose a reason for hiding this comment

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

Does this not need the encoding of getURL()? Do you have an example of when the encoding is needed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

e.g. Thyme &time=again to comment=Thyme%20&time=again.
However, I think host name doesn't have space.
I'll remove this. Thank you.

"default": [],
"description": "A list of repositories to query for issues."
},
"github.host": {
Copy link
Contributor

Choose a reason for hiding this comment

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

Sounds good.

@mikehaas763
Copy link

mikehaas763 commented Nov 7, 2017

I haven't done any vs code extension development before, what's the best and/or easiest way for me to test this out? Do we pass around vsix files or something?

@chrmarti
Copy link
Contributor

chrmarti commented Nov 7, 2017

@mikehaas763 You could checkout this PR from @Ikuyadeu's repo and open it in VS Code. Then run npm install in its folder and launch a second VS Code window with the extension running by pressing F5 in the first window.

@chrmarti chrmarti modified the milestones: October 2017, November 2017 Nov 8, 2017
@chrmarti
Copy link
Contributor

chrmarti commented Nov 8, 2017

Thanks @Ikuyadeu LGTM! I'll merge this even before it is tested so we don't run into merge conflicts with other changes.

@chrmarti chrmarti merged commit 014b16a into microsoft:master Nov 8, 2017
@Ikuyadeu Ikuyadeu deleted the GHE branch November 9, 2017 00:35
@chrmarti
Copy link
Contributor

@Ikuyadeu I missed giving you credit in the 1.19 release notes due to being on vacation. Sorry about that. I will do so in the 1.20 release notes. Thanks again!

@chrmarti chrmarti modified the milestones: November 2017, January 2018 Jan 18, 2018
@Ikuyadeu
Copy link
Contributor Author

@chrmarti OK! Thank you too!

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.

discussion: what would it take to make this work with enterprise github?

3 participants