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: match and update maxRevision entries with decoded keys #458

Merged
merged 7 commits into from
Aug 21, 2023

Conversation

shetzel
Copy link
Collaborator

@shetzel shetzel commented Aug 8, 2023

What does this PR do?

Allows entries in maxRevision.json to be matched and updated by comparing decoded keys. For example, an entry in maxRevision.json with a key of Layout__Broker__c-v1.1 Broker Layout will match on getSourceMember('Layout__Broker__c-v1%2E1 Broker Layout'). It will also update the existing entry when setMemberRevision('Layout__Broker__c-v1%2E1 Broker Layout', {...changes}) is called.

Also, the populateFilePaths function will match remote changes with local metadata files using decoded metadata fullNames.

This allows (e.g.) sf project retrieve preview to report the correct status, and sf project retrieve start (i.e. "a pull") to update local metadata files correctly.

What issues does this PR fix or reference?

@W-11658886@
forcedotcom/cli#1683

NOTE: for testing, SDR PR 1070 is required as well.

@shetzel shetzel changed the title fix: prefer const fix: match and update maxRevision entries with decoded keys Aug 8, 2023
src/shared/remoteSourceTrackingService.ts Outdated Show resolved Hide resolved
@mshanemc
Copy link
Contributor

QA notes:

using linked SDR into STL, then SDR and STL linked in PDR (because Steve used plugin-source)

deploy
✅ no changes seen by retrieve preview

original use case

add the title field to the Broker 1.1 layout and save
project retrieve preview does not recognize that the file matches existing source

Will Retrieve [1] files.
 Type   Fullname                       Path                                                                              
 ────── ────────────────────────────── ───────────────────────────────────────────────────────────────────────────────── 
 Layout Broker__c-v1%2E1 Broker Layout src/force-app/main/default/layouts/Broker__c-v1%2E1 Broker Layout.layout-meta.xml 
 Layout Broker__c-v1.1 Broker Layout                

for reference, without these PRs, the result is still wrong but in a different way

Will Retrieve [1] files.
 Type   Fullname                     Path 
 ────── ──────────────────────────── ──── 
 Layout Broker__c-v1.1 Broker Layout      

✅ 🏆 retrieve updates the existing file.

lets try to break it

create new layout for Broker__c named 1.1 año día

project:retrieve:preview
✅ sees Layout Broker__c-1.1 año día ( no path)

modify layout
retrieve preview shows both files. The non-encoded one has no path (like the first one above)
✅ retrieve start updates the correct file

add a new, empty default pkgDir named src/unpackaged2
✅ modified existing layout and doesn't create a new one

Profiles also use encoding

create Shane's new & fancy profile!
✅ preview correctly shows it ignored

Ignored [2] files. These files won't retrieve because they're ignored by your .forceignore file.
 Type    Fullname                     Path 
 ─────── ──────────────────────────── ──── 
 Profile Admin                             
 Profile Shane's new & fancy profile!  

remove profile from forceignore
retrieve start results

| Created Shane%27s new %26 fancy profile%21 Profile src/unpackaged2/main/default/profiles/Shane%27s new %26 fancy profile%21.profile-meta.xml 

preview
❌ keeps showing up in preview

Will Retrieve [1] files.
 Type    Fullname                     Path 
 ─────── ──────────────────────────── ──── 
 Profile Shane's new & fancy profile!   

create "path": "src/unpackaged3" and make it the default pkgDir.
edit Profile description
❌ retrieves into src/unpackaged3

@mshanemc
Copy link
Contributor

using latest SDR linked into STL, then STL linked into PDR.
org create
../../plugin-deploy-retrieve/bin/dev project:deploy:start
../../plugin-deploy-retrieve/bin/dev project:retrieve:preview
✅ sees no changes except ignored Profile

add Title field to v1.1 Broker Layout
❌ ../../plugin-deploy-retrieve/bin/dev project:retrieve:preview

Will Retrieve [2] files.
 Type   Fullname                       Path                                                                              
 ────── ────────────────────────────── ───────────────────────────────────────────────────────────────────────────────── 
 Layout Broker__c-v1%2E1 Broker Layout src/force-app/main/default/layouts/Broker__c-v1%2E1 Broker Layout.layout-meta.xml 
 Layout Broker__c-v1.1 Broker Layout      

@mshanemc
Copy link
Contributor

QA:

org create
../../plugin-deploy-retrieve/bin/dev project:deploy:start
../../plugin-deploy-retrieve/bin/dev project:retrieve:preview
✅ sees no changes except ignored Profile

add Title field to v1.1 Broker Layout
../../plugin-deploy-retrieve/bin/dev project:retrieve:preview
✅ sees only the layout, knows that it matches existing source
../../plugin-deploy-retrieve/bin/dev project:retrieve:start
✅ successfully retrieves into matching dir
../../plugin-deploy-retrieve/bin/dev project:retrieve:preview
✅ sees no changes

make a local and remote change to create a Conflict
✅ deploy:preview shows conflict
✅ retrieve:preview shows conflict
✅ deploys with --ignore-conflicts
✅ deploy:preview shows no changes
✅ retrieve:preview shows only expected ignored Profile

✅✅✅✅✅✅ works with retrieving conflicts, too.

@mshanemc
Copy link
Contributor

QA: Profiles

create Shane's new & fancy profile!
remove profiles from forceignore
✅ retrieve:start creates 2 profiles, including src/unpackaged/main/default/profiles/Shane%27s new %26 fancy profile%21.profile-meta.xml
modify Profile description in the org ✅ path matches local
✅ retrieve:start modifies profile locally (also created ProfileSessionSetting and ProfilePasswordPolicy)
modify description locally
deploy:preview
❌ shows as a Conflict
deploy:start --ignore-conflicts
✅ deploys and doesn't create a duplicate profile
✅ deploy preview shows no changes after deploy

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