Build: Simplify and optimize git backend: New clone+fetch pattern (#10430)
* New git clone/fetch/checkout behavior first steps
* Use `identifier` argument for `.update()`, add lots of comments for future readers
* Add missing str() cast
* Remove the `identifier` keyword since we are forced to use verbose_name if tags should work :/
* Revert "Remove the `identifier` keyword since we are forced to use verbose_name if tags should work :/"
This reverts commit 82178a378ffd8da3b9260c8678cb78c8f1dfcba5.
* We need the identifier for branches, but not for tags and PRs
* Update some comments after noticing how `Build.identifier/.verbose_name` fields are used
* lint
* Revert "Revert "Remove the `identifier` keyword since we are forced to use verbose_name if tags should work :/""
This reverts commit a45b42b1d027bb7253d2b79325cd6664bdb0ec5b.
* Use version_identifier as an instance property
* Update readthedocs/vcs_support/backends/git.py
Co-authored-by: Manuel Kaufmann <humitos@gmail.com>
* Updates to return values, comments and logging
* Restore common
* Stop fetching --tags and fetch the direct remote reference
* Appease linter: Use raise-from pattern
* Hello darker my old friend
* Restore error handling for clone operation
* Update a few comments, add a bit more raise-from pattern (actually trying to use it for debugging!)
* WIP: refine some comments, log calls and small things while testing locally
* New test class with Feature flag defined
* Adds a tearDown method after discovering that tests were wrongly passing because working directory leaks between test cases
* Log a warning if we aren't specifying the version type when using Git, fetch branches by their exact remote reference and point them to a local branch, rather than FETCH_HEAD
* Update test cases for new git clone+fetch pattern
* Git fetch change: Fetch branches to :refs/remotes/origin/<branch-name> + comment updates
* Overwrite tests to call clone_ng and fetch_ng, and rewrite some entirely
* Update update() docstring
* Always use lsremote for GIT_CLONE_FETCH_CHECKOUT_PATTERN
* Builds need to know about Version.machine=True for tags "stable" so they don't try to get "stable" as a tag - alternatively, we hardcode a check for verbose_name=="stable"
* Conditionally log a warning on stable versions
* linting
* add "machine" to version API test case
* Use "refspec" terminology more consistently
* Add test case for un-named default branches
* Don't have "--no-checkout" when we *need* to checkout the remote HEAD
* Add test case to verify that we can clone+fetch special tag "stable" (machine=True)
* Update readthedocs/vcs_support/backends/git.py
Co-authored-by: Manuel Kaufmann <humitos@gmail.com>
* Remove unused logging
* Use `git fetch <commit hash>` for special "stable" versions
* Building an unnamed default branch now skips `git fetch`
* Remove unnecessary logging, add a lot of comments to tests
* Apply suggestions from @humitos code review
Co-authored-by: Manuel Kaufmann <humitos@gmail.com>
* Update readthedocs/projects/models.py
Co-authored-by: Manuel Kaufmann <humitos@gmail.com>
* Always clean up the presumed repo working dir after a test case
* Move `machine` to `VersionAdminSerializer`
* Add precision to comment
* Use identifier and verbose_name that looks more like actual data would look
* remove unused local reference in git fetch for "stable" tag
* Don't use --no-checkout, just checkout whatever is at the FETCH_HEAD
* Add more logging
* Update comment
* Fix logic condition: Always include `vcs_repository.supports_lsremote`
* Log a warning when we try to generate a pr/mr refspec for an unsupported Git provider
* improve doc strings
* Remove TestGitBackendTwiceInARow
* Use real commit hash in test case
---------
Co-authored-by: Manuel Kaufmann <humitos@gmail.com>