Search
 
SCRIPT & CODE EXAMPLE
 

PHP

get git branch by php

/**
 * @filename: currentgitbranch.php
 * @usage: Include this file after the '<body>' tag in your project
 * @author Kevin Ridgway 
 */
    $stringfromfile = file('.git/HEAD', FILE_USE_INCLUDE_PATH);

    $firstLine = $stringfromfile[0]; //get the string from the array

    $explodedstring = explode("/", $firstLine, 3); //seperate out by the "/" in the string

    $branchname = $explodedstring[2]; //get the one that is always the branch name

    echo "<div style='clear: both; width: 100%; font-size: 14px; font-family: Helvetica; color: #30121d; background: #bcbf77; padding: 20px; text-align: center;'>Current branch: <span style='color:#fff; font-weight: bold; text-transform: uppercase;'>" . $branchname . "</span></div>"; //show it on the page
Comment

get git branch with php

function get_current_git_branch(){
    $fname = sprintf( '.git/HEAD' );
    $data = file_get_contents($fname);   
    $ar  = explode( "/", $data );
    $ar = array_reverse($ar);
    return  trim ("" . @$ar[0]) ;
}

function get_current_git_datetime( $branch='master' ) {
      $fname = sprintf( '.git/refs/heads/%s', $branch );
      $time = filemtime($fname);
      if($time != 0 ){
          return date("Y-m-d H:i:s", $time);
        }else{
            return  "time=0";
      }
}
Comment

PREVIOUS NEXT
Code Example
Php :: debian install php 
Php :: php dies while parsing json 
Php :: php while jump to next loop 
Php :: laravel Form::hidden 
Php :: function default value 
Php :: wordpress use jquery in plugin 
Php :: Woocommerce get image galleries by product id 
Php :: laravel 6 make http request 
Php :: PHP | Send Attachment With Email 
Php :: call to a member function get_results() on null 
Php :: php if time is greater than 
Php :: woocommerce order status change 
Php :: toastr in php 
Php :: is null php 
Php :: switch between php version ubuntu 
Php :: array_merge in php 
Php :: how to set optional third parameter in routes of codeigniter 
Php :: carbon if date is today 
Php :: php iterate through a loop 
Php :: return redirect to extranal url in laravel 
Php :: Write a php program to print hello world 
Php :: php aes 
Php :: arc cosine php 
Php :: php recortar string 
Php :: php epoch conversion 
Php :: error pdo php Exception 
Php :: multe data on database laravel 
Php :: laravel model where in 
Php :: get woocommerce my account page url 
Php :: laravel unique id 
ADD CONTENT
Topic
Content
Source link
Name
1+1 =