|
1 | 1 | using System; |
2 | 2 | using System.Collections.Generic; |
3 | | -using System.IO; |
4 | 3 | using System.Threading; |
5 | 4 | using System.Threading.Tasks; |
6 | 5 |
|
@@ -100,40 +99,16 @@ public void ToggleNodeIsExpanded(RepositoryNode node) |
100 | 99 | } |
101 | 100 | } |
102 | 101 |
|
103 | | - public async Task<string> GetRepositoryRootAsync(string path, RepositoryNode parent = null) |
| 102 | + public async Task<Commands.Command.Result> GetRepositoryRootAsync(string path) |
104 | 103 | { |
105 | 104 | if (!Preferences.Instance.IsGitConfigured()) |
106 | | - { |
107 | | - Models.Notification.Send(null, App.Text("NotConfigured"), true); |
108 | | - return null; |
109 | | - } |
110 | | - |
111 | | - var root = path; |
112 | | - if (!Directory.Exists(root)) |
113 | | - { |
114 | | - if (File.Exists(root)) |
115 | | - root = Path.GetDirectoryName(root); |
116 | | - else |
117 | | - return null; |
118 | | - } |
| 105 | + return Commands.Command.Result.Failed(App.Text("NotConfigured")); |
119 | 106 |
|
120 | | - var isBare = await new Commands.IsBareRepository(root).GetResultAsync(); |
| 107 | + var isBare = await new Commands.IsBareRepository(path).GetResultAsync(); |
121 | 108 | if (isBare) |
122 | | - return root; |
123 | | - |
124 | | - var rs = await new Commands.QueryRepositoryRootPath(root).GetResultAsync(); |
125 | | - if (rs.IsSuccess && !string.IsNullOrWhiteSpace(rs.StdOut)) |
126 | | - return rs.StdOut.Trim(); |
127 | | - |
128 | | - if (Models.SafeDirectories.IsUntrustedRepository(rs.StdErr) && |
129 | | - Models.SafeDirectories.TryGetSafeDirectoryValue(root, rs.StdErr, out var safeDirectory)) |
130 | | - { |
131 | | - var launcher = App.GetLauncher(); |
132 | | - if (launcher?.ActivePage is { } page && page.CanCreatePopup()) |
133 | | - page.Popup = new TrustRepository(page.Node.Id, root, rs.StdErr, safeDirectory, parent, true, false, 0); |
134 | | - } |
| 109 | + return new Commands.Command.Result { IsSuccess = true, StdOut = path }; |
135 | 110 |
|
136 | | - return null; |
| 111 | + return await new Commands.QueryRepositoryRootPath(path).GetResultAsync(); |
137 | 112 | } |
138 | 113 |
|
139 | 114 | public async Task AddRepositoryAsync(string path, RepositoryNode parent, bool moveNode, bool open) |
|
0 commit comments