public void RemoveFile(string path) { lock (_lock) { _treeDefinition.Remove(path); } }
public void CanAddAnExistingSubmodule() { const string submodulePath = "sm_unchanged"; using (var repo = new Repository(SubmoduleTestRepoWorkingDirPath)) { var submodule = repo.Submodules[submodulePath]; Assert.NotNull(submodule); TreeDefinition td = TreeDefinition.From(repo.Head.Tip.Tree); Assert.NotNull(td[submodulePath]); td.Remove(submodulePath); Assert.Null(td[submodulePath]); td.Add(submodule); TreeEntryDefinition fetched = td[submodulePath]; Assert.NotNull(fetched); Assert.Equal(submodule.HeadCommitId, fetched.TargetId); Assert.Equal(TreeEntryTargetType.GitLink, fetched.TargetType); Assert.Equal(Mode.GitLink, fetched.Mode); } }
/// <summary> /// Updates the tree definition. /// </summary> /// <param name="repository">The repository.</param> /// <param name="definition">The definition.</param> internal void UpdateTreeDefinition(IRepository repository, TreeDefinition definition) { if (repository == null) { throw new ArgumentNullException(nameof(repository)); } if (definition == null) { throw new ArgumentNullException(nameof(definition)); } var buffer = new StringBuilder(); foreach (var change in Modified.Concat(Added)) { change.New.ToJson(buffer); definition.Add(change.Path, repository.CreateBlob(buffer), Mode.NonExecutableFile); } foreach (var deleted in Deleted) { definition.Remove(deleted.Path); } }
static void deleteKeyFromTree(string key, TreeDefinition tree) { lock (tree) tree.Remove(key); }
public void Remove(string path) { _treeDefinition.Remove(path); }