-
Notifications
You must be signed in to change notification settings - Fork 507
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Show snippet in variable prompt (#337)
Fixes #320
- Loading branch information
1 parent
6b9d97b
commit 4451624
Showing
3 changed files
with
47 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,11 +21,12 @@ pub fn meta(uri: &str) -> (String, String, String) { | |
format!("https://github.com/{}", uri) | ||
}; | ||
|
||
let parts: Vec<&str> = actual_uri.split('/').collect(); | ||
let uri_to_split = actual_uri.replace(':', "/"); | ||
let parts: Vec<&str> = uri_to_split.split('/').collect(); | ||
let user = parts[parts.len() - 2]; | ||
let repo = parts[parts.len() - 1].replace(".git", ""); | ||
|
||
(actual_uri.clone(), user.to_string(), repo) | ||
(actual_uri, user.to_string(), repo) | ||
} | ||
|
||
#[cfg(test)] | ||
|
@@ -43,7 +44,7 @@ mod tests { | |
#[test] | ||
fn test_meta_github_ssh() { | ||
let (actual_uri, user, repo) = meta("[email protected]:denisidoro/navi.git"); | ||
assert_eq!(actual_uri, "[email protected]/denisidoro/navi.git".to_string()); | ||
assert_eq!(actual_uri, "[email protected]:denisidoro/navi.git".to_string()); | ||
assert_eq!(user, "denisidoro".to_string()); | ||
assert_eq!(repo, "navi".to_string()); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters