mirror of
https://github.com/sourcegit-scm/sourcegit.git
synced 2024-11-01 13:13:21 -07:00
fix<Clone>: fix crash reported by https://gitee.com/sourcegit/sourcegit/issues/I43UGJ
This commit is contained in:
parent
d7290a9cf6
commit
78bb68b82e
3 changed files with 16 additions and 7 deletions
|
@ -17,7 +17,7 @@ namespace SourceGit.Commands {
|
|||
|
||||
rs = rs.Trim();
|
||||
if (Path.IsPathRooted(rs)) return rs;
|
||||
return Path.Combine(Cwd, rs);
|
||||
return Path.GetFullPath(Path.Combine(Cwd, rs));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
using System.IO;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Controls;
|
||||
|
||||
|
@ -40,14 +41,20 @@ namespace SourceGit.Views.Popups {
|
|||
|
||||
var path = Folder;
|
||||
if (!string.IsNullOrEmpty(LocalName)) {
|
||||
path += $"/{LocalName}";
|
||||
path = Path.GetFullPath(Path.Combine(path, LocalName));
|
||||
} else {
|
||||
var idx = Uri.LastIndexOfAny(new char[] { '\\', '/' });
|
||||
var name = Uri.Substring(idx + 1);
|
||||
path += $"/{name.Replace(".git", "")}";
|
||||
var name = Path.GetFileName(Uri);
|
||||
if (name.EndsWith(".git")) name = name.Substring(0, name.Length - 4);
|
||||
path = Path.GetFullPath(Path.Combine(path, name));
|
||||
}
|
||||
|
||||
var repo = Models.Preference.Instance.AddRepository(path, path + "/.git", "");
|
||||
if (!Directory.Exists(path)) {
|
||||
Models.Exception.Raise($"Folder {path} not found!");
|
||||
return false;
|
||||
}
|
||||
|
||||
var gitDir = new Commands.QueryGitDir(path).Result();
|
||||
var repo = Models.Preference.Instance.AddRepository(path, gitDir, "");
|
||||
if (repo != null) Dispatcher.Invoke(() => Models.Watcher.Open(repo));
|
||||
return true;
|
||||
});
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
using System.IO;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SourceGit.Views.Popups {
|
||||
|
@ -22,7 +23,8 @@ namespace SourceGit.Views.Popups {
|
|||
var succ = new Commands.Init(WorkDir).Exec();
|
||||
if (!succ) return false;
|
||||
|
||||
var repo = Models.Preference.Instance.AddRepository(WorkDir, WorkDir + "\\.git", "");
|
||||
var gitDir = Path.GetFullPath(Path.Combine(WorkDir, ".git"));
|
||||
var repo = Models.Preference.Instance.AddRepository(WorkDir, gitDir, "");
|
||||
Dispatcher.Invoke(() => Models.Watcher.Open(repo));
|
||||
return true;
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue