Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Allow ranges for benchable and committable in addition to lists of co…
…mmits (#8)

* Allow ranges for benchable and committable in addition to lists of commits
* Make sure the range isn't too big
  • Loading branch information
MasterDuke17 committed Jul 14, 2016
1 parent fb89156 commit 8e71350
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 5 deletions.
26 changes: 23 additions & 3 deletions benchable.pl
Expand Up @@ -35,8 +35,28 @@ sub process_message {
my $msg_response = '';

if ($body =~ /^ \s* (\S+) \s+ (.+) /xu) {
my @commits = split(',', $1);
my $code = $2;
my ($config, $code) = ($1, $2);

my @commits;
if ($config =~ /,/) {
@commits = split(',', $config);
} elsif ($config =~ /^ (\S+) \.\. (\S+) $/x) {
my ($start, $end) = ($1, $2);

my $old_dir = cwd();
chdir $self->RAKUDO;
return "Bad start" if system('git', 'rev-parse', '--verify', $start) != 0;
return "Bad end" if system('git', 'rev-parse', '--verify', $end) != 0;

my ($result, $exit_status, $time) = $self->get_output('git', 'rev-list', "$start^..$end");
chdir $old_dir;

return "Couldn't find anything in the range" if $exit_status != 0;

@commits = split("\n", $result);
my $num_commits = scalar @commits;
return "Too many commits ($num_commits) in range, you're only allowed 5" if ($num_commits > 5);
}

my ($succeeded, $code_response) = $self->process_code($code, $message);
if ($succeeded) {
Expand Down Expand Up @@ -77,7 +97,7 @@ sub process_message {
}

sub help {
'Like this: ' . $name . ': f583f22,110704d my $a = "a" x 2**16;for ^100000 {my $b = $a.chop($_)}'
'Like this: ' . $name . ': f583f22,110704d my $a = "a" x 2**16;for ^1000 {my $b = $a.chop($_)}'
}

Benchable->new(
Expand Down
24 changes: 22 additions & 2 deletions committable.pl
Expand Up @@ -34,8 +34,28 @@ sub process_message {
my $msg_response = '';

if ($body =~ /^ \s* (\S+) \s+ (.+) /xu) {
my @commits = split(',', $1);
my $code = $2;
my ($config, $code) = ($1, $2);

my @commits;
if ($config =~ /,/) {
@commits = split(',', $config);
} elsif ($config =~ /^ (\S+) \.\. (\S+) $/x) {
my ($start, $end) = ($1, $2);

my $old_dir = cwd();
chdir $self->RAKUDO;
return "Bad start" if system('git', 'rev-parse', '--verify', $start) != 0;
return "Bad end" if system('git', 'rev-parse', '--verify', $end) != 0;

my ($result, $exit_status, $time) = $self->get_output('git', 'rev-list', "$start^..$end");
chdir $old_dir;

return "Couldn't find anything in the range" if $exit_status != 0;

@commits = split("\n", $result);
my $num_commits = scalar @commits;
return "Too many commits ($num_commits) in range, you're only allowed 10" if ($num_commits > 10);
}

my ($succeeded, $code_response) = $self->process_code($code, $message);
if ($succeeded) {
Expand Down

0 comments on commit 8e71350

Please sign in to comment.