1use std::fmt::Display;
2
3use crate::{
4 git::url::RemoteGitUrl,
5 lua_rockspec::{DisplayAsLuaValue, DisplayLuaValue},
6};
7
8pub mod shorthand;
9pub mod url;
10pub mod utils;
11
12impl DisplayAsLuaValue for RemoteGitUrl {
13 fn display_lua_value(&self) -> DisplayLuaValue {
14 DisplayLuaValue::String(self.to_string())
15 }
16}
17
18#[derive(Debug, PartialEq, Eq, Hash, Clone, lux_macros::DisplayAsLuaKV)]
20#[display_lua(key = "source")]
21pub struct GitSource {
22 pub url: RemoteGitUrl,
23 #[display_lua(rename = "tag")]
24 pub checkout_ref: Option<String>,
25}
26
27impl Display for GitSource {
28 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
29 match &self.checkout_ref {
30 Some(checkout_ref) => format!("{}@{}", self.url, checkout_ref).fmt(f),
31 None => self.url.fmt(f),
32 }
33 }
34}