@teambit/merge-lanes 1.0.496 → 1.0.497

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -17,7 +17,7 @@ export declare class MergeLaneCmd implements Command {
17
17
  private: boolean;
18
18
  remoteOp: boolean;
19
19
  constructor(mergeLanes: MergeLanesMain, globalConfig: GlobalConfigMain);
20
- report([name, pattern]: [string, string], { ours, theirs, manual, autoMergeResolve, build, workspace: existingOnWorkspaceOnly, squash, noAutoSnap, noSnap, tag, message: snapMessage, keepReadme, noSquash, skipDependencyInstallation, skipFetch, includeDeps, resolveUnrelated, ignoreConfigChanges, verbose, excludeNonLaneComps, }: {
20
+ report([name, pattern]: [string, string], { ours, theirs, manual, autoMergeResolve, build, workspace: existingOnWorkspaceOnly, squash, noAutoSnap, noSnap, tag, message: snapMessage, keepReadme, noSquash, skipDependencyInstallation, skipFetch, includeDeps, resolveUnrelated, ignoreConfigChanges, verbose, excludeNonLaneComps, detachHead, }: {
21
21
  ours?: boolean;
22
22
  theirs?: boolean;
23
23
  manual?: boolean;
@@ -38,5 +38,6 @@ export declare class MergeLaneCmd implements Command {
38
38
  ignoreConfigChanges?: boolean;
39
39
  verbose?: boolean;
40
40
  excludeNonLaneComps?: boolean;
41
+ detachHead?: boolean;
41
42
  }): Promise<string>;
42
43
  }
@@ -79,7 +79,7 @@ so then the history (and the source-code) of the other lane will be kept.
79
79
  Component pattern format: ${_legacy().COMPONENT_PATTERN_HELP}`
80
80
  }]);
81
81
  _defineProperty(this, "alias", '');
82
- _defineProperty(this, "options", [['', 'manual', 'same as "--auto-merge-resolve manual". in case of merge conflict, write the files with the conflict markers'], ['r', 'auto-merge-resolve <merge-strategy>', 'in case of a merge conflict, resolve according to the provided strategy: [ours, theirs, manual]'], ['', 'ours', 'DEPRECATED. use --auto-merge-resolve. in case of a conflict, keep local modifications'], ['', 'theirs', 'DEPRECATED. use --auto-merge-resolve. in case of a conflict, override local with incoming changes'], ['', 'workspace', 'merge only lane components that are in the current workspace'], ['', 'no-auto-snap', 'do not auto snap after merge completed without conflicts of diverged components (see command description)'], ['', 'no-snap', 'do not pass snaps from the other lane even for non-diverged components (see command description)'], ['', 'tag', 'auto-tag all lane components after merging into main (or tag-merge in case of snap-merge)'], ['', 'build', 'in case of snap during the merge, run the build-pipeline (similar to bit snap --build)'], ['m', 'message <message>', 'override the default message for the auto snap'], ['', 'keep-readme', 'skip deleting the lane readme component after merging'], ['', 'no-squash', 'relevant for merging lanes into main, which by default squashes all lane snaps'], ['', 'squash', 'relevant for merging a lane into another non-main lane, which by default does not squash'], ['', 'ignore-config-changes', 'allow merging when components are modified due to config changes (such as dependencies) only and not files'], ['', 'verbose', 'display detailed information about components that were legitimately unmerged'], ['x', 'skip-dependency-installation', 'do not install dependencies of the imported components'], ['', 'skip-fetch', 'use the local state of target-lane if exits locally, without updating it from the remote'], ['', 'include-deps', 'relevant for "pattern" and "--workspace". merge also dependencies of the specified components'], ['', 'resolve-unrelated [merge-strategy]', 'relevant when a component on a lane and the component on main have nothing in common. merge-strategy can be "ours" (default) or "theirs"'], ['', 'include-non-lane-comps', 'DEPRECATED (this is now the default). when merging main, include workspace components that are not on the lane (by default only lane components are merged)'], ['', 'exclude-non-lane-comps', 'when merging main into a lane, exclude workspace components that are not on the lane (by default all workspace components are merged)']]);
82
+ _defineProperty(this, "options", [['', 'manual', 'same as "--auto-merge-resolve manual". in case of merge conflict, write the files with the conflict markers'], ['r', 'auto-merge-resolve <merge-strategy>', 'in case of a merge conflict, resolve according to the provided strategy: [ours, theirs, manual]'], ['', 'ours', 'DEPRECATED. use --auto-merge-resolve. in case of a conflict, keep local modifications'], ['', 'theirs', 'DEPRECATED. use --auto-merge-resolve. in case of a conflict, override local with incoming changes'], ['', 'workspace', 'merge only lane components that are in the current workspace'], ['', 'no-auto-snap', 'do not auto snap after merge completed without conflicts of diverged components (see command description)'], ['', 'no-snap', 'do not pass snaps from the other lane even for non-diverged components (see command description)'], ['', 'tag', 'auto-tag all lane components after merging into main (or tag-merge in case of snap-merge)'], ['', 'build', 'in case of snap during the merge, run the build-pipeline (similar to bit snap --build)'], ['m', 'message <message>', 'override the default message for the auto snap'], ['', 'keep-readme', 'skip deleting the lane readme component after merging'], ['', 'no-squash', 'relevant for merging lanes into main, which by default squashes all lane snaps'], ['', 'squash', 'relevant for merging a lane into another non-main lane, which by default does not squash'], ['', 'ignore-config-changes', 'allow merging when components are modified due to config changes (such as dependencies) only and not files'], ['', 'verbose', 'display detailed information about components that were legitimately unmerged'], ['x', 'skip-dependency-installation', 'do not install dependencies of the imported components'], ['', 'skip-fetch', 'use the local state of target-lane if exits locally, without updating it from the remote'], ['', 'include-deps', 'relevant for "pattern" and "--workspace". merge also dependencies of the specified components'], ['', 'resolve-unrelated [merge-strategy]', 'relevant when a component on a lane and the component on main have nothing in common. merge-strategy can be "ours" (default) or "theirs"'], ['', 'include-non-lane-comps', 'DEPRECATED (this is now the default). when merging main, include workspace components that are not on the lane (by default only lane components are merged)'], ['', 'exclude-non-lane-comps', 'when merging main into a lane, exclude workspace components that are not on the lane (by default all workspace components are merged)'], ['', 'detach-head', 'UNSUPPORTED YET. for each component, find the divergent point from main and merge to that point. do not change the head']]);
83
83
  _defineProperty(this, "loader", true);
84
84
  _defineProperty(this, "private", true);
85
85
  _defineProperty(this, "remoteOp", true);
@@ -104,7 +104,8 @@ Component pattern format: ${_legacy().COMPONENT_PATTERN_HELP}`
104
104
  resolveUnrelated,
105
105
  ignoreConfigChanges,
106
106
  verbose = false,
107
- excludeNonLaneComps = false
107
+ excludeNonLaneComps = false,
108
+ detachHead
108
109
  }) {
109
110
  build = (await this.globalConfig.getBool(_legacy().CFG_FORCE_LOCAL_BUILD)) || Boolean(build);
110
111
  if (ours || theirs) {
@@ -154,7 +155,8 @@ Component pattern format: ${_legacy().COMPONENT_PATTERN_HELP}`
154
155
  resolveUnrelated: getResolveUnrelated(),
155
156
  ignoreConfigChanges,
156
157
  includeDeps,
157
- excludeNonLaneComps
158
+ excludeNonLaneComps,
159
+ detachHead
158
160
  });
159
161
  const mergeResult = (0, _merging().mergeReport)(_objectSpread(_objectSpread({}, mergeResults), {}, {
160
162
  configMergeResults,
@@ -1 +1 @@
1
- {"version":3,"names":["_chalk","data","_interopRequireDefault","require","_merging","_legacy","_bitError","_remove","e","__esModule","default","ownKeys","r","t","Object","keys","getOwnPropertySymbols","o","filter","getOwnPropertyDescriptor","enumerable","push","apply","_objectSpread","arguments","length","forEach","_defineProperty","getOwnPropertyDescriptors","defineProperties","defineProperty","_toPropertyKey","value","configurable","writable","i","_toPrimitive","Symbol","toPrimitive","call","TypeError","String","Number","MergeLaneCmd","constructor","mergeLanes","globalConfig","name","description","COMPONENT_PATTERN_HELP","report","pattern","ours","theirs","manual","autoMergeResolve","build","workspace","existingOnWorkspaceOnly","squash","noAutoSnap","noSnap","tag","message","snapMessage","keepReadme","noSquash","skipDependencyInstallation","skipFetch","includeDeps","resolveUnrelated","ignoreConfigChanges","verbose","excludeNonLaneComps","getBool","CFG_FORCE_LOCAL_BUILD","Boolean","BitError","mergeStrategy","getResolveUnrelated","undefined","Error","mergeResults","deleteResults","configMergeResults","mergeLaneByCLI","mergeResult","mergeReport","deleteOutput","localResult","removeTemplate","remoteResult","map","item","readmeResult","chalk","yellow","exports"],"sources":["merge-lane.cmd.ts"],"sourcesContent":["import chalk from 'chalk';\nimport { Command, CommandOptions } from '@teambit/cli';\nimport { mergeReport, MergeStrategy } from '@teambit/merging';\nimport { GlobalConfigMain } from '@teambit/global-config';\nimport { COMPONENT_PATTERN_HELP, CFG_FORCE_LOCAL_BUILD } from '@teambit/legacy.constants';\nimport { BitError } from '@teambit/bit-error';\nimport { removeTemplate } from '@teambit/remove';\nimport { MergeLanesMain } from './merge-lanes.main.runtime';\n\nexport class MergeLaneCmd implements Command {\n name = 'merge <lane> [pattern]';\n description = `merge a local or a remote lane to the current lane`;\n extendedDescription = `by default, the provided lane will be fetched from the remote before merging.\nto merge the lane from the local scope without updating it first, use \"--skip-fetch\" flag.\n\nwhen the current and merge candidate lanes are diverged in history and the files could be merged with no conflicts,\nthese components will be snap-merged to complete the merge. use \"no-auto-snap\" to opt-out, or \"tag\" to tag instead.\n\nwhen the components are not diverged in history, and the current lane is behind the merge candidate, the merge will\nsimply update the components and the heads according to the merge candidate.\nto opt-out, use \"--no-snap\", the components will be written as the merge candidate, and will be left as modified.\n\nin case a component in both ends don't share history (no snap is found in common), the merge will require \"--resolve-unrelated\" flag.\nthis flag keeps the history of one end and saves a reference to the other end. the decision of which end to keep is determined by the following:\n1. if the component exists on main, then the history linked to main will be kept.\nin this case, the strategy of \"--resolve-unrelated\" only determines which source-code to keep. it's not about the history.\n2. if the component doesn't exist on main, then by default, the history of the current lane will be kept.\nunless \"--resolve-unrelated\" is set to \"theirs\", in which case the history of the other lane will be kept.\n2. a. an edge case: if the component is deleted on the current lane, the strategy will always be \"theirs\".\nso then the history (and the source-code) of the other lane will be kept.\n`;\n arguments = [\n {\n name: 'lane',\n description: 'lane-name or full lane-id (if remote) to merge to the current lane',\n },\n {\n name: 'pattern',\n description: `partially merge the lane - only components that match the specified component-pattern\nComponent pattern format: ${COMPONENT_PATTERN_HELP}`,\n },\n ];\n alias = '';\n options = [\n [\n '',\n 'manual',\n 'same as \"--auto-merge-resolve manual\". in case of merge conflict, write the files with the conflict markers',\n ],\n [\n 'r',\n 'auto-merge-resolve <merge-strategy>',\n 'in case of a merge conflict, resolve according to the provided strategy: [ours, theirs, manual]',\n ],\n ['', 'ours', 'DEPRECATED. use --auto-merge-resolve. in case of a conflict, keep local modifications'],\n ['', 'theirs', 'DEPRECATED. use --auto-merge-resolve. in case of a conflict, override local with incoming changes'],\n ['', 'workspace', 'merge only lane components that are in the current workspace'],\n [\n '',\n 'no-auto-snap',\n 'do not auto snap after merge completed without conflicts of diverged components (see command description)',\n ],\n ['', 'no-snap', 'do not pass snaps from the other lane even for non-diverged components (see command description)'],\n ['', 'tag', 'auto-tag all lane components after merging into main (or tag-merge in case of snap-merge)'],\n ['', 'build', 'in case of snap during the merge, run the build-pipeline (similar to bit snap --build)'],\n ['m', 'message <message>', 'override the default message for the auto snap'],\n ['', 'keep-readme', 'skip deleting the lane readme component after merging'],\n ['', 'no-squash', 'relevant for merging lanes into main, which by default squashes all lane snaps'],\n ['', 'squash', 'relevant for merging a lane into another non-main lane, which by default does not squash'],\n [\n '',\n 'ignore-config-changes',\n 'allow merging when components are modified due to config changes (such as dependencies) only and not files',\n ],\n ['', 'verbose', 'display detailed information about components that were legitimately unmerged'],\n ['x', 'skip-dependency-installation', 'do not install dependencies of the imported components'],\n ['', 'skip-fetch', 'use the local state of target-lane if exits locally, without updating it from the remote'],\n [\n '',\n 'include-deps',\n 'relevant for \"pattern\" and \"--workspace\". merge also dependencies of the specified components',\n ],\n [\n '',\n 'resolve-unrelated [merge-strategy]',\n 'relevant when a component on a lane and the component on main have nothing in common. merge-strategy can be \"ours\" (default) or \"theirs\"',\n ],\n [\n '',\n 'include-non-lane-comps',\n 'DEPRECATED (this is now the default). when merging main, include workspace components that are not on the lane (by default only lane components are merged)',\n ],\n [\n '',\n 'exclude-non-lane-comps',\n 'when merging main into a lane, exclude workspace components that are not on the lane (by default all workspace components are merged)',\n ],\n ] as CommandOptions;\n loader = true;\n private = true;\n remoteOp = true;\n\n constructor(\n private mergeLanes: MergeLanesMain,\n private globalConfig: GlobalConfigMain\n ) {}\n\n async report(\n [name, pattern]: [string, string],\n {\n ours,\n theirs,\n manual,\n autoMergeResolve,\n build,\n workspace: existingOnWorkspaceOnly = false,\n squash = false,\n noAutoSnap = false,\n noSnap = false,\n tag = false,\n message: snapMessage = '',\n keepReadme = false,\n noSquash = false,\n skipDependencyInstallation = false,\n skipFetch = false,\n includeDeps = false,\n resolveUnrelated,\n ignoreConfigChanges,\n verbose = false,\n excludeNonLaneComps = false,\n }: {\n ours?: boolean;\n theirs?: boolean;\n manual?: boolean;\n autoMergeResolve?: string;\n workspace?: boolean;\n build?: boolean;\n noAutoSnap: boolean;\n noSnap: boolean;\n tag: boolean;\n message: string;\n keepReadme?: boolean;\n squash?: boolean;\n noSquash: boolean;\n skipDependencyInstallation?: boolean;\n skipFetch: boolean;\n includeDeps?: boolean;\n resolveUnrelated?: string | boolean;\n ignoreConfigChanges?: boolean;\n verbose?: boolean;\n excludeNonLaneComps?: boolean;\n }\n ): Promise<string> {\n build = (await this.globalConfig.getBool(CFG_FORCE_LOCAL_BUILD)) || Boolean(build);\n if (ours || theirs) {\n throw new BitError(\n 'the \"--ours\" and \"--theirs\" flags are deprecated. use \"--auto-merge-resolve\" instead. see \"bit lane merge --help\" for more information'\n );\n }\n if (\n autoMergeResolve &&\n autoMergeResolve !== 'ours' &&\n autoMergeResolve !== 'theirs' &&\n autoMergeResolve !== 'manual'\n ) {\n throw new BitError('--auto-merge-resolve must be one of the following: [ours, theirs, manual]');\n }\n if (manual) autoMergeResolve = 'manual';\n const mergeStrategy = autoMergeResolve;\n if (noAutoSnap && snapMessage) throw new BitError('unable to use \"no-snap\" and \"message\" flags together');\n if (includeDeps && !pattern && !existingOnWorkspaceOnly) {\n throw new BitError(`\"--include-deps\" flag is relevant only for --workspace and --pattern flags`);\n }\n const getResolveUnrelated = (): MergeStrategy | undefined => {\n if (!resolveUnrelated) return undefined;\n if (typeof resolveUnrelated === 'boolean') return 'ours';\n if (resolveUnrelated !== 'ours' && resolveUnrelated !== 'theirs' && resolveUnrelated !== 'manual') {\n throw new Error('--resolve-unrelated must be one of the following: [ours, theirs, manual]');\n }\n return resolveUnrelated;\n };\n if (resolveUnrelated && typeof resolveUnrelated === 'boolean') {\n resolveUnrelated = 'ours';\n }\n const { mergeResults, deleteResults, configMergeResults } = await this.mergeLanes.mergeLaneByCLI(name, {\n build,\n // @ts-ignore\n mergeStrategy,\n ours,\n theirs,\n existingOnWorkspaceOnly,\n noAutoSnap,\n noSnap,\n snapMessage,\n keepReadme,\n squash,\n noSquash,\n tag,\n pattern,\n skipDependencyInstallation,\n skipFetch,\n resolveUnrelated: getResolveUnrelated(),\n ignoreConfigChanges,\n includeDeps,\n excludeNonLaneComps,\n });\n\n const mergeResult = mergeReport({ ...mergeResults, configMergeResults, verbose });\n const deleteOutput = `\\n${deleteResults.localResult ? removeTemplate(deleteResults.localResult, false) : ''}${(\n deleteResults.remoteResult || []\n ).map((item) => removeTemplate(item, true))}${\n (deleteResults.readmeResult && chalk.yellow(deleteResults.readmeResult)) || ''\n }\\n`;\n return mergeResult + deleteOutput;\n }\n}\n"],"mappings":";;;;;;AAAA,SAAAA,OAAA;EAAA,MAAAC,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAH,MAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEA,SAAAG,SAAA;EAAA,MAAAH,IAAA,GAAAE,OAAA;EAAAC,QAAA,YAAAA,CAAA;IAAA,OAAAH,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEA,SAAAI,QAAA;EAAA,MAAAJ,IAAA,GAAAE,OAAA;EAAAE,OAAA,YAAAA,CAAA;IAAA,OAAAJ,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAK,UAAA;EAAA,MAAAL,IAAA,GAAAE,OAAA;EAAAG,SAAA,YAAAA,CAAA;IAAA,OAAAL,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAM,QAAA;EAAA,MAAAN,IAAA,GAAAE,OAAA;EAAAI,OAAA,YAAAA,CAAA;IAAA,OAAAN,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAAiD,SAAAC,uBAAAM,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAAA,SAAAG,QAAAH,CAAA,EAAAI,CAAA,QAAAC,CAAA,GAAAC,MAAA,CAAAC,IAAA,CAAAP,CAAA,OAAAM,MAAA,CAAAE,qBAAA,QAAAC,CAAA,GAAAH,MAAA,CAAAE,qBAAA,C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AAC,GAAG,MAAM,IAAI,CAACvC,UAAU,CAACwC,cAAc,CAACtC,IAAI,EAAE;MACrGS,KAAK;MACL;MACAsB,aAAa;MACb1B,IAAI;MACJC,MAAM;MACNK,uBAAuB;MACvBE,UAAU;MACVC,MAAM;MACNG,WAAW;MACXC,UAAU;MACVN,MAAM;MACNO,QAAQ;MACRJ,GAAG;MACHX,OAAO;MACPgB,0BAA0B;MAC1BC,SAAS;MACTE,gBAAgB,EAAES,mBAAmB,CAAC,CAAC;MACvCR,mBAAmB;MACnBF,WAAW;MACXI;IACF,CAAC,CAAC;IAEF,MAAMa,WAAW,GAAG,IAAAC,sBAAW,EAAAhE,aAAA,CAAAA,aAAA,KAAM2D,YAAY;MAAEE,kBAAkB;MAAEZ;IAAO,EAAE,CAAC;IACjF,MAAMgB,YAAY,GAAG,KAAKL,aAAa,CAACM,WAAW,GAAG,IAAAC,wBAAc,EAACP,aAAa,CAACM,WAAW,EAAE,KAAK,CAAC,GAAG,EAAE,GAAG,CAC5GN,aAAa,CAACQ,YAAY,IAAI,EAAE,EAChCC,GAAG,CAAEC,IAAI,IAAK,IAAAH,wBAAc,EAACG,IAAI,EAAE,IAAI,CAAC,CAAC,GACxCV,aAAa,CAACW,YAAY,IAAIC,gBAAK,CAACC,MAAM,CAACb,aAAa,CAACW,YAAY,CAAC,IAAK,EAAE,IAC5E;IACJ,OAAOR,WAAW,GAAGE,YAAY;EACnC;AACF;AAACS,OAAA,CAAAtD,YAAA,GAAAA,YAAA","ignoreList":[]}
1
+ {"version":3,"names":["_chalk","data","_interopRequireDefault","require","_merging","_legacy","_bitError","_remove","e","__esModule","default","ownKeys","r","t","Object","keys","getOwnPropertySymbols","o","filter","getOwnPropertyDescriptor","enumerable","push","apply","_objectSpread","arguments","length","forEach","_defineProperty","getOwnPropertyDescriptors","defineProperties","defineProperty","_toPropertyKey","value","configurable","writable","i","_toPrimitive","Symbol","toPrimitive","call","TypeError","String","Number","MergeLaneCmd","constructor","mergeLanes","globalConfig","name","description","COMPONENT_PATTERN_HELP","report","pattern","ours","theirs","manual","autoMergeResolve","build","workspace","existingOnWorkspaceOnly","squash","noAutoSnap","noSnap","tag","message","snapMessage","keepReadme","noSquash","skipDependencyInstallation","skipFetch","includeDeps","resolveUnrelated","ignoreConfigChanges","verbose","excludeNonLaneComps","detachHead","getBool","CFG_FORCE_LOCAL_BUILD","Boolean","BitError","mergeStrategy","getResolveUnrelated","undefined","Error","mergeResults","deleteResults","configMergeResults","mergeLaneByCLI","mergeResult","mergeReport","deleteOutput","localResult","removeTemplate","remoteResult","map","item","readmeResult","chalk","yellow","exports"],"sources":["merge-lane.cmd.ts"],"sourcesContent":["import chalk from 'chalk';\nimport { Command, CommandOptions } from '@teambit/cli';\nimport { mergeReport, MergeStrategy } from '@teambit/merging';\nimport { GlobalConfigMain } from '@teambit/global-config';\nimport { COMPONENT_PATTERN_HELP, CFG_FORCE_LOCAL_BUILD } from '@teambit/legacy.constants';\nimport { BitError } from '@teambit/bit-error';\nimport { removeTemplate } from '@teambit/remove';\nimport { MergeLanesMain } from './merge-lanes.main.runtime';\n\nexport class MergeLaneCmd implements Command {\n name = 'merge <lane> [pattern]';\n description = `merge a local or a remote lane to the current lane`;\n extendedDescription = `by default, the provided lane will be fetched from the remote before merging.\nto merge the lane from the local scope without updating it first, use \"--skip-fetch\" flag.\n\nwhen the current and merge candidate lanes are diverged in history and the files could be merged with no conflicts,\nthese components will be snap-merged to complete the merge. use \"no-auto-snap\" to opt-out, or \"tag\" to tag instead.\n\nwhen the components are not diverged in history, and the current lane is behind the merge candidate, the merge will\nsimply update the components and the heads according to the merge candidate.\nto opt-out, use \"--no-snap\", the components will be written as the merge candidate, and will be left as modified.\n\nin case a component in both ends don't share history (no snap is found in common), the merge will require \"--resolve-unrelated\" flag.\nthis flag keeps the history of one end and saves a reference to the other end. the decision of which end to keep is determined by the following:\n1. if the component exists on main, then the history linked to main will be kept.\nin this case, the strategy of \"--resolve-unrelated\" only determines which source-code to keep. it's not about the history.\n2. if the component doesn't exist on main, then by default, the history of the current lane will be kept.\nunless \"--resolve-unrelated\" is set to \"theirs\", in which case the history of the other lane will be kept.\n2. a. an edge case: if the component is deleted on the current lane, the strategy will always be \"theirs\".\nso then the history (and the source-code) of the other lane will be kept.\n`;\n arguments = [\n {\n name: 'lane',\n description: 'lane-name or full lane-id (if remote) to merge to the current lane',\n },\n {\n name: 'pattern',\n description: `partially merge the lane - only components that match the specified component-pattern\nComponent pattern format: ${COMPONENT_PATTERN_HELP}`,\n },\n ];\n alias = '';\n options = [\n [\n '',\n 'manual',\n 'same as \"--auto-merge-resolve manual\". in case of merge conflict, write the files with the conflict markers',\n ],\n [\n 'r',\n 'auto-merge-resolve <merge-strategy>',\n 'in case of a merge conflict, resolve according to the provided strategy: [ours, theirs, manual]',\n ],\n ['', 'ours', 'DEPRECATED. use --auto-merge-resolve. in case of a conflict, keep local modifications'],\n ['', 'theirs', 'DEPRECATED. use --auto-merge-resolve. in case of a conflict, override local with incoming changes'],\n ['', 'workspace', 'merge only lane components that are in the current workspace'],\n [\n '',\n 'no-auto-snap',\n 'do not auto snap after merge completed without conflicts of diverged components (see command description)',\n ],\n ['', 'no-snap', 'do not pass snaps from the other lane even for non-diverged components (see command description)'],\n ['', 'tag', 'auto-tag all lane components after merging into main (or tag-merge in case of snap-merge)'],\n ['', 'build', 'in case of snap during the merge, run the build-pipeline (similar to bit snap --build)'],\n ['m', 'message <message>', 'override the default message for the auto snap'],\n ['', 'keep-readme', 'skip deleting the lane readme component after merging'],\n ['', 'no-squash', 'relevant for merging lanes into main, which by default squashes all lane snaps'],\n ['', 'squash', 'relevant for merging a lane into another non-main lane, which by default does not squash'],\n [\n '',\n 'ignore-config-changes',\n 'allow merging when components are modified due to config changes (such as dependencies) only and not files',\n ],\n ['', 'verbose', 'display detailed information about components that were legitimately unmerged'],\n ['x', 'skip-dependency-installation', 'do not install dependencies of the imported components'],\n ['', 'skip-fetch', 'use the local state of target-lane if exits locally, without updating it from the remote'],\n [\n '',\n 'include-deps',\n 'relevant for \"pattern\" and \"--workspace\". merge also dependencies of the specified components',\n ],\n [\n '',\n 'resolve-unrelated [merge-strategy]',\n 'relevant when a component on a lane and the component on main have nothing in common. merge-strategy can be \"ours\" (default) or \"theirs\"',\n ],\n [\n '',\n 'include-non-lane-comps',\n 'DEPRECATED (this is now the default). when merging main, include workspace components that are not on the lane (by default only lane components are merged)',\n ],\n [\n '',\n 'exclude-non-lane-comps',\n 'when merging main into a lane, exclude workspace components that are not on the lane (by default all workspace components are merged)',\n ],\n [\n '',\n 'detach-head',\n 'UNSUPPORTED YET. for each component, find the divergent point from main and merge to that point. do not change the head',\n ],\n ] as CommandOptions;\n loader = true;\n private = true;\n remoteOp = true;\n\n constructor(\n private mergeLanes: MergeLanesMain,\n private globalConfig: GlobalConfigMain\n ) {}\n\n async report(\n [name, pattern]: [string, string],\n {\n ours,\n theirs,\n manual,\n autoMergeResolve,\n build,\n workspace: existingOnWorkspaceOnly = false,\n squash = false,\n noAutoSnap = false,\n noSnap = false,\n tag = false,\n message: snapMessage = '',\n keepReadme = false,\n noSquash = false,\n skipDependencyInstallation = false,\n skipFetch = false,\n includeDeps = false,\n resolveUnrelated,\n ignoreConfigChanges,\n verbose = false,\n excludeNonLaneComps = false,\n detachHead,\n }: {\n ours?: boolean;\n theirs?: boolean;\n manual?: boolean;\n autoMergeResolve?: string;\n workspace?: boolean;\n build?: boolean;\n noAutoSnap: boolean;\n noSnap: boolean;\n tag: boolean;\n message: string;\n keepReadme?: boolean;\n squash?: boolean;\n noSquash: boolean;\n skipDependencyInstallation?: boolean;\n skipFetch: boolean;\n includeDeps?: boolean;\n resolveUnrelated?: string | boolean;\n ignoreConfigChanges?: boolean;\n verbose?: boolean;\n excludeNonLaneComps?: boolean;\n detachHead?: boolean;\n }\n ): Promise<string> {\n build = (await this.globalConfig.getBool(CFG_FORCE_LOCAL_BUILD)) || Boolean(build);\n if (ours || theirs) {\n throw new BitError(\n 'the \"--ours\" and \"--theirs\" flags are deprecated. use \"--auto-merge-resolve\" instead. see \"bit lane merge --help\" for more information'\n );\n }\n if (\n autoMergeResolve &&\n autoMergeResolve !== 'ours' &&\n autoMergeResolve !== 'theirs' &&\n autoMergeResolve !== 'manual'\n ) {\n throw new BitError('--auto-merge-resolve must be one of the following: [ours, theirs, manual]');\n }\n if (manual) autoMergeResolve = 'manual';\n const mergeStrategy = autoMergeResolve;\n if (noAutoSnap && snapMessage) throw new BitError('unable to use \"no-snap\" and \"message\" flags together');\n if (includeDeps && !pattern && !existingOnWorkspaceOnly) {\n throw new BitError(`\"--include-deps\" flag is relevant only for --workspace and --pattern flags`);\n }\n const getResolveUnrelated = (): MergeStrategy | undefined => {\n if (!resolveUnrelated) return undefined;\n if (typeof resolveUnrelated === 'boolean') return 'ours';\n if (resolveUnrelated !== 'ours' && resolveUnrelated !== 'theirs' && resolveUnrelated !== 'manual') {\n throw new Error('--resolve-unrelated must be one of the following: [ours, theirs, manual]');\n }\n return resolveUnrelated;\n };\n if (resolveUnrelated && typeof resolveUnrelated === 'boolean') {\n resolveUnrelated = 'ours';\n }\n const { mergeResults, deleteResults, configMergeResults } = await this.mergeLanes.mergeLaneByCLI(name, {\n build,\n // @ts-ignore\n mergeStrategy,\n ours,\n theirs,\n existingOnWorkspaceOnly,\n noAutoSnap,\n noSnap,\n snapMessage,\n keepReadme,\n squash,\n noSquash,\n tag,\n pattern,\n skipDependencyInstallation,\n skipFetch,\n resolveUnrelated: getResolveUnrelated(),\n ignoreConfigChanges,\n includeDeps,\n excludeNonLaneComps,\n detachHead,\n });\n\n const mergeResult = mergeReport({ ...mergeResults, configMergeResults, verbose });\n const deleteOutput = `\\n${deleteResults.localResult ? removeTemplate(deleteResults.localResult, false) : ''}${(\n deleteResults.remoteResult || []\n ).map((item) => removeTemplate(item, true))}${\n (deleteResults.readmeResult && chalk.yellow(deleteResults.readmeResult)) || ''\n }\\n`;\n return mergeResult + deleteOutput;\n }\n}\n"],"mappings":";;;;;;AAAA,SAAAA,OA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AC1BC,SAAS;MACTE,gBAAgB,EAAEU,mBAAmB,CAAC,CAAC;MACvCT,mBAAmB;MACnBF,WAAW;MACXI,mBAAmB;MACnBC;IACF,CAAC,CAAC;IAEF,MAAMa,WAAW,GAAG,IAAAC,sBAAW,EAAAjE,aAAA,CAAAA,aAAA,KAAM4D,YAAY;MAAEE,kBAAkB;MAAEb;IAAO,EAAE,CAAC;IACjF,MAAMiB,YAAY,GAAG,KAAKL,aAAa,CAACM,WAAW,GAAG,IAAAC,wBAAc,EAACP,aAAa,CAACM,WAAW,EAAE,KAAK,CAAC,GAAG,EAAE,GAAG,CAC5GN,aAAa,CAACQ,YAAY,IAAI,EAAE,EAChCC,GAAG,CAAEC,IAAI,IAAK,IAAAH,wBAAc,EAACG,IAAI,EAAE,IAAI,CAAC,CAAC,GACxCV,aAAa,CAACW,YAAY,IAAIC,gBAAK,CAACC,MAAM,CAACb,aAAa,CAACW,YAAY,CAAC,IAAK,EAAE,IAC5E;IACJ,OAAOR,WAAW,GAAGE,YAAY;EACnC;AACF;AAACS,OAAA,CAAAvD,YAAA,GAAAA,YAAA","ignoreList":[]}
@@ -36,6 +36,7 @@ export type MergeLaneOptions = {
36
36
  shouldIncludeUpdateDependents?: boolean;
37
37
  throwIfNotUpToDate?: boolean;
38
38
  fetchCurrent?: boolean;
39
+ detachHead?: boolean;
39
40
  };
40
41
  export type ConflictPerId = {
41
42
  id: ComponentID;
@@ -179,6 +179,13 @@ function _mergeMove() {
179
179
  };
180
180
  return data;
181
181
  }
182
+ function _harmonyModules2() {
183
+ const data = require("@teambit/harmony.modules.feature-toggle");
184
+ _harmonyModules2 = function () {
185
+ return data;
186
+ };
187
+ return data;
188
+ }
182
189
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
183
190
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
184
191
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
@@ -229,7 +236,8 @@ class MergeLanesMain {
229
236
  excludeNonLaneComps,
230
237
  shouldIncludeUpdateDependents,
231
238
  throwIfNotUpToDate,
232
- fetchCurrent
239
+ fetchCurrent,
240
+ detachHead
233
241
  } = options;
234
242
  const legacyScope = this.scope.legacyScope;
235
243
  if (tag && !currentLaneId.isDefault()) {
@@ -241,6 +249,12 @@ class MergeLanesMain {
241
249
  if (resolveUnrelated && currentLaneId.isDefault()) {
242
250
  throw new (_bitError().BitError)(`unable to resolve unrelated when on main. switch to ${otherLaneId.toString()} and run "bit lane merge main --resolve-unrelated"`);
243
251
  }
252
+ if (detachHead && !(0, _harmonyModules2().isFeatureEnabled)(_harmonyModules2().DETACH_HEAD)) {
253
+ throw new (_bitError().BitError)(`unable to detach head. the feature is not enabled`);
254
+ }
255
+ if (detachHead && !currentLaneId.isDefault()) {
256
+ throw new (_bitError().BitError)(`unable to detach head. the current lane is not main`);
257
+ }
244
258
  if (fetchCurrent && !currentLaneId.isDefault()) {
245
259
  // if current is default, it'll be fetch later on
246
260
  await this.lanes.fetchLaneWithItsComponents(currentLaneId);
@@ -293,7 +307,8 @@ class MergeLanesMain {
293
307
  ignoreConfigChanges,
294
308
  shouldSquash,
295
309
  mergeStrategy,
296
- handleTargetAheadAsDiverged: noSnap
310
+ handleTargetAheadAsDiverged: noSnap,
311
+ detachHead
297
312
  }, currentLane, otherLane);
298
313
  if (pattern) {
299
314
  const componentIds = idsToMerge;
@@ -326,7 +341,10 @@ class MergeLanesMain {
326
341
  (0, _checkout().throwForFailures)(allComponentsStatus);
327
342
  const succeededComponents = allComponentsStatus.filter(c => !c.unchangedMessage);
328
343
  if (shouldSquash) {
329
- await squashSnaps(succeededComponents, currentLaneId, otherLaneId, legacyScope, options.snapMessage);
344
+ await squashSnaps(succeededComponents, currentLaneId, otherLaneId, legacyScope, {
345
+ messageTitle: options.snapMessage,
346
+ detachHead
347
+ });
330
348
  }
331
349
  if (laneToFetchArtifactsFrom) {
332
350
  const ids = allComponentsStatus.map(c => c.id);
@@ -344,7 +362,8 @@ class MergeLanesMain {
344
362
  tag,
345
363
  snapMessage,
346
364
  build,
347
- skipDependencyInstallation
365
+ skipDependencyInstallation,
366
+ detachHead
348
367
  });
349
368
  if (snapshot) await lastMerged?.persistSnapshot(snapshot);
350
369
  const mergedSuccessfully = !mergeResults.failedComponents || mergeResults.failedComponents.length === 0 || mergeResults.failedComponents.every(failedComponent => failedComponent.unchangedLegitimately);
@@ -657,7 +676,7 @@ async function getLogForSquash(otherLaneId) {
657
676
  });
658
677
  return log;
659
678
  }
660
- async function squashSnaps(succeededComponents, currentLaneId, otherLaneId, scope, messageTitle) {
679
+ async function squashSnaps(succeededComponents, currentLaneId, otherLaneId, scope, opts = {}) {
661
680
  const currentLaneName = currentLaneId.name;
662
681
  const log = await getLogForSquash(otherLaneId);
663
682
  await Promise.all(succeededComponents.map(async ({
@@ -668,7 +687,7 @@ async function squashSnaps(succeededComponents, currentLaneId, otherLaneId, scop
668
687
  if (!divergeData) {
669
688
  throw new Error(`unable to squash. divergeData is missing from ${id.toString()}`);
670
689
  }
671
- const modifiedComp = await squashOneComp(currentLaneName, otherLaneId, id, divergeData, log, scope, componentFromModel, messageTitle);
690
+ const modifiedComp = await squashOneComp(currentLaneName, otherLaneId, id, divergeData, log, scope, componentFromModel, opts);
672
691
  if (modifiedComp) {
673
692
  scope.objects.add(modifiedComp);
674
693
  const modelComponent = await scope.getModelComponent(id);
@@ -681,20 +700,35 @@ async function squashSnaps(succeededComponents, currentLaneId, otherLaneId, scop
681
700
  /**
682
701
  * returns Version object if it was modified. otherwise, returns undefined
683
702
  */
684
- async function squashOneComp(currentLaneName, otherLaneId, id, divergeData, log, scope, componentFromModel, messageTitle) {
685
- if (divergeData.isDiverged()) {
686
- throw new (_bitError().BitError)(`unable to squash because ${id.toString()} is diverged in history.
687
- consider switching to "${otherLaneId.name}" first, merging "${currentLaneName}", then switching back to "${currentLaneName}" and merging "${otherLaneId.name}"
688
- alternatively, use "--no-squash" flag to keep the entire history of "${otherLaneId.name}"`);
689
- }
690
- if (divergeData.isSourceAhead()) {
691
- // nothing to do. current is ahead, nothing to merge. (it was probably filtered out already as a "failedComponent")
692
- return undefined;
693
- }
694
- if (!divergeData.isTargetAhead()) {
695
- // nothing to do. current and remote are the same, nothing to merge. (it was probably filtered out already as a "failedComponent")
703
+ async function squashOneComp(currentLaneName, otherLaneId, id, divergeData, log, scope, componentFromModel, opts = {}) {
704
+ const {
705
+ messageTitle,
706
+ detachHead
707
+ } = opts;
708
+ const shouldSquash = () => {
709
+ if (divergeData.isDiverged()) {
710
+ if (detachHead) {
711
+ // for detach head, it's ok to have it as diverged. as long as the target is ahead, we want to squash.
712
+ return true;
713
+ }
714
+ throw new (_bitError().BitError)(`unable to squash because ${id.toString()} is diverged in history.
715
+ consider switching to "${otherLaneId.name}" first, merging "${currentLaneName}", then switching back to "${currentLaneName}" and merging "${otherLaneId.name}"
716
+ alternatively, use "--no-squash" flag to keep the entire history of "${otherLaneId.name}"`);
717
+ }
718
+ if (divergeData.isSourceAhead()) {
719
+ // nothing to do. current is ahead, nothing to merge. (it was probably filtered out already as a "failedComponent")
720
+ return false;
721
+ }
722
+ if (!divergeData.isTargetAhead()) {
723
+ // nothing to do. current and remote are the same, nothing to merge. (it was probably filtered out already as a "failedComponent")
724
+ return false;
725
+ }
726
+ return true;
727
+ };
728
+ if (!shouldSquash()) {
696
729
  return undefined;
697
730
  }
731
+
698
732
  // remote is ahead and was not diverge.
699
733
  const remoteSnaps = divergeData.snapsOnTargetOnly;
700
734
  if (remoteSnaps.length === 0) {