diff options
author | Sean Whitton <spwhitton@spwhitton.name> | 2023-06-12 12:16:04 +0100 |
---|---|---|
committer | Sean Whitton <spwhitton@spwhitton.name> | 2023-06-12 12:25:49 +0100 |
commit | a1909031f69be27e34ae46fcb72c1bcc14bc4a11 (patch) | |
tree | f4556a9d91eeef1c5c1c96bd757d9b537c71a935 /perl5 | |
parent | 10260e3f92f393164c5d5bfe56456c698114f4ea (diff) | |
download | dotfiles-a1909031f69be27e34ae46fcb72c1bcc14bc4a11.tar.gz |
don't use --local for my git config keys & factor out config_bool
Diffstat (limited to 'perl5')
-rw-r--r-- | perl5/Local/MrRepo/Repo/Git.pm | 10 | ||||
-rw-r--r-- | perl5/Local/MrRepo/Repo/Git/Annex.pm | 6 | ||||
-rw-r--r-- | perl5/Local/Util/Git.pm | 4 |
3 files changed, 12 insertions, 8 deletions
diff --git a/perl5/Local/MrRepo/Repo/Git.pm b/perl5/Local/MrRepo/Repo/Git.pm index 5c9737bc..dab96bc7 100644 --- a/perl5/Local/MrRepo/Repo/Git.pm +++ b/perl5/Local/MrRepo/Repo/Git.pm @@ -1,6 +1,6 @@ package Local::MrRepo::Repo::Git; -# Copyright (C) 2019 Sean Whitton +# Copyright (C) 2019, 2023 Sean Whitton # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -45,6 +45,14 @@ sub new { # attributes sub git { return shift->{git} } +sub config_bool { + my ($self, $key, $default) = @_; + my @args = qw(--get --type=bool); + push @args, "--default", $default if $default; + my ($out) = $self->git->config(@args, $key); + $out eq "true" ? 1 : 0 +} + # public methods # could make this runnable from a ~/bin/git-reviewrepo script or diff --git a/perl5/Local/MrRepo/Repo/Git/Annex.pm b/perl5/Local/MrRepo/Repo/Git/Annex.pm index d3eefcdf..7b037f8c 100644 --- a/perl5/Local/MrRepo/Repo/Git/Annex.pm +++ b/perl5/Local/MrRepo/Repo/Git/Annex.pm @@ -65,11 +65,7 @@ sub review { $issues = 1; } # 2. Check for unused files which we should be able to clean up - my ($review_unused) = $self->git->config(qw(--local --get --type=bool - --default true - spwhitton.mrrepo.review-unused)); - - if ($review_unused eq "true") { + if ($self->config_bool("spwhitton.mrrepo.review-unused", "true")) { #<<< try { local $CWD = $self->toplevel; diff --git a/perl5/Local/Util/Git.pm b/perl5/Local/Util/Git.pm index 3f7bf3e9..c48264d6 100644 --- a/perl5/Local/Util/Git.pm +++ b/perl5/Local/Util/Git.pm @@ -33,7 +33,7 @@ sub unpushed_tags { # allow skipping this check on a whole repo chomp(my $ignore = - `$git config --local --get --type=bool spwhitton.unpushed-tags.ignore`); + `$git config --get --type=bool spwhitton.unpushed-tags.ignore`); return () if $ignore eq 'true'; # archive/debian/foo tags are pushed only to dgit repos in split @@ -70,7 +70,7 @@ sub unpushed_tags { # allow skipping remotes which don't like 'ls-remote' # TODO replace with an spwhitton.unpushed-tags.skip-remotes key ? # chomp(my $ignore = - # `$git config --local --get --type=bool remote.$remote.unpushed-tags-ignore`); + # `$git config --get --type=bool remote.$remote.unpushed-tags-ignore`); # next if $ignore eq 'true'; # remotes without URIs are probably git-annex special remotes; skip them |