小编Fre*_*die的帖子

Bash/Shell脚本函数验证Git标记或提交存在并已被推送到远程存储库

我想在那里得到这个问题,看看我是否做得对.以下脚本工作,除了检查提交是否已被推送到远程仓库,我找不到正确的命令:

#!/bin/bash
set -e  # fail on first error    
verify_git_ref() {
        log "Verifying git tag or commit: \"$1\" ...."
        if git show-ref --tags --quiet --verify -- "refs/tags/$1"
        then
            log_success "Git tag \"$1\" verified...."
            GIT_TAG_OR_REF=$1
            return 0
        elif git rev-list $1>/dev/null 2>&1
        then
            log_success "Git commit \"$1\" verified...."
            GIT_TAG_OR_REF=$1
            return 0
        else
            log_error "\"$1\" is not a valid tag or commit, you must use a valid tag or commit in order for this script to continue"
            return 1
        fi …
Run Code Online (Sandbox Code Playgroud)

git bash

7
推荐指数
1
解决办法
7304
查看次数

标签 统计

bash ×1

git ×1