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 :: wp php get product attribute name without pa 
Php :: how to fetch data from two tables in mysqli using php 
Php :: how to use php in a project on localhost 
Php :: Comment exiger une longueur minimale de commentaire dans WordPress 
Php :: how to set tinyint default 0 laravel migration 
Php :: laravel request 
Php :: obtener tipo 
Php :: Attempt to read property "headers" on string 
Php :: how to change phpto size in its properties ubuntu 
Php :: update php 7.2 centos 8 command line without sudo 
Php :: $n = readline(); for($i = 0; $i < $n ; $i++) { $name = readline(); $names[$name] = (isset($names[$name]) ? $names[$name] + 1 : 1); } 
Php :: Input sanitization to prevent XSS 
Php :: asymmetric encryption in php 
Php :: Agregar clases de rol al body en WordPress 
Php :: laravel how to read app/config/app.php debug variable 
Php :: set php variabe with javascript loca storage 
Php :: how to get name through id from mysql using php 
Php :: omnipay capture 
Php :: phpmailer 5 string attachment 
Php :: bitnami wp user pass change 
Php :: Deactivate click events on product card image, title and contents 
Php :: how to convert php code to html 
Php :: import csv in laravel 8 
Php :: PhpDebugBar is not defined nginx 
Php :: skäller västgötaspetsar 
Php :: wordpress add menu frontend 
Php :: br2nl 
Php :: undefined array key php 
Php :: Drupal 9 how to pass arguments to custom blocks 
Php :: php include inside function global 
ADD CONTENT
Topic
Content
Source link
Name
4+9 =