Implement the Git workflow

This commit is contained in:
2026-07-19 11:53:02 +02:00
parent 90a9002124
commit 422f71c8ad
20 changed files with 3441 additions and 45 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -5,6 +5,7 @@ pub mod calendar;
pub mod error;
pub mod gallery_import;
pub mod generation;
pub mod git;
pub mod media;
pub mod menu;
pub mod meta;

View File

@@ -929,8 +929,6 @@ pub(crate) fn rebuild_canonical_post(
.to_string();
let hash = content_hash(content.as_bytes());
let now = now_unix_ms();
let status = match fm.status.as_str() {
"published" => PostStatus::Published,
"archived" => PostStatus::Archived,
@@ -960,7 +958,7 @@ pub(crate) fn rebuild_canonical_post(
post.tags = fm.tags;
post.categories = fm.categories;
post.created_at = fm.created_at;
post.updated_at = now;
post.updated_at = fm.updated_at;
post.published_at = fm.published_at;
qp::update_post(conn, &post)?;
Ok(false)
@@ -993,7 +991,7 @@ pub(crate) fn rebuild_canonical_post(
published_categories: None,
published_excerpt: None,
created_at: fm.created_at,
updated_at: now,
updated_at: fm.updated_at,
published_at: fm.published_at,
};
qp::insert_post(conn, &post)?;
@@ -1747,6 +1745,7 @@ mod tests {
assert_eq!(post.title, "Rebuilt Post");
assert_eq!(post.slug, "rebuilt-post");
assert_eq!(post.tags, vec!["test"]);
assert_eq!(post.updated_at, 1_705_320_000_000);
// Verify translation in DB
let trans =

View File

@@ -8,7 +8,6 @@ use crate::db::queries::script as qs;
use crate::engine::{EngineError, EngineResult};
use crate::model::{Script, ScriptStatus};
use crate::util::frontmatter::read_script_file;
use crate::util::now_unix_ms;
/// Report returned by `rebuild_scripts_from_filesystem`.
#[derive(Debug, Default)]
@@ -83,8 +82,6 @@ pub(crate) fn rebuild_single_script(
.to_string();
let kind = fm.kind.parse().map_err(EngineError::Parse)?;
let now = now_unix_ms();
// File exists on disk -> Published; content is None in DB
let status = ScriptStatus::Published;
@@ -101,7 +98,7 @@ pub(crate) fn rebuild_single_script(
script.status = status;
script.content = None;
script.created_at = fm.created_at;
script.updated_at = now;
script.updated_at = fm.updated_at;
qs::update_script(conn, &script)?;
Ok(false)
}
@@ -119,7 +116,7 @@ pub(crate) fn rebuild_single_script(
status,
content: None,
created_at: fm.created_at,
updated_at: now,
updated_at: fm.updated_at,
};
qs::insert_script(conn, &script)?;
Ok(true)
@@ -246,6 +243,7 @@ end
assert!(script.enabled);
assert_eq!(script.version, 5);
assert_eq!(script.status, ScriptStatus::Published);
assert_eq!(script.updated_at, 1_704_067_200_000);
assert!(script.content.is_none());
}

View File

@@ -8,7 +8,6 @@ use crate::db::queries::template as qt;
use crate::engine::{EngineError, EngineResult};
use crate::model::{Template, TemplateStatus};
use crate::util::frontmatter::read_template_file;
use crate::util::now_unix_ms;
/// Report returned by `rebuild_templates_from_filesystem`.
#[derive(Debug, Default)]
@@ -83,8 +82,6 @@ pub(crate) fn rebuild_single_template(
.to_string();
let kind = fm.kind.parse().map_err(EngineError::Parse)?;
let now = now_unix_ms();
// File exists on disk -> Published; content is None in DB
let status = TemplateStatus::Published;
@@ -100,7 +97,7 @@ pub(crate) fn rebuild_single_template(
tpl.status = status;
tpl.content = None;
tpl.created_at = fm.created_at;
tpl.updated_at = now;
tpl.updated_at = fm.updated_at;
qt::update_template(conn, &tpl)?;
Ok(false)
}
@@ -117,7 +114,7 @@ pub(crate) fn rebuild_single_template(
status,
content: None,
created_at: fm.created_at,
updated_at: now,
updated_at: fm.updated_at,
};
qt::insert_template(conn, &tpl)?;
Ok(true)
@@ -236,6 +233,7 @@ updatedAt: \"2024-01-01T00:00:00.000Z\"
assert_eq!(tpl.version, 3);
assert_eq!(tpl.status, TemplateStatus::Published);
assert!(tpl.content.is_none());
assert_eq!(tpl.updated_at, 1_704_067_200_000);
}
#[test]