Skip to content

Commit c4c8a82

Browse files
committed
fix: remove duplicate JSDoc and add SSH to HTTPS conversion test
- Remove duplicate JSDoc comment from convertGitUrlToHttps function - Add test case to verify getGitRepositoryInfo converts SSH URLs to HTTPS format
1 parent 461028d commit c4c8a82

File tree

2 files changed

+46
-5
lines changed

2 files changed

+46
-5
lines changed

src/utils/__tests__/git.spec.ts

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -561,6 +561,52 @@ describe("getGitRepositoryInfo", () => {
561561
repositoryName: "RooCodeInc/Roo-Code",
562562
})
563563
})
564+
565+
it("should convert SSH URLs to HTTPS format", async () => {
566+
// Clear previous mocks
567+
vitest.clearAllMocks()
568+
569+
// Create a spy to track the implementation
570+
const gitSpy = vitest.spyOn(fs.promises, "readFile")
571+
572+
// Mock successful access to .git directory
573+
vitest.mocked(fs.promises.access).mockResolvedValue(undefined)
574+
575+
// Mock git config file with SSH URL
576+
const mockConfig = `
577+
[core]
578+
repositoryformatversion = 0
579+
filemode = true
580+
bare = false
581+
[remote "origin"]
582+
url = [email protected]:RooCodeInc/Roo-Code.git
583+
fetch = +refs/heads/*:refs/remotes/origin/*
584+
[branch "main"]
585+
remote = origin
586+
merge = refs/heads/main
587+
`
588+
// Mock HEAD file content
589+
const mockHead = "ref: refs/heads/main"
590+
591+
// Setup the readFile mock to return different values based on the path
592+
gitSpy.mockImplementation((path: any, encoding: any) => {
593+
if (path === configPath) {
594+
return Promise.resolve(mockConfig)
595+
} else if (path === headPath) {
596+
return Promise.resolve(mockHead)
597+
}
598+
return Promise.reject(new Error(`Unexpected path: ${path}`))
599+
})
600+
601+
const result = await getGitRepositoryInfo(workspaceRoot)
602+
603+
// Verify that the SSH URL was converted to HTTPS
604+
expect(result).toEqual({
605+
repositoryUrl: "https://github.com/RooCodeInc/Roo-Code.git",
606+
repositoryName: "RooCodeInc/Roo-Code",
607+
defaultBranch: "main",
608+
})
609+
})
564610
})
565611

566612
describe("convertGitUrlToHttps", () => {

src/utils/git.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -89,11 +89,6 @@ export async function getGitRepositoryInfo(workspaceRoot: string): Promise<GitRe
8989
}
9090
}
9191

92-
/**
93-
* Sanitizes a git URL to remove sensitive information like tokens
94-
* @param url The original git URL
95-
* @returns Sanitized URL
96-
*/
9792
/**
9893
* Converts a git URL to HTTPS format
9994
* @param url The git URL to convert

0 commit comments

Comments
 (0)