On 09-05-14 16:47, Diego Novillo wrote:
I would probably use git config directly here. It would work with both
git and svn checkouts (if you have a global .git configuration). But
testing for .git is fine with me as well.
I like Peter's idea of having a ~/.mklog file to override. This would
work for both svn and git checkouts.
Diego,
this patch implements both:
- it uses the ~/.mklog file proposed by Peter
- in absence of a ~/.mklog file, it uses git config, also when not in a git
repository
OK?
Thanks,
- Tom
2014-11-20 Tom de Vries <t...@codesourcery.com>
Peter Bergner <berg...@vnet.ibm.com>
* mklog: Handle .mklog. Use git setting independent of presence .git
directory.
---
contrib/mklog | 56 +++++++++++++++++++++++++++++++++++---------------------
1 file changed, 35 insertions(+), 21 deletions(-)
diff --git a/contrib/mklog b/contrib/mklog
index 840f6f8..abbf0af 100755
--- a/contrib/mklog
+++ b/contrib/mklog
@@ -29,32 +29,46 @@
use File::Temp;
use File::Copy qw(cp mv);
-# Change these settings to reflect your profile.
-$username = $ENV{'USER'};
-$name = `finger $username | grep -o 'Name: .*'`;
-@n = split(/: /, $name);
-$name = $n[1]; chop($name);
-$addr = $username . "\@my.domain.org";
$date = `date +%Y-%m-%d`; chop ($date);
+$dot_mklog_format_msg =
+ "The .mklog format is:\n"
+ . "NAME = ...\n"
+ . "EMAIL = ...\n";
+
+# Create a .mklog to reflect your profile, if necessary.
+my $conf = "$ENV{HOME}/.mklog";
+if (-f "$conf") {
+ open (CONF, "$conf")
+ or die "Could not open file '$conf' for reading: $!\n";
+ while (<CONF>) {
+ if (m/^\s*NAME\s*=\s*(.*)\s*$/) {
+ $name = $1;
+ } elsif (m/^\s*EMAIL\s*=\s*(.*)\s*$/) {
+ $addr = $1;
+ }
+ }
+ if (!($name && $addr)) {
+ die "Could not read .mklog settings.\n"
+ . $dot_mklog_format_msg;
+ }
+} else {
+ $name = `git config user.name`;
+ chomp($name);
+ $addr = `git config user.email`;
+ chomp($addr);
+
+ if (!($name && $addr)) {
+ die "Could not read git user.name and user.email settings.\n"
+ . "Please add missing git settings, or create a .mklog file in"
+ . " $ENV{HOME}.\n"
+ . $dot_mklog_format_msg;
+ }
+}
+
$gcc_root = $0;
$gcc_root =~ s/[^\\\/]+$/../;
-# if this is a git tree then take name and email from the git configuration
-if (-d "$gcc_root/.git") {
- $gitname = `git config user.name`;
- chomp($gitname);
- if ($gitname) {
- $name = $gitname;
- }
-
- $gitaddr = `git config user.email`;
- chomp($gitaddr);
- if ($gitaddr) {
- $addr = $gitaddr;
- }
-}
-
#-----------------------------------------------------------------------------
# Program starts here. You should not need to edit anything below this
# line.
--
1.9.1