Skip to content

Commit

Permalink
chore: rename CommitSha type to LongCommitSha (#25698)
Browse files Browse the repository at this point in the history
  • Loading branch information
rarkins committed Nov 11, 2023
1 parent 552dba5 commit 242e278
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 23 deletions.
10 changes: 6 additions & 4 deletions lib/modules/platform/default-scm.ts
@@ -1,21 +1,23 @@
import * as git from '../../util/git';
import type { CommitFilesConfig, CommitSha } from '../../util/git/types';
import type { CommitFilesConfig, LongCommitSha } from '../../util/git/types';
import type { PlatformScm } from './types';

export class DefaultGitScm implements PlatformScm {
branchExists(branchName: string): Promise<boolean> {
return Promise.resolve(git.branchExists(branchName));
}

commitAndPush(commitConfig: CommitFilesConfig): Promise<CommitSha | null> {
commitAndPush(
commitConfig: CommitFilesConfig,
): Promise<LongCommitSha | null> {
return git.commitFiles(commitConfig);
}

deleteBranch(branchName: string): Promise<void> {
return git.deleteBranch(branchName);
}

getBranchCommit(branchName: string): Promise<CommitSha | null> {
getBranchCommit(branchName: string): Promise<LongCommitSha | null> {
return Promise.resolve(git.getBranchCommit(branchName));
}

Expand All @@ -35,7 +37,7 @@ export class DefaultGitScm implements PlatformScm {
return git.getFileList();
}

checkoutBranch(branchName: string): Promise<CommitSha> {
checkoutBranch(branchName: string): Promise<LongCommitSha> {
return git.checkoutBranch(branchName);
}

Expand Down
6 changes: 3 additions & 3 deletions lib/modules/platform/github/index.ts
Expand Up @@ -30,7 +30,7 @@ import { listCommitTree, pushCommitToRenovateRef } from '../../../util/git';
import type {
CommitFilesConfig,
CommitResult,
CommitSha,
LongCommitSha,
} from '../../../util/git/types';
import * as hostRules from '../../../util/host-rules';
import * as githubHttp from '../../../util/http/github';
Expand Down Expand Up @@ -1896,7 +1896,7 @@ export async function getVulnerabilityAlerts(): Promise<VulnerabilityAlert[]> {
async function pushFiles(
{ branchName, message }: CommitFilesConfig,
{ parentCommitSha, commitSha }: CommitResult,
): Promise<CommitSha | null> {
): Promise<LongCommitSha | null> {
try {
// Push the commit to GitHub using a custom ref
// The associated blobs will be pushed automatically
Expand Down Expand Up @@ -1929,7 +1929,7 @@ async function pushFiles(

export async function commitFiles(
config: CommitFilesConfig,
): Promise<CommitSha | null> {
): Promise<LongCommitSha | null> {
const commitResult = await git.prepareCommit(config); // Commit locally and don't push
const { branchName, files } = config;
if (!commitResult) {
Expand Down
4 changes: 2 additions & 2 deletions lib/modules/platform/github/scm.ts
@@ -1,12 +1,12 @@
import * as git from '../../../util/git';
import type { CommitFilesConfig, CommitSha } from '../../../util/git/types';
import type { CommitFilesConfig, LongCommitSha } from '../../../util/git/types';
import { DefaultGitScm } from '../default-scm';
import { commitFiles } from './';

export class GithubScm extends DefaultGitScm {
override commitAndPush(
commitConfig: CommitFilesConfig,
): Promise<CommitSha | null> {
): Promise<LongCommitSha | null> {
return commitConfig.platformCommit
? commitFiles(commitConfig)
: git.commitFiles(commitConfig);
Expand Down
4 changes: 2 additions & 2 deletions lib/modules/platform/local/scm.ts
@@ -1,7 +1,7 @@
import { execSync } from 'node:child_process';
import { glob } from 'glob';
import { logger } from '../../../logger';
import type { CommitFilesConfig, CommitSha } from '../../../util/git/types';
import type { CommitFilesConfig, LongCommitSha } from '../../../util/git/types';
import type { PlatformScm } from '../types';

let fileList: string[] | undefined;
Expand Down Expand Up @@ -45,7 +45,7 @@ export class LocalFs implements PlatformScm {
return fileList;
}

checkoutBranch(branchName: string): Promise<CommitSha> {
checkoutBranch(branchName: string): Promise<LongCommitSha> {
return Promise.resolve('');
}

Expand Down
10 changes: 5 additions & 5 deletions lib/modules/platform/types.ts
@@ -1,6 +1,6 @@
import type { MergeStrategy } from '../../config/types';
import type { BranchStatus, HostRule, VulnerabilityAlert } from '../../types';
import type { CommitFilesConfig, CommitSha } from '../../util/git/types';
import type { CommitFilesConfig, LongCommitSha } from '../../util/git/types';

type VulnerabilityKey = string;
type VulnerabilityRangeKey = string;
Expand Down Expand Up @@ -228,7 +228,7 @@ export interface Platform {
getBranchPr(branchName: string, targetBranch?: string): Promise<Pr | null>;
initPlatform(config: PlatformParams): Promise<PlatformResult>;
filterUnavailableUsers?(users: string[]): Promise<string[]>;
commitFiles?(config: CommitFilesConfig): Promise<CommitSha | null>;
commitFiles?(config: CommitFilesConfig): Promise<LongCommitSha | null>;
expandGroupMembers?(reviewersOrAssignees: string[]): Promise<string[]>;
}

Expand All @@ -237,11 +237,11 @@ export interface PlatformScm {
isBranchModified(branchName: string): Promise<boolean>;
isBranchConflicted(baseBranch: string, branch: string): Promise<boolean>;
branchExists(branchName: string): Promise<boolean>;
getBranchCommit(branchName: string): Promise<CommitSha | null>;
getBranchCommit(branchName: string): Promise<LongCommitSha | null>;
deleteBranch(branchName: string): Promise<void>;
commitAndPush(commitConfig: CommitFilesConfig): Promise<CommitSha | null>;
commitAndPush(commitConfig: CommitFilesConfig): Promise<LongCommitSha | null>;
getFileList(): Promise<string[]>;
checkoutBranch(branchName: string): Promise<CommitSha>;
checkoutBranch(branchName: string): Promise<LongCommitSha>;
mergeToLocal(branchName: string): Promise<void>;
mergeAndPush(branchName: string): Promise<void>;
}
12 changes: 7 additions & 5 deletions lib/util/git/index.ts
Expand Up @@ -52,8 +52,8 @@ import { configSigningKey, writePrivateKey } from './private-key';
import type {
CommitFilesConfig,
CommitResult,
CommitSha,
LocalConfig,
LongCommitSha,
PushFilesConfig,
StatusResult,
StorageConfig,
Expand Down Expand Up @@ -491,7 +491,7 @@ export function branchExists(branchName: string): boolean {
}

// Return the commit SHA for a branch
export function getBranchCommit(branchName: string): CommitSha | null {
export function getBranchCommit(branchName: string): LongCommitSha | null {
return config.branchCommits[branchName] || null;
}

Expand All @@ -511,7 +511,9 @@ export async function getCommitMessages(): Promise<string[]> {
}
}

export async function checkoutBranch(branchName: string): Promise<CommitSha> {
export async function checkoutBranch(
branchName: string,
): Promise<LongCommitSha> {
logger.debug(`Setting current branch to ${branchName}`);
await syncGit();
try {
Expand Down Expand Up @@ -1100,7 +1102,7 @@ export async function pushCommit({

export async function fetchBranch(
branchName: string,
): Promise<CommitSha | null> {
): Promise<LongCommitSha | null> {
await syncGit();
logger.debug(`Fetching branch ${branchName}`);
try {
Expand All @@ -1117,7 +1119,7 @@ export async function fetchBranch(

export async function commitFiles(
commitConfig: CommitFilesConfig,
): Promise<CommitSha | null> {
): Promise<LongCommitSha | null> {
try {
const commitResult = await prepareCommit(commitConfig);
if (commitResult) {
Expand Down
4 changes: 2 additions & 2 deletions lib/util/git/types.ts
Expand Up @@ -9,7 +9,7 @@ export interface GitAuthor {

export type GitNoVerifyOption = 'commit' | 'push';

export type CommitSha = string;
export type LongCommitSha = string;

export interface StorageConfig {
currentBranch?: string;
Expand All @@ -23,7 +23,7 @@ export interface LocalConfig extends StorageConfig {
additionalBranches: string[];
currentBranch: string;
currentBranchSha: string;
branchCommits: Record<string, CommitSha>;
branchCommits: Record<string, LongCommitSha>;
branchIsModified: Record<string, boolean>;
commitBranches: Record<string, string[]>;
ignoredAuthors: string[];
Expand Down

0 comments on commit 242e278

Please sign in to comment.