git_graph/lib.rs
1//! git-graph shows clear git graphs arranged for your branching model.
2//!
3//! It provides both a library and a command line tool.
4//!
5//! The main steps are:
6//! 1. Read branching model configuration (See [config] and [settings])
7//! 2. Lay out the graph structure according to the branching model (See [graph])
8//! 3. Render the layout to text or SVG (See [mod@print])
9
10/* TODO git-graph has some complex functions, which make it hard to
11understand and modify the code. The code should be made simpler
12so the following warnings can be enabled without triggering.
13
14// Configure clippy to look for complex functions
15#![warn(clippy::cognitive_complexity)]
16#![warn(clippy::too_many_lines)]
17*/
18
19use git2::Repository;
20use std::path::Path;
21
22pub mod config;
23pub mod graph;
24pub mod print;
25pub mod settings;
26
27pub fn get_repo<P: AsRef<Path>>(
28 path: P,
29 skip_repo_owner_validation: bool,
30) -> Result<Repository, git2::Error> {
31 if skip_repo_owner_validation {
32 unsafe { git2::opts::set_verify_owner_validation(false)? }
33 }
34 Repository::discover(path)
35}