From 352a985f288b180131955c48b32c8d9238976d02 Mon Sep 17 00:00:00 2001 From: Yanick Champoux Date: Fri, 8 Aug 2008 14:09:25 -0400 Subject: [PATCH] importing user id from Git --- bin/cil | 18 +++++++++++++++++- lib/CIL/VCS/Git.pm | 8 ++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/bin/cil b/bin/cil index 39db797..00e706a 100755 --- a/bin/cil +++ b/bin/cil @@ -143,6 +143,19 @@ sub cmd_init { fatal("Couldn't create '$issues_dir' directory: $!"); } + my $username = "unknown"; + my $user_email; + + # are we in a Git repository? + my $VCSconfig = ''; + if ( -d '.git' ) { + msg( 'git repository detected, setting VCS accordingly' ); + $VCSconfig = 'VCS: git'; + my $vcs = CIL::VCS::Factory->new( 'Git' ); + $username = $vcs->username if $vcs->username; + $user_email = $vcs->user_email if $vcs->user_email; + } + # create a .cil file here also if ( $args->{bare} ) { unless ( touch $config ) { @@ -152,7 +165,10 @@ sub cmd_init { } else { # write a default .cil file - write_file($config, <<'CONFIG'); + write_file($config, <<"CONFIG"); +$VCSconfig +UserName: $username +UserEmail: $user_email StatusStrict: 1 StatusAllowedList: New StatusAllowedList: InProgress diff --git a/lib/CIL/VCS/Git.pm b/lib/CIL/VCS/Git.pm index 3a6f97c..a256b55 100644 --- a/lib/CIL/VCS/Git.pm +++ b/lib/CIL/VCS/Git.pm @@ -85,6 +85,14 @@ sub get_fh { $self->git->command_output_pipe("cat-file", "blob", "$rev:$path"); } +sub username { + return $_[0]->git->config( 'user.name' ); +} + +sub user_email { + return $_[0]->git->config( 'user.email' ); +} + ## ---------------------------------------------------------------------------- 1; ## ---------------------------------------------------------------------------- -- 2.39.5