File: config.go

package info (click to toggle)
git-lfs 3.3.0-1%2Bdeb12u1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 4,676 kB
  • sloc: sh: 19,133; makefile: 487; ruby: 228
file content (47 lines) | stat: -rw-r--r-- 1,941 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package lfs

import "github.com/git-lfs/git-lfs/v3/config"

// FetchPruneConfig collects together the config options that control fetching and pruning
type FetchPruneConfig struct {
	// The number of days prior to current date for which (local) refs other than HEAD
	// will be fetched with --recent (default 7, 0 = only fetch HEAD)
	FetchRecentRefsDays int
	// Makes the FetchRecentRefsDays option apply to remote refs from fetch source as well (default true)
	FetchRecentRefsIncludeRemotes bool
	// number of days prior to latest commit on a ref that we'll fetch previous
	// LFS changes too (default 0 = only fetch at ref)
	FetchRecentCommitsDays int
	// Whether to always fetch recent even without --recent
	FetchRecentAlways bool
	// Number of days added to FetchRecent*; data outside combined window will be
	// deleted when prune is run. (default 3)
	PruneOffsetDays int
	// Always verify with remote before pruning
	PruneVerifyRemoteAlways bool
	// Name of remote to check for unpushed and verify checks
	PruneRemoteName string
	// Whether to ignore all recent options.
	PruneRecent bool
	// Whether to delete everything pushed.
	PruneForce bool
}

func NewFetchPruneConfig(git config.Environment) FetchPruneConfig {
	pruneRemote, _ := git.Get("lfs.pruneremotetocheck")
	if len(pruneRemote) == 0 {
		pruneRemote = "origin"
	}

	return FetchPruneConfig{
		FetchRecentRefsDays:           git.Int("lfs.fetchrecentrefsdays", 7),
		FetchRecentRefsIncludeRemotes: git.Bool("lfs.fetchrecentremoterefs", true),
		FetchRecentCommitsDays:        git.Int("lfs.fetchrecentcommitsdays", 0),
		FetchRecentAlways:             git.Bool("lfs.fetchrecentalways", false),
		PruneOffsetDays:               git.Int("lfs.pruneoffsetdays", 3),
		PruneVerifyRemoteAlways:       git.Bool("lfs.pruneverifyremotealways", false),
		PruneRemoteName:               pruneRemote,
		PruneRecent:                   false,
		PruneForce:                    false,
	}
}