From 9b072ce099f8eef96427305d3464f43633ee0825 Mon Sep 17 00:00:00 2001 From: Pascal Andy Date: Mon, 9 May 2022 11:29:32 -0400 Subject: [PATCH 1/2] Refactor squash() and dummy() --- bashlava.sh | 118 ++++++++++++++++++++++++++++------------------------ 1 file changed, 63 insertions(+), 55 deletions(-) diff --git a/bashlava.sh b/bashlava.sh index 2b372d5..4f9b22d 100755 --- a/bashlava.sh +++ b/bashlava.sh @@ -2,56 +2,78 @@ ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### # # -# To-Do comment section. Total of 15 +# To-Do comment section. Total of 11 # ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### # : ' // START COMMENT BLOCK - #4 TODO & backlog - #8 UX - #9 Bugfix - #10 Logic & Condition - #11 docs +PINNED issues on GH + issue #4 TODO & backlog + issue #8 UX + issue #9 Bugfix + issue #10 Logic & Condition + issue #11 docs + | + PR Title: 0o0o + Impact on: #4, #8, #9 #10, #11 - PR Title: 0o0o - Impact on: #4, #8, #9 #10, #11 +# TODO edge () +update path to ~/Library/Application Support/FirePress/bashlava -# TODO New Feat dummy() create a dummy commit +# TODO +c() see more than 1 line in git log +- Impact on: #4, #8 -- to quickly test bashlava in a dummy projet +# edge() prompt user - Impact on: #4, #8 +OPTIONS ARE: +1) CREATE edge_neW and DELETE edge_olD (default) +2) CREATE edge_neW and KEEP edge_olD +3) CREATE custom_neW and DELETE edge_olD only +4) CREATE custom_neW and KEEP edge_olD only + +(Your branch name for edge is located .. path here ) # TODO Core_Load_Vars_General -better management core vars / group them, avoid having multiple place to define them -file to check VERSUS file to source +- better management core vars / group them, avoid having multiple place to define them +- file to check VERSUS file to source +- we have few array that are configs. They should be all together under the same block of code. -we have few array that are configs. They should be all together under the same block of code. -source files under /components +# TODO code optimization 0o0o / Need logic to manage file under /private/* favorite URL could be a great example -set a new config flag: debug="true" - +# RANDOM NOTES +- multipass.run / shell +- var subtitution example +- GH enviroment (staging, prod) +- re-use workflow # TODO private scripts logical flags to manage under /private/* -source {_path_components}/private/ Need to check if files exist /private/* when DIR private exist -manage private vars https://github.com/firepress-org/bashlava/issues/83; logic to switch between private fct VERSUS public fct -custom_fct_opensite="false" -custom_fct_help="false" - this will use a fct available to public - else it will use a +- overide like: +- custom_fct_opensite="true" # during pr, merg +- custom_fct_help="false" +# TODO +set a new config flag: debug="true" # TODO -## App check brew + git-crypt + gnupg, shellcheck +## App if app are installed + which git-crypt + which gnupg + which shellcheck + which openssl + + if not propose to install them via brew + if brew ls --versions myformula > /dev/null; then The package is installed else @@ -61,18 +83,10 @@ custom_fct_help="false" # TODO spell checker in comments, vs code extension ? - -# TODO -when the user goes into a prompt, he should be able to provide attri to avoid the pop-up. -ex: ci yes, ci no -ex: show app, show 3 -need to check if gh cli support this as well - - # TODO ci pipeline -create ci for using shellcheck -run test() - +- superlinter (includes shellcheck) +- create ci for using shellcheck +- run test() # TODO Show_Docs() works but not clean, but it works mdv() / Show_Docs @@ -82,19 +96,13 @@ works but not clean, but it works mdv() / Show_Docs but as a priciiple, I like to call a docker container # TODO squash -function that search for the same commit messages in previous commits -then suggestion to do a squash, then prompt user y/n - +- function that search for the same commit messages in previous commits +- then suggestion to do a squash, then prompt user y/n # TODO Show_Fct_Category_F1 , F2 -revisit this function once all file are solid + private logic +- revisit this function once all file are solid + private logic - -# TODO -idea_here - -# TODO -idea_here +List files on B2 // END COMMENT BLOCK ' @@ -355,13 +363,10 @@ function squash { # User_ my_message="Oups, syntax error." && Print_Warning_Stop fi - git reset --hard HEAD~"${input_2}" - git merge --squash HEAD@{1} - git push origin HEAD --force - git status - git add -A - git commit -m "${input_3}" - git push + git reset --soft HEAD~"${input_2}" &&\ + git commit --edit -m "${input_3}" &&\ + git push --force-with-lease &&\ + git pull &&\ log } @@ -390,10 +395,13 @@ function ci { # User_ } function dummy { # User_ - write_dummy_commit_here="README.md" - echo "Dummy Commit ${date_sec}" >> "${write_dummy_commit_here}" - git add -A && git commit -m "Dummy Commit ${date_sec}" && git push - pr + _in_file="README.md" + _hash=$(echo ${date_nano} | sha256sum | awk '{print $1}') + _hash_four_last="${_hash: -4}" + + echo "Dummy Commit, ${date_sec}, ${_hash}" >> "${_in_file}" + git add -A && git commit -m "dummy commit ${_hash_four_last}" && git push + log } function show { # User_ From feda140090bd58f9c82cc1a847ccde8aa5dc10e7 Mon Sep 17 00:00:00 2001 From: Pascal Andy Date: Mon, 9 May 2022 14:45:08 -0400 Subject: [PATCH 2/2] New feat: tci(): tag to trigger the CI --- bashlava.sh | 138 +++++++++++++++++++++++++++++++--------------------- 1 file changed, 82 insertions(+), 56 deletions(-) diff --git a/bashlava.sh b/bashlava.sh index 4f9b22d..734142e 100755 --- a/bashlava.sh +++ b/bashlava.sh @@ -1,76 +1,69 @@ #!/usr/bin/env bash -### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### # -# -# To-Do comment section. Total of 11 -# -### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### # - : ' // START COMMENT BLOCK +To-Do comment section. Total of 11 -PINNED issues on GH - issue #4 TODO & backlog - issue #8 UX - issue #9 Bugfix - issue #10 Logic & Condition - issue #11 docs - | - PR Title: 0o0o - Impact on: #4, #8, #9 #10, #11 - -# TODO edge () -update path to ~/Library/Application Support/FirePress/bashlava - -# TODO -c() see more than 1 line in git log -- Impact on: #4, #8 +_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ +PINNED issues on GH _ + issue #4 TODO & backlog _ + issue #8 UX _ + issue #9 Bugfix _ + issue #10 Logic & Condition _ + issue #11 docs _ + _ +PR Title: New Feat: +Impact on: #4, #8, #9 #10 +_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ -# edge() prompt user -- Impact on: #4, #8 -OPTIONS ARE: -1) CREATE edge_neW and DELETE edge_olD (default) -2) CREATE edge_neW and KEEP edge_olD -3) CREATE custom_neW and DELETE edge_olD only -4) CREATE custom_neW and KEEP edge_olD only +TODO +PR Title: New feat: tci(): tag to trigger the CI +Impact on: #4, #8 + +- User facing +- Now, main_branch builds only when pushing tags +- Now, the CI do not build on every commits on main_branch (its a pain when we merge many PRs) +- Sometime we work directly on the main_branch (typically for CI work) and we dont want to trigger the CI pipeline -(Your branch name for edge is located .. path here ) -# TODO Core_Load_Vars_General +TODO edge() +- dynamic edge name creation +- update path to ~/Library/Application Support/FirePress/bashlava + + +TODO log() +- see 4 line instead of 1 +- adapt log() to see 10 instead of 8 +- Impact on: #4, #8 + + +TODO Core_Load_Vars_General - better management core vars / group them, avoid having multiple place to define them - file to check VERSUS file to source - we have few array that are configs. They should be all together under the same block of code. -# TODO -code optimization 0o0o / Need logic to manage file under /private/* -favorite URL could be a great example -# RANDOM NOTES -- multipass.run / shell -- var subtitution example -- GH enviroment (staging, prod) -- re-use workflow - -# TODO private scripts +TODO private scripts logical flags to manage under /private/* Need to check if files exist /private/* when DIR private exist -logic to switch between private fct VERSUS public fct -- overide like: +Need logic to manage file under /private/* fct VERSUS public fct + +overide like: +- favorite URL - custom_fct_opensite="true" # during pr, merg - custom_fct_help="false" +- set a new config flag: debug="true" -# TODO -set a new config flag: debug="true" - -# TODO +TODO ## App if app are installed which git-crypt which gnupg which shellcheck which openssl + which sha256 if not propose to install them via brew @@ -80,29 +73,49 @@ set a new config flag: debug="true" The package is not installed fi -# TODO -spell checker in comments, vs code extension ? -# TODO ci pipeline +TODO ci pipeline - superlinter (includes shellcheck) - create ci for using shellcheck - run test() -# TODO Show_Docs() + +TODO +edge() prompt user +- Impact on: #4, #8 + +OPTIONS ARE: +1) CREATE edge_neW and DELETE edge_olD (default) +2) CREATE edge_neW and KEEP edge_olD +3) CREATE custom_neW and DELETE edge_olD only +4) CREATE custom_neW and KEEP edge_olD only + +(Your branch name for edge is located .. path here ) + + +TODO Show_Docs() works but not clean, but it works mdv() / Show_Docs we cant provide an abosolute path to the file because the Docker container cant the absolute path I also DONT want to provide two arguments when using glow I might simply stop using a docker container for this but as a priciiple, I like to call a docker container -# TODO squash + +TODO squash - function that search for the same commit messages in previous commits - then suggestion to do a squash, then prompt user y/n -# TODO Show_Fct_Category_F1 , F2 + +TODO Show_Fct_Category_F1 , F2 - revisit this function once all file are solid + private logic -List files on B2 + +TODO RANDOM NOTES +- multipass.run / shell +- var subtitution example +- GH enviroment (staging, prod) +- re-use workflow +- List files on B2 // END COMMENT BLOCK ' @@ -237,8 +250,6 @@ function mrg { # User_ gh pr merge -echo "wip" > /dev/null 2>&1 - # Ensure to checkout to main_branch. # The user maybe did not deleted the PR branch in the previous step (via cli gh pr merge) _branch_exist=$(git branch --list "${default_branch}" | wc -l) @@ -335,6 +346,21 @@ function tag { # User_ esac } +function tci { # User_ + Condition_No_Commits_Pending + Condition_Attr_2_Must_Be_Empty + + _short_hash=$(git rev-parse --short HEAD) + _tag_name="ci_${app_version}_${_short_hash}" + _var_name="_short_hash" _is_it_empty="${_short_hash}" && Condition_Vars_Must_Be_Not_Empty + _var_name="_tag_name" _is_it_empty="${_tag_name}" && Condition_Vars_Must_Be_Not_Empty + + git tag ${_tag_name} && git push --tags && echo + Show_Version + + # For docs, see this PR: 0o0o +} + function release { # User_ Condition_No_Commits_Pending Condition_Attr_2_Must_Be_Empty