1use crate::{
2 git::url::RemoteGitUrl,
3 lua_rockspec::{DisplayAsLuaKV, DisplayLuaKV, DisplayLuaValue},
4};
5
6pub mod shorthand;
7pub mod url;
8pub mod utils;
9
10#[derive(Debug, PartialEq, Clone)]
11pub struct GitSource {
12 pub url: RemoteGitUrl,
13 pub checkout_ref: Option<String>,
14}
15
16impl DisplayAsLuaKV for GitSource {
17 fn display_lua(&self) -> DisplayLuaKV {
18 let mut source_tbl = Vec::new();
19 source_tbl.push(DisplayLuaKV {
20 key: "url".to_string(),
21 value: DisplayLuaValue::String(format!("{}", self.url)),
22 });
23 if let Some(checkout_ref) = &self.checkout_ref {
24 source_tbl.push(DisplayLuaKV {
25 key: "tag".to_string(),
28 value: DisplayLuaValue::String(checkout_ref.to_string()),
29 });
30 }
31 DisplayLuaKV {
32 key: "source".to_string(),
33 value: DisplayLuaValue::Table(source_tbl),
34 }
35 }
36}