Trying to grab git info about a WordPress theme from within a plugin

Creating a WordPress plugin that will retrieve the commit info from select plugins and themes for development purposes. The goal is to have that info be copied to the clipboard once a button is clicked from the admin toolbar.

The issue I am having is grabbing the git info. I have tried getting data with exec('git rev-parse --short HEAD') but have not had any luck. Of course running git rev-parse --short HEAD from within the plugin will only show that plugins info.

Read More

Am I going about this wrong? Thanks in advanced.

Related posts

1 comment

  1. As shown in this build script, you need to make sure you are in the right folder:

    //Time to set the Build Date and Revision.
    $date = date( 'Y-m-d' );
    $revision = '';
    if ( file_exists( dirname( __FILE__ ) . '/.git/HEAD' ) ) {
        $revision = trim( exec( 'git rev-parse --short HEAD' ) );
        $out_contents = preg_replace( '#$wpqi_version = '([^']+)';#', '$wpqi_version = '$1-' . $revision . '';', $out_contents );
    }
    $out_contents = str_replace( '/*BuildDate*/', $date, $out_contents );
    

Comments are closed.