shell

作者: 泥称已被栈用 | 来源:发表于2019-01-08 22:06 被阅读0次
  • 修改maven项目版本号
#!/usr/bin/env bash
if [[ $# != 1 ]]; then
    echo "usage: $0 [commit id]"
    exit 1
fi

mvn versions:set -DgenerateBackupPoms=false -DnewVersion=$1
exit 0
  • git简单提交
#!/usr/bin/env bash

# fetch and check commit message
# if then elif then else fi
if [[ $# != 1 ]]; then
    echo "please input commit message, usage: $0 [commit_message]."
    exit 1
else
    foo=$1
    foo_trim="$(echo -e "${foo}" | tr -d '[:space:]')"
    if [[ ! ${foo_trim} || ${foo_trim} == '' ]]; then
        echo "message cannot be empty, please specific commit message, your input ===>>> [${foo}]"
        exit 1
    fi
    echo "use commit message ===>>> [$1]."
fi

# get git info
current_branch=`git symbolic-ref --short HEAD`
remote_v=`git remote -v`

echo "current branch is ===>>> [${current_branch}]."
echo "try to check if current branch has exits on remote ===>>> ${remote_v}."

# check if branch has exist on remote
branch_exits=`git ls-remote --heads ${remote_v} ${current_branch}`
echo "check result ${branch_exits}."

if [[ ! ${branch_exits} || ${branch_exits} == '' ]]; then
    echo "current branch [${current_branch}] is not exists on remote."
    exit 1;
fi

commit_data=`git status --porcelain`
if [[ ! ${commit_data} || ${commit_data} == '' ]]; then
    echo "current branch [${current_branch}], nothing to commit, working tree clean."
    exit 1;
else
    echo "commit data:"
    echo ${commit_data}
fi

# go push D:
git add .
git commit -m "$1"
git push

exit 0

相关文章

  • Shell 学习

    shell 变量 shell 参数传递 shell 数组 shell 运算符 shell echo 命令 prin...

  • Shell 概述

    学习 Shell 主要包括的内容: Shell 脚本入门 Shell 变量 Shell 内置命令 Shell 运算...

  • Shell 教程

    Shell 变量 Shell 传递参数 Shell 数组 Shell 基本运算符 Shell echo 命令 Sh...

  • shell 第一天

    shell编程初识 1.1 shell编程初识 shell的定义 Shell 是命令解释器 Shell 也是...

  • shell 案例

    Shell编程一 Shell防范ARP攻击 Shell编程二 Shell防范DDos攻击 Shell编程三 ...

  • 【生物信息笔记】shell 脚本 (dry-2)

    shell 和 shell script(脚本)区别: shell 和 shell 脚本是两个不同概念,shell...

  • Linux Shell:基础知识和Shell变量

    摘要:Linux,Shell 整理Shell内容要点: Shell基础知识 Shell变量的类型 Shell变量赋...

  • Shell脚本语言一

    一、语法 格式 运行 Shell变量 Shell字符串 Shell数组 Shell注释 Shell传递参数 She...

  • 使用shell脚本

    使用方式 shell 变量 shell 字符串操作 shell 数组 shell 注释 shell 命令行参数 s...

  • vim学习 09——shell命令

    vim学习 09——shell命令 执行 shell 命令 :!shell命令 : 可以执行 shell 命令。 ...

网友评论

      本文标题:shell

      本文链接:https://www.haomeiwen.com/subject/jklirqtx.html