-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathConfig.pm
49 lines (38 loc) · 924 Bytes
/
Config.pm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
###
### git-follow - Follow lifetime changes of a pathspec in Git.
###
### Copyright (C) 2023 Nickolas Burr <[email protected]>
###
package GitFollow::Config;
use 5.008;
use strict;
use warnings;
use Exporter qw(import);
use GitFollow::Environment qw($GIT_PATH);
our @EXPORT_OK = qw(
get_config
has_config
);
sub get_config;
sub has_config;
# Get git-config(1) value.
sub get_config {
my ($grp, $key) = @_;
my $config = undef;
system("$GIT_PATH config follow.$grp.$key >/dev/null");
$config = (!$?)
? `$GIT_PATH config follow.$grp.$key`
: `$GIT_PATH config follow.$grp$key`;
# Strip trailing newline from config value.
chomp $config;
return $config;
}
# Check if git-config(1) key exists.
sub has_config {
my ($grp, $key) = @_;
system("$GIT_PATH config follow.$grp.$key >/dev/null");
return 1 unless $?;
system("$GIT_PATH config follow.$grp$key >/dev/null");
!($? >> 8);
}
1;