| 117 | } |
| 118 | |
| 119 | fn display_ahead_behind( |
| 120 | &self, |
| 121 | git_chain: &GitChain, |
| 122 | upstream: &str, |
| 123 | branch: &str, |
| 124 | ) -> Result<String, Error> { |
| 125 | let (upstream_obj, _reference) = git_chain.repo.revparse_ext(upstream)?; |
| 126 | let (branch_obj, _reference) = git_chain.repo.revparse_ext(branch)?; |
| 127 | |
| 128 | let ahead_behind = git_chain |
| 129 | .repo |
| 130 | .graph_ahead_behind(branch_obj.id(), upstream_obj.id())?; |
| 131 | |
| 132 | let status = match ahead_behind { |
| 133 | (0, 0) => "".to_string(), |
| 134 | (ahead, 0) => { |
| 135 | format!("{} ahead", ahead) |
| 136 | } |
| 137 | (0, behind) => { |
| 138 | format!("{} behind", behind) |
| 139 | } |
| 140 | (ahead, behind) => { |
| 141 | format!("{} ahead ⦁ {} behind", ahead, behind) |
| 142 | } |
| 143 | }; |
| 144 | |
| 145 | Ok(status) |
| 146 | } |
| 147 | |
| 148 | pub fn display_list( |
| 149 | &self, |