Skip to content

Commit

Permalink
feat: add support for PR reviewers
Browse files Browse the repository at this point in the history
- provide repoverse config interface as public API
  • Loading branch information
RajVarsani committed Dec 23, 2023
1 parent b532105 commit 30206e8
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 11 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "repoverse",
"version": "0.0.9-development",
"version": "0.0.10-development",
"description": "Tool for syncronising common code across multiple repositories",
"main": "./lib/index.js",
"files": [
Expand Down
26 changes: 18 additions & 8 deletions src/Repoverse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,15 @@ interface RepositoryConfig {
repo: string;
path: string;
branch: string;
reviewers: string[];
}

export interface RepoverseConfig {
repositories: RepositoryConfig[];
syncBranchPrefix: string;
accessToken: string;
}

interface CommitDataCache {
[key: string]: CommitData & {
blobCache: {
Expand All @@ -17,14 +25,10 @@ interface CommitDataCache {
}

class Repoverse {
private config: {
repositories: RepositoryConfig[];
syncBranchPrefix: string;
accessToken: string;
};
private config: RepoverseConfig;
private octokit: Octokit;

constructor(config: typeof Repoverse.prototype.config) {
constructor(config: RepoverseConfig) {
this.config = config;
this.octokit = new Octokit({
auth: this.config.accessToken,
Expand Down Expand Up @@ -171,7 +175,13 @@ class Repoverse {
targetRepoConfig: RepositoryConfig,
syncBranchName: string
): Promise<void> {
const { owner, repo, path: targetPath, branch } = targetRepoConfig;
const {
owner,
repo,
path: targetPath,
branch,
reviewers,
} = targetRepoConfig;
if (sourceRepoConfig.owner === owner && sourceRepoConfig.repo === repo) {
return;
}
Expand Down Expand Up @@ -322,7 +332,7 @@ class Repoverse {
owner: owner,
repo: repo,
pull_number: raisedPR.data.number,
reviewers: [owner],
reviewers: reviewers,
});

console.log(
Expand Down
3 changes: 2 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import Repoverse from './Repoverse';
import Repoverse, { RepoverseConfig } from './Repoverse';
module.exports = Repoverse;
export default Repoverse;
export { RepoverseConfig };
3 changes: 2 additions & 1 deletion test/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ function generateFakeRepositoryConfig() {
repo: faker.system.commonFileName(),
path: faker.system.filePath(),
branch: `branch-${faker.lorem.word()}`,
reviewers: [faker.internet.userName()],
};
}

Expand Down Expand Up @@ -239,7 +240,7 @@ describe('Repoverse', () => {
};
}
).data.number,
reviewers: [targetRepositoryConfigs[index].owner],
reviewers: targetRepositoryConfigs[index].reviewers,
});
}

Expand Down

0 comments on commit 30206e8

Please sign in to comment.