Skip to content
This repository was archived by the owner on Dec 5, 2024. It is now read-only.

Commit 31127b0

Browse files
Calling GitClient.CheckoutVersion through Repository
1 parent 24dd8be commit 31127b0

File tree

4 files changed

+13
-3
lines changed

4 files changed

+13
-3
lines changed

src/GitHub.Api/Git/IRepository.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ public interface IRepository : IEquatable<IRepository>, IDisposable, IBackedByCa
2121
ITask RequestLock(NPath file);
2222
ITask ReleaseLock(NPath file, bool force);
2323
ITask DiscardChanges(GitStatusEntry[] discardEntries);
24+
ITask CheckoutVersion(string changeset, IList<string> files);
2425

2526
/// <summary>
2627
/// Gets the name of the repository.

src/GitHub.Api/Git/Repository.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@ public ITask SetupRemote(string remote, string remoteUrl)
142142
public ITask RequestLock(NPath file) => repositoryManager.LockFile(file);
143143
public ITask ReleaseLock(NPath file, bool force) => repositoryManager.UnlockFile(file, force);
144144
public ITask DiscardChanges(GitStatusEntry[] gitStatusEntry) => repositoryManager.DiscardChanges(gitStatusEntry);
145+
public ITask CheckoutVersion(string changeset, IList<string> files) => repositoryManager.CheckoutVersion(changeset, files);
145146
public ITask RemoteAdd(string remote, string url) => repositoryManager.RemoteAdd(remote, url);
146147
public ITask RemoteRemove(string remote) => repositoryManager.RemoteRemove(remote);
147148
public ITask DeleteBranch(string branch, bool force) => repositoryManager.DeleteBranch(branch, force);

src/GitHub.Api/Git/RepositoryManager.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ public interface IRepositoryManager : IDisposable
3838
ITask LockFile(NPath file);
3939
ITask UnlockFile(NPath file, bool force);
4040
ITask DiscardChanges(GitStatusEntry[] gitStatusEntries);
41+
ITask CheckoutVersion(string changeset, IList<string> files);
4142
ITask UpdateGitLog();
4243
ITask UpdateGitStatus();
4344
ITask UpdateGitAheadBehindStatus();
@@ -345,6 +346,13 @@ public ITask DiscardChanges(GitStatusEntry[] gitStatusEntries)
345346
return HookupHandlers(task, true);
346347
}
347348

349+
public ITask CheckoutVersion(string changeset, IList<string> files)
350+
{
351+
var task = GitClient.CheckoutVersion(changeset, files)
352+
.Then(() => DataNeedsRefreshing?.Invoke(CacheType.GitStatus));
353+
return HookupHandlers(task, false);
354+
}
355+
348356
public ITask UpdateGitLog()
349357
{
350358
var task = GitClient.Log()

src/UnityExtension/Assets/Editor/GitHub.Unity/UI/HistoryView.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -789,9 +789,9 @@ protected void Checkout(GitLogEntry entry)
789789

790790
if (!promptUser || EditorUtility.DisplayDialog(ConfirmCheckoutTitle, string.Format(ConfirmCheckoutMessage, this.fullPath), ConfirmCheckoutOK, ConfirmCheckoutCancel))
791791
{
792-
GitClient.CheckoutVersion(entry.commitID, new string[] { this.fullPath }).ThenInUI((checkoutSuccess, result) => {
793-
AssetDatabase.Refresh();
794-
}).Start();
792+
Repository.CheckoutVersion(entry.commitID, new string[] { fullPath })
793+
.ThenInUI(AssetDatabase.Refresh)
794+
.Start();
795795
}
796796
}
797797
else

0 commit comments

Comments
 (0)