This repository has been archived by the owner on Nov 16, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 27
Create Issue button #8
Merged
Merged
Changes from 3 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
9cd899a
:rocket: Support creating issues
jens1o 70c3f31
finish up pr
jens1o d8a7d4c
trim trailing whitespaces
jens1o cce6a57
implement picker
jens1o 39e8696
cleanup
jens1o d8ea44f
remove debug helper
jens1o 5e526ee
support private repos and cleanup
jens1o File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
import * as path from 'path'; | ||
|
||
import * as GitHub from 'github'; | ||
import * as open from 'open'; | ||
import { copy } from 'copy-paste'; | ||
import { fill } from 'git-credential-node'; | ||
|
||
|
@@ -44,6 +45,7 @@ export class GitHubIssuesPrsProvider implements TreeDataProvider<TreeItem> { | |
|
||
constructor(private context: ExtensionContext) { | ||
context.subscriptions.push(commands.registerCommand('githubIssuesPrs.refresh', this.refresh, this)); | ||
context.subscriptions.push(commands.registerCommand('githubIssuesPrs.createIssue', this.createIssue, this)); | ||
context.subscriptions.push(commands.registerCommand('githubIssuesPrs.openIssue', this.openIssue, this)); | ||
context.subscriptions.push(commands.registerCommand('githubIssuesPrs.openPullRequest', this.openIssue, this)); | ||
// context.subscriptions.push(commands.registerCommand('githubIssuesPrs.checkoutPullRequest', this.checkoutPullRequest, this)); | ||
|
@@ -93,6 +95,21 @@ export class GitHubIssuesPrsProvider implements TreeDataProvider<TreeItem> { | |
} | ||
} | ||
|
||
private async createIssue() { | ||
let remotes: GitRemote[]; | ||
|
||
try { | ||
remotes = await this.getGitHubRemotes(); | ||
} catch (err) { | ||
return false; | ||
} | ||
|
||
// take first one | ||
await open(getGitHubUrl(remotes[0].url) + '/issues/new'); | ||
|
||
return true; | ||
} | ||
|
||
private async poll() { | ||
if (!this.lastFetch || this.lastFetch + 30 * 60 * 1000 < Date.now()) { | ||
return this.refresh(); | ||
|
@@ -288,3 +305,10 @@ export class GitHubIssuesPrsProvider implements TreeDataProvider<TreeItem> { | |
return remotes; | ||
} | ||
} | ||
|
||
/** | ||
* Helper function which removes the ending `.git` | ||
*/ | ||
function getGitHubUrl(url: string): string { | ||
return url.substr(0, url.lastIndexOf('.git')); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The URL might be in SSH format (e.g., git@github.com:octocat/Hello-World.git). You can instead use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah, didn't played with the js api tbh, thanks! |
||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The first one might not be the right one. Maybe you could let the user choose one with window.showQuickPick() when there are multiple remotes?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds reasonable, but should we remember it, and if yes, where?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wouldn't remember it for now to keep things simple.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay.