Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit901a5a7

Browse files
committed
Minor improvements to git_changelog.
Avoid depending on Date::Calc, which isn't in a basic Perl installation,when we can equally well use Time::Local which is. Also fix the parsingof timestamps to take heed of the timezone. (It looks like cvs2git emittedall commit timestamps with zone GMT, so this refinement might've lookedunnecessary when looking at converted data; but it's needed now.)Fix parsing of message bodies so that blank lines that may or may not getemitted by "git log" aren't confused with real data. This avoids strangeformatting of the oldest commit on a branch.Check child-process exit status, so that we actually notice if "git log"fails, and so that we don't accumulate zombie children.
1 parentce1dcd4 commit901a5a7

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

‎src/tools/git_changelog

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727

2828
use strict;
2929
use warnings;
30-
requireDate::Calc;
30+
requireTime::Local;
3131
require Getopt::Long;
3232
require IPC::Open2;
3333

@@ -51,8 +51,9 @@ my %all_commits_by_branch;
5151
my%commit;
5252
formy$branch (@BRANCHES) {
5353
my$commitnum = 0;
54-
IPC::Open2::open2(my$git_out,my$git_in,@git,"origin/$branch")
55-
||die"can't run@git origin/$branch:$!";
54+
my$pid =
55+
IPC::Open2::open2(my$git_out,my$git_in,@git,"origin/$branch")
56+
||die"can't run@git origin/$branch:$!";
5657
while (my$line = <$git_out>) {
5758
if ($line =~/^commit\s+(.*)/) {
5859
push_commit(\%commit)if%commit;
@@ -69,16 +70,20 @@ for my $branch (@BRANCHES) {
6970
elsif ($line =~/^Date:\s+(.*)/) {
7071
$commit{'date'} =$1;
7172
}
72-
elsif ($line =~/^\s+/) {
73+
elsif ($line =~/^\s\s/) {
7374
$commit{'message'} .=$line;
7475
}
7576
}
77+
waitpid($pid, 0);
78+
my$child_exit_status =$? >> 8;
79+
die"@git origin/$branch failed"if$child_exit_status != 0;
7680
}
7781

7882
my%position;
7983
formy$branch (@BRANCHES) {
8084
$position{$branch} = 0;
8185
}
86+
8287
while (1) {
8388
my$best_branch;
8489
my$best_inversions;
@@ -103,7 +108,9 @@ while (1) {
103108
print$winner->{'header'};
104109
print"Commit-Order-Inversions:$best_inversions\n"
105110
if$best_inversions != 0;
111+
print"\n";
106112
print$winner->{'message'};
113+
print"\n";
107114
$winner->{'done'} = 1;
108115
formy$branch (@BRANCHES) {
109116
my$leader =$all_commits_by_branch{$branch}->[$position{$branch}];
@@ -149,8 +156,11 @@ sub hash_commit {
149156

150157
subparse_datetime {
151158
my ($dt) =@_;
152-
$dt =~/^(\d\d\d\d)-(\d\d)-(\d\d)\s+(\d\d):(\d\d):(\d\d)/;
153-
return Date::Calc::Mktime($1,$2,$3,$4,$5,$6);
159+
$dt =~/^(\d\d\d\d)-(\d\d)-(\d\d)\s+(\d\d):(\d\d):(\d\d)\s+([-+])(\d\d)(\d\d)$/;
160+
my$gm = Time::Local::timegm($6,$5,$4,$3,$2-1,$1);
161+
my$tzoffset = ($8 * 60 +$9) * 60;
162+
$tzoffset = -$tzoffsetif$7eq'-';
163+
return$gm -$tzoffset;
154164
}
155165

156166
subusage {

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp