コード例 #1
0
        public void CloneBranch(KBGit git, string remotename, string url, string branch)
        {
            git.InitializeRepository();
            git.Remotes.Remotes.Add(new Remote {
                Name = remotename, Url = new Uri(url)
            });
            var tip = PullBranch(git.Remotes.Remotes.Single(), branch, git);

            git.Branches.ResetBranchPointer("master", tip);
            git.Branches.Checkout("master");
        }
コード例 #2
0
        public string Handle(KBGit git, GrammarLine[] config, string[] cmdParams)
        {
            var match = config.SingleOrDefault(x => x.Grammar.Length == cmdParams.Length &&
                                               x.Grammar.Zip(cmdParams, (gramar, arg) => gramar.StartsWith("<") || gramar == arg).All(m => m));

            if (match == null)
            {
                return($"KBGit Help\r\n----------\r\ngit {string.Join("\r\ngit ", config.Select(x => $"{string.Join(" ", x.Grammar),-34} - {x.Explanation}."))}");
            }

            git.LoadState();
            var result = match.ActionOnMatch(git, cmdParams);

            git.StoreState();

            return(result);
        }
コード例 #3
0
        public static void Main()
        {
            var git = new KBGit(@"c:\temp\kbgit\");

            git.Init();
            File.WriteAllText(git.CodeFolder + "file.txt", "Hello world");
            git.Commit("Adding note", "kasper", DateTime.Now, git.ScanFileSystem());
            Console.WriteLine(git.Log());
            WaitKey();

            Console.WriteLine("---");
            File.WriteAllText(git.CodeFolder + "file.txt", "Hello world\nAnd more stuff here");
            File.WriteAllText(git.CodeFolder + "readme.md", "#title\n\nthis module is bla bla\nand then more bla bla");
            git.Commit("Adding extra text and readme", "kasper", DateTime.Now, git.ScanFileSystem());
            Console.WriteLine(git.Log());

            Console.WriteLine("---");
            File.WriteAllText(git.CodeFolder + "file.txt",
                              "# title\n\nthis module is bla bla\nand then more bla bla" + "\nso much\nmoooore\n123....wow\nlalala");
            git.Commit("More text to file1", "kasper", DateTime.Now, git.ScanFileSystem());
            Console.WriteLine(git.Log());
            WaitKey();

            Console.WriteLine("---");
            Console.WriteLine("creating branch");
            git.CheckOut_b("Feature1", git.HeadRef(1));
            File.WriteAllText(git.CodeFolder + "featurefile.cs",
                              "class Feature \n{ Some cool feature \n}" + "\nso much\nmoooore\n123....wow\nlalala");
            git.Commit("Add feature 1", "kasper", DateTime.Now, git.ScanFileSystem());
            Console.WriteLine(git.Log());
            WaitKey();

            Console.WriteLine("reset to main");
            git.Checkout("master");
            WaitKey();
        }
コード例 #4
0
 public GitServer(KBGit git)
 {
     this.git = git;
 }