Skip to content

Commit

Permalink
refactor(platform): pass CommitFilesConfig through
Browse files Browse the repository at this point in the history
  • Loading branch information
rarkins committed Jun 2, 2020
1 parent 6516cc1 commit 75c0ca6
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 62 deletions.
27 changes: 5 additions & 22 deletions lib/platform/bitbucket-server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -443,32 +443,15 @@ export function getAllRenovateBranches(
return config.storage.getAllRenovateBranches(branchPrefix);
}

export async function commitFiles({
branchName,
files,
message,
}: CommitFilesConfig): Promise<string | null> {
logger.debug(
`commitFiles(${JSON.stringify(
{
branchName,
filesLength: files.length,
message,
},
null,
2
)})`
);
const commit = config.storage.commitFiles({
branchName,
files,
message,
});
export async function commitFiles(
commitFilesConfig: CommitFilesConfig
): Promise<string | null> {
const commit = config.storage.commitFiles(commitFilesConfig);

// wait for pr change propagation
await delay(1000);
// refresh cache
await getBranchPr(branchName, true);
await getBranchPr(commitFilesConfig.branchName, true);
return commit;
}

Expand Down
15 changes: 5 additions & 10 deletions lib/platform/bitbucket/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -295,16 +295,11 @@ export function mergeBranch(branchName: string): Promise<void> {
return config.storage.mergeBranch(branchName);
}

export function commitFiles({
branchName,
files,
message,
}: CommitFilesConfig): Promise<string | null> {
return config.storage.commitFiles({
branchName,
files,
message,
});
// istanbul ignore next
export function commitFiles(
commitFilesConfig: CommitFilesConfig
): Promise<string | null> {
return config.storage.commitFiles(commitFilesConfig);
}

export function getCommitMessages(): Promise<string[]> {
Expand Down
12 changes: 2 additions & 10 deletions lib/platform/gitea/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -865,16 +865,8 @@ const platform: Platform = {
return Promise.resolve();
},

commitFiles({
branchName,
files,
message,
}: CommitFilesConfig): Promise<string | null> {
return config.storage.commitFiles({
branchName,
files,
message,
});
commitFiles(commitFilesConfig: CommitFilesConfig): Promise<string | null> {
return config.storage.commitFiles(commitFilesConfig);
},

getPrBody(prBody: string): string {
Expand Down
14 changes: 4 additions & 10 deletions lib/platform/github/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -568,16 +568,10 @@ export function mergeBranch(branchName: string): Promise<void> {
}

// istanbul ignore next
export function commitFiles({
branchName,
files,
message,
}: CommitFilesConfig): Promise<string | null> {
return config.storage.commitFiles({
branchName,
files,
message,
});
export function commitFiles(
commitFilesConfig: CommitFilesConfig
): Promise<string | null> {
return config.storage.commitFiles(commitFilesConfig);
}

// istanbul ignore next
Expand Down
15 changes: 5 additions & 10 deletions lib/platform/gitlab/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -632,16 +632,11 @@ export function isBranchStale(branchName: string): Promise<boolean> {
return config.storage.isBranchStale(branchName);
}

export function commitFiles({
branchName,
files,
message,
}: CommitFilesConfig): Promise<string | null> {
return config.storage.commitFiles({
branchName,
files,
message,
});
// istanbul ignore next
export function commitFiles(
commitFilesConfig: CommitFilesConfig
): Promise<string | null> {
return config.storage.commitFiles(commitFilesConfig);
}

export function getFile(
Expand Down

0 comments on commit 75c0ca6

Please sign in to comment.