This commit is contained in:
leo 2021-08-04 19:11:22 +08:00
parent d7290a9cf6
commit 78bb68b82e
3 changed files with 16 additions and 7 deletions

View file

@ -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));
}
}
}

View file

@ -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;
});

View file

@ -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;
});