diff options
| author | Teddy Wing | 2020-07-28 23:33:45 +0200 | 
|---|---|---|
| committer | Teddy Wing | 2020-07-28 23:33:45 +0200 | 
| commit | 03f51738a656b8db55d299efcc104b2b20f16055 (patch) | |
| tree | d94a91bc22ff109ec55435e252ec4e314a5785e9 /src | |
| parent | 8e921835f8aa4f6650a5df151435675b82fb24c8 (diff) | |
| download | git-suggestion-03f51738a656b8db55d299efcc104b2b20f16055.tar.bz2 | |
Suggestion: Remove unused `patch` method
The newer `Suggestion.diff()` method fulfills the same need.
Diffstat (limited to 'src')
| -rw-r--r-- | src/suggestion.rs | 65 | 
1 files changed, 0 insertions, 65 deletions
| diff --git a/src/suggestion.rs b/src/suggestion.rs index 68a2430..531f4b1 100644 --- a/src/suggestion.rs +++ b/src/suggestion.rs @@ -37,28 +37,6 @@ pub struct Suggestion {  }  impl Suggestion { -    // TODO: Rename to `diff` -    pub fn patch(&self) -> String { -        let mut diff: Vec<_> = self.diff.lines() -            .filter(|l| !l.starts_with("-")) -            .map(|l| { -                if l.starts_with("+") { -                    return l.replacen("+", " ", 1); -                } - -                l.to_owned() -            }) -            .collect(); - -        let last = diff.len() - 1; -        diff[last] = diff.last().unwrap() -            .replacen(" ", "-", 1); - -        diff.push(self.suggestion_patch()); - -        diff.join("\n") -    } -      pub fn diff(&self) -> String {          let repo = Repository::open(".").unwrap(); @@ -193,49 +171,6 @@ mod tests {      use super::*;      #[test] -    fn suggestion_patch_generates_patch() { -        // Diff from gabgodBB (https://github.com/gabgodBB) and suggestion from -        // probablycorey (https://github.com/probablycorey) in this pull -        // request: https://github.com/cli/cli/pull/1123 - -        let suggestion = Suggestion { -            diff: r#"@@ -1, 9 +1, 11 @@ - package command -  - import ( -+	"bufio" // used to input comment - 	"errors" - 	"fmt" - 	"io" -+	"os" // used to input comment"#.to_owned(), -            comment: r#"It's ok to leave these uncommented - -```suggestion -	"os" -```"#.to_owned(), -            commit: "".to_owned(), -            path: "".to_owned(), -            original_start_line: Some(8), -            original_end_line: 8, -        }; - -        assert_eq!( -            suggestion.patch(), -            r#"@@ -1, 9 +1, 11 @@ - package command -  - import ( - 	"bufio" // used to input comment - 	"errors" - 	"fmt" - 	"io" --	"os" // used to input comment -+	"os" -"#, -        ); -    } - -    #[test]      fn unified_diff() {          use unidiff::PatchSet; | 
