Skip to content

Commit

Permalink
Merge pull request #3403 from cloudfoundry-incubator/search-git-forks
Browse files Browse the repository at this point in the history
Also show forked repos when suggesting github repos in deploy app
  • Loading branch information
nwmac authored Feb 14, 2019
2 parents 6465845 + a9eec17 commit 2df0a40
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions src/frontend/app/shared/data-services/scm/github-scm.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import { GitSCM, SCMIcon } from './scm';
import { Observable } from 'rxjs';
import { map, filter } from 'rxjs/operators';
import { HttpClient } from '@angular/common/http';
import { Observable } from 'rxjs';
import { filter, map } from 'rxjs/operators';

import { GitBranch, GitCommit, GitRepo } from '../../../store/types/git.types';
import { GitSCM, SCMIcon } from './scm';
import { GitSCMType } from './scm.service';
import { GitRepo, GitCommit, GitBranch } from '../../../store/types/git.types';

export class GitHubSCM implements GitSCM {

constructor(public httpClient: HttpClient, public gitHubURL: string) {}
constructor(public httpClient: HttpClient, public gitHubURL: string) { }

getType(): GitSCMType {
return 'github';
Expand All @@ -29,7 +30,7 @@ export class GitHubSCM implements GitSCM {
}

getBranches(projectName: string): Observable<GitBranch[]> {
return this.httpClient.get(`${this.gitHubURL}/repos/${projectName}/branches`) as Observable<GitBranch[]>;
return this.httpClient.get(`${this.gitHubURL}/repos/${projectName}/branches`) as Observable<GitBranch[]>;
}

getCommit(projectName: string, commitSha: string): Observable<GitCommit> {
Expand All @@ -54,9 +55,9 @@ export class GitHubSCM implements GitSCM {

getMatchingRepositories(projectName: string): Observable<string[]> {
const prjParts = projectName.split('/');
let url = `${this.gitHubURL}/search/repositories?q=${projectName}+in:name`;
let url = `${this.gitHubURL}/search/repositories?q=${projectName}+in:name+fork:true`;
if (prjParts.length > 1) {
url = `${this.gitHubURL}/search/repositories?q=${prjParts[1]}+in:name+user:${prjParts[0]}`;
url = `${this.gitHubURL}/search/repositories?q=${prjParts[1]}+in:name+fork:true+user:${prjParts[0]}`;
}
return this.httpClient.get(url).pipe(
filter((repos: any) => !!repos.items),
Expand Down

0 comments on commit 2df0a40

Please sign in to comment.