我想在我的网站上显示git版本 [英] i want to display the git version on my site

查看:110
本文介绍了我想在我的网站上显示git版本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在我的网站上显示git版本号。



我发现它是一个提交哈希,并且不适合非技术用户参考。

我已经创建了这个类来显示当前脚本本地git的版本号。

解决方案

Gist: https://gist.github.com/ lukeoliff / 5501074

 <?php 

类QuickGit {

public static function version(){
exec('git describe --always',$ version_mini_hash);
exec('git rev-list HEAD | wc -l',$ version_number);
exec('git log -1',$ line);
$ version ['short'] =v1。。trim($ version_number [0])。。。$ version_mini_hash [0]; $'$'$ ='v1。。trim($ version_number [0])。。$ version_mini_hash [0](.str_replace('commit','',$ line [0] ) )。
返回$ version;
}

}


I want to display the git version number on my site.

I found that it was a commit hash and this wasn't suitable for non-technical users to reference.

I have created this class to display the version 'number' of the current git local to this script.

解决方案

Gist: https://gist.github.com/lukeoliff/5501074

<?php

class QuickGit {

  public static function version() {
    exec('git describe --always',$version_mini_hash);
    exec('git rev-list HEAD | wc -l',$version_number);
    exec('git log -1',$line);
    $version['short'] = "v1.".trim($version_number[0]).".".$version_mini_hash[0];
    $version['full'] = "v1.".trim($version_number[0]).".$version_mini_hash[0] (".str_replace('commit ','',$line[0]).")";
    return $version;
  }

}

这篇关于我想在我的网站上显示git版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