isgit

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2025 License: MIT Imports: 2 Imported by: 0

README

isgit

I created this simple package to find out if a directory is part of a git repo, the only other way I could find to do this was by calling git rev-parse --show-top-level this is a lot simpler and faster, but doesn't actually check the state of git, instead it just looks for a .git directory present in any parent directory.

Benchmark

BenchmarkGetRootDirWD-12                   30321             38386 ns/op
BenchmarkGetRootDirWithBinary-12             184           6591809 ns/op

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetRootDir

func GetRootDir(path string) (string, error)

GetRootDir returns the root directory of the Git repository containing the given path. Returns an empty string if no Git repository is found.

func GetRootDirWD

func GetRootDirWD() (string, error)

GetRootDirWD returns the root directory of the Git repository containing the current working directory. Returns an empty string if no Git repository is found.

func IsCurrentDirInGitRepo

func IsCurrentDirInGitRepo() (bool, error)

IsCurrentDirInGitRepo checks if the current working directory is within a Git repository.

func IsGitRepo

func IsGitRepo(dir string) (bool, error)

IsGitRepo checks if the given directory is within a Git repository.

Types

This section is empty.

Jump to

Keyboard shortcuts

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