MCPcopy
hub / github.com/git-lfs/git-lfs / TestScanPreviousVersions

Function TestScanPreviousVersions

lfs/scanner_git_test.go:111–188  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

109}
110
111func TestScanPreviousVersions(t *testing.T) {
112 repo := test.NewRepo(t)
113 repo.Pushd()
114 defer func() {
115 repo.Popd()
116 repo.Cleanup()
117 }()
118
119 now := time.Now()
120
121 inputs := []*test.CommitInput{
122 { // 0
123 CommitDate: now.AddDate(0, 0, -20),
124 Files: []*test.FileInput{
125 {Filename: "file1.txt", Size: 20},
126 {Filename: "file2.txt", Size: 30},
127 {Filename: "folder/nested.txt", Size: 40},
128 {Filename: "folder/nested2.txt", Size: 31},
129 },
130 },
131 { // 1
132 CommitDate: now.AddDate(0, 0, -10),
133 Files: []*test.FileInput{
134 {Filename: "file2.txt", Size: 22},
135 },
136 },
137 { // 2
138 NewBranch: "excluded",
139 CommitDate: now.AddDate(0, 0, -6),
140 Files: []*test.FileInput{
141 {Filename: "file2.txt", Size: 12},
142 {Filename: "folder/nested2.txt", Size: 16},
143 },
144 },
145 { // 3
146 ParentBranches: []string{"master"},
147 CommitDate: now.AddDate(0, 0, -4),
148 Files: []*test.FileInput{
149 {Filename: "folder/nested.txt", Size: 42},
150 {Filename: "folder/nested2.txt", Size: 6},
151 },
152 },
153 { // 4
154 Files: []*test.FileInput{
155 {Filename: "folder/nested.txt", Size: 22},
156 },
157 },
158 }
159 outputs := repo.AddCommits(inputs)
160
161 // Previous commits excludes final state of each file, which is:
162 // file1.txt [0] (unchanged since first commit so excluded)
163 // file2.txt [1] (because [2] is on another branch so excluded)
164 // folder/nested.txt [4] (updated at last commit)
165 // folder/nested2.txt [3]
166
167 // The only changes which will be included are changes prior to final state
168 // where the '-' side of the diff is inside the date range

Callers

nothing calls this directly

Calls 6

PushdMethod · 0.95
PopdMethod · 0.95
CleanupMethod · 0.95
AddCommitsMethod · 0.95
scanPreviousVersionsFunction · 0.85
EqualMethod · 0.45

Tested by

no test coverage detected