Skip to content

Commit 02d22bb

Browse files
committed
remove variables from puff.yml, add get_branch method, bug fix
1 parent 0b7efef commit 02d22bb

6 files changed

Lines changed: 22 additions & 14 deletions

File tree

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
/target
1+
/target
2+
.env

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "atomic-git"
3-
version = "0.1.0"
3+
version = "0.1.1"
44
edition = "2024"
55

66
[lib]

crates/atomicframework-macro/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ pub fn derive_userdata(input: TokenStream) -> TokenStream {
2121
let lua_wrappers = methods.iter().map(|m| {
2222
let fname = format_ident!("{}", m);
2323
quote! {
24-
use atomicframework::userdata::IntoLuaValue;
2524
extern "C" fn #fname(lua: rglua::lua::LuaState) -> i32 {
25+
use atomicframework::userdata::IntoLuaValue;
2626
unsafe {
2727
let ud = rglua::prelude::lua_touserdata(lua, 1) as *mut #struct_name;
2828
let obj = &*ud;

puff.yml

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
variables:
2-
SRCDS: "D:/Projects/Roleplay/steamapps/common/GarrysModDS"
3-
41
configuration:
52
shell: powershell
63
default: cicd
@@ -12,19 +9,17 @@ tasks:
129
move:
1310
commands:
1411
- if (Test-Path "${SRCDS}/garrysmod/lua/bin/gmsv_atomic_git_win32.dll") { Remove-Item -Force "${SRCDS}/garrysmod/lua/bin/gmsv_atomic_git_win32.dll" }
15-
- Move-Item -Force "./target/i686-pc-windows-msvc/release/atomic_git.dll" "${SRCDS}/garrysmod/lua/bin/gmsv_atomic_git_win32.dll"
12+
- 'Move-Item -Force "./target/i686-pc-windows-msvc/release/atomic_git.dll" "${SRCDS}/garrysmod/lua/bin/gmsv_atomic_git_win32.dll"'
1613
killsrcds:
1714
commands:
1815
- |
1916
if (Get-Process "srcds" -ErrorAction SilentlyContinue) {
2017
taskkill /F /IM srcds.exe
21-
} else {
22-
Write-Host "srcds.exe не найден — скипаю"
23-
}
18+
} else { }
2419
2520
startsrcds:
2621
commands:
27-
- cd ${SRCDS}; ${SRCDS}/start.bat
22+
- cd ${SRCDS}; Start-Process "${SRCDS}/start.bat" -WindowStyle Hidden -RedirectStandardOutput "$env:TEMP\out.txt" -RedirectStandardError "$env:TEMP\err.txt"
2823
cicd:
2924
commands:
3025
- puff build

src/gitrepo.rs

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
use atomicframework::macros::Userdata;
2-
use anyhow::{anyhow, Result};
2+
use anyhow::{anyhow, bail, Result};
33
use git2::Repository;
44

55
#[derive(Userdata)]
6-
#[userdata("get_commit_id")]
6+
#[userdata("get_commit_id", "get_branch")]
77
pub struct GitRepo {
88
repo: Repository,
99
}
@@ -23,4 +23,16 @@ impl GitRepo {
2323

2424
Ok(id)
2525
}
26+
27+
fn get_branch(&self) -> anyhow::Result<String> {
28+
let head = self.repo.head()?;
29+
30+
if head.is_branch() {
31+
if let Some(name) = head.shorthand() {
32+
return Ok(name.to_string());
33+
}
34+
}
35+
36+
bail!("Detached ~HEAD")
37+
}
2638
}

0 commit comments

Comments
 (0)