archimatetool / archi-modelrepository-plugin

coArchi - a plug-in to share and collaborate on Archi models.
153 stars 53 forks source link

Issues with branches and commits with non-model content #71

Open Phillipus opened 5 years ago

Phillipus commented 5 years ago

The test "letstest" repo has an orphan branch called "web" and the "Archisurance" repo has a "gh-pages" branch (not an orphan). These branches contain content not related to the model. So what happens if user switches to this branch:

  1. The branch is checked out. There are no grafico XML files.
  2. GraficoModelLoader tries to load grafico files with GraficoModelImporter but this fails returning a null new IArchimateModel.
  3. User has now switched to a non-grafico branch but the ArchiMateModel still looks the same as before.
  4. User cannot switch back to another branch because this action causes (1) Export to grafico then (2) Ask user to commit this change. If user says yes, the special branch has this new commit. If user cancels they are stuck.

We probably need to hide these special branches. Note - I don't know how to determine an orphan branch in JGit.

Perhaps when we check if a new commit is required before doing a further action we should have the option to abandon the changes for the commit as well as cancelling?

Originally posted by @Phillipus in https://github.com/archimatetool/archi-modelrepository-plugin/issues/67#issuecomment-435372046

Phillipus commented 5 years ago

In fact this is not just limited to branches, but any commit that does not contain Archi grafico XML files.

Phillipus commented 5 years ago

Comment from @jbsarrodie in orginal thread:

@Phillipus

Our "letstest" repo has an orphan branch called "web" and the "Archisurance" repo has a "gh-pages" branch (not an orphan). These branches contain content not related to the model. So what happens if user switches to this branch:

I know, I did the same test.

We probably need to hide these special branches. Note - I don't know how to determine an orphan branch in JGit.

I might have found another option....

Few knows it, but branch name can contain some non alphabetical characters like slash '/'. So when a user creates a branch, we could (internally) add a known prefix that ends with '/', for example 'Archi/'. Doing so would allow us to filter branches managed by Archi: either 'master' or a branch that starts by 'Archi/'. Of course we could remove the prefix to only show the remaining part in UI.

We could even us this to keep track of the "parents" of a branch (ie. the branches it is forked off). For this we would simply add the short name of a branch to the full name of its parent: Imagine we create 'Project_A' off 'master', this would create 'master/Project_A'. If we then create 'Scenario_1' off 'Project_A', this would create 'master/Project_A/Scenario_1'...

So all branches managed by Archi would start with 'master', making it easy to filter them. This would have the advantage to allow to show this full path in the Branch view.

Of course, this really works only if we never rename a branch, but we already assume this would not happen.