| 1 | package lfs |
| 2 | |
| 3 | import "github.com/git-lfs/git-lfs/v3/config" |
| 4 | |
| 5 | // FetchPruneConfig collects together the config options that control fetching and pruning |
| 6 | type FetchPruneConfig struct { |
| 7 | // The number of days prior to current date for which (local) refs other than HEAD |
| 8 | // will be fetched with --recent (default 7, 0 = only fetch HEAD) |
| 9 | FetchRecentRefsDays int |
| 10 | // Makes the FetchRecentRefsDays option apply to remote refs from fetch source as well (default true) |
| 11 | FetchRecentRefsIncludeRemotes bool |
| 12 | // number of days prior to latest commit on a ref that we'll fetch previous |
| 13 | // LFS changes too (default 0 = only fetch at ref) |
| 14 | FetchRecentCommitsDays int |
| 15 | // Whether to always fetch recent even without --recent |
| 16 | FetchRecentAlways bool |
| 17 | // Number of days added to FetchRecent*; data outside combined window will be |
| 18 | // deleted when prune is run. (default 3) |
| 19 | PruneOffsetDays int |
| 20 | // Always verify with remote before pruning reachable objects |
| 21 | PruneVerifyRemoteAlways bool |
| 22 | // When verifiying, always verify all reachable and unreachable objects with remote (default false) |
| 23 | PruneVerifyUnreachableAlways bool |
| 24 | // Name of remote to check for unpushed and verify checks |
| 25 | PruneRemoteName string |
| 26 | // Whether to ignore all recent options. |
| 27 | PruneRecent bool |
| 28 | // Whether to delete everything pushed. |
| 29 | PruneForce bool |
| 30 | } |
| 31 | |
| 32 | func NewFetchPruneConfig(git config.Environment) FetchPruneConfig { |
| 33 | pruneRemote, _ := git.Get("lfs.pruneremotetocheck") |
| 34 | if len(pruneRemote) == 0 { |
| 35 | pruneRemote = "origin" |
| 36 | } |
| 37 | |
| 38 | return FetchPruneConfig{ |
| 39 | FetchRecentRefsDays: git.Int("lfs.fetchrecentrefsdays", 7), |
| 40 | FetchRecentRefsIncludeRemotes: git.Bool("lfs.fetchrecentremoterefs", true), |
| 41 | FetchRecentCommitsDays: git.Int("lfs.fetchrecentcommitsdays", 0), |
| 42 | FetchRecentAlways: git.Bool("lfs.fetchrecentalways", false), |
| 43 | PruneOffsetDays: git.Int("lfs.pruneoffsetdays", 3), |
| 44 | PruneVerifyRemoteAlways: git.Bool("lfs.pruneverifyremotealways", false), |
| 45 | PruneVerifyUnreachableAlways: git.Bool("lfs.pruneverifyunreachablealways", false), |
| 46 | PruneRemoteName: pruneRemote, |
| 47 | PruneRecent: false, |
| 48 | PruneForce: false, |
| 49 | } |
| 50 | } |