-
Notifications
You must be signed in to change notification settings - Fork 778
GitHub Integration (Proof of Concept) #578
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
2e6dedb
99e91e1
0d41ab9
bd4f2de
1215417
b7b7712
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| .project-stats > :last-child { | ||
| margin-left: 2rem; | ||
| } | ||
|
|
||
| .last-committed { | ||
| font-style: italic; | ||
| color: rgb(119, 119, 119); | ||
| margin-top: 1rem; | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,105 @@ | ||
| import { Icon } from 'office-ui-fabric-react/lib/Icon' | ||
| import { Link } from 'office-ui-fabric-react'; | ||
| import * as React from 'react'; | ||
|
|
||
| import './RepoDetails.css' | ||
|
|
||
| interface IRepoDetailsProps { | ||
| url: string; | ||
| } | ||
|
|
||
| interface IRepoDetailsState { | ||
| openIssues: number; | ||
| openPulls: number; | ||
| lastCommit: Date; | ||
| detailsFound: boolean; | ||
| } | ||
|
|
||
| class RepoDetails extends React.Component<IRepoDetailsProps, IRepoDetailsState> { | ||
|
Owner
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. Just curious, why did you create a new component instead of updating the
Contributor
Author
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. Once I've finished this I might remove the heading tag and put it inside the SourceRepository component, this is a good point |
||
|
|
||
| private controller: AbortController; | ||
|
|
||
| constructor(props: IRepoDetailsProps) { | ||
| super(props); | ||
|
|
||
| this.controller = new AbortController(); | ||
|
|
||
| this.state = { | ||
| openIssues: 0, | ||
| openPulls: 0, | ||
| lastCommit: new Date(), | ||
| detailsFound: false, | ||
| }; | ||
| } | ||
|
|
||
| private getRepoOwnerAndName(repoUrl: string) { | ||
| const frags = repoUrl.split("/"); | ||
|
davidackroyd99 marked this conversation as resolved.
|
||
| let retval = []; | ||
|
|
||
| for(var i = frags.length - 1; i > 0; i--) { | ||
| if(frags[i].length > 0) { | ||
| retval.push(frags[i]) | ||
| } | ||
|
|
||
| if(retval.length == 2) { | ||
| break; | ||
| } | ||
| } | ||
|
|
||
| return retval.reverse(); | ||
| } | ||
|
|
||
| private buildGitHubUrl(details: Array<string>) { | ||
| return `https://api.github.com/repos/${details[0]}/${details[1]}`; | ||
| } | ||
|
|
||
| public componentDidMount() { | ||
| if (this.props.url) { | ||
| const ownerAndName = this.getRepoOwnerAndName(this.props.url); | ||
|
|
||
| if(ownerAndName.length == 2) { | ||
| console.log(ownerAndName); | ||
| fetch(this.buildGitHubUrl(ownerAndName), {signal: this.controller.signal}).then(response => { | ||
| return response.json(); | ||
| }).then(json => { | ||
| console.log(json); | ||
| this.setState({ | ||
| detailsFound: true, | ||
| openIssues: json['open_issues'], | ||
| openPulls: 0, | ||
| lastCommit: new Date(json['pushed_at']) | ||
| }); | ||
| // tslint:disable-next-line:no-console | ||
| }).catch((e) => console.log("Failed to load dependents.", e)); | ||
|
davidackroyd99 marked this conversation as resolved.
|
||
| } | ||
|
|
||
| this.setState({ | ||
| openIssues: 100, | ||
| openPulls: 23, | ||
| lastCommit: new Date(2020, 8, 21) | ||
| }); | ||
| } | ||
| } | ||
|
|
||
| public render() { | ||
| if (!this.state.detailsFound) { | ||
| return null; | ||
| } | ||
|
|
||
| return ( | ||
| <div> | ||
| <h2>Project Details</h2> | ||
|
|
||
| <div className="project-stats"> | ||
| <Link href={this.props.url + "/issues"}><Icon iconName="Error" className="ms-Icon issues-icon" />{this.state.openIssues}</Link> | ||
| {/* <Link href={this.props.url + "/pulls"}><Icon iconName="BranchPullRequest" className="ms-Icon pulls-icon" />{this.state.openPulls}</Link> */} | ||
| </div> | ||
|
|
||
| <p className="last-committed">Last pushed on {this.state.lastCommit.toLocaleDateString()}</p> | ||
| </div> | ||
| ); | ||
| } | ||
| } | ||
|
|
||
| export default RepoDetails; | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.
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
projectUrlis the package's website, not necessarily it's source repository. Please use therepositoryUrlproperty instead:BaGet/src/BaGet.Core/Metadata/BaGetPackageMetadata.cs
Lines 28 to 29 in f0ee2c5
BaGet/src/BaGet.UI/src/DisplayPackage/Registration.tsx
Line 31 in f0ee2c5
This property isn't part of the NuGet V3 protocol, but, it maps to the package's source repository metadata: https://docs.microsoft.com/en-us/nuget/reference/nuspec#repository
By the way, the
repositoryUrlproperty on the TypeScript interface should be nullable. Could you fix that as part of your changes?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.
Will do!