public Importer() { StagingDirectory = GetStagingDirectory(); Git = new Gitter(); Finder = new FileFinder(); FileSync = new FileSync(); Backup = new FileBackup(); }
//[Test] public void Test_AddFile() { var gitter = new Gitter(); gitter.Init(); throw new NotImplementedException(); }
public void Test_IsWithinRepository_False() { var gitter = new Gitter(); var repoDir = Path.GetFullPath("WorkingDir"); Directory.CreateDirectory(repoDir); Assert.IsFalse(gitter.IsWithinRepository(repoDir)); }
public void Test_Init() { var gitter = new Gitter(); gitter.Init(); var gitDir = Path.GetFullPath(".git"); var gitDirExists = Directory.Exists(gitDir); Assert.IsTrue(gitDirExists); }
public DataSaver(GitDBSettings settings, DataTypeManager typeManager, DataIdManager idManager, DataPreparer preparer, DataLinker linker, DataChecker checker, Gitter gitter) : base(settings) { Settings = settings; IdManager = idManager; TypeManager = typeManager; Preparer = preparer; Checker = checker; Linker = linker; Gitter = gitter; Namer = new FileNamer (settings.Location); }
public void Test_IsWithinRepository() { var gitter = new Gitter(); var repoDir = Path.GetFullPath("WorkingDir"); var gitDir = Path.Combine(repoDir, ".git"); Directory.CreateDirectory(repoDir); Directory.CreateDirectory(gitDir); Assert.IsTrue(gitter.IsWithinRepository(repoDir)); }
public void Test_IsWithinRepository_Deeper_False() { var gitter = new Gitter(); var repoDir = Path.GetFullPath("WorkingDir"); var subDir = Path.Combine(repoDir, "mysubdir"); var subDir2 = Path.Combine(subDir, "deepersubdir"); Directory.CreateDirectory(repoDir); Directory.CreateDirectory(subDir); Directory.CreateDirectory(subDir2); Assert.IsFalse(gitter.IsWithinRepository(subDir2)); }
static void Main(string[] args) { IConfiguration config = new ConfigurationBuilder() .SetBasePath(Directory.GetCurrentDirectory()) .AddJsonFile("appsettings.json", true, true) .Build(); var destFolder = config["SaveDestinationDirectory"]; var connectionString = config["DbConnectionString"]; var gitUserName = config["GitUserName"]; var gitPassword = config["GitPassword"]; var gitBranch = config["GitBranch"]; var gitCommitterAuthorName = config["CommitterAuthorName"]; var gitCommitterAuthorEmail = config["CommitterAuthorEmail"]; var dbSchemaParser = new DbSchemaParser(connectionString); var modules = dbSchemaParser.GetSchema(); var schemaSaver = new SchemaToFileSaver(destFolder); schemaSaver.Save(modules); schemaSaver.DeleteNotExisting(modules); var gitter = new Gitter(destFolder, gitUserName, gitPassword, gitBranch); if (!string.IsNullOrWhiteSpace(gitCommitterAuthorName)) { gitter.CommitterAuthorName = gitCommitterAuthorName; } if (!string.IsNullOrWhiteSpace(gitCommitterAuthorEmail)) { gitter.CommitterAuthorEmail = gitCommitterAuthorEmail; } var pushed = gitter.TryPush(out var pushResultMessage); Console.WriteLine(pushed ? "Pushed properly" : "Error occurred"); Console.WriteLine(pushResultMessage); }
public void Test_Identify() { var branchName = "TestBranch"; var initializer = new TestSourceProjectInitializer(OriginalDirectory, WorkingDirectory); initializer.CloneSource = true; initializer.Initialize(); var gitter = new Gitter(); gitter.Branch(branchName, true); // Create a new test branch and move to it gitter.Branch("zz"); // Create a branch at the end of the list var identifier = new GitBranchIdentifier(); var identifiedBranch = identifier.Identify(); Assert.AreEqual(branchName, identifiedBranch, "Branch doesn't match."); }
public override bool Run(string[] args) { new FilesGrabber( OriginalDirectory, CurrentDirectory ).GrabOriginalFiles(); var branch = new GitBranchIdentifier().Identify(); var gitter = new Gitter(); var testBranchName = "TestBranch"; // Create a new branch and check it out gitter.Branch(testBranchName, true); var testFileName = Path.GetFullPath("test.txt"); File.WriteAllText(testFileName, "Test content"); gitter.Add(testFileName); gitter.Commit("Added test file"); // Increment the version so the .node files conflict ExecuteScript("IncrementVersion", "3"); // Commit the version related files ExecuteScript("CommitVersion"); // Checkout the original branch gitter.Checkout(branch); // Run the MergeBranch script ExecuteScript("MergeBranch", testBranchName); ExecuteScript("HelloWorld"); return(!IsError); }
public void Test_Init_Add_Commit_Clone() { Console.WriteLine(""); Console.WriteLine("===== Preparing Test ====="); Console.WriteLine(""); var testProjectName = "TestProject"; // Create a path to the test project var testProjectDir = Path.GetFullPath(testProjectName); // Create the source project directory Directory.CreateDirectory(testProjectDir); // Create a temporary path to the destination project var tmpProjectCloneDir = Path.GetFullPath(testProjectName + "Clone"); // Create the destination project directory Directory.CreateDirectory(tmpProjectCloneDir); // Move to the test project directory Directory.SetCurrentDirectory(testProjectDir); var gitter = new Gitter(); Console.WriteLine(""); Console.WriteLine("===== Executing Test ====="); Console.WriteLine(""); // Initialize source git repo var repo = gitter.Init(); var testFileName = "TestFile.txt"; // Create a test file path var testFilePath = testProjectDir + Path.DirectorySeparatorChar + testFileName; var testFileContent = "Test content"; // Create the test file File.WriteAllText(testFilePath, testFileContent); Console.WriteLine("Adding test file..."); // Add the test file repo.Add(testFilePath); Console.WriteLine("Committing..."); // Commit the test file repo.Commit(); Console.WriteLine("Cloning..."); // Clone the temporary project into a new directory gitter.Clone(".", "../" + testProjectName + "Clone"); var clonedTestFile = tmpProjectCloneDir + Path.DirectorySeparatorChar + testFileName; Console.WriteLine(""); Console.WriteLine("===== Checking Result ====="); Console.WriteLine(""); // Assert that the file was clone Assert.IsTrue(File.Exists(clonedTestFile), "The test file wasn't cloned."); Assert.AreEqual(testFileContent, File.ReadAllText(clonedTestFile), "The cloned test file doesn't have the expected contents."); }
public static void Main(string[] args) { Console.WriteLine("Starting GitDeployer"); Console.WriteLine(""); var sleepTime = Convert.ToInt32(args [0]); Console.WriteLine("Sleep time: " + sleepTime + " seconds"); var repositoryPath = args [1]; Console.WriteLine("Repository path: " + repositoryPath); var path = Path.GetFullPath(args [2]); if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } Environment.CurrentDirectory = path; var updateCommand = args [3]; if (args.Length > 4) { for (int i = 4; i < args.Length; i++) { updateCommand += " " + args [i]; } } Console.WriteLine("Update command: " + updateCommand); Console.WriteLine(""); var gitter = new Gitter(); var isRunning = true; var needsUpdate = false; while (isRunning) { try { Console.WriteLine("Checking remote repository"); if (gitter.IsWithinRepository(path)) { var repository = gitter.Open(path); var changesFound = repository.Pull("origin"); needsUpdate = changesFound; } else { gitter.Clone(repositoryPath, path); needsUpdate = true; } if (needsUpdate) { Update(updateCommand); } else { Console.WriteLine("Already up to date. Update skipped."); } Thread.Sleep(sleepTime * 1000); } catch (Exception ex) { Console.WriteLine("Error:"); Console.WriteLine(ex.ToString()); } } }
public void Test_Pull() { var workingDirectory = Environment.CurrentDirectory; var processStarter = new ProcessStarter(); Console.WriteLine(""); Console.WriteLine("Setting up source repository..."); Console.WriteLine(""); // Set up the source directory var sourceRepository = Path.GetFullPath("SourceRepo"); Console.WriteLine("Source repo: " + sourceRepository); Directory.CreateDirectory(sourceRepository); Directory.SetCurrentDirectory(sourceRepository); var testFileName = "test.txt"; // Set up the source file var sourceFile = Path.Combine(sourceRepository, testFileName); File.WriteAllText(sourceFile, "Hello world 1"); Console.WriteLine("Source file: " + sourceFile); // Set up the source repository processStarter.Start("git init"); processStarter.Start("git add test.txt"); processStarter.Start("git commit -am 'Initial commit'"); Directory.SetCurrentDirectory(workingDirectory); Console.WriteLine(""); Console.WriteLine("Setting up destination repository and cloning..."); Console.WriteLine(""); // Set up destination directory and clone var destinationRepository = Path.GetFullPath("DestinationRepo"); Console.WriteLine("Destination repo: " + destinationRepository); //Directory.CreateDirectory (sourceRepository); processStarter.Start("git clone -v " + sourceRepository + " " + destinationRepository); var destinationFile = Path.Combine(destinationRepository, testFileName); Console.WriteLine("Destination file: " + destinationFile); Assert.IsTrue(File.Exists(destinationFile), "File not found: " + destinationFile); Console.WriteLine(""); Console.WriteLine("Editing the source file..."); Console.WriteLine(""); // Change the source file File.WriteAllText(sourceFile, "Hello world 2"); Directory.SetCurrentDirectory(sourceRepository); processStarter.Start("git commit -am 'Updated test file'"); Directory.SetCurrentDirectory(destinationRepository); var gitter = new Gitter(); var repository = gitter.Open(destinationRepository); Console.WriteLine(""); Console.WriteLine("Pulling changes to destination repository..."); Console.WriteLine(""); repository.Pull("origin"); var expectedContent = "Hello world 2"; Assert.AreEqual(expectedContent, File.ReadAllText(destinationFile), "Invalid content"); }
public LocalGitDeploymentRetriever() { Git = new Gitter(); }