MCPcopy Create free account
hub / github.com/GCWing/BitFun / parse_remote_branches

Function parse_remote_branches

src/apps/desktop/src/api/git_api.rs:226–277  ·  view source on GitHub ↗
(output: &str)

Source from the content-addressed store, hash-verified

224}
225
226fn parse_remote_branches(output: &str) -> Vec<GitBranch> {
227 output
228 .lines()
229 .filter_map(|line| {
230 let mut fields = line.splitn(6, '\t');
231 let current = fields.next()? == "*";
232 let full_ref = fields.next()?;
233 let name = fields.next()?.to_string();
234 let upstream = fields
235 .next()
236 .map(str::trim)
237 .filter(|s| !s.is_empty())
238 .map(str::to_string);
239 let last_commit = fields
240 .next()
241 .map(str::trim)
242 .filter(|s| !s.is_empty())
243 .map(str::to_string);
244 let last_commit_date = fields
245 .next()
246 .map(str::trim)
247 .filter(|s| !s.is_empty())
248 .map(str::to_string);
249 let remote = full_ref.starts_with("refs/remotes/");
250
251 Some(GitBranch {
252 name,
253 current,
254 remote,
255 upstream,
256 ahead: 0,
257 behind: 0,
258 last_commit,
259 last_commit_date: last_commit_date.clone(),
260 base_branch: None,
261 child_branches: None,
262 merged_branches: None,
263 branch_type: None,
264 has_conflicts: None,
265 can_merge: None,
266 is_stale: None,
267 merge_status: None,
268 stats: None,
269 created_at: None,
270 last_activity_at: last_commit_date,
271 tags: None,
272 description: None,
273 linked_issues: None,
274 })
275 })
276 .collect()
277}
278
279fn parse_remote_commits(output: &str) -> Vec<GitCommit> {
280 output

Callers 2

git_get_branchesFunction · 0.85

Calls 4

collectMethod · 0.80
nextMethod · 0.80
is_emptyMethod · 0.45
cloneMethod · 0.45

Tested by

no test coverage detected