@@ -12,6 +12,7 @@ import {
1212 extractRepositoryName ,
1313 getWorkspaceGitInfo ,
1414 convertGitUrlToHttps ,
15+ isGitHubRepository ,
1516} from "../git"
1617import { truncateOutput } from "../../integrations/misc/extract-text"
1718
@@ -898,6 +899,38 @@ describe("extractRepositoryName", () => {
898899 } )
899900} )
900901
902+ describe ( "isGitHubRepository" , ( ) => {
903+ it ( "should return true for github.com HTTPS URLs" , ( ) => {
904+ expect ( isGitHubRepository ( "https://github.com/user/repo.git" ) ) . toBe ( true )
905+ expect ( isGitHubRepository ( "https://github.com/user/repo" ) ) . toBe ( true )
906+ } )
907+
908+ it ( "should return true for github.com SSH URLs" , ( ) => {
909+ expect ( isGitHubRepository ( "[email protected] :user/repo.git" ) ) . toBe ( true ) 910+ expect ( isGitHubRepository ( "ssh://[email protected] /user/repo.git" ) ) . toBe ( true ) 911+ } )
912+
913+ it ( "should return true for GitHub URLs with different casing" , ( ) => {
914+ expect ( isGitHubRepository ( "https://GitHub.com/user/repo.git" ) ) . toBe ( true )
915+ expect ( isGitHubRepository ( "https://GITHUB.COM/user/repo.git" ) ) . toBe ( true )
916+ } )
917+
918+ it ( "should return false for non-GitHub URLs" , ( ) => {
919+ expect ( isGitHubRepository ( "https://gitlab.com/user/repo.git" ) ) . toBe ( false )
920+ expect ( isGitHubRepository ( "https://bitbucket.org/user/repo.git" ) ) . toBe ( false )
921+ expect ( isGitHubRepository ( "[email protected] :user/repo.git" ) ) . toBe ( false ) 922+ } )
923+
924+ it ( "should return false for undefined or empty URLs" , ( ) => {
925+ expect ( isGitHubRepository ( undefined ) ) . toBe ( false )
926+ expect ( isGitHubRepository ( "" ) ) . toBe ( false )
927+ } )
928+
929+ it ( "should handle sanitized GitHub URLs" , ( ) => {
930+ expect ( isGitHubRepository ( "https://github.com/user/repo" ) ) . toBe ( true )
931+ } )
932+ } )
933+
901934describe ( "getWorkspaceGitInfo" , ( ) => {
902935 const workspaceRoot = "/test/workspace"
903936
0 commit comments