Skip to content

Commit

Permalink
Add a function to get the git config as a hash (in Perl)
Browse files Browse the repository at this point in the history
  • Loading branch information
Scott Baker committed Mar 9, 2016
1 parent efc22bb commit c5570c0
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions libs/header_clean/header_clean.pl
Original file line number Diff line number Diff line change
Expand Up @@ -167,3 +167,23 @@ sub clean_up_input {

return 1;
}

# Return git config as a hash
sub get_git_config {
my $cmd = "git config --list";
my @out = `$cmd`;

my %hash;
foreach my $line (@out) {
my ($key,$value) = split("=",$line,2);
$value =~ s/\s+$//;
my @path = split(/\./,$key);

my $last = pop @path;
my $p = \%hash;
$p = $p->{$_} //= {} for @path;
$p->{$last} = $value;
}

return \%hash;
}

0 comments on commit c5570c0

Please sign in to comment.