Esempio n. 1
0
    public IEnumerator MissingFolderForDriftingMetaCreated()
    {
        injectionHelper.GetInstance <GitSettingsJson>().CreateFoldersForDriftingMeta = true;

        string metaFileName = "Test Folder.meta";
        string metaFilePath = Path.Combine(gitManager.GetCurrentRepoPath(), metaFileName);

        File.WriteAllText(metaFilePath, "Test Meta");
        Assert.IsTrue(File.Exists(metaFilePath));
        gitManager.AutoStage(metaFileName);
        yield return(null);

        GitStatusEntry metaStatusEntry;

        Assert.IsTrue(data.RepositoryStatus.Get(metaFileName, out metaStatusEntry));
        Assert.AreEqual(FileStatus.NewInIndex, metaStatusEntry.Status);
        var addedMetaCommit = gitManager.Repository.Commit("Drifting Meta Commit", signature, signature);

        yield return(null);

        File.Delete(metaFilePath);
        gitManager.AutoStage(metaFileName);
        yield return(null);

        Assert.IsTrue(data.RepositoryStatus.Get(metaFileName, out metaStatusEntry));
        Assert.AreEqual(FileStatus.DeletedFromIndex, metaStatusEntry.Status);
        Assert.IsFalse(File.Exists(metaFilePath));
        gitManager.Repository.Commit("Removed meta", signature, signature);
        GitCommands.Checkout(gitManager.Repository, addedMetaCommit, new CheckoutOptions()
        {
            CheckoutNotifyFlags = CheckoutNotifyFlags.Updated,
            OnCheckoutNotify    = gitManager.CheckoutNotifyHandler
        });
        Assert.IsTrue(File.Exists(metaFilePath));
        Assert.IsTrue(Directory.Exists(GitManager.AssetPathFromMeta(metaFilePath)));
    }