make parsed branch configurable
This commit is contained in:
+15
@@ -19,6 +19,20 @@
|
|||||||
# This is accessible in all templates.
|
# This is accessible in all templates.
|
||||||
#site_description = ""
|
#site_description = ""
|
||||||
|
|
||||||
|
# Which branch to use for generating history.
|
||||||
|
#
|
||||||
|
# Itsy-Gitsy currently only supports traversing the history of a single branch,
|
||||||
|
# which is the one named here. Common options are "master" and "main".
|
||||||
|
# Defaults to "master" if not specified.
|
||||||
|
#
|
||||||
|
# Note that this probably should not contain any remote prefix, like "origin/",
|
||||||
|
# though it may. Also note that the "default branch" is only a concept for
|
||||||
|
# remote repositories; local repositories do not have the concept, hence this
|
||||||
|
# must be explicitly specified.
|
||||||
|
#
|
||||||
|
# This can also be set per-repository.
|
||||||
|
#branch = "master"
|
||||||
|
|
||||||
# List of directories, each of which contains Git repositories to
|
# List of directories, each of which contains Git repositories to
|
||||||
# index.
|
# index.
|
||||||
#
|
#
|
||||||
@@ -457,6 +471,7 @@ generated_by = "Itsy-Gitsy"
|
|||||||
|
|
||||||
# Per-repository settings, same as the global versions described above:
|
# Per-repository settings, same as the global versions described above:
|
||||||
|
|
||||||
|
#branch = "master"
|
||||||
#render_markdown = false
|
#render_markdown = false
|
||||||
#syntax_highlighting = false
|
#syntax_highlighting = false
|
||||||
#syntax_highlight_theme = "base16-ocean.dark"
|
#syntax_highlight_theme = "base16-ocean.dark"
|
||||||
|
|||||||
+5
-3
@@ -192,6 +192,8 @@ pub fn parse_repo(
|
|||||||
let mut history_count = 0;
|
let mut history_count = 0;
|
||||||
let mut branch_count = 0;
|
let mut branch_count = 0;
|
||||||
let mut tag_count = 0;
|
let mut tag_count = 0;
|
||||||
|
let branch_name = settings.branch.as_deref().unwrap_or("master");
|
||||||
|
let branch_obj = repo.revparse_single(branch_name)?;
|
||||||
|
|
||||||
// Cache the shortnames of all references
|
// Cache the shortnames of all references
|
||||||
let mut references: BTreeMap<String, Vec<String>> = BTreeMap::new();
|
let mut references: BTreeMap<String, Vec<String>> = BTreeMap::new();
|
||||||
@@ -213,7 +215,7 @@ pub fn parse_repo(
|
|||||||
loud!();
|
loud!();
|
||||||
let mut revwalk = repo.revwalk()?;
|
let mut revwalk = repo.revwalk()?;
|
||||||
revwalk.set_sorting(git2::Sort::TOPOLOGICAL)?;
|
revwalk.set_sorting(git2::Sort::TOPOLOGICAL)?;
|
||||||
revwalk.push_head()?;
|
revwalk.push(branch_obj.id())?;
|
||||||
loudest!(" - Parsing history:");
|
loudest!(" - Parsing history:");
|
||||||
for oid in revwalk {
|
for oid in revwalk {
|
||||||
let oid = oid?;
|
let oid = oid?;
|
||||||
@@ -379,11 +381,11 @@ pub fn parse_repo(
|
|||||||
let max_depth = settings.limit_tree_depth.unwrap_or(usize::MAX);
|
let max_depth = settings.limit_tree_depth.unwrap_or(usize::MAX);
|
||||||
if max_depth > 0 {
|
if max_depth > 0 {
|
||||||
loudest!(" - Walking root files");
|
loudest!(" - Walking root files");
|
||||||
walk_file_tree(&repo, "HEAD", &mut root_files, 0, usize::MAX, false, "")?;
|
walk_file_tree(&repo, branch_name, &mut root_files, 0, usize::MAX, false, "")?;
|
||||||
// TODO: maybe this should be optional? Walking the whole tree
|
// TODO: maybe this should be optional? Walking the whole tree
|
||||||
// could be slow on huge repos.
|
// could be slow on huge repos.
|
||||||
loudest!(" - Walking all files");
|
loudest!(" - Walking all files");
|
||||||
walk_file_tree(&repo, "HEAD", &mut all_files, 0, max_depth, true, "")?;
|
walk_file_tree(&repo, branch_name, &mut all_files, 0, max_depth, true, "")?;
|
||||||
}
|
}
|
||||||
loud!(" - parsed {} files", all_files.len());
|
loud!(" - parsed {} files", all_files.len());
|
||||||
|
|
||||||
|
|||||||
@@ -10,7 +10,6 @@ use settings::{GitsyCli, GitsySettings};
|
|||||||
// TODO:
|
// TODO:
|
||||||
//
|
//
|
||||||
// * basic, light, dark, and fancy default themes
|
// * basic, light, dark, and fancy default themes
|
||||||
// * specify default branch, use instead of HEAD
|
|
||||||
// * better error propagation
|
// * better error propagation
|
||||||
// * automated tests
|
// * automated tests
|
||||||
// * documentation + examples
|
// * documentation + examples
|
||||||
|
|||||||
@@ -192,6 +192,7 @@ pub struct GitsySettingsRepo {
|
|||||||
pub name: Option<String>,
|
pub name: Option<String>,
|
||||||
pub description: Option<String>,
|
pub description: Option<String>,
|
||||||
pub website: Option<String>,
|
pub website: Option<String>,
|
||||||
|
pub branch: Option<String>,
|
||||||
pub asset_files: Option<Vec<String>>,
|
pub asset_files: Option<Vec<String>>,
|
||||||
pub render_markdown: Option<bool>,
|
pub render_markdown: Option<bool>,
|
||||||
pub syntax_highlight: Option<bool>,
|
pub syntax_highlight: Option<bool>,
|
||||||
@@ -232,6 +233,7 @@ pub struct GitsySettings {
|
|||||||
pub site_url: Option<String>,
|
pub site_url: Option<String>,
|
||||||
pub site_description: Option<String>,
|
pub site_description: Option<String>,
|
||||||
pub asset_files: Option<Vec<String>>,
|
pub asset_files: Option<Vec<String>>,
|
||||||
|
pub branch: Option<String>,
|
||||||
#[serde(rename(deserialize = "gitsy_templates"))]
|
#[serde(rename(deserialize = "gitsy_templates"))]
|
||||||
pub templates: GitsySettingsTemplates,
|
pub templates: GitsySettingsTemplates,
|
||||||
#[serde(rename(deserialize = "gitsy_outputs"))]
|
#[serde(rename(deserialize = "gitsy_outputs"))]
|
||||||
@@ -300,6 +302,7 @@ impl GitsySettings {
|
|||||||
if repo.name.is_none() {
|
if repo.name.is_none() {
|
||||||
repo.name = Some(k.clone());
|
repo.name = Some(k.clone());
|
||||||
}
|
}
|
||||||
|
global_to_repo!(settings, repo, branch);
|
||||||
global_to_repo!(settings, repo, render_markdown);
|
global_to_repo!(settings, repo, render_markdown);
|
||||||
global_to_repo!(settings, repo, syntax_highlight);
|
global_to_repo!(settings, repo, syntax_highlight);
|
||||||
global_to_repo!(settings, repo, syntax_highlight_theme);
|
global_to_repo!(settings, repo, syntax_highlight_theme);
|
||||||
@@ -332,6 +335,7 @@ impl GitsySettings {
|
|||||||
repo_descriptions.insert(GitsySettingsRepo {
|
repo_descriptions.insert(GitsySettingsRepo {
|
||||||
path: dir.path().clone(),
|
path: dir.path().clone(),
|
||||||
name: Some(name),
|
name: Some(name),
|
||||||
|
branch: settings.branch.clone(),
|
||||||
render_markdown: settings.render_markdown.clone(),
|
render_markdown: settings.render_markdown.clone(),
|
||||||
syntax_highlight: settings.syntax_highlight.clone(),
|
syntax_highlight: settings.syntax_highlight.clone(),
|
||||||
syntax_highlight_theme: settings.syntax_highlight_theme.clone(),
|
syntax_highlight_theme: settings.syntax_highlight_theme.clone(),
|
||||||
|
|||||||
Reference in New Issue
Block a user