Documentation ¶
Index ¶
- Constants
- func FindFileOrDirectory(directory, filename string) (string, bool)
- func WithDetection(c Config) heartbeat.HandleOption
- func Write(folder, project string) error
- type Config
- type Detecter
- type Err
- type File
- type Git
- type Map
- type MapPattern
- type Mercurial
- type Result
- type Subversion
- type Tfvc
Constants ¶
const ( // WakaTimeProjectFile is the special file which if present should contain the project name and optional branch name // that will be used instead of the auto-detected project and branch names. WakaTimeProjectFile = ".wakatime-project" )
Variables ¶
This section is empty.
Functions ¶
func FindFileOrDirectory ¶ added in v1.18.10
FindFileOrDirectory searches for a file or directory named `filename`. Search starts in `directory` and will traverse through all parent directories. `directory` may also be a file, and in that case will start from the file's directory.
func WithDetection ¶
func WithDetection(c Config) heartbeat.HandleOption
WithDetection finds the current project and branch. First looks for a .wakatime-project file. Second, uses the --project arg. Third, uses the folder name from a revision control repository. Last, uses the --alternate-project arg.
Types ¶
type Config ¶
type Config struct { // Patterns contains the overridden project name per path. MapPatterns []MapPattern // SubmodulePatterns contains the paths to validate for submodules. SubmodulePatterns []regex.Regex // ShouldObfuscateProject determines if the project name should be obfuscated according some rules. ShouldObfuscateProject bool }
Config contains project detection configurations.
type File ¶
type File struct {
Filepath string
}
File contains file data.
type Git ¶
type Git struct { // Filepath contains the entity path. Filepath string // SubmodulePatterns will be matched against the submodule path and if matching, will skip it. SubmodulePatterns []regex.Regex }
Git contains git data.
type Map ¶
type Map struct { Filepath string Patterns []MapPattern }
Map contains map data.
func (Map) Detect ¶
Detect use the ~/.wakatime.cfg file to set custom project names by matching files with regex patterns. Project maps go under the [projectmap] config section.
For example:
[projectmap] /home/user/projects/foo = new project name /home/user/projects/bar(\d+)/ = project{0}
Will result in file '/home/user/projects/foo/src/main.c' to have project name 'new project name' and file '/home/user/projects/bar42/main.c' to have project name 'project42'.
type MapPattern ¶
type MapPattern struct { // Name is the project name. Name string // Regex is the regular expression for a specific path. Regex regex.Regex }
MapPattern contains [projectmap] data.
type Mercurial ¶
type Mercurial struct { // Filepath contains the entity path. Filepath string }
Mercurial contains mercurial data.
type Result ¶
Result contains the result of Detect().
func Detect ¶
func Detect(entity string, patterns []MapPattern) Result
Detect finds the current project and branch from config plugins.
type Subversion ¶
type Subversion struct { // Filepath contains the entity path. Filepath string }
Subversion contains svn data.