ToolboxHub / ToolboxToolbox

Declarative dependency management for Matlab.
The Unlicense
27 stars 11 forks source link

TbTb creates copy of my repo when specifying the flavor #89

Open aernesto opened 6 years ago

aernesto commented 6 years ago

My setup

Following the instructions from this wiki, I cloned my repo Foo into the TbTb default projects folder:
/MY/MATLAB/USER/PATH/projects/Foo

As I usually work on the branch dev, I specified the field
"flavor": "dev"
in the Foo.json file.

The surprising behavior

After launching MATLAB, the command tbUseProject('Foo'); automatically creates a copy of my repo and renames it by appending the branch name to the folder name, yielding the new folder:
/MY/MATLAB/USER/PATH/projects/Foo_dev

This behavior surprised me because it has the following consequences:

  1. If I want to make an edit to my project on the fly, without pushing my changes to GitHub, these edits should be brought to the Foo_dev folder and not to the Foo folder.
  2. If I type tbUseProject('Foo_dev');, TbTb complains because no file Foo_dev.json exists. If I create such file and keep the line "flavor": "dev", then TbTb will create the folder
    /MY/MATLAB/USER/PATH/projects/Foo_dev_dev, which is clearly not useful to me.

To keep things consistent, it seems to me that any project living in the projects folder should be callable by tbUseProject. The solution to item 2 above is to omit the line specifying the flavor in the Foo_dev.json file.

A suggestion for improvement

But there is a more high-level question about what the intended workflow for TbTb and different branches from the same git project is. Creating one folder per branch doesn't seem ideal to me; especially if each branch requires a different .json file. Instead I could imagine an optional second argument that could be given to the tbUseProject() function, which would specify the branch (or any tree-ish) that the user intends to use during his TbTb session. TbTb would then checkout the appropriate branch, directly in the Foo folder. This suggested second argument could be designed to take priority over the field flavor from the .json file. Other situations that could occur are:

  1. If no second argument is specified, then TbTb uses the flavor from the .json file -- but note that I am also suggesting to change the current behavior in this scenario; that is, no Foo_dev folder would get created.
  2. If no second argument is specified, and no flavor field exists in the .json file, TbTb behaves as it currently does.
DavidBrainard commented 5 years ago

I apologize I somehow missed this issue when it was posted.

I agree that the way "flavor" handles branches is not ideal. I can't remember right now why we did it that way when we designed the system.

What we do in our lab when we develop is just have one .json file and then switch branches outside of TbTb, using git directly. This works pretty well for us but I agree that having a way to do it in the calls tbUse and tbUseProject makes sense.

One possibility would be to change the behavior of flavor to do what you expected, and then make it passable as a key-value pair to the function calls. (Actually, I think it already is parsed there as a key-value pair). The other would be to add a new field called, say, "branch" and have that do what you expect.

I will think about this and try to implement something. It is not going to be real soon, though, as I'm piled up with other things.