Skip to content

Commit

Permalink
feat(patches): separate patches legacy into new folder
Browse files Browse the repository at this point in the history
  • Loading branch information
marc.sirisak committed Apr 24, 2024
1 parent bf3cab6 commit 92271f4
Show file tree
Hide file tree
Showing 35 changed files with 291 additions and 231 deletions.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ src/modules.ts
test/.eslintrc.js
test/setupTests.js
patches/patches.json
patches_legacy/patches.json
src/tchap
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ src/vector/modernizr.js

#remove tchap files from prettier
patches/
patches_legacy/
yarn-linked-dependencies/
linked-dependencies/
.github/
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
"coverage": "yarn test --coverage",
"analyse:unused-exports": "ts-node ./scripts/analyse_unused_exports.ts",
"patch-package": "patch-package",
"patches-reapply": "cd .yarn-linked-dependencies/matrix-js-sdk; git checkout .; cd ../..; ./scripts/tchap/apply_patches.sh",
"patches-reapply": "cd ./yarn-linked-dependencies/matrix-js-sdk; git checkout .; cd ../..; ./scripts/tchap/apply_patches.sh",
"patch-make": "node scripts/tchap/makePatch.ts",
"analyse:webpack-bundles": "webpack-bundle-analyzer webpack-stats.json webapp",
"update:jitsi": "curl -s https://meet.element.io/libs/external_api.min.js > ./res/jitsi_external_api.min.js"
Expand Down
230 changes: 0 additions & 230 deletions patches/patches.json
Original file line number Diff line number Diff line change
@@ -1,240 +1,10 @@
{
"tchap-room-icons": {
"package": "matrix-react-sdk",
"files": [
"src/components/views/avatars/DecoratedRoomAvatar.tsx",
"src/components/views/right_panel/RoomSummaryCard.tsx"
]
},
"simplify-exchange-key-message": {
"package": "matrix-react-sdk",
"files": [
"src/components/views/dialogs/IncomingSasDialog.tsx",
"src/components/views/dialogs/VerificationRequestDialog.tsx",
"src/components/views/right_panel/VerificationPanel.tsx",
"src/components/views/verification/VerificationComplete.tsx"
]
},
"bug-reporting": {
"package": "matrix-react-sdk",
"github-issue":"https://github.com/tchapgouv/tchap-web-v4/issues/527, https://github.com/tchapgouv/tchap-web-v4/issues/526, https://github.com/tchapgouv/tchap-product/issues/267",
"comments" : "add email in rageshake + voip",
"files": [
"src/components/views/dialogs/BugReportDialog.tsx",
"src/rageshake/submit-rageshake.ts",
"src/components/views/elements/AccessibleButton.tsx",
"src/components/views/messages/LegacyCallEvent.tsx"
]
},
"content-scanner": {
"package": "matrix-react-sdk",
"files": [
"src/components/views/messages/MAudioBody.tsx",
"src/components/views/messages/MImageBody.tsx",
"src/components/views/messages/MImageReplyBody.tsx",
"src/components/views/messages/MStickerBody.tsx",
"src/components/views/messages/MVideoBody.tsx",
"src/components/views/messages/MVoiceMessageBody.tsx"
]
},
"disable-access-options": {
"package": "matrix-react-sdk",
"files": ["src/components/views/settings/tabs/room/SecurityRoomSettingsTab.tsx"]
},
"forgot-password": {
"package": "matrix-react-sdk",
"files": [
"src/components/structures/auth/ForgotPassword.tsx",
"src/components/structures/auth/forgot-password/EnterEmail.tsx"
]
},
"hide-room-alias-settings": {
"package": "matrix-react-sdk",
"files": ["src/components/views/settings/tabs/room/GeneralRoomSettingsTab.tsx"]
},

"login": {
"package": "matrix-react-sdk",
"github-issue": "https://github.com/tchapgouv/tchap-web-v4/issues/507",
"files": [
"src/components/structures/auth/Login.tsx",
"src/components/views/auth/PasswordLogin.tsx",
"src/utils/ErrorUtils.tsx"
]
},
"registration-for-mainlining": {
"package": "matrix-react-sdk",
"comments": "registration process is customized",
"github-issue": "https://github.com/tchapgouv/tchap-web-v4/issues/460",
"files": [
"src/components/structures/auth/Registration.tsx",
"src/components/views/auth/RegistrationForm.tsx"
]
},
"password-policy": {
"package": "matrix-react-sdk",
"files": ["src/components/views/auth/PassphraseField.tsx"]
},
"public-room-server-list": {
"package": "matrix-react-sdk",
"files": [
"res/css/views/directory/_NetworkDropdown.pcss",
"src/components/views/directory/NetworkDropdown.tsx"
]
},
"auto-accept-tac": {
"package": "matrix-react-sdk",
"files": [
"src/IdentityAuthClient.tsx",
"src/Terms.ts"
]
},
"hide-discovery-email-phone-settings": {
"package": "matrix-react-sdk",
"files": ["src/components/views/settings/tabs/user/GeneralUserSettingsTab.tsx"]
},
"activate-expired-account-panel": {
"package": "matrix-js-sdk",
"files": [
"src/http-api/interface.ts",
"src/http-api/fetch.ts",
"src/sync.ts"
]
},
"cross-signing-ui": {
"comments": "reword cross-signing dialogs and remove confirmation dialog",
"github-issue": "https://github.com/tchapgouv/tchap-web-v4/issues/406,https://github.com/tchapgouv/tchap-web-v4/issues/487",
"package": "matrix-react-sdk",
"files": [
"src/async-components/views/dialogs/security/CreateSecretStorageDialog.tsx",
"src/toasts/SetupEncryptionToast.ts",
"src/components/structures/auth/CompleteSecurity.tsx",
"res/css/views/auth/_CompleteSecurityBody.pcss",
"src/components/structures/auth/SetupEncryptionBody.tsx",
"src/components/views/rooms/DecryptionFailureBar.tsx"
]
},
"fix-inviting-a-person-already-present-in-the-room": {
"comments": "When inviting by its email adress someone already in the room, the error message was wrong and break the invitation process",
"github-issue": "https://github.com/tchapgouv/tchap-web-v4/issues/394",
"package": "matrix-react-sdk",
"files": ["src/utils/MultiInviter.ts"]
},
"activate-cross-signing-and-secure-storage-react": {
"comments": "introduce a feature flag for activating cross signing and secure storage (unify previous patches)",
"github-issue": "https://github.com/tchapgouv/tchap-web-v4/issues/433, https://github.com/tchapgouv/tchap-web-v4/issues/540",
"package": "matrix-react-sdk",
"files": [
"src/components/views/settings/SecureBackupPanel.tsx",
"src/components/views/settings/CrossSigningPanel.tsx",
"src/components/structures/MatrixChat.tsx",
"src/components/views/settings/DevicesPanel.tsx"
]
},
"user-menu": {
"comments": "Add 'Help' link to external FAQ, and Christmas egg",
"github-issue": "https://github.com/tchapgouv/tchap-web-v4/issues/395",
"package": "matrix-react-sdk",
"files": [
"src/components/structures/UserMenu.tsx",
"res/css/structures/_UserMenu.pcss"
]
},
"ux-improvements-for-xsss": {
"github-issue": "https://github.com/tchapgouv/tchap-web-v4/issues/442",
"package": "matrix-react-sdk",
"files": ["src/components/views/dialogs/security/AccessSecretStorageDialog.tsx"]
},
"use-the-term-direct-messages-not-people-and-tchap-annonces": {
"github-issue": "https://github.com/tchapgouv/tchap-web-v4/issues/448",
"package": "matrix-react-sdk",
"files": [
"src/components/views/dialogs/SpacePreferencesDialog.tsx",
"src/components/views/context_menus/RoomContextMenu.tsx",
"src/components/views/settings/tabs/user/SidebarUserSettingsTab.tsx",
"src/components/views/spaces/QuickSettingsButton.tsx",
"src/components/views/rooms/RoomList.tsx",
"src/stores/spaces/index.ts"
]
},
"remove-thread-buttons": {
"github-issue": "https://github.com/tchapgouv/tchap-web-v4/issues/472",
"package": "matrix-react-sdk",
"files": [
"src/components/views/context_menus/MessageContextMenu.tsx",
"src/components/views/messages/MessageActionBar.tsx",
"src/components/views/right_panel/LegacyRoomHeaderButtons.tsx"
]
},
"change-sections-order-in-security-privacy-settings": {
"github-issue": "https://github.com/tchapgouv/tchap-web-v4/issues/465",
"comments": "Fixed in element-web 1.11.48 (?) : Translation of common|secure_backup currently broken, so string is replaces. Goback to element's string when translation system is finished migrating.",
"package": "matrix-react-sdk",
"files": [
"src/components/views/settings/CryptographyPanel.tsx",
"src/components/views/settings/tabs/user/SecurityUserSettingsTab.tsx"
]
},
"add-translations-for-server-errors": {
"github-issue": "https://github.com/tchapgouv/tchap-web-v4/issues/485",
"package": "matrix-react-sdk",
"files": [
"src/stores/RoomViewStore.tsx"
]
},
"error-tchap-is-down": {
"github-issue": "https://github.com/tchapgouv/tchap-web-v4/issues/507",
"package": "matrix-react-sdk",
"files": [
"src/components/structures/RoomSearchView.tsx",
"src/components/structures/RoomStatusBar.tsx"
]
},
"export-room-members": {
"github-issue": "https://github.com/tchapgouv/tchap-web-v4/issues/593",
"package": "matrix-react-sdk",
"files": [
"src/components/views/rooms/MemberList.tsx"
]
},
"tchap-features-from-config": {
"github-issue": "",
"package": "matrix-react-sdk",
"files": [
"src/IConfigOptions.ts",
"src/components/views/settings/Notifications.tsx"
]
},
"only-fr-and-en": {
"comments" : "Leave all language files where they are to limit the work during upgrades, and instead filter languages in code.",
"package": "matrix-react-sdk",
"files": [
"src/languageHandler.tsx"
]
},
"better-text-for-locked-messages": {
"package": "matrix-react-sdk",
"files": [
"src/components/views/messages/DecryptionFailureBody.tsx",
"src/components/views/rooms/ThreadSummary.tsx"
]
},
"customize-room-header-bar": {
"package": "matrix-react-sdk",
"files": [
"src/components/views/rooms/RoomHeader.tsx",
"res/css/views/rooms/_RoomHeader.pcss"
],
"github-issue": "https://github.com/tchapgouv/tchap-web-v4/issues/844",
"comments": "audio feature flag, external room header, hide some icons"
},
"display-call-button-anyway": {
"package": "matrix-react-sdk",
"files": [
"src/hooks/room/useRoomCall.ts"
],
"github-issue": "https://github.com/tchapgouv/tchap-web-v4/issues/868",
"comments": "display call button regardless of widget and room permission",
"remove_when" : "https://github.com/tchapgouv/tchap-backend/issues/18"
}
}
85 changes: 85 additions & 0 deletions patches_legacy/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
## How to make patches

