Making WordPress.org


Ignore:
Timestamp:
02/02/2019 01:57:09 PM (6 years ago)
Author:
ocean90
Message:

Slack: Include author and timestamp in commit notifications.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/common/includes/slack/trac/commit-handler.php

    r8180 r8181  
    3636
    3737    protected function generate_payload() {
    38         $author = $this->svnlook( 'author' );
    39         $log = Commit::format_commit_for_slack( $this->trac, $this->svnlook( 'log' ) );
    40 
    41         $url = $this->trac->get_commit_template( $this->rev );
     38        $author   = $this->svnlook( 'author' );
     39        $log      = Commit::format_commit_for_slack( $this->trac, $this->svnlook( 'log' ) );
     40        $date     = $this->svnlook( 'date' );
     41        $url      = $this->trac->get_commit_template( $this->rev );
    4242        $revision = 'r' . $this->rev;
    43 
    4443        $username = $this->trac->get_commit_username();
    4544        $icon     = $this->trac->get_icon();
    4645        $color    = $this->trac->get_color();
    4746
     47        $title    = "$username $revision";
    4848        $text     = "*$username <$url|$revision> by $author*\n$log";
    4949        $fallback = "$username $revision by $author";
     
    5252        $this->send->set_icon( $icon );
    5353        $this->send->add_attachment( array(
    54             'color'     => $color,
    55             'text'      => $text,
    56             'fallback'  => $fallback,
    57             'mrkdwn_in' => array( 'text' ),
     54            'title'       => $title,
     55            'title_link'  => $url,
     56            'author_name' => $author,
     57            'author_icon' => sprintf( 'https://wordpress.org/grav-redirect.php?user=%s&s=32', $author ),
     58            'color'       => $color,
     59            'text'        => $text,
     60            'fallback'    => $fallback,
     61            'mrkdwn_in'   => array( 'text' ),
     62            'ts'          => $date,
     63            'footer'      => sprintf( '<%s|%s>', $this->trac->get_url(), $this->trac->get_name() ),
     64            'footer_icon' => sprintf( '%s/chrome/common/trac.ico', $this->trac->get_url() ),
    5865        ) );
    5966    }
     
    7279        }
    7380
     81        if ( $subcommand === 'date' ) {
     82            // Convert output to timestamp.
     83            $command = 'date --date "$( ' . $command . ' )" +%s';
     84        }
     85
    7486        exec( $command, $output, $return_var );
    7587        if ( $return_var === 0 ) {
Note: See TracChangeset for help on using the changeset viewer.