create gentoo ebuild, make pushing tags optional

This commit is contained in:
Bryson Steck 2025-03-23 12:22:23 -06:00
parent 0ec62a34d4
commit d54a7debca
Signed by: bryson
SSH key fingerprint: SHA256:XpKABw/nP4z8UVaH+weLaBnEOD86+cVwif+QjuYLGT4
4 changed files with 155 additions and 5 deletions

View file

@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE pkgmetadata SYSTEM "https://www.gentoo.org/dtd/metadata.dtd">
<pkgmetadata>
<maintainer type="person">
<email>me@brysonsteck.xyz</email>
<name>Bryson Steck</name>
</maintainer>
<longdescription lang="en">
</longdescription>
<upstream>
<remote-id type="codeberg">brysonsteck/refractr</remote-id>
</upstream>
</pkgmetadata>

View file

@ -0,0 +1,132 @@
# Copyright 2025 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
# Autogenerated by pycargoebuild 0.13.5
EAPI=8
CRATES="
advapi32-sys@0.2.0
anstream@0.6.18
anstyle-parse@0.2.6
anstyle-query@1.1.2
anstyle-wincon@3.0.7
anstyle@1.0.10
bitflags@2.9.0
block-buffer@0.10.4
cc@1.2.17
cfg-if@1.0.0
cfg_aliases@0.2.1
clap@4.5.32
clap_builder@4.5.32
clap_derive@4.5.32
clap_lex@0.7.4
colorchoice@1.0.3
colored@3.0.0
cpufeatures@0.2.17
crypto-common@0.1.6
ctrlc@3.4.5
digest@0.10.7
displaydoc@0.2.5
equivalent@1.0.2
form_urlencoded@1.2.1
generic-array@0.14.7
hashbrown@0.15.2
heck@0.5.0
hex@0.4.3
icu_collections@1.5.0
icu_locid@1.5.0
icu_locid_transform@1.5.0
icu_locid_transform_data@1.5.0
icu_normalizer@1.5.0
icu_normalizer_data@1.5.0
icu_properties@1.5.1
icu_properties_data@1.5.0
icu_provider@1.5.0
icu_provider_macros@1.5.0
idna@1.0.3
idna_adapter@1.2.0
indexmap@2.8.0
is_terminal_polyfill@1.70.1
jobserver@0.1.32
libc@0.2.171
libssh2-sys@0.3.1
libz-sys@1.1.22
litemap@0.7.5
log@0.4.26
memchr@2.7.4
nix@0.29.0
once_cell@1.21.1
openssl-probe@0.1.6
openssl-sys@0.9.106
percent-encoding@2.3.1
pkg-config@0.3.32
proc-macro2@1.0.94
quit@2.0.0
quit_macros@2.0.0
quote@1.0.40
serde@1.0.219
serde_derive@1.0.219
serde_spanned@0.6.8
sha2@0.10.8
shlex@1.3.0
smallvec@1.14.0
stable_deref_trait@1.2.0
strsim@0.11.1
syn@2.0.100
synstructure@0.13.1
tinystr@0.7.6
toml@0.8.20
toml_datetime@0.6.8
toml_edit@0.22.24
typenum@1.18.0
unicode-ident@1.0.18
url@2.5.4
username@0.2.0
users@0.11.0
utf16_iter@1.0.5
utf8_iter@1.0.4
utf8parse@0.2.2
vcpkg@0.2.15
version_check@0.9.5
winapi-build@0.1.1
winapi@0.2.8
windows-sys@0.59.0
windows-targets@0.52.6
windows_aarch64_gnullvm@0.52.6
windows_aarch64_msvc@0.52.6
windows_i686_gnu@0.52.6
windows_i686_gnullvm@0.52.6
windows_i686_msvc@0.52.6
windows_x86_64_gnu@0.52.6
windows_x86_64_gnullvm@0.52.6
windows_x86_64_msvc@0.52.6
winnow@0.7.4
write16@1.0.0
writeable@0.5.5
yoke-derive@0.7.5
yoke@0.7.5
zerofrom-derive@0.1.6
zerofrom@0.1.6
zerovec-derive@0.10.3
zerovec@0.10.4
"
declare -A GIT_CRATES=(
[git2]='https://github.com/brysonsteck/git2-rs;1ca81270e632ac30c6e1367d3032ca3043068b2f;git2-rs-%commit%'
[libgit2-sys]='https://github.com/brysonsteck/git2-rs;1ca81270e632ac30c6e1367d3032ca3043068b2f;git2-rs-%commit%/libgit2-sys'
)
inherit cargo
DESCRIPTION=""
HOMEPAGE=""
SRC_URI="
${CARGO_CRATE_URIS}
"
LICENSE="MPL-2.0"
# Dependent crate licenses
LICENSE+=" MIT MPL-2.0 Unicode-3.0"
SLOT="0"
KEYWORDS="~amd64"

View file

@ -107,6 +107,7 @@ pub struct Config {
pub to: Vec<String>,
pub branches: Vec<String>,
pub work_dir: Option<String>,
pub push_tags: bool,
pub git: Git,
pub schedule: Schedule,
}

View file

@ -50,13 +50,15 @@ impl Refractr {
Ok(work_dir.to_string_lossy().to_string())
}
fn get_refs(&self, branches: &Vec<String>, tags: StringArray) -> Vec<String> {
fn get_refs(&self, branches: &Vec<String>, tags: Option<StringArray>) -> Vec<String> {
let mut refs_branches = Vec::new();
for branch in branches {
refs_branches.push(format!("refs/heads/{}", branch));
}
for tag in &tags {
refs_branches.push(format!("refs/tags/{}", tag.unwrap()))
if let Some(tags) = tags {
for tag in &tags {
refs_branches.push(format!("refs/tags/{}", tag.unwrap()))
}
}
refs_branches
}
@ -192,8 +194,10 @@ impl Refractr {
let mut refs = Vec::new();
let mut refs_str = String::new();
let tags = repo.tag_names(None).unwrap();
let strings = self.get_refs(&cfg.branches, tags);
let strings = self.get_refs(&cfg.branches, match cfg.push_tags {
true => Some(repo.tag_names(None).unwrap()),
false => None
});
for branch in &strings {
refs.push(branch.as_str());
refs_str.push_str(format!("{} ", branch).as_str());