The Wayback Machine - https://web.archive.org/web/20210102183723/https://github.com/teambit/bit/issues/1985
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

Ability to keep non-versioned changes in component history #1985

Open
itaymendel opened this issue Sep 9, 2019 · 1 comment
Open

Ability to keep non-versioned changes in component history #1985

itaymendel opened this issue Sep 9, 2019 · 1 comment
Milestone

Comments

@itaymendel
Copy link
Member

@itaymendel itaymendel commented Sep 9, 2019

Bit components only support Tagging as a versioning feature. Component Tags capture the component's functionality. They contain the component's implementation, dependency graph, and additional metadata. A Tag is designed to be consumable so it is versioned using a SemVer. There's a need to keep intermediate component functionality and share them without affecting the consumption process.

The main difference between a Tag and a Snap is the fact that a Tag has a named SemVer as
a published version.

To resolve it there are several feature and improvements to implement:

Introduce bit snap functionality

bit-snap - Records changes to a component.

A snapped component is staged to be exported.

Description

Create a new snapshot of the current contents of a component and the given log message describing the changes. The new snap is listed in the component's index and is a child of the tip of the current Lane (another previous snapshot). The Lane is updated to point to the new tip.

A snapshot records a component functionality and holds additional information on the action:

  • Functionality is defined by various data points and its contents are used as the snapshot's hash
    • Implementation as found in the tracked files in the workspace.
    • Dependency graph that includes all component's resolved dependencies, including components,
      packages, peerDependencies, and devDependencies.
    • Metadata and additional configurations such as build and test environments, overrides,
      etc.
  • Parents 0-N list of the previous snapshot/tag.
  • Author name and email to understand which developer modified the component functionality.
  • Author date the time the functionality has been changed.
  • Message a message containing a summary of the change (we should consider splitting it to
    support title and change type).
  • Auto-snap information that annotates that the snapshot has taken due to a dependency being snap-ed. It should include info on the component(s) that caused the triggered auto-snap.
  • Hash the hash of the current functionality.

image

Auto-snapshots for dependent components

Bit implicitly creates snapshots for components that depend on a component being explicitly snap-ed. The implicit auto-tag adds additional information on the snapshot-like the dependency that caused the snapshot.
The --message for the auto-snap concats the message from the dependency and the dependency name.
In case several dependencies where snap-ed at the same time, the info saved for the auto-snap lists all components that caused the update. Additionally, the auto-snap message concats all messages (create a paragraph for each individual dependency.)

Component HEAD pointer

Whenever a new snap occurs, the HEAD pointer of the component in that lane should point to the new snap.

Detached HEAD

Similar to Git. Can't do snap nor tag if HEAD points to a different snap than what's currently in the workspace. To resolve to create a new lane.

Synopsis

$ bit snap [--ignore-unresolved-dependencies] [--message] [--verbose] [--all] [--skip-tests]  [--force] [<component id pattern>...]

Options

--ignore-unresolved-dependencies

Create a snapshot even if there are dependencies Bit is unable to resolve.

--all

Snap all new and modified components (synonym to * component ID pattern).

--force

Force Bit to take a snapshot even if the component is not modified.

[--message]

Use as the message attached to the snapshot.

component id pattern

Glob-pattern indicated which component to create a snapshot for.

Examples

bit snap --all

Create a snapshot for all modified components.

bit snap foo/*

Create a snapshot for all modified components that their name starts with foo/*.

Update bit tag

  • Version should refer to a snapshot and include a SemVer.
  • Version should support the additional auto-tag information, similar to snapshot.
  • By default bit tag can only tag components that are already snapped.

New options

--snap

Create a snapshot for a new/modified component, and create a Tag that references to it.

--dependents

Similar to snaps --dependents flag - this option tags all components that depend on the tagged components. If any of them is new/modified, use the --snap to create a snapshot that the version points to.

Support component ID patterns

bit tag should support patterns to understand which components it should version. For example - bit tag ui/*.

Affects on other commands

  • status should show snaps as staged.
  • checkout should allow checkout to a snap [TB: how? by hash?] [IM - yes, should also support abbreviated hash].
  • merge should allow merging to and from a snap.
  • diff should allow diffing snaps (and snap<>tags)
  • import should import snaps alongside the rest of the component data.
  • export should export snaps alongside the rest of the component data.
  • instal TBD
  • remove TBD
  • eject TBD
  • link should create a symlink in the node_modules folder to snaps.
  • log should list all snaps alongside the tags in the component's log.
  • show should work on snaps as well, and show snap information [TB: For all history?] [IM - component history is managed by bit log. bit show should simply show the hash and any additional information we find useful].
@GiladShoham GiladShoham added this to the 15.0.0 milestone Sep 9, 2019
@itaymendel itaymendel changed the title Ability to keep non-tagged changes in component history Ability to keep non-versioned changes in component history Sep 9, 2019
@Tallyb
Copy link
Contributor

@Tallyb Tallyb commented Sep 13, 2019

Some Qs:

  1. Does snap do a build and test like tag? is it forcing build and test?
  2. force on tag and force on snap do not behave the same
  3. As tag is a special case of snap, doesn't it make more sense to combine the two into one command with tag just being an option --tag patch
  4. tag has the scope option that does not exist on snap.
davidfirst added a commit that referenced this issue Jul 17, 2020
* implement the "lanes" feature, similar to the description in #1986. 

* implement the "snaps" feature, similar to the description in #1985. 

* disconnect the hash calculation of a Version object from its path, it helps to be flexible with schema changes and avoid HashMismatch exceptions

* snap and tag are working in conjunction

* snap - have head snap as Ref in memory

* fix modified status after snap

* change parent hash prop if version hash is changed

* change parent prop to be an array of parents

* fix snap head upon untag

* fix untag for snaps

* provide a more descriptive error message when a hash is missing

* avoid fetching all versions when not needed

* fix bug of second tag after snap

* fix bit-log to show snaps. support diverged snaps history. fix import and export of snaps. write remote head to a new file at refs/remote

* implement import --object when the local head is different than the remote head

* (wip) started working on bit lane command

* revert the implementation of saving different "Component" objects per lanes (done by dd20bb1)

* implement Lane object (inherit BitObject)

* add basic validation for "lane" object, introduce "bit cat-lane" command, fix "bit status" when snapping on master then on a new lane

*  remove scope-name from lane-id

* fix bit diff to work with snaps

* bit checkout is working for Snaps

* add tests for bit merge with snaps

* recognize diverged components, suggest to merge them in bit status and throw error on bit import in case --merge was not entered

* fix status of merge-pending to show the number of snaps existing on local/remote

* add the common snap before diverge data into the diverge results

* implement a snap-merge of diverged components

* fix bit-status to show an unresolved component as such, implement bit merge --resolve

* implement merge --abort

* prevent tag/snap/checkout/merge a component with conflicts, enable untag/remove

* basic lane export is working

* write exported components heads into refs/remote

* started implementing "bit import" lanes

* move current-local-name from .bitmap to scope.json

* basic functionality of switching between master to a lane is working

* add test for "bit diff" when on a lane, fix "bit status" when snapped on a lane, refactor "diverge" data

* Started working on "bit merge" for lanes. fix tag & checkout lane for multiple components

* fix tests, fix exporting from master to write the snaps into the remote ref

* basic "bit merge" of lanes is working

* fix merging from a remote lane into master

* start working on noSnap flag

* consolidating merge-lanes with snap-merge logic. add merge-snaps output

* implement --no-snap and --message flags of bit-merge

* add existingOnWorkspaceOnly flag for bit-merge

* add e2e-test and output when using --existing flag for bit-merge

* implement bit lane --merge and --not-merged flags

* add a flag "new-lane-name" for bit-checkout

* introduce new flags for "bit import": --new-lane-name and --checkout

* copy components data from origin lane to a newly created lane (except master)

* introduce "bit switch" to switch/create/import lanes

* introduce "bit fetch" command to fetch remote objects

* improve lane-id

* bit fetch is working, change tests to work with bit-switch and bit-fetch

* basic case of switching from a lane back to master is working

* basic case of importing a component when checked out to a lane

* change bit-lane to function only as list/show not as "add". change the output according to the new specs

* started working on workspace-lanes

* implement workspace-lane object to save the current (checked out) versions per local lane

* export with no ids when checked out to a lane, exports the lane

* change the export output to indicate that lanes were exported

* separate getAllBitIds and getAllIdsAvailableOnLane methods to not use the same cache

* implement remove local lanes

* enable fetching lane list from a remote

* when user is checked out to a lane, "bit remove" removes the component from the lane only

* enable removing remote lanes

* block tagging when on a lane for now. we might change it later

* implement auto-snap

* skip a test about fetching dependencies parents for now, it will be back once the backward compatibility is implemented

* implement auto-snap on lanes

* fix ModelComponent.latest() to always work with the current lane

* skip an e2e-test for now until backward compatibility is implemented

* support feature-toggle mechanism

* backward compatibility: do not save snaps.head and component parents when lane feature is disabled

* backward compatibility - fix import from old clients

* throw errors when trying to use lanes/snaps and the feature is disabled

* re-enable some tests now that backward compatibility is supported

* extract create-lane functionality to a new file

* extract export-lanes functionality to a new file

* refactoring. make sure fetch api gets bit-ids or remote-lane-ids. (remove the hack of converting lane-id into bit-id)

* clean some unneeded flags on checkout command

* fix MergeConflictOnRemote to be backward compatible

* refactoring and mark lane flags as experimental

* remove some dups snap/tag

* extract switch lane logic from checkout-version.ts to switch-lanes.ts

* consolidate snap-model-component into tag-model-component

* clear confusion between remoteHead and laneHeadRemote

* extract merge-lanes code to a new file merge-lanes.ts, refactor RemoteLane to use RemoteLaneId whenever possible

* extract the diverge-data into a new file, add a new prop "remoteHead" and avoid adding the master remote into laneRemoteHead

* extract the logic of version traversal into a new file

* remove the hack of reseting the model-component heads

* fix some forward compatibility issues with index.json

* fix RemoteLaneId to indicate that a scope is mandatory

* change ModelComponent.snaps.head to ModelComponent.head

* fix bug when merging components to master

* change variables with snapHead to head
@davidfirst davidfirst mentioned this issue Jul 17, 2020
0 of 8 tasks complete
odedre added a commit that referenced this issue Jul 19, 2020
commit c064f84
Author: Ran Mizrahi <[email protected]>
Date:   Sun Jul 19 12:55:12 2020 +0300

    Harmony/scope (#2861)

    * component history working

    * builder api working

    * fixed component model when for new components

    * prettier2 execution

    * made workspace work as UI root and refactored few bad dependency relationships (e.g. bundler) to the workspace

    * scope is rendering

    * scope sidebar is rendering

    * workspace and scope are now both fetching from component host

    * lint errors

commit 030eeb7
Author: David First <[email protected]>
Date:   Sat Jul 18 22:41:04 2020 -0400

    refactor Compiler extension and fix "main" package.json prop during link process (#2863)

    * refactor compiler extesnsion - remove dead code, change render() to report()

    * rename src/extensions/compiler/compiler.cmd.tsx to src/extensions/compiler/compiler.cmd.ts

    * restructure the "compile" class, extract the new compiler code to a new class CompileComponent

    * fix "main" prop of package.json written for author to have the correct file given by the extensions

    * rename src/extensions/compiler/compile.ts to src/extensions/compiler/workspace-compiler.ts

commit 09a5fec
Author: David First <[email protected]>
Date:   Fri Jul 17 23:49:12 2020 -0400

    change compiler api. compileFile => transpileFile, compileOnCapsules => build (#2860)

commit 6c882b6
Author: David First <[email protected]>
Date:   Fri Jul 17 20:52:41 2020 -0400

    fix Capsule.component to be Component and not ConsumerComponent (#2858)

    * fix Capsule.component to be Component and not ConsumerComponent

    * move capsule commands from isolate-ext to workspace-ext

commit caeddeb
Author: Ran Mizrahi <[email protected]>
Date:   Sat Jul 18 03:47:44 2020 +0300

    Harmony/builder api (#2854)

    * component history working

    * builder api working

    * fixed component model when for new components

    * prettier2 execution

    Co-authored-by: Ran Mizrahi <[email protected]>

commit 0043035
Author: David First <[email protected]>
Date:   Fri Jul 17 20:07:14 2020 -0400

    add extra-data to Analytics to indicate whether the workspace is harmony (#2859)

commit 6bdc653
Author: David First <[email protected]>
Date:   Fri Jul 17 16:01:17 2020 -0400

    change publisher to work with workspace only, remove createNetworkFromScope method (#2857)

commit 5bf6535
Author: David First <[email protected]>
Date:   Fri Jul 17 15:20:03 2020 -0400

    fix "npm run format" to prettify also .js and .css extensions, similar to the lint-staged (#2856)

commit e403658
Author: David First <[email protected]>
Date:   Fri Jul 17 15:18:54 2020 -0400

    rename compiler extension from "compile" to "@teambit/compiler" (#2855)

    also, change the extension to the new format (with a class).

commit 7138e50
Author: David First <[email protected]>
Date:   Fri Jul 17 11:12:33 2020 -0400

    upgrade prettier from 1.x to 2.x and re-format all files (#2852)

commit 78ba57c
Author: David First <[email protected]>
Date:   Thu Jul 16 20:53:10 2020 -0400

    implement "lanes" (#1986) and "snaps" (#1985) features (#2754)

    * implement the "lanes" feature, similar to the description in #1986.

    * implement the "snaps" feature, similar to the description in #1985.

    * disconnect the hash calculation of a Version object from its path, it helps to be flexible with schema changes and avoid HashMismatch exceptions

    * snap and tag are working in conjunction

    * snap - have head snap as Ref in memory

    * fix modified status after snap

    * change parent hash prop if version hash is changed

    * change parent prop to be an array of parents

    * fix snap head upon untag

    * fix untag for snaps

    * provide a more descriptive error message when a hash is missing

    * avoid fetching all versions when not needed

    * fix bug of second tag after snap

    * fix bit-log to show snaps. support diverged snaps history. fix import and export of snaps. write remote head to a new file at refs/remote

    * implement import --object when the local head is different than the remote head

    * (wip) started working on bit lane command

    * revert the implementation of saving different "Component" objects per lanes (done by dd20bb1)

    * implement Lane object (inherit BitObject)

    * add basic validation for "lane" object, introduce "bit cat-lane" command, fix "bit status" when snapping on master then on a new lane

    *  remove scope-name from lane-id

    * fix bit diff to work with snaps

    * bit checkout is working for Snaps

    * add tests for bit merge with snaps

    * recognize diverged components, suggest to merge them in bit status and throw error on bit import in case --merge was not entered

    * fix status of merge-pending to show the number of snaps existing on local/remote

    * add the common snap before diverge data into the diverge results

    * implement a snap-merge of diverged components

    * fix bit-status to show an unresolved component as such, implement bit merge --resolve

    * implement merge --abort

    * prevent tag/snap/checkout/merge a component with conflicts, enable untag/remove

    * basic lane export is working

    * write exported components heads into refs/remote

    * started implementing "bit import" lanes

    * move current-local-name from .bitmap to scope.json

    * basic functionality of switching between master to a lane is working

    * add test for "bit diff" when on a lane, fix "bit status" when snapped on a lane, refactor "diverge" data

    * Started working on "bit merge" for lanes. fix tag & checkout lane for multiple components

    * fix tests, fix exporting from master to write the snaps into the remote ref

    * basic "bit merge" of lanes is working

    * fix merging from a remote lane into master

    * start working on noSnap flag

    * consolidating merge-lanes with snap-merge logic. add merge-snaps output

    * implement --no-snap and --message flags of bit-merge

    * add existingOnWorkspaceOnly flag for bit-merge

    * add e2e-test and output when using --existing flag for bit-merge

    * implement bit lane --merge and --not-merged flags

    * add a flag "new-lane-name" for bit-checkout

    * introduce new flags for "bit import": --new-lane-name and --checkout

    * copy components data from origin lane to a newly created lane (except master)

    * introduce "bit switch" to switch/create/import lanes

    * introduce "bit fetch" command to fetch remote objects

    * improve lane-id

    * bit fetch is working, change tests to work with bit-switch and bit-fetch

    * basic case of switching from a lane back to master is working

    * basic case of importing a component when checked out to a lane

    * change bit-lane to function only as list/show not as "add". change the output according to the new specs

    * started working on workspace-lanes

    * implement workspace-lane object to save the current (checked out) versions per local lane

    * export with no ids when checked out to a lane, exports the lane

    * change the export output to indicate that lanes were exported

    * separate getAllBitIds and getAllIdsAvailableOnLane methods to not use the same cache

    * implement remove local lanes

    * enable fetching lane list from a remote

    * when user is checked out to a lane, "bit remove" removes the component from the lane only

    * enable removing remote lanes

    * block tagging when on a lane for now. we might change it later

    * implement auto-snap

    * skip a test about fetching dependencies parents for now, it will be back once the backward compatibility is implemented

    * implement auto-snap on lanes

    * fix ModelComponent.latest() to always work with the current lane

    * skip an e2e-test for now until backward compatibility is implemented

    * support feature-toggle mechanism

    * backward compatibility: do not save snaps.head and component parents when lane feature is disabled

    * backward compatibility - fix import from old clients

    * throw errors when trying to use lanes/snaps and the feature is disabled

    * re-enable some tests now that backward compatibility is supported

    * extract create-lane functionality to a new file

    * extract export-lanes functionality to a new file

    * refactoring. make sure fetch api gets bit-ids or remote-lane-ids. (remove the hack of converting lane-id into bit-id)

    * clean some unneeded flags on checkout command

    * fix MergeConflictOnRemote to be backward compatible

    * refactoring and mark lane flags as experimental

    * remove some dups snap/tag

    * extract switch lane logic from checkout-version.ts to switch-lanes.ts

    * consolidate snap-model-component into tag-model-component

    * clear confusion between remoteHead and laneHeadRemote

    * extract merge-lanes code to a new file merge-lanes.ts, refactor RemoteLane to use RemoteLaneId whenever possible

    * extract the diverge-data into a new file, add a new prop "remoteHead" and avoid adding the master remote into laneRemoteHead

    * extract the logic of version traversal into a new file

    * remove the hack of reseting the model-component heads

    * fix some forward compatibility issues with index.json

    * fix RemoteLaneId to indicate that a scope is mandatory

    * change ModelComponent.snaps.head to ModelComponent.head

    * fix bug when merging components to master

    * change variables with snapHead to head

commit bd1a2a1
Author: Ran Mizrahi <[email protected]>
Date:   Fri Jul 17 02:45:50 2020 +0300

    component history working (#2851)

    Co-authored-by: Ran Mizrahi <[email protected]>

commit b061300
Author: Ran Mizrahi <[email protected]>
Date:   Thu Jul 16 14:30:40 2020 +0300

    Harmony/component load (#2840)

    - change component model
    - load components from the scope
    - update scope component with state from workspace
    - transform many workspace methods to use new ComponentID as arg
    - do not mutate original components from "onTag" envs' services

    Co-authored-by: Ran Mizrahi <[email protected]>
    Co-authored-by: Gilad Shoham <[email protected]>

commit 1e6a8ac
Author: Gilad Shoham <[email protected]>
Date:   Wed Jul 15 23:45:40 2020 +0300

    fix windows e2e tests (#2846)

commit 73fb3c3
Author: Gilad Shoham <[email protected]>
Date:   Wed Jul 15 22:19:02 2020 +0300

    Harmony/workspace ui (#2835)

    First version of workspace ui

    Co-authored-by: Gilad Shoham <[email protected]>
    Co-authored-by: Ran Mizrahi <[email protected]>
    Co-authored-by: Uri Kutner <[email protected]>
    Co-authored-by: oded <[email protected]>
    Co-authored-by: David First <[email protected]>

commit bc90436
Author: David First <[email protected]>
Date:   Mon Jul 13 23:08:05 2020 -0400

    improve bit link --rewire to preserve the internal paths (#2839)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
3 participants
You can’t perform that action at this time.