Esempio n. 1
0
 public void TestGitTreeishDefaultIsMaster()
 {
     using (var tempRepo = new TempDirectory())
     {
         CreateTempRepo(tempRepo);
         var repo = new GitRepository(Path.GetFileName(tempRepo.Path), Directory.GetParent(tempRepo.Path).FullName, Log);
         Assert.AreEqual("master", repo.CurrentLocalTreeish().Value);
         Assert.AreEqual(TreeishType.Branch, repo.CurrentLocalTreeish().Type);
     }
 }
Esempio n. 2
0
 public void TestGitCheckoutExistingBranch()
 {
     using (var tempRepo = new TempDirectory())
     {
         CreateTempRepo(tempRepo);
         CreateNewBranchInTempRepo(tempRepo, "new_branch");
         var repo = new GitRepository(Path.GetFileName(tempRepo.Path),
                                      Directory.GetParent(tempRepo.Path).FullName, Log);
         repo.Checkout("new_branch");
         Assert.AreEqual("new_branch", repo.CurrentLocalTreeish().Value);
         Assert.AreEqual(TreeishType.Branch, repo.CurrentLocalTreeish().Type);
     }
 }
Esempio n. 3
0
 public void TestGitTreeishOnTag()
 {
     using (var tempRepo = new TempDirectory())
     {
         CreateTempRepo(tempRepo);
         using (new DirectoryJumper(tempRepo.Path))
         {
             var runner = new ShellRunner();
             runner.Run("git tag testTag");
             runner.Run("git checkout testTag");
         }
         var repo = new GitRepository(Path.GetFileName(tempRepo.Path), Directory.GetParent(tempRepo.Path).FullName, Log);
         Assert.AreEqual("testTag", repo.CurrentLocalTreeish().Value);
         Assert.AreEqual(TreeishType.Tag, repo.CurrentLocalTreeish().Type);
     }
 }
Esempio n. 4
0
        protected override int Execute()
        {
            Log.Info("Updating packages");
            PackageUpdater.UpdatePackages();
            var cwd    = Directory.GetCurrentDirectory();
            var module = Path.GetFileName(cwd);

            var curRepo = new GitRepository(module, Helper.CurrentWorkspace, Log);

            if (treeish == null)
            {
                treeish = curRepo.CurrentLocalTreeish().Value;
            }

            var getter = new ModuleGetter(
                Helper.GetModules(),
                new Dep(module, treeish),
                policy,
                null,
                verbose);

            getter.GetModule();

            return(0);
        }
Esempio n. 5
0
 public void TestGitTreeishInClearGitRepo()
 {
     using (var tempdir = new TempDirectory())
     {
         new GitRepository("unexisting_module", tempdir.Path, Log).Init();
         var repo = new GitRepository("unexisting_module", tempdir.Path, Log);
         Assert.AreEqual("master", repo.CurrentLocalTreeish().Value);
     }
 }
Esempio n. 6
0
 public void TestGitTreeishDetached()
 {
     using (var tempRepo = new TempDirectory())
     {
         CreateTempRepo(tempRepo);
         string sha1;
         using (new DirectoryJumper(tempRepo.Path))
         {
             var runner = new ShellRunner();
             runner.Run("git rev-parse HEAD");
             sha1 = runner.Output.Trim();
             runner.Run("git checkout " + sha1);
         }
         var repo = new GitRepository(Path.GetFileName(tempRepo.Path),
                                      Directory.GetParent(tempRepo.Path).FullName, Log);
         Assert.AreEqual(sha1, repo.CurrentLocalTreeish().Value);
         Assert.AreEqual(TreeishType.CommitHash, repo.CurrentLocalTreeish().Type);
     }
 }
Esempio n. 7
0
        private void CheckBranch()
        {
            if (string.IsNullOrEmpty(dep.Treeish))
                return;

            try
            {
                var repo = new GitRepository(dep.Name, Helper.CurrentWorkspace, Log);
                var current = repo.CurrentLocalTreeish().Value;
                if (current != dep.Treeish)
                    ConsoleWriter.WriteWarning($"{dep.Name} on @{current} but adding @{dep.Treeish}");
            }
            catch (Exception e)
            {
                Log.Error($"FAILED-TO-CHECK-BRANCH {dep}", e);
            }
        }
Esempio n. 8
0
        private void CheckBranch()
        {
            if (string.IsNullOrEmpty(analyzerModule.Treeish))
            {
                return;
            }

            try
            {
                var repo    = new GitRepository(analyzerModule.Name, Helper.CurrentWorkspace, Log);
                var current = repo.CurrentLocalTreeish().Value;
                if (current != analyzerModule.Treeish)
                {
                    ConsoleWriter.WriteWarning($"{analyzerModule.Name} on @{current} but adding @{analyzerModule.Treeish}");
                }
            }
            catch (Exception e)
            {
                Log.LogError($"FAILED-TO-CHECK-BRANCH {analyzerModule}", e);
            }
        }
Esempio n. 9
0
        protected override int Execute()
        {
            cwd               = Directory.GetCurrentDirectory();
            workspace         = Directory.GetParent(cwd).FullName;
            moduleName        = Path.GetFileName(cwd);
            currentRepository = new GitRepository(moduleName, workspace, Log);

            if (checkingBranch == null)
            {
                checkingBranch = currentRepository.HasLocalBranch("master") ?
                                 "master" : currentRepository.CurrentLocalTreeish().Value;
            }

            var response = Usages.GetUsagesResponse(moduleName, checkingBranch);

            var usages = response.Items
                         .SelectMany(kvp => kvp.Value)
                         .Where(d => d.Treeish == "master")
                         .DistinctBy(d => d.Name);

            Grep(usages);
            return(0);
        }
Esempio n. 10
0
        protected override int Execute()
        {
            cwd               = Directory.GetCurrentDirectory();
            workspace         = Directory.GetParent(cwd).FullName;
            moduleName        = Path.GetFileName(cwd);
            currentRepository = new GitRepository(moduleName, workspace, Log);

            if (currentRepository.HasLocalChanges())
            {
                throw new CementException("You have uncommited changes");
            }
            branch = currentRepository.CurrentLocalTreeish().Value;
            if (checkingBranch == null)
            {
                checkingBranch = branch;
            }

            var response = Usages.GetUsagesResponse(moduleName, checkingBranch);

            var toBuild = response.Items.SelectMany(kvp => kvp.Value).Where(d => d.Treeish == "master").ToList();

            BuildDeps(toBuild);
            return(0);
        }