Problem/Motivation

After initiating Varbase patches and setting a rule to not use any merge request patches, I have implemented a Drush command to replace any merge request patch with a local patch.

Proposed resolution

Root `composer.json` file.

Name: varbase:composer:cleanup:patches
Aliases: var-ccup
Description: This command detects any merge request patches, downloads them to the local patches folder with a timestamp, and updates the root `composer.json` file to use the timestamped local patch file.

Example:

  ./bin/drush varbase:composer:cleanup:patches
  

or

  ./bin/drush var-ccup
  

External `patches-file` json file.

Name: varbase:composer:cleanup:patches-file
Aliases: var-ccupf
Description: This command detects any merge request patches, downloads them to the local patches folder with a timestamp, and updates the `patches-file JSON` file to use the timestamped local patch file.

Example:

  ./bin/drush varbase:composer:cleanup:patches-file
  

or

   ./bin/drush var-ccupf
  

Remaining tasks

Varbase update type

  • ✅ No Update
  • ➖ Optional Update
  • ➖ Forced Update
  • ➖ Forced Update if Unchanged

User interface changes

  • N/A

API changes

  • N/A

Data model changes

  • N/A

Release notes snippet

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

abu-zakham created an issue. See original summary.

abu-zakham’s picture

Assigned: abu-zakham » Unassigned
Status: Active » Needs review

rajab natshah’s picture

Issue summary: View changes
rajab natshah’s picture

Title: Drush command to clean up composer.json » Add varbase:composer-clean-up drush command to clean up composer.json
rajab natshah’s picture

Issue summary: View changes
rajab natshah’s picture

Issue summary: View changes
Status: Needs review » Needs work

1. Let us wrap the command code with try catch

try {

}
catch (\Exception $e) {

}

2. Let use the \Drupal::logger('Varbase') to log the fixes
3. Let use drush logger for std output from drush
3. Maybe check if the folder patches is in the system ( if the chmod, chown, was not right )
4. Give a warning if the Merge request was added twice

  • maybe it was in the composer.json file before
  • then a run for ./bin/drush varbase:composer-clean-up or lando drush varbase:composer-clean-up fixed it
  • And then another patch for the same project + the same MR was added again in some way

5. Maybe more scenarios.

rajab natshah’s picture

Maybe we could add a flag or other command to only check if the root composer.json has "/-/merge_requests/"

Thank you, for the smart idea and implementation for it!
On the way for Better to ensure that our used patches are protected from any change.

rajab natshah’s picture

Status: Needs work » Needs review

rajab natshah’s picture

Reviewed the code and merged
Optimizing the idea to follow with
Storage of Local Patches Branch
Examples of Names for Local Patch files

1. Grep on "/-/merge_requests" not only "merge_requests", as it may be in the file name of a a patch.
2. Add Project name, date , issue id and the MR number.

$project_name--$date--$issue_id--$mr_id.patch

  • Adding the project name will ease browsing the patches folder.
  • Having the date and time will timestampe the download time to track for history or further updates
  • Having the issue id is important to ready more about the issue and track status update if more changes if it got committed into a release
  • Having the MR id will help when having number of MRs in the same issue
rajab natshah’s picture

Better to print out the list of clean patches ( better drush messaging )

rajab natshah’s picture

Title: Add varbase:composer-clean-up drush command to clean up composer.json » Add varbase:composer:cleanup:patches drush command to clean up composer.json from any merge request patchs
Issue summary: View changes

  • Rajab Natshah committed 7a8a94c0 on 9.1.x
    Issue #3448429: Add varbase:composer:cleanup:patches drush command to...

  • Rajab Natshah committed 9581ed1e on 9.1.x
    Issue #3448429: Add varbase:composer:cleanup:patches drush command to...

  • Rajab Natshah committed 4c6522f4 on 10.0.x
    Issue #3448429: Add varbase:composer:cleanup:patches drush command to...
rajab natshah’s picture

Issue summary: View changes
rajab natshah’s picture

Title: Add varbase:composer:cleanup:patches drush command to clean up composer.json from any merge request patchs » Add varbase:composer:cleanup:patches drush command to clean up composer.json from any merge request patches
rajab natshah’s picture

Issue summary: View changes
rajab natshah’s picture

Issue summary: View changes

  • Rajab Natshah committed 3d676e8b on 10.0.x
    Issue #3448429: Add varbase:composer:cleanup:patches drush command to...

  • Rajab Natshah committed 79e86b73 on 9.1.x
    Issue #3448429: Add varbase:composer:cleanup:patches drush command to...
rajab natshah’s picture

Issue summary: View changes
rajab natshah’s picture

Issue summary: View changes
rajab natshah’s picture

Issue summary: View changes
rajab natshah’s picture

Issue summary: View changes
rajab natshah’s picture

rajab natshah’s picture

Status: Needs review » Fixed
rajab natshah’s picture

Issue summary: View changes

✅ Released varbase_core-9.1.35

rajab natshah’s picture

Issue summary: View changes
rajab natshah’s picture

Issue summary: View changes
rajab natshah’s picture

Issue summary: View changes
rajab natshah’s picture

Issue summary: View changes
rajab natshah’s picture

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

rajab natshah’s picture

Issue summary: View changes

✅ Release varbase-10.0.0

rajab natshah’s picture

Issue summary: View changes

✅ Released varbase-9.1.4