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, list_commits, list_refs,
10};
11pub use schedule::{ScanSchedule, ScanScheduleKind, ScanScheduleProvider, ScheduleStore};
12pub use webhook::{
13    parse_bitbucket_push, parse_github_push, parse_gitlab_push, WebhookEvent, WebhookProvider,
14};
15
16use chrono::{DateTime, Utc};
17use serde::{Deserialize, Serialize};
18
19#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
20#[serde(rename_all = "snake_case")]
21pub enum GitRefKind {
22    Branch,
23    Tag,
24}
25
26#[derive(Debug, Clone, Serialize, Deserialize)]
27pub struct GitRef {
28    pub kind: GitRefKind,
29    pub name: String,
30    pub sha: String,
31    pub date: Option<DateTime<Utc>>,
32    pub message: Option<String>,
33}
34
35#[derive(Debug, Clone, Serialize, Deserialize)]
36pub struct GitCommit {
37    pub sha: String,
38    pub short_sha: String,
39    pub author: String,
40    pub date: DateTime<Utc>,
41    pub subject: String,
42}
43
44#[derive(Debug, Clone, Serialize, Deserialize)]
45pub struct RepoRefs {
46    pub branches: Vec<GitRef>,
47    pub tags: Vec<GitRef>,
48    pub recent_commits: Vec<GitCommit>,
49}