<!---
Thanks so much for your contribution! If this is your first time
contributing, please ensure that you have read the
[CONTRIBUTING](https://github.com/pulumi/pulumi/blob/master/CONTRIBUTING.md)
documentation.
-->
# Description
<!--- Please include a summary of the change and which issue is fixed.
Please also include relevant motivation and context. -->
This is a pass over all of /sdk to replace asserts that just checked we
had an error with asserts for what the error value is.
Just checking for an error is a weak test that can result in error paths
being broken and tests not detecting it.
As suggested by the [godocs](https://pkg.go.dev/context#Background).
This means a search for `context.TODO` now just shows up places we
really do seem to be missing a threaded in context in real code.
In general, go-git can't clone from Azure DevOps, because the latter
requires the capabilities multi_ack and multi_ack_detailed, which aren't
implemented. However, there's now a workaround, which boils down to
this: pretend, for the initial clone, that those capabilities _are_
supported, and expect them not to be used.
(See https://github.com/go-git/go-git/pull/613 for more on this
workaround.)
Signed-off-by: Michael Bridgen <mbridgen@pulumi.com>
This commit replaces `ioutil.TempDir` with `t.TempDir` in tests. The
directory created by `t.TempDir` is automatically removed when the test
and all its subtests complete.
Prior to this commit, temporary directory created using `ioutil.TempDir`
needs to be removed manually by calling `os.RemoveAll`, which is omitted
in some tests. The error handling boilerplate e.g.
defer func() {
if err := os.RemoveAll(dir); err != nil {
t.Fatal(err)
}
}
is also tedious, but `t.TempDir` handles this for us nicely.
Reference: https://pkg.go.dev/testing#T.TempDir
Signed-off-by: Eng Zer Jun <engzerjun@gmail.com>
* Generalise git branch test
In #10118 the git checkout was adapted so it would work with simple
branch names (i.e., "main" rather than "refs/heads/main"). However, it
still won't work with a branch that's not the default branch -- this
test demonstrates so.
* Support all simple and full branch names
If you want to have a non-default branch checked out, you need to fetch
it _and_ make a local reference for it. If you don't giv e a specific
reference, *Repository.Clone(...) updates remote heads, but does not
create local refs.
So, to support the varieties of branch names that people might use, the
provided branch name needs to be interpreted, and used for the
*Repository.Clone(...).
* Support cloning at a tag
Although the field is .Branch, we might expect people to ask for a tag
too. It's probably possible, with some back and forth, to disambiguate
between a simple branch name and a simple tag name; but, for the sake of
simplicity, require people to give `refs/tags/tag`.
* Queue changelog entry
* Check more cases of supplied branch name
- ... including things that should result in an error
- verify that the remote named in a remote ref is "origin"; anything
else is surely a mistake
Signed-off-by: Michael Bridgen <mbridgen@pulumi.com>
* Accept short branch names in GitRepo.Branch
Users often give short names for branches -- e.g., `dev`, rather than
`refs/heads/dev`. This commit makes that work rather than produce an
error, by adopting the heuristic that anything that doesn't look like a
full branch name (i.e., not starting with ref/heads/) must be a short
name.
Signed-off-by: Michael Bridgen <mbridgen@pulumi.com>