-
-
Notifications
You must be signed in to change notification settings - Fork 165
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Caching git heights #801
Open
AArnott
wants to merge
10
commits into
dotnet:main
Choose a base branch
from
djluck:version-caching-perf-improv
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Caching git heights #801
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
86213c2
## Summary
e82e23a
Fixing required documentation errors
9251308
Constructor must be public
fad06f0
Removing test SDK to see if this is cause for broken build
3fe9ec6
Simplifying logic around discarding cache height when base version do…
234625e
Fixing doco issue
85eef33
Testing adding a reference to compiler.unsafe to see if it will help …
7202d1b
More messing around with package versions- this time System.Numerics
670f6e7
Fixing a bug that meant the incorrect height would be returned for co…
2b58c63
Adding support for the single version file scenario- git heights are …
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
using System.IO; | ||
using LibGit2Sharp; | ||
using Xunit; | ||
using Version = System.Version; | ||
|
||
namespace Nerdbank.GitVersioning | ||
{ | ||
public class GitHeightCacheTests | ||
{ | ||
[Fact] | ||
public void CachedHeightAvailable_NoCacheFile() | ||
{ | ||
var cache = new GitHeightCache(Directory.GetCurrentDirectory(), "non-existent-dir", new Version(1, 0)); | ||
Assert.False(cache.CachedHeightAvailable); | ||
} | ||
|
||
[Fact] | ||
public void CachedHeightAvailable_RootCacheFile() | ||
{ | ||
File.WriteAllText($"./{GitHeightCache.CacheFileName}", ""); | ||
var cache = new GitHeightCache(Directory.GetCurrentDirectory(), null, new Version(1, 0)); | ||
Assert.True(cache.CachedHeightAvailable); | ||
} | ||
|
||
[Fact] | ||
public void CachedHeightAvailable_CacheFile() | ||
{ | ||
Directory.CreateDirectory("./testDir"); | ||
File.WriteAllText($"./testDir/{GitHeightCache.CacheFileName}", ""); | ||
var cache = new GitHeightCache(Directory.GetCurrentDirectory(),"testDir/", new Version(1, 0)); | ||
Assert.True(cache.CachedHeightAvailable); | ||
} | ||
|
||
[Fact] | ||
public void GitHeightCache_RoundtripCaching() | ||
{ | ||
var cache = new GitHeightCache(Directory.GetCurrentDirectory(), null, new Version(1, 0)); | ||
|
||
// test initial set | ||
cache.SetHeight(new ObjectId("8b1f731de6b98aaf536085a62c40dfd3e38817b6"), 2); | ||
var cachedHeight = cache.GetHeight(); | ||
Assert.Equal("8b1f731de6b98aaf536085a62c40dfd3e38817b6", cachedHeight.CommitId.Sha); | ||
Assert.Equal(2, cachedHeight.Height); | ||
Assert.Equal("1.0", cachedHeight.BaseVersion.ToString()); | ||
|
||
// verify overwriting works correctly | ||
cache.SetHeight(new ObjectId("352459698e082aebef799d77807961d222e75efe"), 3); | ||
cachedHeight = cache.GetHeight(); | ||
Assert.Equal("352459698e082aebef799d77807961d222e75efe", cachedHeight.CommitId.Sha); | ||
Assert.Equal("1.0", cachedHeight.BaseVersion.ToString()); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should probably be constructing the git height cache only when
useHeightCaching
is true.