Skip to content

Commit

Permalink
fix: remote url is ssh
Browse files Browse the repository at this point in the history
  • Loading branch information
prokopsimek committed Aug 19, 2019
1 parent 107b194 commit f9d57bc
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 23 deletions.
8 changes: 1 addition & 7 deletions src/contexts/projectComponent/ProjectComponentContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@ import { injectable, inject } from 'inversify';
import { Types, PracticeContextFactory } from '../../types';
import { ProgrammingLanguage, ProjectComponent } from '../../model';
import { PracticeContext } from '../practice/PracticeContext';
import { ContextBase } from '../ContextBase';

@injectable()
export class ProjectComponentContext extends ContextBase {
export class ProjectComponentContext {
readonly projectComponent: ProjectComponent;
get path(): string {
return this.projectComponent.path;
Expand All @@ -19,15 +18,10 @@ export class ProjectComponentContext extends ContextBase {
@inject(Types.ProjectComponent) projectComponent: ProjectComponent,
@inject(Types.PracticeContextFactory) practiceContextFactory: PracticeContextFactory,
) {
super();
this.projectComponent = projectComponent;
this.practiceContextFactory = practiceContextFactory;
}

async init(): Promise<void> {
throw new Error('Method not implemented.');
}

getPracticeContext(): PracticeContext {
return this.practiceContextFactory(this.projectComponent);
}
Expand Down
1 change: 0 additions & 1 deletion src/scanner/Scanner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,6 @@ export class Scanner {
const practicesWithContext: PracticeWithContext[] = [];
for (const componentWithCtx of componentsWithContext) {
const componentContext = componentWithCtx.languageContext.getProjectComponentContext(componentWithCtx.component);
await componentContext.init();
const practiceContext = componentContext.getPracticeContext();

const applicablePractices = await filterAsync(this.practices, async (p) => {
Expand Down
2 changes: 0 additions & 2 deletions src/services/git/Git.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable @typescript-eslint/explicit-member-accessibility */
import { Repository } from '../../model';
import { GitHubClient } from './GitHubClient';
import { GitHubUrlParser } from './GitHubUrlParser';
Expand All @@ -20,7 +19,6 @@ export class Git {
this.cache = cache;
}

//should be explicit-member-accessibility disabled? There is just a warning
async listDirectory(path: string): Promise<(GitHubFile | GitHubDir)[]> {
return this.cache.getOrSet(this.contentCacheKey(path), async () => {
const params = GitHubUrlParser.getOwnerAndRepoName(this.repository.url);
Expand Down
19 changes: 6 additions & 13 deletions src/services/git/GitHubUrlParser.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,12 @@
import { ErrorFactory } from '../../lib/errors/ErrorFactory';

/* eslint-disable @typescript-eslint/explicit-member-accessibility */
import gitUrlParse from 'git-url-parse';

export class GitHubUrlParser {
public static getOwnerAndRepoName(url: string): { owner: string; repoName: string } {
url = url.replace('http://', '');
url = url.replace('https://', '');
const urlTokens = url.split('/');
if (urlTokens.length !== 3) {
throw ErrorFactory.newInternalError(`Malformed github url: ${url}`);
}
const repoName = urlTokens[2].endsWith('.git') ? urlTokens[2].replace('.git', '') : urlTokens[2];
static getOwnerAndRepoName(url: string): { owner: string; repoName: string } {
const parsedUrl = gitUrlParse(url);

return {
owner: urlTokens[1],
repoName,
owner: parsedUrl.owner,
repoName: parsedUrl.name,
};
}
}

0 comments on commit f9d57bc

Please sign in to comment.