generate marmaid graph
This commit is contained in:
37
git/generae_overview_mermaid.sh
Normal file
37
git/generae_overview_mermaid.sh
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
$ #!/bin/bash
|
||||||
|
|
||||||
|
# Function to escape special characters for Mermaid
|
||||||
|
escape_for_mermaid() {
|
||||||
|
echo "$1" | sed 's/[^a-zA-Z0-9]/_/g'
|
||||||
|
}
|
||||||
|
|
||||||
|
# Start the Mermaid diagram
|
||||||
|
echo "%%{init: { 'theme': 'base' } }%%"
|
||||||
|
echo "gitGraph"
|
||||||
|
|
||||||
|
# Set master as the main branch
|
||||||
|
main_branch="master"
|
||||||
|
|
||||||
|
# Start with the main branch
|
||||||
|
echo " commit id: \"Initial commit\""
|
||||||
|
|
||||||
|
# Keep track of declared branches
|
||||||
|
declared_branches=("$main_branch")
|
||||||
|
|
||||||
|
# Function to find the base branch
|
||||||
|
find_base_branch() {
|
||||||
|
local branch=$1
|
||||||
|
local base=$(git show-branch -a 2>/dev/null | grep '\*' | grep -v "$branch" | head -n1 | sed 's/.*\[\(.*\)\].*/\1/' | sed 's/[\^~].*//')
|
||||||
|
if [[ -z "$base" ]]; then
|
||||||
|
echo "$main_branch"
|
||||||
|
else
|
||||||
|
echo "$base"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# Function to declare a branch if not already declared
|
||||||
|
declare_branch() {
|
||||||
|
local branch=$1
|
||||||
|
if [[ ! " ${declared_branches[@]} " =~ " ${branch} " ]]; then
|
||||||
|
echo " branch $branch"
|
||||||
|
doneprocess_branch "$branch"--sort=committerdate --format='%(refname:short)' refs/heads/)
|
Reference in New Issue
Block a user