File: config.go

package info (click to toggle)
git-lfs 3.6.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 4,808 kB
  • sloc: sh: 21,256; makefile: 507; ruby: 417
file content (50 lines) | stat: -rw-r--r-- 2,181 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
48
49
50
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 reachable objects
	PruneVerifyRemoteAlways bool
	// When verifiying, always verify all reachable and unreachable objects with remote (default false)
	PruneVerifyUnreachableAlways 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),
		PruneVerifyUnreachableAlways:  git.Bool("lfs.pruneverifyunreachablealways", false),
		PruneRemoteName:               pruneRemote,
		PruneRecent:                   false,
		PruneForce:                    false,
	}
}