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

feat: last mod date #716

Merged
merged 4 commits into from
Dec 5, 2024
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
23 changes: 0 additions & 23 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,29 +38,6 @@ jobs:
fail-fast: false
with:
os: ${{ matrix.os }}
xNuts-ps:
needs: linux-unit-tests
uses: salesforcecli/github-workflows/.github/workflows/externalNut.yml@main
strategy:
fail-fast: false
matrix:
os: ['ubuntu-latest', 'windows-latest']
command:
- 'yarn test:nuts:tracking:basics'
- 'yarn test:nuts:tracking:conflicts'
- 'yarn test:nuts:tracking:forceignore'
- 'yarn test:nuts:tracking:remote'
- 'yarn test:nuts:tracking:lwc'
- 'yarn test:nuts:deb'
- 'yarn mocha "test/nuts/trackingCommands/mpd-*.nut.ts" --slow 3000 --timeout 600000 --parallel'
with:
packageName: '@salesforce/source-tracking'
externalProjectGitUrl: 'https://github.com/salesforcecli/plugin-source'
command: ${{matrix.command}}
os: ${{matrix.os}}
preSwapCommands: 'yarn upgrade @salesforce/source-deploy-retrieve@latest; npx yarn-deduplicate; yarn install'
useCache: false
secrets: inherit
Copy link
Collaborator

Choose a reason for hiding this comment

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

👍 good catch!


xNuts-pdr:
needs: linux-unit-tests
Expand Down
2 changes: 2 additions & 0 deletions src/shared/remote/fileOperations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ export const revisionToRemoteChangeElement = (memberRevision: MemberRevision): R
revisionCounter: memberRevision.RevisionCounter,
changedBy: memberRevision.ChangedBy,
memberIdOrName: memberRevision.MemberIdOrName,
lastModifiedDate: memberRevision.LastModifiedDate,
});

export const upgradeFileContents = (contents: ContentsV0): ContentsV1 => ({
Expand All @@ -70,6 +71,7 @@ export const upgradeFileContents = (contents: ContentsV0): ContentsV1 => ({
lastRetrievedFromServer: value.lastRetrievedFromServer ?? undefined,
ChangedBy: 'unknown',
MemberIdOrName: 'unknown',
LastModifiedDate: 'unknown',
},
])
),
Expand Down
2 changes: 2 additions & 0 deletions src/shared/remote/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export type SourceMember = {
MemberIdOrName: string;
/** userID of the person who made change */
ChangedBy: string;
LastModifiedDate: string;
};

export type MemberRevision = SourceMember & {
Expand All @@ -57,4 +58,5 @@ export const SOURCE_MEMBER_FIELDS = [
'RevisionCounter',
'IsNewMember',
'ChangedBy',
'LastModifiedDate',
] satisfies Array<keyof SourceMember>;
1 change: 1 addition & 0 deletions src/shared/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ export type RemoteChangeElement = {
modified?: boolean;
changedBy: string;
revisionCounter: number;
lastModifiedDate: string;
/** the ID of the metadata that was changed. Each metadata type has a different 3-char prefix */
memberIdOrName: string;
};
Expand Down
2 changes: 1 addition & 1 deletion src/sourceTracking.ts
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ export class SourceTracking extends AsyncCreatable {
if (options.format === 'ChangeResultWithPaths') {
return populateFilePaths({
elements: filteredChanges.map(remoteChangeElementToChangeResult),
packageDirPaths: this.project.getPackageDirectories().map((pkgDir) => pkgDir.path),
packageDirPaths: this.project.getPackageDirectories().map((pkgDir) => pkgDir.fullPath),
shetzel marked this conversation as resolved.
Show resolved Hide resolved
registry: this.registry,
});
}
Expand Down
2 changes: 2 additions & 0 deletions test/unit/remote/fileOperations.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ describe('writing file version based on env', () => {
RevisionCounter: 1,
MemberName: 'MyClass',
IsNewMember: false,
LastModifiedDate: new Date().toJSON(),
} satisfies MemberRevision,
],
]);
Expand Down Expand Up @@ -97,6 +98,7 @@ describe('upgrading undefined file version to v1 file', () => {
IsNameObsolete: false,
RevisionCounter: 1,
MemberName: 'MyClass',
LastModifiedDate: 'unknown',
} satisfies Omit<MemberRevision, 'IsNewMember'>);
});

Expand Down
10 changes: 8 additions & 2 deletions test/unit/remote/remoteSourceTracking.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import { RemoteSyncInput, RemoteChangeElement } from '../../../src/shared/types'
import * as orgQueryMocks from '../../../src/shared/remote/orgQueries';

import { getMetadataNameFromKey, getMetadataTypeFromKey } from '../../../src/shared/functions';
import { ContentsV0, MemberRevision, SourceMember } from '../../../src/shared/remote/types';
import { ContentsV0, ContentsV1, MemberRevision, SourceMember } from '../../../src/shared/remote/types';

config.truncateThreshold = 0;

Expand All @@ -34,6 +34,7 @@ const defaultSourceMemberValues = {
RevisionCounter: 1,
ChangedBy: 'Shelby McLaughlin',
MemberIdOrName: '00eO4000003cP5JIAU',
LastModifiedDate: new Date().toJSON(),
} satisfies Partial<SourceMember>;

const getSourceMember = (revision: number, isDeleted = false): SourceMember => ({
Expand Down Expand Up @@ -126,6 +127,7 @@ describe('remoteSourceTrackingService', () => {
changedBy: 'Shelby McLaughlin',
revisionCounter: 1,
memberIdOrName,
lastModifiedDate: defaultSourceMemberValues.LastModifiedDate,
};
const changeResult = remoteChangeElementToChangeResult(rce);
expect(changeResult).to.deep.equal({
Expand All @@ -137,6 +139,7 @@ describe('remoteSourceTrackingService', () => {
changedBy: 'Shelby McLaughlin',
revisionCounter: 1,
memberIdOrName,
lastModifiedDate: defaultSourceMemberValues.LastModifiedDate,
});
});

Expand All @@ -149,6 +152,7 @@ describe('remoteSourceTrackingService', () => {
changedBy: 'Shelby McLaughlin',
revisionCounter: 1,
memberIdOrName,
lastModifiedDate: defaultSourceMemberValues.LastModifiedDate,
};
const changeResult = remoteChangeElementToChangeResult(rce);
expect(changeResult).to.deep.equal({
Expand All @@ -160,6 +164,7 @@ describe('remoteSourceTrackingService', () => {
changedBy: 'Shelby McLaughlin',
revisionCounter: 1,
memberIdOrName,
lastModifiedDate: defaultSourceMemberValues.LastModifiedDate,
});
});
});
Expand Down Expand Up @@ -564,6 +569,7 @@ describe('remoteSourceTrackingService', () => {
});
const contents = {
serverMaxRevisionCounter: 1,
fileVersion: 1,
sourceMembers: {
'Profile###my(awesome)profile': {
...defaultSourceMemberValues,
Expand All @@ -575,7 +581,7 @@ describe('remoteSourceTrackingService', () => {
MemberType: 'Profile',
},
},
};
} satisfies ContentsV1;
setContents(contents);
await remoteSourceTrackingService.syncSpecifiedElements([
{
Expand Down
Loading