Documentation
¶
Overview ¶
Package common provides utility functions shared across the Git server.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ExtractRepoPathFromURL ¶
ExtractRepoPathFromURL extracts the repository path from a Git Smart HTTP URL. It removes the specified suffix and any leading/trailing slashes to get the clean repository path.
Parameters:
- urlPath: The full URL path from the HTTP request (e.g., "/myrepo.git/info/refs")
- suffix: The suffix to remove (e.g., "/info/refs", "/git-upload-pack")
Returns:
- The clean repository path (e.g., "myrepo.git") or empty string if invalid
Example:
ExtractRepoPathFromURL("/myrepo.git/info/refs", "/info/refs") → "myrepo.git" ExtractRepoPathFromURL("/path/to/repo.git/git-upload-pack", "/git-upload-pack") → "path/to/repo.git"
func GetTransportServer ¶
func NormalizeRepoPath ¶
NormalizeRepoPath normalizes a repository path to ensure proper Git bare repository naming. It trims whitespace and ensures the path ends with ".git" suffix, which is the standard convention for bare Git repositories.
Parameters:
- repoPath: The raw repository path/name from user input
Returns:
- The normalized repository path with ".git" suffix
Examples:
NormalizeRepoPath("myrepo") → "myrepo.git" NormalizeRepoPath("myrepo.git") → "myrepo.git" NormalizeRepoPath(" myrepo ") → "myrepo.git"
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.