common

package
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 5, 2025 License: MIT Imports: 7 Imported by: 0

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

func ExtractRepoPathFromURL(urlPath, suffix string) string

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 NormalizeRepoPath

func NormalizeRepoPath(repoPath string) string

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"

func WriteServiceAdvertisement

func WriteServiceAdvertisement(w io.Writer, service string) error

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL