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

feat(Git Sync): Support for multiple files on the same repository #7843

Draft
wants to merge 4 commits into
base: develop
Choose a base branch
from

Conversation

gatzjames
Copy link
Contributor

@gatzjames gatzjames commented Aug 16, 2024

Highlights:

  • UX for choosing which file to clone
  • Each file that is cloned is isolated from others as it is a separate git repo
  • Update tests
image

Blockers:


Logic for Git Sync:

The structure of Insomnia files in the git repository is stored inside a folder named 📁 .insomnia.
For example a Collection with a Request will be stored in a repository like this:

.
└── .insomnia/
    ├── Workspace/
    │   └── wrk_c9eee6d3eff145e9a83f83c1a91ebd7d.yml
    ├── Request/
    │   └── req_8b75cc5c6d804e2a8eeb990634cbac62.yml
    └── Environment/
        └── env_92493b7aaf0049d1be35f7758edf746e.yml

In Insomnia when we clone a repository:

  • Anything inside the 📁 .insomnia folder is mapped to NeDB
  • Anything related to git inside the 📁 .git folder is mapped to a folder for that workspace inside version control named 📁 git
  • All other files get mapped inside a folder for that workspace inside version control named 📁 other
  • Git uses these mappings to check if a file has been updated or deleted.

Currently if we add another Collection to the repository will create a structure like this:

.
└── .insomnia/
    ├── Workspace/
    │   ├── wrk_c9eee6d3eff145e9a83f83c1a91ebd7d.yml
    │   └── wrk_7611b6018dcd4867ba928fcf060d0139.yml
    ├── Request/
    │   ├── req_8b75cc5c6d804e2a8eeb990634cbac62.yml
    │   └── req_e045d7a223474f388e530edee5e877f7.yml
    └── Environment/
        ├── env_92493b7aaf0049d1be35f7758edf746e.yml
        └── env_1907bca338254a9bab501a8e3bd62b6d.yml

Requirements:

  • When cloning a workspace we want it to be isolated.
    This is so that when someone is working on a specific branch on a specific Workspace it doesn't affect other Workspaces of the same repo that are cloned locally.
  • Backwards compatibillity

Limitations from the approaches that have been tried:

Use the filesystem routing to only map related records of a single Workspace to NeDB:

  • When git clone or pull runs the order of the files that are stored is not guaranteed.
    This means that anything that requires walking the tree to check if a Request belongs to a specific Workspace is not reliable.
    e.g. we can't know for sure if the Request req_8b75cc5c6d804e2a8eeb990634cbac62 belongs to Workspace wrk_c9eee6d3eff145e9a83f83c1a91ebd7d or wrk_7611b6018dcd4867ba928fcf060d0139.

Map all Workspaces and all their records to NeDB:

  • This is what is happening now and creates a lot of issues:
    • Pulling or changing branches on one Workspaces affects other Workspaces which is not the desired UX
    • Constantly creates Merge Conflicts which are not supported currently by isomorphic-git
    • Can lead to data loss in case the code doesn't handle specific edge cases for pull/push etc.

Other approaches:

Store workspaces in the 📁 .insomnia folder to separate the data per workspace:

The above example would look like this:

.
└── .insomnia/
    ├── wrk_c9eee6d3eff145e9a83f83c1a91ebd7d/
    │   ├── Workspace/
    │   │   └── wrk_c9eee6d3eff145e9a83f83c1a91ebd7d.yml
    │   ├── Request/
    │   │   └── req_8b75cc5c6d804e2a8eeb990634cbac62.yml
    │   └── Environment/
    │       └── env_92493b7aaf0049d1be35f7758edf746e.yml
    └── wrk_7611b6018dcd4867ba928fcf060d0139/
        ├── Workspace/
        │   └── wrk_7611b6018dcd4867ba928fcf060d0139.yml
        ├── Request/
        │   └── req_e045d7a223474f388e530edee5e877f7.yml
        └── Environment/
            └── env_1907bca338254a9bab501a8e3bd62b6d.yml      

➕ Pros:

  • Simple to separate each workspace

➖ Cons:

  • Will break the git functionality for previous versions of the app
  • Requires existing repos to re-connect with git

Closes INS-4277

@gatzjames gatzjames self-assigned this Aug 16, 2024
@gatzjames gatzjames force-pushed the feature/git-multiple-workspaces branch from d51a358 to e5e755d Compare August 20, 2024 09:30
@gatzjames gatzjames marked this pull request as ready for review August 20, 2024 09:38
filfreire
filfreire previously approved these changes Aug 21, 2024
Copy link
Member

@filfreire filfreire left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Tested cloning https://github.com/gatzjames/insomnia-git-example and then selecting one of the design documents that shows up.

@filfreire filfreire requested a review from a team August 21, 2024 08:46
@gatzjames gatzjames force-pushed the feature/git-multiple-workspaces branch 2 times, most recently from 5799bec to 2fa2190 Compare August 23, 2024 07:04
@gatzjames gatzjames marked this pull request as draft August 23, 2024 07:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants