Detect false-positive conflicts between local and remote when initializing source tracking #2572
Replies: 2 comments 5 replies
-
This is not exactly what you're talking about, but if you know what the source tracking state should be you can script it with something like: |
Beta Was this translation helpful? Give feedback.
-
I understand you're describing something more advanced than my basic reset suggestion. I was sharing it just in case it was new information. Another idea to solve this without CLI changes would be for the org pool to know about the associated source control branch/commit of the metadata deployed to it. If the developer ensures the same branch/commit is used when getting an org from the pool, then switches to their development branch, the source tracking state should be correct. This isn't a perfect solution either and has its problems but mentioning it as a possibility. I think you have some nice ideas as well and I don't want to take anything away from the discussion. I'm just throwing some things out there that might work well enough in the current CLI. |
Beta Was this translation helpful? Give feedback.
-
Summary
To speed up our CI/CD pipelines and dev/admin workflows, our team is implementing scratch org pools (to be clear, we're using the pool tools provided by DX@Scale, but we don't use DX@Scale otherwise). We are creating two separate pools: one for validation and running tests within CI/CD pipelines, and one for use by our devs & admins.
Here's how we envisioned this working for the dev/admin scratch org pool:
sf force source push
on all of our DX packages (38 and counting) in the correct order. This takes 15-20 minutes to complete.Where did we go wrong?
We did not understand how source tracking works for scratch orgs!
We thought that since we "pre-pushed" all packages to the scratch orgs after creating them in the pipeline, that when a developer claimed one and pushed from their local branch, only the diffs would need to be pushed, so this would be very fast.
Instead, when the developer claims the scratch org, no local source tracking for that scratch org exists. Running
sf project deploy preview
initializes source tracking, but flags nearly all metadata within the package as conflicts. Then runningsf force source push --force-overwrite
to push and resolve all conflicts takes just as long as the initial push after the scratch org was created. However, all (or nearly all) of the reported conflicts are false-positives, because the metadata in the local source tree is identical to what is deployed in the scratch org.What can be done?
The code that initializes source tracking for a new remote should be smart enough to detect and automatically resolve these false-positive conflicts when local and remote metadata are identical.
In case it's useful, here's an idea for how that could work.
lastRetrievedFromServer
to matchserverRevisionCounter
).Why should anyone care?
This will save developers tons of time when using scratch orgs that have been pre-allocated.
For example, when running the script to push all of our packages (not including managed package versions) to a scratch org:
Beta Was this translation helpful? Give feedback.
All reactions