diff --git a/check_files.go b/check_files.go index e65e4e7..a6a4641 100644 --- a/check_files.go +++ b/check_files.go @@ -82,7 +82,8 @@ func (c *checker) undeployed(f *FileFacts, repo *Repo, paths []string) map[strin return units } -// release compares every PHP file outside uploads with the local install: +// release compares every PHP file outside uploads with the local install, +// and one that differs in a git-sourced plugin with composer.lock's ref: // one flag per package or theme, its ID covering every differing file, so // accepting it holds until any of them changes again. func (c *checker) release(f *FileFacts, repo *Repo, paths []string, undeployed map[string]bool) { @@ -90,6 +91,7 @@ func (c *checker) release(f *FileFacts, repo *Repo, paths []string, undeployed m type diff struct{ changed, extra []string } diffs := map[string]*diff{} skipped := map[string]int{} + edited := map[string]int{} // files production has as composer.lock's ref has them, the checkout not for _, p := range paths { if strings.HasPrefix(p, content+"/uploads/") { continue @@ -130,6 +132,9 @@ func (c *checker) release(f *FileFacts, repo *Repo, paths []string, undeployed m case !ok && (strings.Contains(p, "/build/") || strings.Contains(p, "/dist/") && strings.HasSuffix(p, ".asset.php")): skipped["built files the checkout hasn't built (build/, dist/*.asset.php)"]++ continue + case repo.AtLock(p, f.Files[p]): + edited[u]++ + continue } d := diffs[u] if d == nil { @@ -160,6 +165,9 @@ func (c *checker) release(f *FileFacts, repo *Repo, paths []string, undeployed m for _, what := range slices.Sorted(maps.Keys(skipped)) { c.info("%d PHP file(s) not compared: %s", skipped[what], what) } + for _, u := range slices.Sorted(maps.Keys(edited)) { + c.info("%s: %d PHP file(s) match composer.lock's ref but not the checkout's install, which was edited: compared with the ref", u, edited[u]) + } // The collector runs core, mu-plugins, drop-ins and the site's wp-cli; the // hasher doesn't. When those differ, the collector's answers are suspect. var ran []string diff --git a/check_files_test.go b/check_files_test.go index 3768c5f..edcf7df 100644 --- a/check_files_test.go +++ b/check_files_test.go @@ -136,6 +136,45 @@ func TestReleaseComparedWithDeployedCommit(t *testing.T) { } } +// A git-sourced plugin whose checkout copy was edited by hand: production's +// file as composer.lock's ref has it isn't flagged (a note says so); one the +// ref doesn't have, or that GitHub can't serve, still is. +func TestReleaseEditedCheckoutComparedWithLockRef(t *testing.T) { + sum := func(s string) string { b := sha256.Sum256([]byte(s)); return hex.EncodeToString(b[:]) } + atRef := map[string]string{"inc/a.php": "