Skip to content
Snippets Groups Projects
Verified Commit d298edec authored by Volker Schukai's avatar Volker Schukai :alien:
Browse files

fix: test gorelease

parent 9aeb0c55
No related branches found
No related tags found
No related merge requests found
...@@ -225,7 +225,7 @@ builds: ...@@ -225,7 +225,7 @@ builds:
]; ];
scripts.tag-version.exec = '' scripts.tag-version.exec = ''
!#${pkgs.bash}/bin/bash #!${pkgs.bash}/bin/bash
set -x set -x
${pkgs.git}/bin/git config user.email "''${GITLAB_USER_EMAIL}" ${pkgs.git}/bin/git config user.email "''${GITLAB_USER_EMAIL}"
${pkgs.git}/bin/git config user.name "''${GITLAB_USER_NAME:-"Gitlab CI"}" ${pkgs.git}/bin/git config user.name "''${GITLAB_USER_NAME:-"Gitlab CI"}"
...@@ -242,7 +242,7 @@ builds: ...@@ -242,7 +242,7 @@ builds:
''; '';
scripts.update-files.exec = '' scripts.update-files.exec = ''
!#${pkgs.bash}/bin/bash #!${pkgs.bash}/bin/bash
update_symlink() { update_symlink() {
local source_path="$1" local source_path="$1"
local target_path="$2" local target_path="$2"
...@@ -282,7 +282,6 @@ builds: ...@@ -282,7 +282,6 @@ builds:
scripts.build-app.exec = '' scripts.build-app.exec = ''
#!${pkgs.bash}/bin/bash #!${pkgs.bash}/bin/bash
${pkgs.nix}/bin/nix build .#version ${pkgs.nix}/bin/nix build .#version
''; '';
...@@ -330,431 +329,431 @@ ${pkgs.nix}/bin/nix build .#version ...@@ -330,431 +329,431 @@ ${pkgs.nix}/bin/nix build .#version
# #
# #
#''; #'';
#
# This scritp is used to deploy the app to the gitlab registry # # This scritp is used to deploy the app to the gitlab registry
# It is used by the gitlab-ci.yml file # # It is used by the gitlab-ci.yml file
# The environment variables are set in the gitlab project settings # # The environment variables are set in the gitlab project settings
scripts.deploy-app.exec = '' # scripts.deploy-app.exec = ''
#!${pkgs.bash}/bin/bash ##!${pkgs.bash}/bin/bash
#
PATH="''${PATH}":${pkgs.coreutils}/bin #PATH="''${PATH}":${pkgs.coreutils}/bin
PATH="''${PATH}":${pkgs.jq}/bin/ #PATH="''${PATH}":${pkgs.jq}/bin/
PATH="''${PATH}":${pkgs.curl}/bin/ #PATH="''${PATH}":${pkgs.curl}/bin/
PATH="''${PATH}":${pkgs.moreutils}/bin/ #PATH="''${PATH}":${pkgs.moreutils}/bin/
PATH="''${PATH}":${pkgs.gnutar}/bin #PATH="''${PATH}":${pkgs.gnutar}/bin
PATH="''${PATH}":${pkgs.gzip}/bin/ #PATH="''${PATH}":${pkgs.gzip}/bin/
PATH="''${PATH}":${pkgs.eza}/bin/ #PATH="''${PATH}":${pkgs.eza}/bin/
PATH="''${PATH}":${pkgs.git}/bin/ #PATH="''${PATH}":${pkgs.git}/bin/
PATH="''${PATH}":${inputs.version.defaultPackage."${builtins.currentSystem}"}/bin/ #PATH="''${PATH}":${inputs.version.defaultPackage."${builtins.currentSystem}"}/bin/
#
export -f PATH #export -f PATH
#
if [[ -f .env-gitlab-ci ]]; then #if [[ -f .env-gitlab-ci ]]; then
source .env-gitlab-ci # source .env-gitlab-ci
rm .env-gitlab-ci # rm .env-gitlab-ci
fi #fi
#
set -x #set -x
## if $HOME not set, set it to current directory ### if $HOME not set, set it to current directory
if [[ -z "''${HOME}" ]]; then #if [[ -z "''${HOME}" ]]; then
HOME=$(pwd) # HOME=$(pwd)
fi #fi
#
export HOME #export HOME
#
git config user.email "''${GITLAB_USER_EMAIL}" #git config user.email "''${GITLAB_USER_EMAIL}"
git config user.name "''${GITLAB_USER_NAME:-"Gitlab CI"}" #git config user.name "''${GITLAB_USER_NAME:-"Gitlab CI"}"
git config pull.rebase true #git config pull.rebase true
git config http.sslVerify "false" #git config http.sslVerify "false"
git remote set-url origin https://pad:''${GITLAB_TOKEN}@''${CI_REPOSITORY_URL#*@} #git remote set-url origin https://pad:''${GITLAB_TOKEN}@''${CI_REPOSITORY_URL#*@}
#
git fetch --all --tags --unshallow #git fetch --all --tags --unshallow
git reset --hard origin/master #git reset --hard origin/master
git checkout $CI_COMMIT_REF_NAME #git checkout $CI_COMMIT_REF_NAME
git pull origin $CI_COMMIT_REF_NAME #git pull origin $CI_COMMIT_REF_NAME
#
#
if [ ! -z "''${CI_PROJECT_DIR}" ]; then #if [ ! -z "''${CI_PROJECT_DIR}" ]; then
echo "CI_PROJECT_DIR is set, using it as project root." # echo "CI_PROJECT_DIR is set, using it as project root."
project_root=$(realpath "''${CI_PROJECT_DIR}")/ # project_root=$(realpath "''${CI_PROJECT_DIR}")/
elif [ ! -z "''${DEVENV_ROOT}" ]; then #elif [ ! -z "''${DEVENV_ROOT}" ]; then
echo "DEVENV_ROOT is set, using it as project root." # echo "DEVENV_ROOT is set, using it as project root."
project_root=$(realpath "''${DEVENV_ROOT}")/ # project_root=$(realpath "''${DEVENV_ROOT}")/
else #else
echo "Error: DEVENV_ROOT or CI_PROJECT_DIR environment variables are not set." # echo "Error: DEVENV_ROOT or CI_PROJECT_DIR environment variables are not set."
exit 1 # exit 1
fi #fi
#
if [ ! -d "''${project_root}" ]; then #if [ ! -d "''${project_root}" ]; then
echo "Error: Project root directory does not seem to be valid." # echo "Error: Project root directory does not seem to be valid."
echo "Check the DEVENV_ROOT or CI_PROJECT_DIR environment variables." # echo "Check the DEVENV_ROOT or CI_PROJECT_DIR environment variables."
exit 1 # exit 1
fi #fi
#
if [ -z "'CI_JOB_TOKEN" ]; then #if [ -z "'CI_JOB_TOKEN" ]; then
echo "Error: CI_JOB_TOKEN variable is not set." # echo "Error: CI_JOB_TOKEN variable is not set."
exit 1 # exit 1
fi #fi
#
git --no-pager log --decorate=short --pretty=oneline #git --no-pager log --decorate=short --pretty=oneline
#
## the version should be the same as in the build task ### the version should be the same as in the build task
if ! version auto --git --verbose --exit-code-if-no-bump #if ! version auto --git --verbose --exit-code-if-no-bump
then #then
echo "ERROR: Could not update version." # echo "ERROR: Could not update version."
exit 1 # exit 1
fi #fi
#
git --no-pager log --decorate=short --pretty=oneline #git --no-pager log --decorate=short --pretty=oneline
#
gitVersion=$(version print --git) #gitVersion=$(version print --git)
#
#
for file in $(eza "''${project_root}"dist/*); do #for file in $(eza "''${project_root}"dist/*); do
filname=$(basename ''${file}) # filname=$(basename ''${file})
curl -v --insecure -H "JOB-TOKEN: ''${CI_JOB_TOKEN}" --upload-file \ # curl -v --insecure -H "JOB-TOKEN: ''${CI_JOB_TOKEN}" --upload-file \
''${file} \ # ''${file} \
https://gitlab.schukai.com/api/v4/projects/''${CI_PROJECT_ID}/packages/generic/${config.env.APP_NAME}/''${gitVersion}/''${filname} # https://gitlab.schukai.com/api/v4/projects/''${CI_PROJECT_ID}/packages/generic/${config.env.APP_NAME}/''${gitVersion}/''${filname}
done #done
#
git push -o ci.skip origin ''${CI_COMMIT_REF_NAME} --tags #git push -o ci.skip origin ''${CI_COMMIT_REF_NAME} --tags
#
echo "done" #echo "done"
#
''; # '';
#
scripts.do-git-commit.exec = '' # scripts.do-git-commit.exec = ''
#!${pkgs.bash}/bin/bash # #!${pkgs.bash}/bin/bash
#
# Define colors if the terminal supports it # # Define colors if the terminal supports it
if [ -t 1 ]; then # if [ -t 1 ]; then
RED='\033[0;31m' # RED='\033[0;31m'
GREEN='\033[0;32m' # GREEN='\033[0;32m'
RESET='\033[0m' # RESET='\033[0m'
BOLD='\033[1m' # BOLD='\033[1m'
else # else
RED="" # RED=""
GREEN="" # GREEN=""
RESET="" # RESET=""
fi # fi
#
step=1 # step=1
#
reset # reset
clear # clear
#
# create random log file # # create random log file
LOGFILE="$(mktemp)" # LOGFILE="$(mktemp)"
if [ $? -ne 0 ]; then # if [ $? -ne 0 ]; then
echo -e "''${RED}✖ Could not create temporary log file. Exiting.''${RESET}" # echo -e "''${RED}✖ Could not create temporary log file. Exiting.''${RESET}"
exit 1 # exit 1
fi # fi
#
log_and_display() { # log_and_display() {
echo -e "''${GREEN}==> $step. $1''${RESET}" | tee -a $LOGFILE # echo -e "''${GREEN}==> $step. $1''${RESET}" | tee -a $LOGFILE
step=$((step + 1)) # step=$((step + 1))
} # }
#
log_error_and_display() { # log_error_and_display() {
echo -e "''${RED}==> $step. $1''${RESET}" | tee -a $LOGFILE # echo -e "''${RED}==> $step. $1''${RESET}" | tee -a $LOGFILE
} # }
#
printLogfileAndExit() { # printLogfileAndExit() {
exit_code=$1 # exit_code=$1
echo -e "\n\n========================================\n\n\n" # echo -e "\n\n========================================\n\n\n"
#
echo -e "\n\n''${BOLD}Git and GitLab Automation Script''${RESET}\n\nI have performed the following actions:\n\n" # echo -e "\n\n''${BOLD}Git and GitLab Automation Script''${RESET}\n\nI have performed the following actions:\n\n"
cat "$LOGFILE" # cat "$LOGFILE"
#
# Optional: Remove log file # # Optional: Remove log file
${pkgs.coreutils}/bin/rm -f "$LOGFILE" # ${pkgs.coreutils}/bin/rm -f "$LOGFILE"
#
if [ $exit_code -eq 0 ]; then # if [ $exit_code -eq 0 ]; then
echo -e "\n''${GREEN}✔''${RESET} All actions were successful" | tee -a $LOGFILE # echo -e "\n''${GREEN}✔''${RESET} All actions were successful" | tee -a $LOGFILE
elif [ $exit_code -eq -1 ]; then # elif [ $exit_code -eq -1 ]; then
echo -e "\n''${RED}✖''${RESET} The script was manually cancelled" | tee -a $LOGFILE # echo -e "\n''${RED}✖''${RESET} The script was manually cancelled" | tee -a $LOGFILE
exit_code=0 # exit_code=0
else # else
echo -e "\n''${RED}✖''${RESET} Some actions failed" | tee -a $LOGFILE # echo -e "\n''${RED}✖''${RESET} Some actions failed" | tee -a $LOGFILE
fi # fi
#
exit $exit_code # exit $exit_code
} # }
#
print_headline() { # print_headline() {
local title=$1 # local title=$1
local underline=$(printf '─%.0s' $(seq 1 ''${#title})) # local underline=$(printf '─%.0s' $(seq 1 ''${#title}))
echo -e "\n\n''${BOLD}''${title}\n''${underline}''${RESET}\n" # echo -e "\n\n''${BOLD}''${title}\n''${underline}''${RESET}\n"
} # }
#
do_cancel() { # do_cancel() {
echo -e "''${RED}==> ✖ Cancelled.''${RESET}" | tee -a $LOGFILE # echo -e "''${RED}==> ✖ Cancelled.''${RESET}" | tee -a $LOGFILE
printLogfileAndExit -1 # printLogfileAndExit -1
} # }
#
# Function for unified logging and display # # Function for unified logging and display
log_action() { # log_action() {
if [ $? -eq 0 ]; then # if [ $? -eq 0 ]; then
echo -e " ''${GREEN}✔''${RESET} $1: Successful" | tee -a $LOGFILE # echo -e " ''${GREEN}✔''${RESET} $1: Successful" | tee -a $LOGFILE
else # else
echo -e " ''${RED}✖''${RESET} $1: Failed" | tee -a $LOGFILE # echo -e " ''${RED}✖''${RESET} $1: Failed" | tee -a $LOGFILE
printLogfileAndExit 1 # printLogfileAndExit 1
fi # fi
} # }
#
print_what_to_do() { # print_what_to_do() {
echo -e "\n\nWhat do you want to do?\n" # echo -e "\n\nWhat do you want to do?\n"
} # }
#
git_status=$(git status --porcelain) # git_status=$(git status --porcelain)
if [[ -z "$git_status" ]]; then # if [[ -z "$git_status" ]]; then
log_error_and_display "No changes to commit. Exiting." # log_error_and_display "No changes to commit. Exiting."
printLogfileAndExit 0 # printLogfileAndExit 0
fi # fi
#
print_headline "Choose commit type" # print_headline "Choose commit type"
selection=$(gum choose "feat: (new feature for the user, not a new feature for build script)" "fix: (bug fix for the user, not a fix to a build script)" "chore: (updating grunt tasks etc.; no production code change)" "docs: (changes to the documentation)" "style: (formatting, missing semi colons, etc; no production code change)" "refactor: (refactoring production code, eg. renaming a variable)" "test: (adding missing tests, refactoring tests; no production code change)" "Cancel") # selection=$(gum choose "feat: (new feature for the user, not a new feature for build script)" "fix: (bug fix for the user, not a fix to a build script)" "chore: (updating grunt tasks etc.; no production code change)" "docs: (changes to the documentation)" "style: (formatting, missing semi colons, etc; no production code change)" "refactor: (refactoring production code, eg. renaming a variable)" "test: (adding missing tests, refactoring tests; no production code change)" "Cancel")
#
commit_type=$(echo "$selection" | awk -F':' '{print $1}') # commit_type=$(echo "$selection" | awk -F':' '{print $1}')
#
if [[ "$commit_type" == "Cancel" ]]; then # if [[ "$commit_type" == "Cancel" ]]; then
do_cancel # do_cancel
fi # fi
#
log_and_display "You chose the commit type: $commit_type" # log_and_display "You chose the commit type: $commit_type"
#
# NEXT STEP ISSUE HANDLING ############################################################################################################ # # NEXT STEP ISSUE HANDLING ############################################################################################################
#log_and_display "Issue handling" # #log_and_display "Issue handling"
#
gitlabIssues=() # gitlabIssues=()
while IFS= read -r line; do # while IFS= read -r line; do
if [[ $line =~ ^# ]]; then # if [[ $line =~ ^# ]]; then
id=$(echo "$line" | awk '{print substr($1, 2)}') # id=$(echo "$line" | awk '{print substr($1, 2)}')
title=$(echo "$line" | awk -F'about' '{print $1}' | awk '{$1=$2=""; print substr($0, 3)}') # title=$(echo "$line" | awk -F'about' '{print $1}' | awk '{$1=$2=""; print substr($0, 3)}')
gitlabIssues+=("$id > $title") # gitlabIssues+=("$id > $title")
fi # fi
done < <(gum spin --spinner dot --show-output --title "Ask gitlab ..." -- glab issue list --output-format=details) # done < <(gum spin --spinner dot --show-output --title "Ask gitlab ..." -- glab issue list --output-format=details)
#
## if issues are available, ask if user wants to use an existing issue or create a new one # ## if issues are available, ask if user wants to use an existing issue or create a new one
createOption="Create new issue" # createOption="Create new issue"
existingOption="Use existing issue" # existingOption="Use existing issue"
cancelOption="Cancel" # cancelOption="Cancel"
#
print_headline "Choose issue handling" # print_headline "Choose issue handling"
if [ ''${#gitlabIssues[@]} -eq 0 ]; then # if [ ''${#gitlabIssues[@]} -eq 0 ]; then
log_and_display "There are no issues available." # log_and_display "There are no issues available."
#
print_what_to_do # print_what_to_do
choice=$(gum choose "$createOption" "$cancelOption") # choice=$(gum choose "$createOption" "$cancelOption")
#
else # else
log_and_display "There are ''${#gitlabIssues[@]} issues available." # log_and_display "There are ''${#gitlabIssues[@]} issues available."
print_what_to_do # print_what_to_do
choice=$(gum choose "$createOption" "$existingOption" "$cancelOption") # choice=$(gum choose "$createOption" "$existingOption" "$cancelOption")
fi # fi
#
if [[ "$choice" == "$cancelOption" ]]; then # if [[ "$choice" == "$cancelOption" ]]; then
do_cancel # do_cancel
fi # fi
#
## array of issue ids # ## array of issue ids
work_on_issue_ids=() # work_on_issue_ids=()
#
issue_text="" # issue_text=""
#
if [[ "$choice" == "$createOption" ]]; then # if [[ "$choice" == "$createOption" ]]; then
print_headline "Create new issue" # print_headline "Create new issue"
issue_text=$(gum input --placeholder "Enter issue title") # issue_text=$(gum input --placeholder "Enter issue title")
echo -e "Enter issue description. ''${RED}End with Ctrl+D''${RESET}\n" # echo -e "Enter issue description. ''${RED}End with Ctrl+D''${RESET}\n"
issue_description=$(gum write --placeholder "Enter issue description. End with Ctrl+D") # issue_description=$(gum write --placeholder "Enter issue description. End with Ctrl+D")
#
if [[ -z "$issue_text" ]]; then # if [[ -z "$issue_text" ]]; then
log_error_and_display "Issue title is empty. Exiting." # log_error_and_display "Issue title is empty. Exiting."
printLogfileAndExit 1 # printLogfileAndExit 1
fi # fi
#
log_and_display "You entered the issue title: $issue_text" # log_and_display "You entered the issue title: $issue_text"
log_and_display "You entered the issue description: $issue_description" # log_and_display "You entered the issue description: $issue_description"
echo -e "\n" # echo -e "\n"
#
gum confirm "Do you want to create this issue?" # gum confirm "Do you want to create this issue?"
# gum confirm exits with status 0 if confirmed and status 1 if cancelled. # # gum confirm exits with status 0 if confirmed and status 1 if cancelled.
if [ $? -eq 1 ]; then # if [ $? -eq 1 ]; then
do_cancel # do_cancel
fi # fi
#
issue_output=$(glab issue create -t"$issue_text" --no-editor --description "$issue_description") # issue_output=$(glab issue create -t"$issue_text" --no-editor --description "$issue_description")
issue_id=$(echo "$issue_output" | grep -oP '(?<=/issues/)\d+') # issue_id=$(echo "$issue_output" | grep -oP '(?<=/issues/)\d+')
#
work_on_issue_ids+=("$issue_id") # work_on_issue_ids+=("$issue_id")
#
log_action "glab issue with id $issue_id created" # log_action "glab issue with id $issue_id created"
#
else # else
#
print_headline "Use existing issue" # print_headline "Use existing issue"
echo -e "Select issue with arrow keys and press tab or space to select. Press enter to confirm.\n" # echo -e "Select issue with arrow keys and press tab or space to select. Press enter to confirm.\n"
issue_ids=$(gum choose --no-limit "''${gitlabIssues[@]}") # issue_ids=$(gum choose --no-limit "''${gitlabIssues[@]}")
#
# assign issue_ids to work_on_issue_ids. iterate over lines and take integer from beginning of line # # assign issue_ids to work_on_issue_ids. iterate over lines and take integer from beginning of line
while IFS= read -r line; do # while IFS= read -r line; do
work_on_issue_ids+=($(echo "$line" | grep -oP '^\d+')) # work_on_issue_ids+=($(echo "$line" | grep -oP '^\d+'))
done <<<"$issue_ids" # done <<<"$issue_ids"
#
fi # fi
#
if [ ''${#work_on_issue_ids[@]} -eq 0 ]; then # if [ ''${#work_on_issue_ids[@]} -eq 0 ]; then
log_and_display "No issue selected. Exiting." # log_and_display "No issue selected. Exiting."
printLogfileAndExit 0 # printLogfileAndExit 0
fi # fi
#
# NEXT STEP COMMIT MESSAGE ############################################################################################################ # # NEXT STEP COMMIT MESSAGE ############################################################################################################
# print work_on_issue_ids # # print work_on_issue_ids
work_on_issue_ids_string="" # work_on_issue_ids_string=""
for i in "''${work_on_issue_ids[@]}"; do # for i in "''${work_on_issue_ids[@]}"; do
work_on_issue_ids_string+="#$i " # work_on_issue_ids_string+="#$i "
done # done
#
log_and_display "You chose to work on the following issues: ''${work_on_issue_ids_string}" # log_and_display "You chose to work on the following issues: ''${work_on_issue_ids_string}"
#
#
print_headline "Check for changes to commit" # print_headline "Check for changes to commit"
#
# ' ' = unmodified # # ' ' = unmodified
# M = modified # # M = modified
# T = file type changed (regular file, symbolic link or submodule) # # T = file type changed (regular file, symbolic link or submodule)
# A = added # # A = added
# D = deleted # # D = deleted
# R = renamed # # R = renamed
# C = copied (if config option status.renames is set to "copies") # # C = copied (if config option status.renames is set to "copies")
# U = updated but unmerged # # U = updated but unmerged
# https://man.freebsd.org/cgi/man.cgi?query=git-status&sektion=1&manpath=freebsd-release-ports # # https://man.freebsd.org/cgi/man.cgi?query=git-status&sektion=1&manpath=freebsd-release-ports
#
count_all_changes=$(echo "$git_status" | wc -l) # count_all_changes=$(echo "$git_status" | wc -l)
count_staged_changes=$(echo "$git_status" | grep -c '^M') # count_staged_changes=$(echo "$git_status" | grep -c '^M')
count_new_staged_files=$(echo "$git_status" | grep -c '^A') # count_new_staged_files=$(echo "$git_status" | grep -c '^A')
count_staged_changes=$((count_staged_changes + count_new_staged_files)) # count_staged_changes=$((count_staged_changes + count_new_staged_files))
#
git_options_all="All $count_all_changes changes" # git_options_all="All $count_all_changes changes"
git_options_staged="Only the $count_staged_changes staged changes" # git_options_staged="Only the $count_staged_changes staged changes"
git_options_select_files="Select files" # git_options_select_files="Select files"
git_options_cancel="Cancel" # git_options_cancel="Cancel"
#
git_options_array=() # git_options_array=()
if [[ $count_all_changes -gt 0 ]]; then # if [[ $count_all_changes -gt 0 ]]; then
git_options_array+=("$git_options_all") # git_options_array+=("$git_options_all")
fi # fi
#
if [[ $count_staged_changes -gt 0 ]]; then # if [[ $count_staged_changes -gt 0 ]]; then
git_options_array+=("$git_options_staged") # git_options_array+=("$git_options_staged")
fi # fi
#
git_options_array+=( "$git_options_select_files" ) # git_options_array+=( "$git_options_select_files" )
git_options_array+=( "$git_options_cancel" ) # git_options_array+=( "$git_options_cancel" )
#
#
selection=$(gum choose "''${git_options_array[@]}") # selection=$(gum choose "''${git_options_array[@]}")
if [[ "$selection" == "$git_options_cancel" ]]; then # if [[ "$selection" == "$git_options_cancel" ]]; then
do_cancel # do_cancel
fi # fi
#
if [[ "$selection" == "$git_options_all" ]]; then # if [[ "$selection" == "$git_options_all" ]]; then
git add -A # git add -A
echo "1" # echo "1"
elif [[ "$selection" == "$git_options_select_files" ]]; then # elif [[ "$selection" == "$git_options_select_files" ]]; then
#
files=() # files=()
while IFS= read -r line; do # while IFS= read -r line; do
files+=("$line") # files+=("$line")
done <<<"$git_status" # done <<<"$git_status"
#
selected_files=$(gum choose --no-limit "''${files[@]}") # selected_files=$(gum choose --no-limit "''${files[@]}")
#
# no files selected # # no files selected
if [[ -z "$selected_files" ]]; then # if [[ -z "$selected_files" ]]; then
log_and_display "No files selected. Exiting." # log_and_display "No files selected. Exiting."
printLogfileAndExit 0 # printLogfileAndExit 0
fi # fi
#
# add selected files # # add selected files
while IFS= read -r line; do # while IFS= read -r line; do
## git proclimne could have letter, ? or ! at the beginning of the line # ## git proclimne could have letter, ? or ! at the beginning of the line
file=$(echo "$line" | awk '{print $2}') # file=$(echo "$line" | awk '{print $2}')
if [[ -z "$file" || ! -f "$file" ]]; then # if [[ -z "$file" || ! -f "$file" ]]; then
log_and_display "No file found in line: $line" # log_and_display "No file found in line: $line"
continue # continue
fi # fi
#
git add "$file" # git add "$file"
done <<<"$selected_files" # done <<<"$selected_files"
#
fi # fi
#
## count staged changes again and print # ## count staged changes again and print
count_staged_changes=$(echo "$git_status" | grep -c '^M') # count_staged_changes=$(echo "$git_status" | grep -c '^M')
count_new_staged_files=$(echo "$git_status" | grep -c '^A') # count_new_staged_files=$(echo "$git_status" | grep -c '^A')
count_staged_changes=$((count_staged_changes + count_new_staged_files)) # count_staged_changes=$((count_staged_changes + count_new_staged_files))
#
log_and_display "You have $count_staged_changes staged changes to commit." # log_and_display "You have $count_staged_changes staged changes to commit."
#
# NEXT STEP COMMIT MESSAGE ############################################################################################################ # # NEXT STEP COMMIT MESSAGE ############################################################################################################
#
print_headline "Enter commit message" # print_headline "Enter commit message"
commit_message=$(gum input --placeholder "Enter commit message" --value "$commit_type: $issue_text $work_on_issue_ids_string") # commit_message=$(gum input --placeholder "Enter commit message" --value "$commit_type: $issue_text $work_on_issue_ids_string")
#
if [[ -z "$commit_message" ]]; then # if [[ -z "$commit_message" ]]; then
log_error_and_display "Commit message is empty. Exiting." # log_error_and_display "Commit message is empty. Exiting."
printLogfileAndExit 1 # printLogfileAndExit 1
fi # fi
#
log_and_display "You entered the commit message: $commit_message" # log_and_display "You entered the commit message: $commit_message"
#
gum confirm "Do you want to commit with this message?" # gum confirm "Do you want to commit with this message?"
if [ $? -eq 1 ]; then # if [ $? -eq 1 ]; then
do_cancel # do_cancel
fi # fi
#
# NEXT STEP COMMIT #################################################################################################################### # # NEXT STEP COMMIT ####################################################################################################################
print_headline "Committing changes" # print_headline "Committing changes"
#
if ! git commit -m "$commit_message" ; then # if ! git commit -m "$commit_message" ; then
log_error_and_display "Commit failed. Exiting." # log_error_and_display "Commit failed. Exiting."
printLogfileAndExit 1 # printLogfileAndExit 1
fi # fi
#
log_and_display "Commit successful." # log_and_display "Commit successful."
#
# NEXT STEP PUSH ###################################################################################################################### # # NEXT STEP PUSH ######################################################################################################################
#
print_headline "Pushing changes" # print_headline "Pushing changes"
#
if ! git push ; then # if ! git push ; then
log_error_and_display "Push failed. Exiting." # log_error_and_display "Push failed. Exiting."
printLogfileAndExit 1 # printLogfileAndExit 1
fi # fi
#
log_and_display "Push successful." # log_and_display "Push successful."
#
# Close issue ###################################################################################################################### # # Close issue ######################################################################################################################
#
print_headline "Closing issues" # print_headline "Closing issues"
#
for issue_id in "''${work_on_issue_ids[@]}"; do # for issue_id in "''${work_on_issue_ids[@]}"; do
#
gum confirm "Do you want to close issue #$issue_id?" # gum confirm "Do you want to close issue #$issue_id?"
if [ $? -eq 1 ]; then # if [ $? -eq 1 ]; then
continue # continue
fi # fi
#
if ! glab issue close "$issue_id" ; then # if ! glab issue close "$issue_id" ; then
log_error_and_display "Closing issue $issue_id failed. Exiting." # log_error_and_display "Closing issue $issue_id failed. Exiting."
else # else
log_and_display "Closing issue $issue_id successful." # log_and_display "Closing issue $issue_id successful."
fi # fi
done # done
#
printLogfileAndExit 0 # printLogfileAndExit 0
''; # '';
enterShell = '' enterShell = ''
update-files update-files
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment