mirror of
https://github.com/sourcegit-scm/sourcegit.git
synced 2024-12-23 20:47:25 -08:00
feature<App>: supports to open repository from commandline directly
This commit is contained in:
parent
91f3f1263a
commit
5f2fe64e80
3 changed files with 16 additions and 3 deletions
|
@ -139,9 +139,14 @@ namespace SourceGit {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Show main window
|
// Show main window
|
||||||
MainWindow = new UI.Launcher();
|
if (e.Args.Length == 1) {
|
||||||
|
MainWindow = new UI.Launcher(e.Args[0]);
|
||||||
|
} else {
|
||||||
|
MainWindow = new UI.Launcher(null);
|
||||||
|
}
|
||||||
MainWindow.Show();
|
MainWindow.Show();
|
||||||
|
|
||||||
|
|
||||||
// Check for update.
|
// Check for update.
|
||||||
if (Setting.CheckUpdate && Setting.LastCheckUpdate != DateTime.Now.DayOfYear) {
|
if (Setting.CheckUpdate && Setting.LastCheckUpdate != DateTime.Now.DayOfYear) {
|
||||||
Setting.LastCheckUpdate = DateTime.Now.DayOfYear;
|
Setting.LastCheckUpdate = DateTime.Now.DayOfYear;
|
||||||
|
|
|
@ -212,6 +212,8 @@ namespace SourceGit.Git {
|
||||||
/// <param name="path">Local path.</param>
|
/// <param name="path">Local path.</param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public static bool IsValid(string path) {
|
public static bool IsValid(string path) {
|
||||||
|
if (!Directory.Exists(path)) return false;
|
||||||
|
|
||||||
var startInfo = new ProcessStartInfo();
|
var startInfo = new ProcessStartInfo();
|
||||||
startInfo.FileName = App.Setting.Tools.GitExecutable;
|
startInfo.FileName = App.Setting.Tools.GitExecutable;
|
||||||
startInfo.Arguments = "rev-parse --git-dir";
|
startInfo.Arguments = "rev-parse --git-dir";
|
||||||
|
|
|
@ -95,9 +95,15 @@ namespace SourceGit.UI {
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Constructor
|
/// Constructor
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public Launcher() {
|
public Launcher(string path) {
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
NewTab(null, null);
|
if (path != null && App.IsGitConfigured && Git.Repository.IsValid(path)) {
|
||||||
|
var repo = App.Setting.FindRepository(path);
|
||||||
|
if (repo == null) repo = App.Setting.AddRepository(path, "");
|
||||||
|
Open(repo);
|
||||||
|
} else {
|
||||||
|
NewTab(null, null);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
Loading…
Reference in a new issue