/// <summary> /// Deletes the working copy of this repository. It also releases any native handle of the repository. /// </summary> public void DeleteWorkingCopy() { if (!this.IsRepositoryInitialized) { throw new ModuniException("The repository is not initialized."); } string repositoryURL = this.RepositoryURL; this.Dispose(); DirectoryExtensions.DeleteCompletely(repositoryURL); }
/// <summary> /// Removes the submodule whose relative path is specified as argument. /// </summary> /// <param name="relativePath">The relative path of the submodule to be removed.</param> /// <param name="forceRemoval">If set to <c>true</c>, it deletes the submodule even if it has local modifications.</param> public void RemoveSubmodule(string relativePath, bool forceRemoval) { if (!this.IsRepositoryInitialized) { throw new ModuniException("The repository is not initialized."); } if (forceRemoval) { DirectoryExtensions.DeleteCompletely(System.IO.Path.Combine(this.RepositoryURL, relativePath)); } this.RemoveFile(relativePath, true); this.DeleteSubmoduleFromConfiguration(relativePath); this.StageFile(".gitmodules"); DirectoryExtensions.DeleteCompletely(System.IO.Path.Combine(System.IO.Path.Combine(this.RepositoryURL, ".git/modules"), relativePath)); }
/// <summary> /// Moves the repository to the path specified as argument. /// </summary> /// <param name="pathToMoveTo">The new path of the repository.</param> public void MoveTo(string pathToMoveTo) { if (!this.IsRepositoryInitialized) { throw new ModuniException("The repository is not initialized."); } // If it is a submodule, we can't move it by our own so we do nothing if (System.IO.File.Exists(System.IO.Path.Combine(this.RepositoryURL, ".git"))) { return; } if (System.IO.Directory.Exists(pathToMoveTo)) { DirectoryExtensions.DeleteCompletely(pathToMoveTo); } string repositoryURL = this.RepositoryURL; this.Dispose(); System.IO.Directory.Move(repositoryURL, pathToMoveTo); this.gitRepositoryHandle = new Repository(pathToMoveTo); }