mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Collect and convert git repo data to 'struct git_info'
We have this nasty habit of randomly passing down all the different things that we use to look up the local and remote git repository, and the information associated with it. Start collecting the data into a 'struct git_info' instead, so that it is easier to manage, and easier and more logical to just look up different parts of the puzzle. This is a fairly mechanical conversion, but has moved all the basic information collection to the 'is_git_repository()' function. That function no longer actually opens the repository (so the 'dry_run' argument is gone, and instead a successful 'is_git_repository()' is followed by 'opn_git_repository()' if you actually want the old non-dry_run semantics. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
parent
acc4dc57af
commit
7e632173e0
11 changed files with 365 additions and 349 deletions
|
@ -44,34 +44,31 @@ static void moveDir(QString oldName, QString newName)
|
|||
static void localRemoteCleanup()
|
||||
{
|
||||
// cleanup the local cache dir
|
||||
struct git_info info = { };
|
||||
QDir localCacheDirectory(localCacheDir);
|
||||
QCOMPARE(localCacheDirectory.removeRecursively(), true);
|
||||
|
||||
// get the remote/branch information as parsed by our git tooling
|
||||
const char *branch, *remote;
|
||||
struct git_repository *git_repo;
|
||||
|
||||
// when this is first executed, we expect the branch not to exist on the remote server;
|
||||
// if that's true, this will print a harmless error to stderr
|
||||
git_repo = is_git_repository(qPrintable(cloudTestRepo), &branch, &remote, false);
|
||||
is_git_repository(qPrintable(cloudTestRepo), &info) && open_git_repository(&info);
|
||||
|
||||
// this odd comparison is used to tell that we were able to connect to the remote repo;
|
||||
// in the error case we get the full cloudTestRepo name back as "branch"
|
||||
if (branch != randomBranch) {
|
||||
if (info.branch != randomBranch) {
|
||||
// dang, we weren't able to connect to the server - let's not fail the test
|
||||
// but just give up
|
||||
QSKIP("wasn't able to connect to server");
|
||||
}
|
||||
|
||||
// force delete any remote branch of that name on the server (and ignore any errors)
|
||||
delete_remote_branch(git_repo, remote, branch);
|
||||
delete_remote_branch(info.repo, info.url, info.branch);
|
||||
|
||||
// and since this will have created a local repo, remove that one, again so the tests start clean
|
||||
QCOMPARE(localCacheDirectory.removeRecursively(), true);
|
||||
|
||||
free((void *)branch);
|
||||
free((void *)remote);
|
||||
git_repository_free(git_repo);
|
||||
free((void *)info.branch);
|
||||
free((void *)info.url);
|
||||
git_repository_free(info.repo);
|
||||
}
|
||||
|
||||
void TestGitStorage::initTestCase()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue