MCPcopy Create free account
hub / github.com/AmrDeveloper/GQL / select_references

Function select_references

src/gitql/gitql_data_provider.rs:59–110  ·  view source on GitHub ↗
(
    repo: &gix::Repository,
    selected_columns: &[String],
)

Source from the content-addressed store, hash-verified

57}
58
59fn select_references(
60 repo: &gix::Repository,
61 selected_columns: &[String],
62) -> Result<Vec<Row>, String> {
63 let git_references = repo.references();
64 if let Err(error) = git_references {
65 return Err(error.to_string());
66 }
67
68 let repo_path = repo.path().to_str().unwrap();
69 let references = git_references.ok().unwrap();
70 let mut rows: Vec<Row> = vec![];
71
72 for reference in references.all().unwrap().flatten() {
73 let mut values: Vec<Box<dyn Value>> = Vec::with_capacity(selected_columns.len());
74 for column_name in selected_columns {
75 if column_name == "name" {
76 let name = reference.name().shorten().to_string();
77 values.push(Box::new(TextValue::new(name)));
78 continue;
79 }
80
81 if column_name == "full_name" {
82 let full_name = reference.name().as_bstr().to_string();
83 values.push(Box::new(TextValue::new(full_name)));
84 continue;
85 }
86
87 if column_name == "type" {
88 let category = if let Some(category) = reference.name().category() {
89 format!("{category:?}")
90 } else {
91 "Other".to_string()
92 };
93 values.push(Box::new(TextValue::new(category)));
94 continue;
95 }
96
97 if column_name == "repo" {
98 values.push(Box::new(TextValue::new(repo_path.to_string())));
99 continue;
100 }
101
102 values.push(Box::new(NullValue));
103 }
104
105 let row = Row { values };
106 rows.push(row);
107 }
108
109 Ok(rows)
110}
111
112fn select_commits(repo: &gix::Repository, selected_columns: &[String]) -> Result<Vec<Row>, String> {
113 let head_id = repo.head_id();

Callers 1

select_gql_objectsFunction · 0.85

Calls 1

lenMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…