Skip to content
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

Replace Process.Start with libgit2sharp #361

Merged
merged 5 commits into from
May 8, 2013
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
10 changes: 8 additions & 2 deletions GitTfs/Core/GitRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ public GitRepository(TextWriter stdout, string gitDir, IContainer container, Glo
_repository.Dispose();
}

public void UpdateRef(string gitRefName, string shaCommit, string message = null)
{
_repository.Refs.Add(gitRefName, shaCommit, allowOverwrite: true, logMessage: message);
}

public string GitDir { get; set; }
public string WorkingCopyPath { get; set; }
public string WorkingCopySubdir { get; set; }
Expand All @@ -58,7 +63,8 @@ private void SetUpPaths(ProcessStartInfo gitCommand)

public string GetConfig(string key)
{
return _repository.Config.Get<string>(key, null);
var entry = _repository.Config.Get<string>(key);
return entry == null ? null : entry.Value;
}

public IEnumerable<IGitTfsRemote> ReadAllTfsRemotes()
Expand Down Expand Up @@ -438,7 +444,7 @@ public bool CreateBranch(string gitBranchName, string target)
Reference reference;
try
{
reference = _repository.Refs.Create(gitBranchName, target);
reference = _repository.Refs.Add(gitBranchName, target);
}
catch (Exception)
{
Expand Down
6 changes: 3 additions & 3 deletions GitTfs/Core/GitTfsRemote.cs
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ public void Apply(ITfsChangeset changeset, string destinationRef)
{
var log = Apply(MaxCommitHash, changeset);
var commit = Commit(log);
Repository.CommandNoisy("update-ref", destinationRef, commit);
Repository.UpdateRef(destinationRef, commit);
}

public void QuickFetch()
Expand Down Expand Up @@ -270,9 +270,9 @@ public void UpdateRef(string commitHash, long changesetId)
{
MaxCommitHash = commitHash;
MaxChangesetId = changesetId;
Repository.CommandNoisy("update-ref", "-m", "C" + MaxChangesetId, RemoteRef, MaxCommitHash);
Repository.UpdateRef(RemoteRef, MaxCommitHash, "C" + MaxChangesetId);
if (Autotag)
Repository.CommandNoisy("update-ref", TagPrefix + "C" + MaxChangesetId, MaxCommitHash);
Repository.UpdateRef(TagPrefix + "C" + MaxChangesetId, MaxCommitHash);
LogCurrentMapping();
}

Expand Down
1 change: 1 addition & 0 deletions GitTfs/Core/IGitRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ public interface IGitRepository : IGitHelpers
void DeleteTfsRemote(IGitTfsRemote remoteId);
bool HasRemote(string remoteId);
bool HasRef(string gitRef);
void UpdateRef(string gitRefName, string commitSha, string message = null);
void MoveTfsRefForwardIfNeeded(IGitTfsRemote remote);
IEnumerable<TfsChangesetInfo> GetLastParentTfsCommits(string head);
IEnumerable<TfsChangesetInfo> GetLastParentTfsCommits(string head, bool includeStubRemotes);
Expand Down
2 changes: 1 addition & 1 deletion GitTfsTest/Core/RemoteConfigConverterTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ private IEnumerable<RemoteInfo> Load(params ConfigurationEntry<string>[] configs
[Fact]
public void NoConfig()
{
var remotes = _loader.Load(Enumerable.Empty<ConfigurationEntry>());
var remotes = _loader.Load(Enumerable.Empty<ConfigurationEntry<string>>());
Assert.Empty(remotes);
}

Expand Down
2 changes: 1 addition & 1 deletion lib/libgit2sharp
Submodule libgit2sharp updated 362 files