Commit Graph

2 Commits

Author SHA1 Message Date
tbkka
6187697a6c [Python3] Fix test failures in update_checkout (#33141)
Use correct relative import for Python 2&3

Remove unused variable

Fix import ordering per python_lint
2020-07-28 11:47:55 -07:00
Nate Chandler
2ef8f1b90e [Update Checkout] Fall back to revision if branch checkout fails.
In workflows featuring git worktrees, it is common for the same branch
to be in use by multiple multiple checkouts.  For example, at the
moment, the "master" branches of swift-format, swift-tensorflow-apis,
and pythonkit (and the "release" branch of ninja) are indicated, in
update-checkout-config.json, by both "master" and "release/5.3".  If one
has a workflow featuring git worktrees, that means that when one runs
<<update_checkout --scheme master>> in one's mainline directory and
<<update_checkout --scheme release/5.3>> in one's release/5.3 directory,
the latter will encounter failures for each of those four projects
because the branch "master" will already be checked out in the mainline
directory's worktrees and so it cannot be checked out in the
release/5.3's directory's worktrees.  The error looks something like:

    /path/to/swift-container/release53/swift-format failed
    (ret=128): ['git', 'checkout', u'master']
    fatal: 'master' is already checked out at
    '/path/to/swift-container/mainline/swift-format'

    /path/to/swift-container/release53/tensorflow-swift-apis failed
    (ret=128): ['git', 'checkout', u'master']
    fatal: 'master' is already checked out at
    '/path/to/swift-container/mainline/tensorflow-swift-apis'

    /path/to/swift-container/release53/pythonkit failed (ret=128):
    ['git', 'checkout', u'master']
    fatal: 'master' is already checked out at
    '/path/to/swift-container/mainline/pythonkit'

    /path/to/swift-container/release53/ninja failed (ret=128):
    ['git', 'checkout', u'release']
    fatal: 'release' is already checked out at
    '/path/to/swift-container/mainline/ninja'

Here, that workflow is enabled.  If <<git checkout branch_name>> fails,
for one of the projects, update_checkout falls back to getting the SHA
for the indicated branch via <<git rev-parse branch_name>> and then
checking out the SHA directly.
2020-07-23 23:45:18 -07:00