- Make some changes to dependencies files (matrix-react-sdk or matrix-js-sdk) : in node_modules/matrix-react-sdk, or in the yarn-linked repo if you are using yarn links.
- add the info for your new patch `my-new-patch-name` in `patches/patches.json`
- run `yarn patch-make my-new-patch-name`

Wwhen you have made edits to the files, recreate the patch by running again : `yarn patch-make my-new-patch-name`

Note : if you are making a patch while your local env has yarn links, patch-package will take longer time to run "Diffing your files with clean files". But it does work.

## Merge patches when upgrading element.

First run the merge command, it takes long if you have multiple patches

```
bash ./scripts/tchap/merge-patches.sh merge
```

If some patches are in conflict, a folder is created in patches_temp/

To see the conflicted files run :

```
bash ./scripts/tchap/merge-patches.sh continue <absolute_path>/tchap-web-v4/patches_temp/PATCH_NAME
```

Fix the conlicts inside the <absolute_path>/tchap-web-v4/patches_temp/PATCH_NAME/node_modules/....

After the conflict is solved, run again
bash ./scripts/tchap/merge-patches.sh continue <absolute_path>/tchap-web-v4/patches_temp/PATCH_NAME

A notice should be in the log that a new patch has been created in folder : absolute_path>/tchap-web-v4/patches/

