Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Move commit shortening into a shared function (only implemented in Be…
…nchable and Committable for now)
  • Loading branch information
MasterDuke17 committed Aug 28, 2016
1 parent fbf968b commit f649e15
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
6 changes: 3 additions & 3 deletions Benchable.p6
Expand Up @@ -143,7 +143,7 @@ method process($message, $config, $code is copy) {
for @commits -> $commit {
# convert to real ids so we can look up the builds
my $full-commit = self.to-full-commit($commit);
my $short-commit = $commit.substr(0, 7);
my $short-commit = self.get-short-commit($commit);
if not defined $full-commit {
%times{$short-commit}<err> = Cannot find this revision;
} elsif not self.build-exists($full-commit) {
Expand Down Expand Up @@ -178,7 +178,7 @@ Z: loop (my int $x = 0; $x < @commits - 1; $x++) {
if abs(%times{@commits[$x]}<min> - %times{@commits[$x + 1]}<min>) >= %times{@commits[$x]}<min>*0.1 {
my ($new-commit, $exit-status, $exit-signal, $time) = self.get-output('git', 'rev-list', '--bisect', '--no-merges', @commits[$x] ~ '^..' ~ @commits[$x + 1]);
if $exit-status == 0 and $new-commit.defined and $new-commit ne '' {
my $short-commit = $new-commit.substr(0, 7);
my $short-commit = self.get-short-commit($new-commit);
if not self.build-exists($new-commit) {
%times{$short-commit}<err> = No build for this commit;
} elsif %times{$short-commit}:!exists and $short-commit ne @commits[$x] and $short-commit ne @commits[$x + 1] { # actually run the code
Expand All @@ -191,7 +191,7 @@ Z: loop (my int $x = 0; $x < @commits - 1; $x++) {
}
}

@commits .= map(*.substr(0, 7));
@commits .= map({ self.get-short-commit($_) });

if @commits >= ITERATIONS {
my $pfilename = 'plot.svg';
Expand Down
2 changes: 1 addition & 1 deletion Committable.p6
Expand Up @@ -88,7 +88,7 @@ method process($message, $config, $code is copy) {
$output ~= «exit signal = {Signal($signal)} ($signal if $signal != 0;
}
}
my $short-commit = $commit.substr(0, 7);
my $short-commit = self.get-short-commit($commit);

# Code below keeps results in order. Example state:
# @result = [ { commits => [‘A’, ‘B’], output => ‘42‘ },
Expand Down
4 changes: 4 additions & 0 deletions Whateverable.pm6
Expand Up @@ -77,6 +77,10 @@ multi method irc-privmsg-me($msg) {

method help($message) { See {SOURCE} } # override this in your bot

method get-short-commit($original-commit) {
$original-commit ~~ /^ <xdigit> ** 7..40 $/ ?? $original-commit.substr(0, 7) !! $original-commit;
}

method get-output(*@run-args, :$timeout = $!timeout, :$stdin) {
my $out = Channel.new; # TODO switch to some Proc :merge thing once it is implemented
my $proc = Proc::Async.new(|@run-args, :w(defined $stdin));
Expand Down

0 comments on commit f649e15

Please sign in to comment.