Is it possible to add a version number using git / github

前端 未结 5 1354
逝去的感伤
逝去的感伤 2020-12-08 20:04

I\'m using Github, and realized they have a nice little api for accessing repo information like commits, who did it, etc.

This would be a great way to show previous

5条回答
  •  温柔的废话
    2020-12-08 20:53

    I'm using this:

    function git_func {
        GITBIN=/usr/bin/git
        if [[ $1 == "commit" ]] && [[ "$#" -ne 1 ]]
        then
            GIT_VERSION=`$GITBIN rev-list HEAD | wc -l`
            let GIT_VERSION+=1
            perl -e "s/(\d+\.\d+\.)\d+/\${1}$GIT_VERSION/;" -pi.save config.json
            rm config.json.save
        fi
    
        GITCMD="$GITBIN "
        for var in "$@"
        do
            GITCMD="$GITCMD \"$var\""
        done
        eval $GITCMD
    }
    
    
    alias git='git_func'
    

    config.json contains this:

    "version": "0.1.44" 
    

提交回复
热议问题