mirror of
https://github.com/OneUptime/oneuptime
synced 2024-11-22 15:24:55 +00:00
refactor: Set author identity in CodeRepositoryUtil
This commit adds a new method, setAuthorIdentity, to the CodeRepositoryUtil class. The method sets the author's name and email in the global git configuration using the provided data. It executes the necessary git config command and logs the output. This change enhances the functionality of the CodeRepositoryUtil class by allowing the author's identity to be easily configured for git operations.
This commit is contained in:
parent
448326ee88
commit
24845b267f
@ -7,6 +7,19 @@ import ServiceLanguageUtil from "Common/Utils/ServiceLanguage";
|
||||
|
||||
export default class CodeRepositoryUtil {
|
||||
|
||||
public static async setAuthorIdentity(data: {
|
||||
repoPath: string;
|
||||
authorName: string;
|
||||
authorEmail: string;
|
||||
}): Promise<void> {
|
||||
const command: string = `cd ${data.repoPath} && git config --global user.name "${data.authorName}" && git config --global user.email "${data.authorEmail}"`;
|
||||
|
||||
logger.debug("Executing command: " + command);
|
||||
|
||||
const stdout: string = await Execute.executeCommand(command);
|
||||
|
||||
logger.debug(stdout);
|
||||
}
|
||||
|
||||
// returns the folder name of the cloned repository
|
||||
public static async cloneRepository(data: {
|
||||
@ -27,7 +40,7 @@ export default class CodeRepositoryUtil {
|
||||
|
||||
const folderName: string = await Execute.executeCommand(getFolderNameCommand);
|
||||
|
||||
return folderName;
|
||||
return folderName.trim();
|
||||
|
||||
}
|
||||
|
||||
|
@ -24,6 +24,11 @@ import CopilotActionProcessingException from "./Exceptions/CopilotActionProcessi
|
||||
let currentFixCount: number = 1;
|
||||
|
||||
const init: PromiseVoidFunction = async (): Promise<void> => {
|
||||
|
||||
await CodeRepositoryUtil.setAuthorIdentity({
|
||||
email: "copilot@oneuptime.com",
|
||||
name: "OneUptime Copilot",
|
||||
});
|
||||
|
||||
const codeRepositoryResult: CodeRepositoryResult = await InitUtil.init();
|
||||
|
||||
@ -36,6 +41,8 @@ const init: PromiseVoidFunction = async (): Promise<void> => {
|
||||
codeRepository: codeRepositoryResult.codeRepository,
|
||||
});
|
||||
|
||||
debugger;
|
||||
|
||||
logger.info(
|
||||
`Repository ${codeRepositoryResult.codeRepository.name} cloned successfully.`,
|
||||
);
|
||||
|
@ -46,6 +46,18 @@ export default class CodeRepositoryUtil {
|
||||
|
||||
return GetLocalRepositoryPath();
|
||||
}
|
||||
|
||||
|
||||
public static async setAuthorIdentity(data: {
|
||||
name: string;
|
||||
email: string;
|
||||
}): Promise<void> {
|
||||
await CodeRepositoryServerUtil.setAuthorIdentity({
|
||||
repoPath: this.getLocalRepositoryPath(),
|
||||
authorName: data.name,
|
||||
authorEmail: data.email,
|
||||
});
|
||||
}
|
||||
|
||||
// returns the folder name of the cloned repository.
|
||||
public static async cloneRepository(data: {
|
||||
@ -90,6 +102,8 @@ export default class CodeRepositoryUtil {
|
||||
repoPath: repoLocalPath,
|
||||
});
|
||||
|
||||
debugger;
|
||||
|
||||
this.folderNameOfClonedRepository = folderName;
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,3 @@
|
||||
import { GetLocalRepositoryPath } from "../Config";
|
||||
import ServiceFileTypesUtil from "./ServiceFileTypes";
|
||||
import Dictionary from "Common/Types/Dictionary";
|
||||
import BadDataException from "Common/Types/Exception/BadDataException";
|
||||
@ -8,6 +7,7 @@ import CodeRepositoryFile from "CommonServer/Utils/CodeRepository/CodeRepository
|
||||
import LocalFile from "CommonServer/Utils/LocalFile";
|
||||
import ServiceRepository from "Model/Models/ServiceRepository";
|
||||
import ServiceLanguageUtil from "Common/Utils/ServiceLanguage";
|
||||
import CodeRepositoryUtil from "./CodeRepository";
|
||||
|
||||
export default class ServiceRepositoryUtil {
|
||||
public static async getFileLanguage(data: {
|
||||
@ -30,7 +30,7 @@ export default class ServiceRepositoryUtil {
|
||||
|
||||
const fileContent: string =
|
||||
await CodeRepositoryCommonServerUtil.getFileContent({
|
||||
repoPath: GetLocalRepositoryPath(),
|
||||
repoPath: CodeRepositoryUtil.getLocalRepositoryPath(),
|
||||
filePath: filePath,
|
||||
});
|
||||
|
||||
@ -50,7 +50,7 @@ export default class ServiceRepositoryUtil {
|
||||
|
||||
const allFiles: Dictionary<CodeRepositoryFile> =
|
||||
await CodeRepositoryCommonServerUtil.getFilesInDirectoryRecursive({
|
||||
repoPath: GetLocalRepositoryPath(),
|
||||
repoPath: CodeRepositoryUtil.getLocalRepositoryPath(),
|
||||
directoryPath: serviceRepository.servicePathInRepository || ".",
|
||||
acceptedFileExtensions:
|
||||
ServiceFileTypesUtil.getFileExtentionsByServiceLanguage(
|
||||
|
Loading…
Reference in New Issue
Block a user