File tree Expand file tree Collapse file tree 2 files changed +25
-3
lines changed Expand file tree Collapse file tree 2 files changed +25
-3
lines changed Original file line number Diff line number Diff line change @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
9
9
10
10
### Fixed
11
11
- Keep commit message when pre-commit hook fails ([ #1035 ] ( https://github.com/extrawurst/gitui/issues/1035 ) )
12
+ - honor ` pushurl ` when checking whether we need username and password for pushing ([ #953 ] ( https://github.com/extrawurst/gitui/issues/953 ) )
12
13
13
14
## [ 0.19] - 2021-12-08 - Bare Repo Support
14
15
Original file line number Diff line number Diff line change @@ -32,9 +32,11 @@ impl BasicAuthCredential {
32
32
/// know if username and password are needed for this url
33
33
pub fn need_username_password ( repo_path : & RepoPath ) -> Result < bool > {
34
34
let repo = repo ( repo_path) ?;
35
- let url = repo
36
- . find_remote ( & get_default_remote_in_repo ( & repo) ?) ?
37
- . url ( )
35
+ let remote =
36
+ repo. find_remote ( & get_default_remote_in_repo ( & repo) ?) ?;
37
+ let url = remote
38
+ . pushurl ( )
39
+ . or_else ( || remote. url ( ) )
38
40
. ok_or ( Error :: UnknownRemote ) ?
39
41
. to_owned ( ) ;
40
42
let is_http = url. starts_with ( "http" ) ;
@@ -188,6 +190,25 @@ mod tests {
188
190
assert_eq ! ( need_username_password( repo_path) . unwrap( ) , false ) ;
189
191
}
190
192
193
+ #[ test]
194
+ #[ serial]
195
+ fn test_dont_need_username_password_if_pushurl_ssh ( ) {
196
+ let ( _td, repo) = repo_init ( ) . unwrap ( ) ;
197
+ let root = repo. path ( ) . parent ( ) . unwrap ( ) ;
198
+ let repo_path: & RepoPath =
199
+ & root. as_os_str ( ) . to_str ( ) . unwrap ( ) . into ( ) ;
200
+
201
+ repo
. remote ( DEFAULT_REMOTE_NAME , "http://[email protected] " )
202
+ . unwrap ( ) ;
203
+ repo. remote_set_pushurl (
204
+ DEFAULT_REMOTE_NAME ,
205
+ Some ( "[email protected] :user/repo" ) ,
206
+ )
207
+ . unwrap ( ) ;
208
+
209
+ assert_eq ! ( need_username_password( repo_path) . unwrap( ) , false ) ;
210
+ }
211
+
191
212
#[ test]
192
213
#[ serial]
193
214
#[ should_panic]
You can’t perform that action at this time.
0 commit comments