Skip to main content

sloc_git/
lib.rs

1// SPDX-License-Identifier: AGPL-3.0-or-later
2// Copyright (C) 2026 Nima Shafie <nimzshafie@gmail.com>
3
4pub mod ops;
5pub mod schedule;
6pub mod webhook;
7
8pub use ops::{
9    clone_or_fetch, create_worktree, destroy_worktree, get_sha, host_allowlist_configured,
10    is_local_repo_path, list_commits, list_refs, list_refs_local, normalize_git_url,
11    open_local_repo, populate_submodules, publish_dir,
12};
13pub use schedule::{ScanSchedule, ScanScheduleKind, ScanScheduleProvider, ScheduleStore};
14pub use webhook::{
15    WebhookEvent, WebhookProvider, hmac_sha256_hex, parse_bitbucket_push, parse_github_push,
16    parse_gitlab_push,
17};
18
19use chrono::{DateTime, Utc};
20use serde::{Deserialize, Serialize};
21
22#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
23#[serde(rename_all = "snake_case")]
24pub enum GitRefKind {
25    Branch,
26    Tag,
27}
28
29#[derive(Debug, Clone, Serialize, Deserialize)]
30pub struct GitRef {
31    pub kind: GitRefKind,
32    pub name: String,
33    pub sha: String,
34    pub date: Option<DateTime<Utc>>,
35    pub message: Option<String>,
36}
37
38#[derive(Debug, Clone, Serialize, Deserialize)]
39pub struct GitCommit {
40    pub sha: String,
41    pub short_sha: String,
42    pub author: String,
43    pub date: DateTime<Utc>,
44    pub subject: String,
45}
46
47#[derive(Debug, Clone, Serialize, Deserialize)]
48pub struct RepoRefs {
49    pub branches: Vec<GitRef>,
50    pub tags: Vec<GitRef>,
51    pub recent_commits: Vec<GitCommit>,
52}