2021-04-29 05:05:55 -07:00
|
|
|
using System.Threading.Tasks;
|
|
|
|
using System.Windows;
|
|
|
|
using System.Windows.Controls;
|
|
|
|
using System.Windows.Navigation;
|
|
|
|
|
|
|
|
namespace SourceGit.Views {
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 文件历史
|
|
|
|
/// </summary>
|
2021-06-17 18:26:19 -07:00
|
|
|
public partial class Histories : Controls.Window {
|
2021-04-29 05:05:55 -07:00
|
|
|
private string repo = null;
|
|
|
|
private string file = null;
|
2021-06-06 23:14:53 -07:00
|
|
|
private bool isLFSEnabled = false;
|
2021-04-29 05:05:55 -07:00
|
|
|
|
|
|
|
public Histories(string repo, string file) {
|
|
|
|
this.repo = repo;
|
|
|
|
this.file = file;
|
2021-06-08 02:26:01 -07:00
|
|
|
this.isLFSEnabled = new Commands.LFS(repo).IsFiltered(file);
|
2021-04-29 05:05:55 -07:00
|
|
|
|
|
|
|
InitializeComponent();
|
|
|
|
|
|
|
|
Task.Run(() => {
|
|
|
|
var commits = new Commands.Commits(repo, $"-n 10000 -- \"{file}\"").Result();
|
|
|
|
Dispatcher.Invoke(() => {
|
|
|
|
loading.IsAnimating = false;
|
|
|
|
loading.Visibility = Visibility.Collapsed;
|
|
|
|
commitList.ItemsSource = commits;
|
|
|
|
commitList.SelectedIndex = 0;
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
#region WINDOW_COMMANDS
|
|
|
|
private void Minimize(object sender, RoutedEventArgs e) {
|
|
|
|
SystemCommands.MinimizeWindow(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
private void Quit(object sender, RoutedEventArgs e) {
|
|
|
|
Close();
|
|
|
|
}
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region EVENTS
|
|
|
|
private void OnCommitSelectedChanged(object sender, SelectedCellsChangedEventArgs e) {
|
|
|
|
var commit = (sender as DataGrid).SelectedItem as Models.Commit;
|
|
|
|
if (commit == null) return;
|
|
|
|
|
|
|
|
var start = $"{commit.SHA}^";
|
|
|
|
if (commit.Parents.Count == 0) start = "4b825dc642cb6eb9a060e54bf8d69288fbee4904";
|
|
|
|
|
|
|
|
diffViewer.Diff(repo, new Widgets.DiffViewer.Option() {
|
|
|
|
RevisionRange = new string[] { start, commit.SHA },
|
2021-06-06 23:14:53 -07:00
|
|
|
Path = file,
|
|
|
|
UseLFS = isLFSEnabled,
|
2021-04-29 05:05:55 -07:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
private void GotoCommit(object sender, RequestNavigateEventArgs e) {
|
|
|
|
Models.Watcher.Get(repo).NavigateTo(e.Uri.OriginalString);
|
|
|
|
e.Handled = true;
|
|
|
|
}
|
|
|
|
#endregion
|
|
|
|
}
|
|
|
|
}
|