Pop-up dictionary browser extension for language learning. Successor to Yomichan. (PERSONAL FORK)
at lambda-fork/main 61 lines 1.6 kB view raw
1#!/usr/bin/env bash 2# bash script which tags the current commit with a calver version 3# and pushes the tag to the remote repository 4 5# Define color codes 6RED='\033[0;31m' 7GREEN='\033[0;32m' 8YELLOW='\033[1;33m' 9NC='\033[0m' # No Color 10 11if [[ $(git branch --show-current) != "master" ]]; then 12 echo -e "${RED}Please only tag commits on master branch.${NC}" 13 exit 1 14fi 15 16echo -e "${YELLOW}Checking if branch is up to date...${NC}" 17 18changed=0 19git remote update origin && git status -uno | grep -q 'Your branch is behind' && changed=1 20if [ $changed = 1 ]; then 21 echo -e "${RED}Please git pull before tagging.${NC}" 22 exit 1 23fi 24 25# Ask user to confirm the commit and the tag name 26echo -e "${YELLOW}Current HEAD of master branch:${NC}" 27git log -1 --decorate 28echo 29 30# get the current date in the format YY.MM.DD 31DATE=$(date +%y.%-m.%-d) 32 33# Check if the tag already exists and increment if necessary 34COUNTER=0 35TAG=$DATE.$COUNTER 36while git rev-parse "$TAG" >/dev/null 2>&1; do 37 # Increment the counter and recreate TAG with DATE 38 echo -e "${YELLOW}Tag $TAG already exists, incrementing.${NC}" 39 COUNTER=$((COUNTER + 1)) 40 TAG="$DATE.$COUNTER" 41done 42echo 43echo -e -n "${YELLOW}Tagging current HEAD of master with tag ${TAG}. Are you sure? (y/n): ${NC}" 44read -p "" -n 1 -r 45echo 46if [[ ! $REPLY =~ ^[Yy]$ ]]; then 47 echo -e "${RED}Tagging aborted.${NC}" 48 exit 1 49fi 50 51git tag -s $TAG 52 53echo -e -n "${YELLOW}Do you want to push the tag ${TAG} to the remote repository (which will cause a pre-release to get created)? (y/n): ${NC}" 54read -p "" -n 1 -r 55echo 56if [[ ! $REPLY =~ ^[Yy]$ ]]; then 57 echo -e "${RED}Push aborted.${NC}" 58 exit 1 59fi 60 61git push origin $TAG