twosigma / git-meta

Repository for the git-meta project -- build your own monorepo using Git submodules
http://twosigma.github.io/git-meta
BSD 3-Clause "New" or "Revised" License
216 stars 50 forks source link

Flaky test "rebase in a sub, was conflicted" #864

Closed geofft closed 1 year ago

geofft commented 2 years ago
$ for i in {1..30}; do yarn test -g 'rebase in a sub, was conflicted' || break; done

yarn run v1.22.18
$ mocha test -g 'rebase in a sub, was conflicted'

  SubmoduleRebaseUtil
    continueSubmodules
Applying 'message'
Submodule s continuing rewrite from d07e97f43d7f6bae50a88b99c3c10ccd380d4dfa onto ffd40f6e3cfaecc64dfaea7a8d5032cc256ca1c8.
      ✓ rebase in a sub, was conflicted (551ms)

  1 passing (569ms)

Done in 2.88s.
yarn run v1.22.18
$ mocha test -g 'rebase in a sub, was conflicted'

  SubmoduleRebaseUtil
    continueSubmodules
Applying 'message'
Submodule s continuing rewrite from c91064bf09c5f0832032c0b6c323d0c5ef217254 onto d831ee3992ed646a7b591eb63212548aaa2534c9.
      1) rebase in a sub, was conflicted

  0 passing (558ms)
  1 failing

  1) SubmoduleRebaseUtil
       continueSubmodules
         rebase in a sub, was conflicted:
     Error: for repo x
    for commit M
        for path s expected Submodule { d_url: 'a', d_sha: 'qs' } but got Submodule { d_url: 'a', d_sha: 'r' }
    for open submodule s
        missing commit qs
        HEAD is r but expected qs
        In index
            unexpected change to q: File { d_contents: 'q', d_isExecutable: false }
      at Object.exports.assertEqualRepoMaps (lib/util/repo_ast_util.js:600:15)
      at Object.<anonymous> (lib/util/repo_ast_test_util.js:368:17)
      at Generator.next (<anonymous>)
      at onFulfilled (node_modules/co/index.js:65:19)

error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

This caused CI to fail on #863.

geofft commented 2 years ago

It looks like what's going on is that we're hitting this Pokémon exception handler: https://github.com/twosigma/git-meta/blob/9ed0aff5fe99843e07b60a5f6062ef70eac3d7e5/node/lib/util/submodule_rebase_util.js#L183-L187

The exception being ignored is of the form

  SubmoduleRebaseUtil
    continueSubmodules
Applying 'message'
Submodule s continuing rewrite from ade8295420afaf169f68655d473e02b5ca20bef5 onto 80692b65d57bfa7f3199e7e40745d02a3fd9d64d.
[Error: object not found - no match for id (ade8295420afaf169f68655d473e02b5ca20bef5)] {
  errno: -3,
  errorFunction: 'Rebase.commit'
}

I don't understand why we'd get "object not found" in this case. It's the same as the thing being rewritten from.

geofft commented 2 years ago

I get the same error bumping nodegit to 0.27, so it's not that.

I dumped the submodule's "status" out of StatusUtil.getRepoStatus, and I see

Applying 'message'
{"d_commit":{"d_sha":"20a4ca249fc8d04e807d07f4700651e86096f4d0","d_url":"/tmp/git-meta-test2022311-27614-uxptu7.41xm/a"},"d_index":{"d_sha":"8c55b375f7a10e55e30f83e1ff5d99f826597225","d_url":"/tmp/git-meta-test2022311-27614-uxptu7.41xm/a","d_relation":4},"d_workdir":{"d_status":{"d_currentBranchName":null,"d_headCommit":"8c55b375f7a10e55e30f83e1ff5d99f826597225","d_staged":{"q":1},"d_workdir":{},"d_submodules":{},"d_rebase":{"d_headName":"HEAD","d_originalHead":"20a4ca249fc8d04e807d07f4700651e86096f4d0","d_onto":"8c55b375f7a10e55e30f83e1ff5d99f826597225"},"d_sequencerState":null},"d_relation":0}}
Submodule s continuing rewrite from 20a4ca249fc8d04e807d07f4700651e86096f4d0 onto 8c55b375f7a10e55e30f83e1ff5d99f826597225.
[Error: object not found - no match for id (20a4ca249fc8d04e807d07f4700651e86096f4d0)] {
  errno: -3,
  errorFunction: 'Rebase.commit'
}

It's odd that this is the reported current comit (.d_commit.d_sha) that it's saying is not found.