-
Notifications
You must be signed in to change notification settings - Fork 4
TA-4066: Implement git integration #243
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Zgjim Haziri (ZgjimHaziri)
merged 21 commits into
master
from
TA-4066-implement-git-integration
Aug 11, 2025
Merged
Changes from 16 commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
266a4d2
Setup `git-profile` interface and profile loading
ZgjimHaziri 5e4d637
Add options to export/import commands
ZgjimHaziri f9bc5d0
Implement export/import integration
ZgjimHaziri da018e5
Fix git issues with non-existing branch and merge conflicts
ZgjimHaziri 77aad45
Merge branch 'master' into git-integration-poc
ZgjimHaziri 2d6bf6c
TA-3911: Initial refactoring from review
ZgjimHaziri 8c3a3d0
TA-3911: Use specific version for `simple-git`
ZgjimHaziri 67cb469
TA-3911: Rename git to VCS
ZgjimHaziri 1ac5db0
TA-3911: Latest changes after testing
ZgjimHaziri 175be3d
TA-4066: Merge branch `master` into TA-4066-implement-git-integration
ZgjimHaziri 946b538
TA-4066: Rename vcs back to git
ZgjimHaziri f5e01eb
TA-4066: Rename folders
ZgjimHaziri 2fc5d28
TA-4066: Mark commands and options as beta
ZgjimHaziri 2682aa9
TA-4066: Bump minor version
ZgjimHaziri e982c0f
TA-4066: Fix issues with pushing to branch
ZgjimHaziri 73895fd
TA-4066: Fix test syntax
ZgjimHaziri 1082dbe
TA-4066: Make constants readonly
ZgjimHaziri babb14f
TA-4066: Simplify profile listing by making it synchronous
ZgjimHaziri ff84e0a
TA-4066: Remove default value definition in non-last parameter
ZgjimHaziri 4caad6c
Merge branch 'master' into TA-4066-implement-git-integration
ZgjimHaziri 25bb869
TA-4066: Fix test setup based on changes
ZgjimHaziri File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,60 @@ | ||
| import { QuestionService } from "../../core/utils/question.service"; | ||
| import { FatalError, logger } from "../../core/utils/logger"; | ||
| import { GitProfileService } from "../../core/git-profile/git-profile.service"; | ||
| import { AuthenticationType, GitProfile } from "../../core/git-profile/git-profile.interface"; | ||
|
|
||
| export class GitProfileCommandService { | ||
| private gitProfileService = new GitProfileService(); | ||
|
|
||
| public async createProfile(setAsDefault: boolean): Promise<void> { | ||
| const profile: GitProfile = {} as GitProfile; | ||
| const questions = new QuestionService(); | ||
| try { | ||
| profile.name = await questions.ask("Name of the Git profile to create: "); | ||
| profile.username = await questions.ask("Your Git username: "); | ||
| profile.repository = await questions.ask("Your repository (format: repoOwner/repoName): "); | ||
| const type = await questions.ask("Authentication type: PAT (1), SSH token (2): " ); | ||
| switch (type) { | ||
| case "1": | ||
| profile.authenticationType = AuthenticationType.PAT; | ||
| profile.token = await questions.ask("Your Personal Access Token (PAT): " ); | ||
| break; | ||
| case "2": | ||
| profile.authenticationType = AuthenticationType.SSH; | ||
| break; | ||
| default: | ||
| logger.error(new FatalError("Invalid type")); | ||
| break; | ||
| } | ||
| // possibly check if the user has sent a valid token that has access in the repository | ||
|
|
||
| this.gitProfileService.storeProfile(profile); | ||
| if (setAsDefault) { | ||
| await this.makeDefaultProfile(profile.name); | ||
| } | ||
| } finally { | ||
| await questions.close(); | ||
| } | ||
| logger.info("Git Profile created successfully!"); | ||
| } | ||
|
|
||
| public async listProfiles(): Promise<void> { | ||
| this.gitProfileService.readAllProfiles().then((profiles: string[]) => { | ||
| const defaultProfile = this.gitProfileService.getDefaultProfile(); | ||
| if (profiles) { | ||
| profiles.forEach(profile => { | ||
| if (defaultProfile && defaultProfile === profile) { | ||
| logger.info(profile + " (default)"); | ||
| } else { | ||
| logger.info(profile); | ||
| } | ||
| }); | ||
| } | ||
| }); | ||
| } | ||
|
|
||
| public async makeDefaultProfile(profile: string): Promise<void> { | ||
| await this.gitProfileService.makeDefaultProfile(profile); | ||
| logger.info("Default Git profile: " + profile); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| /** | ||
| * Commands to create and list access profiles. | ||
| */ | ||
|
|
||
| import { Command, OptionValues } from "commander"; | ||
| import { Configurator, IModule } from "../../core/command/module-handler"; | ||
| import { Context } from "../../core/command/cli-context"; | ||
| import { GitProfileCommandService } from "./git-profile-command.service"; | ||
| import { logger } from "../../core/utils/logger"; | ||
|
|
||
| class Module extends IModule { | ||
|
|
||
| public register(context: Context, configurator: Configurator): void { | ||
| const gitCommand = configurator.command("git") | ||
| .beta() | ||
| .description("Commands related to Git settings"); | ||
|
|
||
| const gitProfileCommand = gitCommand.command("profile") | ||
| .beta() | ||
| .description("Manage Git profiles required to use git-related operations."); | ||
|
|
||
| gitProfileCommand.command("list") | ||
| .description("Command to list all stored Git profiles") | ||
| .beta() | ||
| .action(this.listProfiles); | ||
|
|
||
| gitProfileCommand.command("create") | ||
| .description("Command to create a new Git profile") | ||
| .option("--setAsDefault", "Set this Git profile as default") | ||
| .beta() | ||
| .action(this.createProfile); | ||
|
|
||
| gitProfileCommand.command("default <profile>") | ||
| .description("Command to set a Git profile as default") | ||
| .beta() | ||
| .action(this.defaultProfile); | ||
| } | ||
|
|
||
| private async defaultProfile(context: Context, command: Command): Promise<void> { | ||
| const profile = command.args[0]; | ||
| await new GitProfileCommandService().makeDefaultProfile(profile); | ||
| } | ||
|
|
||
| private async createProfile(context: Context, command: Command, options: OptionValues): Promise<void> { | ||
| await new GitProfileCommandService().createProfile(options.setAsDefault); | ||
| } | ||
|
|
||
| private async listProfiles(context: Context, command: Command): Promise<void> { | ||
| await new GitProfileCommandService().listProfiles(); | ||
| } | ||
| } | ||
|
|
||
| export = Module; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| export interface GitProfile { | ||
| name: string; | ||
| username?: string; | ||
| repository: string; // in the format "owner/repository" | ||
| token?: string; | ||
| authenticationType: AuthenticationType; | ||
| } | ||
|
|
||
| export type AuthenticationType = "SSH" | "Personal Access Token"; | ||
|
|
||
| // tslint:disable-next-line:variable-name | ||
| export const AuthenticationType: { [key: string]: AuthenticationType } = { | ||
| SSH: "SSH", | ||
| PAT: "Personal Access Token", | ||
| }; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.