Skip to content

Commit

Permalink
Add support for Sourceforge repositories
Browse files Browse the repository at this point in the history
  • Loading branch information
Siddhant-K-code committed May 6, 2024
1 parent d13e12b commit 9866c73
Show file tree
Hide file tree
Showing 5 changed files with 195 additions and 1 deletion.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ For example, try it on the VS Code repo:

![VS Code - GitHub1s](https://raw.githubusercontent.com/conwnet/github1s/master/resources/images/vs-code-github1s.png)

You can also use [https://gitlab1s.com](https://gitlab1s.com) or [https://npmjs1s.com](https://npmjs1s.com) in the same way.
You can also use [https://gitlab1s.com](https://gitlab1s.com), [https://sourceforge1s.com](https://sourceforge1s.com), or [https://npmjs1s.com](https://npmjs1s.com) in the same way.

For browser extensions, see [Third-party Related Projects](https://github.com/conwnet/github1s#third-party-related-projects).

Expand Down
2 changes: 2 additions & 0 deletions extensions/github1s/src/adapters/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { GitLab1sAdapter } from './gitlab1s';
import { BitbucketAdapter } from './bitbucket1s';
import { Npmjs1sAdapter } from './npmjs1s';
import { OSSInsightAdapter } from './ossinsight';
import { Sourceforge1sAdapter } from './sourceforge1s'; // Import the Sourceforge adapter
import { DataSource, PlatformName, RouterParser } from './types';

const emptyAdapter = {
Expand All @@ -26,6 +27,7 @@ export const registerAdapters = async (): Promise<void> => {
adapterManager.registerAdapter(new BitbucketAdapter()),
adapterManager.registerAdapter(new Npmjs1sAdapter()),
adapterManager.registerAdapter(new OSSInsightAdapter()),
adapterManager.registerAdapter(new Sourceforge1sAdapter()), // Register the Sourceforge adapter
]);
};

Expand Down
108 changes: 108 additions & 0 deletions extensions/github1s/src/adapters/sourceforge1s/data-source.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
/**
* @file Sourceforge1s data-source-provider
* @author Your Name
*/

import {
DataSource,
Directory,
File,
Branch,
Tag,
Commit,
TextSearchResults,
TextSearchQuery,
TextSearchOptions,
BlameRange,
SymbolDefinitions,
SymbolReferences,
SymbolHover,
} from '../types';

export class Sourceforge1sDataSource extends DataSource {
private static instance: Sourceforge1sDataSource | null = null;

public static getInstance(): Sourceforge1sDataSource {
if (Sourceforge1sDataSource.instance) {
return Sourceforge1sDataSource.instance;
}
return (Sourceforge1sDataSource.instance = new Sourceforge1sDataSource());
}

// Implement the DataSource methods for Sourceforge
async provideDirectory(repo: string, ref: string, path: string, recursive = false): Promise<Directory | null> {
// Implementation for fetching a directory from Sourceforge
return null;
}

async provideFile(repo: string, ref: string, path: string): Promise<File | null> {
// Implementation for fetching a file from Sourceforge
return null;
}

async provideBranches(repo: string, options?: CommonQueryOptions): Promise<Branch[]> {
// Implementation for fetching branches from Sourceforge
return [];
}

async provideTags(repo: string, options?: CommonQueryOptions): Promise<Tag[]> {
// Implementation for fetching tags from Sourceforge
return [];
}

async provideCommits(repo: string, options?: CommitsQueryOptions): Promise<Commit[]> {
// Implementation for fetching commits from Sourceforge
return [];
}

async provideTextSearchResults(
repo: string,
ref: string,
query: TextSearchQuery,
options?: TextSearchOptions
): Promise<TextSearchResults> {
// Implementation for text search in Sourceforge
return { results: [], truncated: false };
}

async provideFileBlameRanges(repo: string, ref: string, path: string): Promise<BlameRange[]> {
// Implementation for fetching file blame ranges from Sourceforge
return [];
}

async provideSymbolDefinitions(
repo: string,
ref: string,
path: string,
line: number,
character: number,
symbol: string
): Promise<SymbolDefinitions> {
// Implementation for fetching symbol definitions from Sourceforge
return [];
}

async provideSymbolReferences(
repo: string,
ref: string,
path: string,
line: number,
character: number,
symbol: string
): Promise<SymbolReferences> {
// Implementation for fetching symbol references from Sourceforge
return [];
}

async provideSymbolHover(
repo: string,
ref: string,
path: string,
line: number,
character: number,
symbol: string
): Promise<SymbolHover | null> {
// Implementation for fetching symbol hover information from Sourceforge
return null;
}
}
33 changes: 33 additions & 0 deletions extensions/github1s/src/adapters/sourceforge1s/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/**
* @file Sourceforge1s adapter
* @author Your Name
*/

import { Sourceforge1sDataSource } from './data-source';
import { Sourceforge1sRouterParser } from './router-parser';
import { Adapter, CodeReviewType, PlatformName } from '../types';
import { setVSCodeContext } from '@/helpers/vscode';

export class Sourceforge1sAdapter implements Adapter {
public scheme: string = 'sourceforge1s';
public platformName = PlatformName.OfficialPage; // Adjust as needed
public codeReviewType = CodeReviewType.CodeReview; // Adjust as needed

resolveDataSource() {
return Promise.resolve(Sourceforge1sDataSource.getInstance());
}

resolveRouterParser() {
return Promise.resolve(Sourceforge1sRouterParser.getInstance());
}

activateAsDefault() {
// Implement activation logic here
setVSCodeContext('github1s:views:settings:visible', true);
}

deactivateAsDefault() {
// Implement deactivation logic here
setVSCodeContext('github1s:views:settings:visible', false);
}
}
51 changes: 51 additions & 0 deletions extensions/github1s/src/adapters/sourceforge1s/router-parser.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/**
* @file router parser for Sourceforge1s
* @author Your Name
*/

import * as adapterTypes from '../types';
import { parseSourceforgePath } from './parse-path';

export class Sourceforge1sRouterParser extends adapterTypes.RouterParser {
private static instance: Sourceforge1sRouterParser | null = null;

public static getInstance(): Sourceforge1sRouterParser {
if (Sourceforge1sRouterParser.instance) {
return Sourceforge1sRouterParser.instance;
}
return (Sourceforge1sRouterParser.instance = new Sourceforge1sRouterParser());
}

parsePath(path: string): Promise<adapterTypes.RouterState> {
return parseSourceforgePath(path);
}

buildTreePath(repo: string, ref?: string, filePath?: string): string {
return ref ? (filePath ? `/${repo}/tree/${ref}/${filePath}` : `/${repo}/tree/${ref}`) : `/${repo}`;
}

buildBlobPath(repo: string, ref: string, filePath: string, startLine?: number, endLine?: number): string {
const hash = startLine ? (endLine ? `#L${startLine}-L${endLine}` : `#L${startLine}`) : '';
return `/${repo}/blob/${ref}/${filePath}${hash}`;
}

buildCommitListPath(repo: string): string {
return `/${repo}/commits`;
}

buildCommitPath(repo: string, commitSha: string): string {
return `/${repo}/commit/${commitSha}`;
}

buildCodeReviewListPath(repo: string): string {
return `/${repo}/pull-requests`;
}

buildCodeReviewPath(repo: string, codeReviewId: string): string {
return `/${repo}/pull-request/${codeReviewId}`;
}

buildExternalLink(path: string): string {
return `https://sourceforge.net${path.startsWith('/') ? path : `/${path}`}`;
}
}

0 comments on commit 9866c73

Please sign in to comment.