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

fix: Enable Source-Tracking Commands (Push*, Pull*, View Changes*) for Source-Tracked Sandboxes #4755

Merged
merged 27 commits into from
Apr 6, 2023

Conversation

klewis-sfdc
Copy link
Contributor

@klewis-sfdc klewis-sfdc commented Mar 27, 2023

What does this PR do?

  • Fixes the getWorkspaceOrgType function to properly identify source-tracked sandboxes as being source-tracking enabled.

  • Making this change exposes the SFDX: Push*, SFDX: Pull*, and SFDX: View Changes* commands when connected to a source-tracked sandbox org. These commands have been slightly renamed, to remove the word "Scratch" from the command title.

  • ⚠️ This PR changes the behavior of the Push-or-deploy-on-save setting. Prior to this PR, this setting would initiate a deploy operation on save. After this PR the setting will initiate a push operation on save - since the extension code now recognizes a sandbox with source-tracking enabled as being a source-tracked org. ⚠️

What issues does this PR fix or reference?

@W-12757190@
Fixes #2952

Many thanks to @FabienTaillon for submitting a draft PR (#4727) to implement this.

Functionality Before

  • getWorkspaceOrgType would return OrgType.NonSourceTracked for a source-tracked Sandbox.

  • When enabled, the Push-or-deploy-on-save setting would initiate a deploy operation on save.

  • The following commands were not exposed when connected to a source-tracked Sandbox:
    'SFDX: Pull Source from Default Scratch Org',
    'SFDX: Pull Source from Default Scratch Org and Override Conflicts',
    'SFDX: Pull Source from Default Scratch Org (Legacy)',**
    'SFDX: Pull Source from Default Scratch Org and Override Conflicts (Legacy)',**

    'SFDX: Push Source to Default Scratch Org',
    'SFDX: Push Source to Default Scratch Org and Override Conflicts',
    'SFDX: Push Source to Default Scratch Org (Legacy)',**
    'SFDX: Push Source to Default Scratch Org and Override Conflicts (Legacy)',**

    'SFDX: View Local Changes',
    'SFDX: View Changes in Default Scratch Org',
    'SFDX: View All Changes (Local and in Default Scratch Org)',
    'SFDX: View All Changes (Local and in Default Scratch Org) (Legacy)'**

Note: the "(Legacy)" commands were removed in #4771

Functionality After

  • getWorkspaceOrgType returns OrgType.SourceTracked for a source-tracked Sandbox.

  • When enabled, the Push-or-deploy-on-save setting initiates a push operation on save.

  • The following commands ARE exposed when connected to a source-tracked Sandbox (and are renamed slightly):
    'SFDX: Pull Source from Default Org',
    'SFDX: Pull Source from Default Org and Override Conflicts',

    'SFDX: Push Source to Default Org',
    'SFDX: Push Source to Default Org and Override Conflicts',

    'SFDX: View Local Changes',
    'SFDX: View Changes in Default Org',
    'SFDX: View All Changes (Local and in Default Org)',

Todos:

  • Check for behavioral changes re: the push-or-deploy-on-save setting
  • Keep Deploy* and Retrieve* commands, Org Browser and Conflict View exposed for source-tracked sandboxes to keep existing behavior consistent.

@klewis-sfdc klewis-sfdc marked this pull request as ready for review March 27, 2023 21:42
@klewis-sfdc klewis-sfdc requested a review from a team as a code owner March 27, 2023 21:42
Copy link
Contributor

@sbudhirajadoc sbudhirajadoc left a comment

Choose a reason for hiding this comment

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

I'll defer to @AnanyaJha and approve once she has looked at this change because Ken and I discussed this change and came up with this text together.

@klewis-sfdc klewis-sfdc changed the title feat: Expose Push* and Pull* Commands for Source-Tracked Sandboxes feat: Enable Source-Tracking Commands (Push*, Pull*, View Changes*) for Source-Tracked Sandboxes Mar 30, 2023
@klewis-sfdc
Copy link
Contributor Author

@sbudhirajadoc and @AnanyaJha FYI - realized that this workspaceOrgType change also exposes the SFDX: View Changes* commands - which is good since those commands can be used to check source status in a source-tracked sandbox now. Just wanted to give you a heads up that I also updated the title text for those commands to remove "Scratch".

@@ -150,14 +150,14 @@
{
"id": "metadata",
"name": "Metadata",
"when": "sfdx:project_opened && sfdx:default_username_has_no_change_tracking"
"when": "sfdx:project_opened && (sfdx:default_username_has_no_change_tracking || !sfdx:is_scratch_org)"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Had to add this context variable in order to keep the Deploy* and Retrieve* commands exposed for source-tracked Sandboxes but not yet expose them for Scratch Orgs.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Do the deploy/retrieve commands not yet work for scratch orgs?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

They work to deploy and retrieve the components, but they do not fix up source tracking correctly, since they don't have the source tracking library in the flow.

I broke the original PR up to split out the work in this PR, and the next two PRs will be to "fix Retrieve for source-tracked sandboxes" (to add in STL #4773), and then "fix Deploy for source-tracked sandboxes" (to add in STL).

After those two, we will expose deploy/retrieve for Scratch orgs (now that they will be handling source tracking correctly). And finally, expose Org Browser.

import * as vscode from 'vscode';
import { OrgAuthInfo } from '../util';

export async function setIsScratchOrg() {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Pulled this out from workspaceContext to make testing easier.

@@ -56,6 +55,10 @@ export async function setupWorkspaceOrgType(defaultUsernameOrAlias?: string) {
setDefaultUsernameHasChangeTracking(false);
setDefaultUsernameHasNoChangeTracking(false);
break;
case 'NoUsernameFoundError':
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Saw this error when I was writing the unit test.

2023-04-05_22-35-59

@klewis-sfdc klewis-sfdc changed the title feat: Enable Source-Tracking Commands (Push*, Pull*, View Changes*) for Source-Tracked Sandboxes fix: Enable Source-Tracking Commands (Push*, Pull*, View Changes*) for Source-Tracked Sandboxes Apr 6, 2023
Copy link
Collaborator

@AnanyaJha AnanyaJha left a comment

Choose a reason for hiding this comment

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

:shipit:

@@ -150,14 +150,14 @@
{
"id": "metadata",
"name": "Metadata",
"when": "sfdx:project_opened && sfdx:default_username_has_no_change_tracking"
"when": "sfdx:project_opened && (sfdx:default_username_has_no_change_tracking || !sfdx:is_scratch_org)"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do the deploy/retrieve commands not yet work for scratch orgs?

@jeffb-sfdc
Copy link
Contributor

I QA'd this and didn't find any issues. I tested push, pull, and view changes on a scratch org, a source tracked sandbox org, and tests deploy & retrieve on a (non-source tracked) sandbox org.

@klewis-sfdc klewis-sfdc merged commit b1b348b into develop Apr 6, 2023
12 checks passed
@klewis-sfdc klewis-sfdc deleted the ken/push-and-pull-for-src-trk-sandboxes branch April 6, 2023 23:38
sbudhirajadoc added a commit that referenced this pull request Apr 13, 2023
change to stay in line with this PR -- #4755
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.

Setting to change to pull/push operations in context menu for source-tracked Sandboxes
4 participants