project

package
v0.1.0-alpha.3 Latest Latest
Warning

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

Go to latest
Published: Dec 16, 2025 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DetectProject

func DetectProject() (string, error)

DetectProject attempts to determine the project name using a prioritized strategy:

  1. If a tmporc config file is found (via FindTmporc) and a non-empty path is returned, the project name is the base name of the directory that contains that config file.
  2. Otherwise, if the repository name can be determined from Git (via GetGitRepoName) and it is non-empty, that name is used.
  3. If neither of the above produce a name, the base name of the current working directory is returned.

The function returns the detected project name. An error is returned only if the current working directory cannot be obtained (os.Getwd failure). Errors from FindTmporc and GetGitRepoName are not propagated; they are treated as an absence of a discovered name and the detection falls through to the next strategy.

func FindTmporc

func FindTmporc() (string, error)

FindTmporc searches the current working directory and each parent directory up to the filesystem root for a file named ".tmporc". If found, it returns the path to that file and a nil error. If no ".tmporc" file is found, it returns an empty string and a nil error. If obtaining the current working directory fails, the underlying error is returned.

func GetGitRepoName

func GetGitRepoName() (string, error)

GetGitRepoName returns the name of the current Git repository.

It runs "git rev-parse --show-toplevel" to determine the repository root directory, trims any surrounding whitespace from the command output, and returns the base name of that directory.

The function uses the current working directory to locate the repository. If the git command fails (for example, if "git" is not available, the working directory is not inside a Git repository, or the command returns another error), it returns an empty string and the underlying error.

func GetGitRoot

func GetGitRoot() (string, error)

GetGitRoot returns the absolute path to the top-level directory of the current Git repository by invoking "git rev-parse --show-toplevel". It trims any trailing newline or whitespace from the command output and returns that path as a string. If the working directory is not inside a Git repository or the git command fails, an error is returned. Note: this function expects the "git" executable to be available in PATH.

func IsInGitRepo

func IsInGitRepo() bool

IsInGitRepo reports whether the current working directory is inside a Git repository. It runs "git rev-parse --git-dir" and returns true if the command exits successfully. If git is not available in PATH, the command fails, or the directory is not a Git repository, the function returns false. This function spawns an external process and does not modify the current working directory.

Types

This section is empty.

Jump to

Keyboard shortcuts

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