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