File tree Expand file tree Collapse file tree 1 file changed +49
-0
lines changed
Expand file tree Collapse file tree 1 file changed +49
-0
lines changed Original file line number Diff line number Diff line change 1+ # ##
2+ # ## git-follow - Follow lifetime changes of a pathspec in Git.
3+ # ##
4+ # ## Copyright (C) 2023 Nickolas Burr <nickolasburr@gmail.com>
5+ # ##
6+ package GitFollow::Config ;
7+
8+ use 5.008;
9+ use strict;
10+ use warnings;
11+ use Exporter qw( import) ;
12+ use GitFollow::Environment qw( $GIT_PATH) ;
13+
14+ our @EXPORT = qw(
15+ get_config
16+ has_config
17+ ) ;
18+
19+ sub get_config ;
20+ sub has_config ;
21+
22+ # Get git-config(1) value.
23+ sub get_config {
24+ my ($grp , $key ) = @_ ;
25+ my $config = undef ;
26+
27+ system (" $GIT_PATH config follow.$grp .$key >/dev/null" );
28+
29+ $config = (!$? )
30+ ? ` $GIT_PATH config follow.$grp .$key `
31+ : ` $GIT_PATH config follow.$grp$key ` ;
32+
33+ # Strip trailing newline from config value.
34+ chomp $config ;
35+ return $config ;
36+ }
37+
38+ # Check if git-config(1) key exists.
39+ sub has_config {
40+ my ($grp , $key ) = @_ ;
41+
42+ system (" $GIT_PATH config follow.$grp .$key >/dev/null" );
43+ return 1 unless $? ;
44+
45+ system (" $GIT_PATH config follow.$grp$key >/dev/null" );
46+ !($? >> 8);
47+ }
48+
49+ 1;
You can’t perform that action at this time.
0 commit comments