Compare the old patch and the new patch, if it looks ok to you then delete manually the old patch

NB : merge command can be used with only one patch also

```
bash ./scripts/tchap/merge-patches.sh merge <absolute_path>/tchap-web-v4/patches/PATCH_NAME/PATCH_FILE.patch
```

## How to deal with patch conflicts

Patch files are generated by machines, and should not be edited by humans, it will cause errors.

Humans confronted with a conflict between two versions of a patch file should solve the conflict by hand in the code files, and then regenerate the patch file.

Imagine you have a conflict in file Conflict.tsx, which causes a conflict in the corresponding patch file.

Conflict.tsx is in node_modules/matrix-react-sdk, so it is gitignored, so the conflict appears in git only on the patch file.

You have this situation : (timeline is read from bottom to top)

```
* merge conflict between develop_tchap and my-feature-branch !
|\
* | merge of other-feature-branch into develop_tchap
| * commits implementing work on my-feature-branch
|/
* develop_tchap code
```

What you can do : (timeline is read from bottom to top)

```
* merge my-feature-branch into develop_tchap : no more confict !
|\
| * merge tmp-branch and my-feature-branch : solve Conflicted.tsx by hand, then regenerate patch file
| |\
| * | make tmp-branch from develop_tchap, commit develop_tchap's version of Conflicted.tsx
|/ /
| * commit my-feature-branch's version of Conflicted.tsx
* | merge of other-feature-branch into develop_tchap
| * commits implementing work on my-feature-branch
|/
* develop_tchap code
```

When you check out a branch, watch out that since Conflicted.tsx is gitignored, the changes are not applied to it. Conflict.tsx's version is still the one of the previous branch you were at.

To get the version of Conflicted.tsx corresponding to the branch you just checked out, you can recreate it cleanly :

```
yarn patches-reapply
```
File renamed without changes.
Loading

0 comments on commit 92271f4

Please sign in to comment.