Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve branch ordering control options for complex git branch diagrams #1497

Open
bedge opened this issue Jul 26, 2024 · 0 comments
Open

Improve branch ordering control options for complex git branch diagrams #1497

bedge opened this issue Jul 26, 2024 · 0 comments
Labels
enhancement New feature or request

Comments

@bedge
Copy link

bedge commented Jul 26, 2024

In my branch diagram I want:

  • vertical orientation
  • main in the middle
  • feature branches on the left
  • release and patches on the right

This helps keep the entire tree comprehensible when there's many feature and release branches.
eg;
image

With a branch numbering system that only goes one direction, ie:

%%{init: { '.... 'mainBranchOrder': 5}} }%%

    branch 2.5-feature-1 order: 1
    branch 2.5-feature-2 order: 2
    branch 2.5-feature-3 order: 3
    branch 2.6-feature-1 order: 4
    branch release-2.5 order: 6
    branch 2.5-bug-1 order: 7
    branch 2.5-bug-2 order: 8
    branch release-2.6 order: 9

This is cumbersome because when adding new branches, one must continuously renumber the branches when a new one is needed that isn't at the end of the existing sequence.

Describe the solution you'd like

I'd like to see branch ordering support 2 things

  1. Negative numbers, so one could say:
%%{init: { '.... 'mainBranchOrder': 0}} }%%
    branch 2.5-feature-1 order: -4
    branch 2.5-feature-2 order: -3
    branch 2.5-feature-3 order: -2
    branch 2.6-feature-1 order: -1
    branch release-2.5 order: 1
    branch 2.5-bug-1 order: 2
    branch 2.5-bug-2 order: 3
    branch release-2.6 order: 4

IOW, set main to zero, and use negative numbers to go the left and positive to the right.

  1. A variable counter for the "order".
    With this, one could insert a new branch in the order without the need to manually renumber all branches to one side the inserrt.
    The above could become:
%%{init: { '.... 'mainBranchOrder': 0}} }%%
      branch 2.6-feature-1 order: left_order
    branch 2.5-feature-3 order: --left_order
    branch 2.5-feature-2 order: --left_order
    branch 2.5-feature-1 order: --left_order

    branch release-2.5 order: right_order
    branch 2.5-bug-1 order: ++right_order
    branch 2.5-bug-2 order: ++right_order
    branch release-2.6 order: ++right_order

with left_order and right_order being counters that are pre-decremented (--) or pre-incremented (++) as (crudely) shown above.

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

I manually renumber all of the branches from the insert point to the end

This is super inconvenient and error prone.

Additional context
Add any other context or screenshots about the feature request here.

Here's my full sample so you can see the issue:

---
config:
    gitGraph:
        parallelCommits: false
---
%%{init: { 'logLevel': 'debug', 'gitGraph': {'showBranches': true, 'showCommitLabel':true, 'mainBranchOrder': 5}} }%%

gitGraph TB:
    commit id: "start"
    branch 2.5-feature-1 order: 1
    commit
    checkout main
    branch 2.5-feature-2 order: 2
    commit
    checkout main
    merge 2.5-feature-1
    branch 2.5-feature-3 order: 3
    commit
    checkout main
    merge 2.5-feature-2
    merge 2.5-feature-3 tag: "Feature complete" id: "Feature complete"
    commit id: "last commit pre 2.5 branch - lock maven versions"
    branch release-2.5 order: 6
    commit tag: "2.5 bug" id: "bug found pre-release"
    checkout main
    merge release-2.5  type: REVERSE id: "2.5 bug merge"
    branch 2.6-feature-1 order: 4
    commit
    checkout release-2.5
    commit  type: HIGHLIGHT tag: "v2.5" id: "release 2.5"
    branch 2.5-bug-1 order: 7
    commit tag: "1st 2.5 patch" id: "1st post-release bug fix"
    checkout main
    commit
    merge 2.5-bug-1 type: REVERSE id: "merge 1st 2.5 patch"
    checkout release-2.5
    merge 2.5-bug-1 type: HIGHLIGHT tag: "v2.5.1" id: "release 2.5.1"
    checkout main
    merge release-2.5 type: REVERSE
    commit
    checkout main
    merge 2.6-feature-1
    checkout release-2.5
    branch 2.5-bug-2 order: 8
    commit type: REVERSE tag: "2nd bugfix in 2.5 (2.5.1)" id: "2nd post-release bug fix"
    checkout release-2.5
    merge 2.5-bug-2  type: HIGHLIGHT tag: "v2.5.2" id: "bug 2 not fixed"
    checkout 2.5-bug-2
    commit  tag: "2nd bugfix in 2.5 (2.5.1), 2nd attempt"
    checkout release-2.5
    merge 2.5-bug-2 type: HIGHLIGHT tag: "v2.5.2" id: "bug 2 fixed"
    checkout main
    merge release-2.5  type: REVERSE
    checkout main
    merge release-2.5 type: REVERSE tag: "Termination of 2.5 release"
    commit  id: "2.6 feature complete"
    branch release-2.6 order: 9
    checkout release-2.6
    commit  tag: "1st bugfix in 2.6"
    checkout main
    commit
    checkout main
    merge release-2.6 type: REVERSE
@bedge bedge added the enhancement New feature or request label Jul 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant