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