Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions messages/deploy.metadata.md
Original file line number Diff line number Diff line change
Expand Up @@ -257,3 +257,8 @@ The `pushPackageDirectoriesSequentially` property is not respected by this comma
# apiVersionMsgDetailed

%s %s metadata to %s using the v%s %s API.

# noSourceTrackingWarning

Starting in December 2025, this command will require that the target org use source tracking.
Specifically, to use this command with a production org, scratch org created with the `--no-track-source` flag, or other non-source-tracking org, you must specify the metadata you want to deploy with either the `--metadata`, `--source-dir`, or `--manifest` flag.
5 changes: 5 additions & 0 deletions messages/retrieve.start.md
Original file line number Diff line number Diff line change
Expand Up @@ -199,3 +199,8 @@ This command expects the org to support source tracking. If it doesn't, you must
- Use the `--source-dir`, `--manifest` or `--package-name` flags to retrieve metadata in source format.

- Use the `--target-metadata-dir` flag to retrieve metadata in metadata format to a directory.

# noSourceTrackingWarning

Starting in December 2025, this command will require that the target org use source tracking.
Specifically, to use this command with a production org, scratch org created with the `--no-track-source` flag, or other non-source-tracking org, you must specify the metadata you want to retrieve with either the `--metadata`, `--source-dir`, or `--manifest` flag.
6 changes: 6 additions & 0 deletions src/commands/project/deploy/start.ts
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,12 @@ export default class DeployMetadata extends SfCommand<DeployResultJson> {
throw messages.createError('error.NoTestsSpecified');
}

const noDeployFlags = !flags['source-dir'] && !flags.manifest && !flags.metadata && !flags['metadata-dir'];

if (noDeployFlags && !(await flags['target-org'].tracksSource())) {
this.warn(messages.getMessage('noSourceTrackingWarning'));
}

const api = await resolveApi(this.configAggregator);
const username = flags['target-org'].getUsername();
const title = flags['dry-run'] ? 'Deploying Metadata (dry-run)' : 'Deploying Metadata';
Expand Down
14 changes: 14 additions & 0 deletions src/commands/project/retrieve/start.ts
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,19 @@ export default class RetrieveMetadata extends SfCommand<RetrieveResultJson> {
// eslint-disable-next-line complexity
public async run(): Promise<RetrieveResultJson> {
const { flags } = await this.parse(RetrieveMetadata);

// Add warning for non-source-tracking orgs when using default behavior
const isChanges =
!flags['source-dir'] &&
!flags['manifest'] &&
!flags['metadata'] &&
!flags['target-metadata-dir'] &&
!flags['package-name']?.length;

if (isChanges && !(await flags['target-org'].tracksSource())) {
this.warn(messages.getMessage('noSourceTrackingWarning'));
}

let resolvedTargetDir: string | undefined;
if (flags['output-dir']) {
resolvedTargetDir = resolve(flags['output-dir']);
Expand Down Expand Up @@ -518,6 +531,7 @@ const buildRetrieveOptions = async (
output: string | undefined
): Promise<RetrieveSetOptions> => {
const apiVersion = await resolveApiVersion(flags);

return {
usernameOrConnection: flags['target-org'].getUsername() ?? flags['target-org'].getConnection(flags['api-version']),
merge: true,
Expand Down
9 changes: 9 additions & 0 deletions test/nuts/retrieve/noTracking.nut.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,15 @@ describe('retrieve mdapi format without project', () => {
expect(result?.files).to.not.be.empty;
});

it('should fail when retrieving changes from a non-tracking org', () => {
const result = execCmd<RetrieveResultJson>(`project:retrieve:start -o ${session.hubOrg.username} --json`, {
ensureExitCode: 1,
});

expect(result.jsonOutput?.name).to.equal('noSourceTracking');
expect(result.jsonOutput?.message).to.include('Unable to track changes in your source files');
});

after(async () => {
await session?.clean();
});
Expand Down