sh 复制Boilerplate并将其推送到新的Repo

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了sh 复制Boilerplate并将其推送到新的Repo相关的知识,希望对你有一定的参考价值。

#!/bin/bash

# To be able to use the script it must be made executable:
# chmod +x CopyBoilerplate.sh
#
# Call of the script:
# ~/CopyBoilerplate.sh

cloneInSameFolder=false

# Clone via SSH or HTTPS?
cloneType="HTTPS"

# Name of your Boilerplate (username/name)
BoilerplateRepo="jonnitto/Boilerplate"


yellowStyle="$(tput setaf 11)"
headlineStyle="$(tput bold)$(tput setaf 15)"
redStyle="$(tput setaf 9)"
greenStyle="$(tput setaf 10)"
resetStyle="$(tput sgr0)"


prompt() {
  echo
  echo $1
  echo -n "» "
  read inputvalue
}


echoStatus() {
  echo
  echo
  echo "-----[" $1 "]-----"
  echo
}


echoError() {
  echo
  echo
  echo ${redStyle}$1${resetStyle}
  echo
}


exitInstall() {
  echo
  echo
  echoStatus "${yellowStyle}No actions were taken${resetStyle}"
  echo
  echo
  exit 1
}


testFolder() {
  if [ "$cloneInSameFolder" = true ] ; then
    if [ "$(ls -A)" ] ; then
      echoError "The current folder must be empty"
      exit 0
    fi
  fi
}


setRepoName() { Please specify the URL of the empty repository
  prompt "Please enter the URL of the ${yellowStyle}empty repository${resetStyle} (e. g. https://github.com/jonnitto/WebsiteCom)"
  case $inputvalue in
    exit|Exit|EXIT|abort|stop|ABORT|STOP) exitInstall ;;
    *)
      # String prüfen
      if echo "$inputvalue" | grep -q "\.git$" ; then
        echoError "Please specify the URL without .git"
        setRepoName
      elif echo "$inputvalue" | grep -q "\/$" ; then
        echoError "Please specify name without a slash (/) at the end"
        setRepoName
      elif echo "$inputvalue" | grep -q "^https:\/\/github\.com" ; then
        export REPO_URL=${inputvalue}
        export REPO_URL_PLAIN="${inputvalue/https:\/\/github.com\//}"
        export REPO_NAME="${REPO_URL_PLAIN#*\/}"
        if [ "$cloneInSameFolder" = true ] ; then
          export REPO_FOLDER="."
        else
          export REPO_FOLDER=$REPO_NAME
        fi
      else
        echoError "Please provide complete URL (including https://github.com)"
        setRepoName
      fi
    ;;
  esac
}


copyBoilerplate() {
  if [ "$cloneType" = "HTTPS" ] ; then
    git clone https://github.com/${BoilerplateRepo}.git ${REPO_FOLDER}
  elif [ "$cloneType" = "SSH" ] ; then
    git clone git@github.com:${BoilerplateRepo}.git ${REPO_FOLDER}
  fi
  cd ${REPO_FOLDER} && rm -rf .git
}


initGit() {
  git init
  if [ "$cloneType" = "HTTPS" ] ; then
    git remote add origin https://github.com/${REPO_URL_PLAIN}.git
  elif [ "$cloneType" = "SSH" ] ; then
    git remote add origin git@github.com:${REPO_URL_PLAIN}.git
  fi
  git fetch
  if [ "$(find .git/objects -type f)" ] ; then
    echoError "Please specify empty repository"
    if [ "$cloneInSameFolder" = true ] ; then
      rm -rf ..?* .[!.]* *
    else
      cd ..
      rm -rf ${REPO_FOLDER}
    fi
    exit 0
  else
    git add .
    git commit -m "TASK: Copy from Boilerplate"
    git push -u origin master
  fi
}


installComponents() {
  composer update
  yarn
}


cloneFeedback() {
  echo
  echo
  echo
  echoStatus "${greenStyle}Copy boilerplate with ${cloneType}${resetStyle}"
}


cloneActions() {
  clear
  testFolder
  cloneFeedback
  setRepoName
  copyBoilerplate
  initGit
  installComponents
}


cloneActions
exit 0

以上是关于sh 复制Boilerplate并将其推送到新的Repo的主要内容,如果未能解决你的问题,请参考以下文章

构建 docker-compose 镜像并将其推送到容器注册表中

python tar.gz一个目录并将其推送到Glacier。

我可以使用 AWS Glue 将 S3 上的 json 数据转换为列格式并将其推送到 Redshift 吗?

遍历一个数组,将每个项目添加到一个对象并将其推送到 Javascript 中的数组

我可以使用AWS Glue将S3上的json数据转换为柱状格式并将其推送到Redshift吗?

sh 构建Docker镜像,将其推送到AWS EC2 Container Registry,然后将其部署到AWS Elastic Beanstalk