Skip to content
This repository was archived by the owner on Jul 28, 2024. It is now read-only.

588 date modified merge driver#725

Merged
octopuss merged 23 commits intomasterfrom
588-date-modified-merge-driver
Feb 25, 2016
Merged

588 date modified merge driver#725
octopuss merged 23 commits intomasterfrom
588-date-modified-merge-driver

Conversation

@octopuss
Copy link
Copy Markdown
Contributor

This PR closes #588 by adding custom merge driver which selects more recent significant dates from both merged files and saves them. Then traditional git merge feature-branch is made.

Please review :

Thank you

$initializationDir = VERSIONPRESS_PLUGIN_DIR . '/src/Initialization';
MergeDriverConfigurer::installGitattributes($initializationDir);
MergeDriverConfigurer::installGitMergeDriver($initializationDir);
WP_CLI::success("Git merge driver for VersionPress files added.");
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

  • Maybe just "Git merge driver added".

@borekb
Copy link
Copy Markdown
Member

borekb commented Feb 16, 2016

Overall great work, my line comments are smaller things, maybe just two other things to discuss are:

  • I think we should have tests for this. We have CloneTest as the only workflow test now but maybe this could be simpler, working inside a single repo (not across clones), creating local test branch and merging it back.
  • Wasn't there a .sh variant of the driver?

$gitconfigVariables = array(
'wp-plugins' => rtrim(ltrim(PathUtils::getRelativePath(VP_PROJECT_ROOT, WP_PLUGIN_DIR), '.'), '/\\'),
'merge-driver-script' => 'ini-merge.php',
'bin-dir' => PHP_BINDIR . '/php'
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

  • This isn't a directory but an executable. It's confusing in gitconfig.tpl.

@JanVoracek JanVoracek added this to the 3.0 milestone Feb 16, 2016
$matches = array();
preg_match($dateMatchPattern, $aFile, $matches);
if (count($matches) == 0) {
echo "not found";
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Perhaps some leftover of debugging?

  • Remove echo

@octopuss octopuss force-pushed the 588-date-modified-merge-driver branch from 0d8f7fc to 3cd6d80 Compare February 17, 2016 08:59
@octopuss octopuss force-pushed the 588-date-modified-merge-driver branch from 22fb6c6 to 12f9c53 Compare February 17, 2016 12:33
@octopuss octopuss mentioned this pull request Feb 19, 2016
3 tasks
@JanVoracek
Copy link
Copy Markdown
Contributor

Waiting for completing measurements in #588 (comment).

@borekb
Copy link
Copy Markdown
Member

borekb commented Feb 22, 2016

A couple of questions / suggestions about this:

2016-02-22 11_05_31-clipboard

  1. Is this for 100 or 1000 files? Maybe this row should be merged into the two tables below, e.g., repeat the test for both 100 and 1000 files?
  2. Just to make sure, was this run on Mac OS or was it a Linux VM? (Assuming Mac OS, I'm OK with calling that "Linux" :) )
  3. Same note as 1.

$mergeEC = MergeDriverTestUtils::runProcess(MERGE_CMD);
$time_end = microtime(true);
$execution_time = ($time_end - $time_start);
echo 'Php Execution Time: '.$execution_time.' Sec';
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

  • Formatting

@octopuss
Copy link
Copy Markdown
Contributor Author

The problem is missing replacement of slashes here https://github.com/versionpress/versionpress/blob/588-date-modified-merge-driver/plugins/versionpress/tests/Utils/MergeDriverTestUtils.php#L97

I think that if you install VersionPress from scratch the driver script path will contain correct slashes.

@borekb
Copy link
Copy Markdown
Member

borekb commented Feb 22, 2016

Now that you mention it, it seems to me that there should also be a MergeDriverInstaller::uninstallMergeDriver() method and the ..TestUtils class should use it rather than duplicating logic.

@octopuss
Copy link
Copy Markdown
Contributor Author

You are right. It seems correct to remove driver when VersionPress will be uninstalled.

…ich is called when VersionPress is deactivated.

$this->assertEquals(1, MergeDriverTestUtils::runProcess(self::$mergeCmd));

copy(self::$repositoryDir . '/file.ini', '/Users/Ivan/expected-merge-conflict.ini');
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

  • Wrong absolute path (with username).

@octopuss octopuss self-assigned this Feb 23, 2016
octopuss and others added 8 commits February 23, 2016 11:42
- The test was not actually testing anything as the posts in both test and clone sites have likely been modified in the same second. `sleep()` was added.
- Test renamed from `updatedArticleCanBeMergedFromClone()` to `dateModifiedMergesAutomatically()` to better reflect what id does.
- Some other things slightly refactored.

private static $masterDate;

private static $branchDate;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

  • Many of these variables are used in one place only, they are unnecessary noise in this class and should be inlined.

@octopuss octopuss force-pushed the 588-date-modified-merge-driver branch from 8f1be93 to cf015b1 Compare February 24, 2016 16:12
@borekb
Copy link
Copy Markdown
Member

borekb commented Feb 25, 2016

Good job, seems ready to merge to me. 👍

octopuss added a commit that referenced this pull request Feb 25, 2016
@octopuss octopuss merged commit 77de2a8 into master Feb 25, 2016
@octopuss octopuss deleted the 588-date-modified-merge-driver branch February 25, 2016 13:20
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Date modified not handled properly

3 participants