Skip to content

Use gvfs-helper to download initial commit #232

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

Merged
merged 6 commits into from
Nov 13, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@

<!-- Version information -->
<ScalarVersion>0.2.173.2</ScalarVersion>
<GitPackageVersion>2.20191111.3-sc</GitPackageVersion>
<GitPackageVersion>2.20191113.1</GitPackageVersion>

<!-- Signing certificates -->
<AuthenticodeCert>Microsoft400</AuthenticodeCert>
Expand Down
33 changes: 2 additions & 31 deletions Scalar.Common/Git/GitObjects.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

namespace Scalar.Common.Git
{
public abstract class GitObjects
public class GitObjects
{
protected readonly ITracer Tracer;
protected readonly GitObjectsHttpRequestor GitObjectRequestor;
Expand Down Expand Up @@ -47,35 +47,6 @@ public static bool IsLooseObjectsDirectory(string value)
return value.Length == 2 && value.All(c => Uri.IsHexDigit(c));
}

public virtual bool TryDownloadCommit(string commitSha)
{
const bool PreferLooseObjects = false;
IEnumerable<string> objectIds = new[] { commitSha };

GitProcess gitProcess = new GitProcess(this.Enlistment);
RetryWrapper<GitObjectsHttpRequestor.GitObjectTaskResult>.InvocationResult output = this.GitObjectRequestor.TryDownloadObjects(
objectIds,
onSuccess: (tryCount, response) => this.TrySavePackOrLooseObject(objectIds, PreferLooseObjects, response, gitProcess),
onFailure: (eArgs) =>
{
EventMetadata metadata = CreateEventMetadata(eArgs.Error);
metadata.Add("Operation", "DownloadAndSaveObjects");
metadata.Add("WillRetry", eArgs.WillRetry);

if (eArgs.WillRetry)
{
this.Tracer.RelatedWarning(metadata, eArgs.Error.ToString(), Keywords.Network | Keywords.Telemetry);
}
else
{
this.Tracer.RelatedError(metadata, eArgs.Error.ToString(), Keywords.Network);
}
},
preferBatchedLooseObjects: PreferLooseObjects);

return output.Succeeded && output.Result.Success;
}

public virtual void DeleteStaleTempPrefetchPackAndIdxs()
{
string[] staleTempPacks = this.ReadPackFileNames(Path.Combine(this.Enlistment.GitPackRoot, GitObjects.TempPackFolder), ScalarConstants.PrefetchPackPrefix);
Expand Down Expand Up @@ -170,7 +141,7 @@ public virtual bool TryDownloadPrefetchPacks(GitProcess gitProcess, long latestT
}
}

public virtual string WriteLooseObject(Stream responseStream, string sha,byte[] bufToCopyWith)
public virtual string WriteLooseObject(Stream responseStream, string sha, byte[] bufToCopyWith)
{
try
{
Expand Down
11 changes: 11 additions & 0 deletions Scalar.Common/Git/GitProcess.cs
Original file line number Diff line number Diff line change
Expand Up @@ -438,6 +438,17 @@ public Result SparseCheckoutSet(List<string> foldersToSet)
});
}

public Result GvfsHelperDownloadCommit(string commitId)
{
return this.InvokeGitInWorkingDirectoryRoot(
$"gvfs-helper -f post",
fetchMissingObjects: false,
writeStdIn: writer =>
{
writer.Write($"{commitId}\n");
});
}

public Result Status(bool allowObjectDownloads, bool useStatusCache, bool showUntracked = false)
{
string command = "status";
Expand Down
86 changes: 0 additions & 86 deletions Scalar.Common/Git/ScalarGitObjects.cs

This file was deleted.

Loading