当前位置: 首页>>代码示例>>C#>>正文


C# SparkleLib.SparkleGit类代码示例

本文整理汇总了C#中SparkleLib.SparkleGit的典型用法代码示例。如果您正苦于以下问题:C# SparkleGit类的具体用法?C# SparkleGit怎么用?C# SparkleGit使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


SparkleGit类属于SparkleLib命名空间,在下文中一共展示了SparkleGit类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Start

        // Clones the remote repository
        public void Start()
        {
            SparkleHelpers.DebugInfo ("Git", "[" + TargetFolder + "] Cloning Repository");

            if (Directory.Exists (TargetFolder))
                Directory.Delete (TargetFolder, true);

            if (CloningStarted != null)
                CloningStarted (this, new SparkleEventArgs ("CloningStarted"));

            SparkleGit git = new SparkleGit (SparklePaths.SparkleTmpPath,
                "clone \"" + RemoteOriginUrl + "\" " + "\"" + TargetFolder + "\"");

            git.Exited += delegate {
                SparkleHelpers.DebugInfo ("Git", "Exit code " + git.ExitCode.ToString ());

                if (git.ExitCode != 0) {
                    SparkleHelpers.DebugInfo ("Git", "[" + TargetFolder + "] Cloning failed");

                    if (CloningFailed != null)
                        CloningFailed (this, new SparkleEventArgs ("CloningFailed"));
                } else {
                    InstallConfiguration ();
                    InstallExcludeRules ();

                    SparkleHelpers.DebugInfo ("Git", "[" + TargetFolder + "] Repository cloned");

                    if (CloningFinished != null)
                        CloningFinished (this, new SparkleEventArgs ("CloningFinished"));
                }
            };

            git.Start ();
        }
开发者ID:f2knight,项目名称:SparkleShare,代码行数:35,代码来源:SparkleFetcher.cs

示例2: Fetch

        public override bool Fetch()
        {
            SparkleGit git = new SparkleGit (SparklePaths.SparkleTmpPath,
                "clone \"" + base.remote_url + "\" " + "\"" + base.target_folder + "\"");

            git.Start ();
            git.WaitForExit ();

            SparkleHelpers.DebugInfo ("Git", "Exit code " + git.ExitCode.ToString ());

            if (git.ExitCode != 0) {
                return false;
            } else {
                InstallConfiguration ();
                InstallExcludeRules ();
                return true;
            }
        }
开发者ID:TriggerHappy,项目名称:SparkleShare,代码行数:18,代码来源:SparkleFetcherGit.cs

示例3: GetCurrentHash

        private string GetCurrentHash()
        {
            // Remove stale rebase-apply files because it
            // makes the method return the wrong hashes.
            string rebase_apply_file = SparkleHelpers.CombineMore (LocalPath, ".git", "rebase-apply");
            if (File.Exists (rebase_apply_file))
                File.Delete (rebase_apply_file);

            SparkleGit git = new SparkleGit (LocalPath, "log -1 --format=%H");
            git.Start ();
            git.WaitForExit ();

            string output = git.StandardOutput.ReadToEnd ();
            string hash   = output.Trim ();

            return hash;
        }
开发者ID:f2knight,项目名称:SparkleShare,代码行数:17,代码来源:SparkleRepo.cs

示例4: GetUserEmail

        private string GetUserEmail()
        {
            SparkleGit git = new SparkleGit (LocalPath, "config --get user.email");
            git.Start ();
            git.WaitForExit ();

            string output = git.StandardOutput.ReadToEnd ();
            string user_email   = output.Trim ();

            return user_email;
        }
开发者ID:derflocki,项目名称:SparkleShare,代码行数:11,代码来源:SparkleRepo.cs

示例5: GetCurrentHash

        private string GetCurrentHash()
        {
            SparkleGit git = new SparkleGit (LocalPath, "log -1 --format=%H");
            git.Start ();
            git.WaitForExit ();

            string output = git.StandardOutput.ReadToEnd ();
            string hash   = output.Trim ();

            return hash;
        }
开发者ID:derflocki,项目名称:SparkleShare,代码行数:11,代码来源:SparkleRepo.cs

示例6: CollectGarbage

        // Removes unneeded objects
        private void CollectGarbage()
        {
            SparkleHelpers.DebugInfo ("Git", "[" + Name + "] Collecting garbage...");

            SparkleGit git = new SparkleGit (LocalPath, "gc");
            git.Start ();
            git.WaitForExit ();

            SparkleHelpers.DebugInfo ("Git", "[" + Name + "] Garbage collected.");
        }
开发者ID:derflocki,项目名称:SparkleShare,代码行数:11,代码来源:SparkleRepo.cs

示例7: Add

        // Stages the made changes
        private void Add()
        {
            SparkleHelpers.DebugInfo ("Git", "[" + Name + "] Staging changes...");

            SparkleGit git = new SparkleGit (LocalPath, "add --all");
            git.Start ();
            git.WaitForExit ();

            SparkleHelpers.DebugInfo ("Git", "[" + Name + "] Changes staged.");
            SparkleEventArgs args = new SparkleEventArgs ("Added");

            if (Added != null)
                Added (this, args);
        }
开发者ID:derflocki,项目名称:SparkleShare,代码行数:15,代码来源:SparkleRepo.cs

示例8: Push

        // Pushes the changes to the remote repo
        public void Push()
        {
            _IsSyncing = true;
            _IsPushing = true;

            SparkleHelpers.DebugInfo ("Git", "[" + Name + "] Pushing changes...");
            SparkleGit git = new SparkleGit (LocalPath, "push origin master");

            SparkleEventArgs args = new SparkleEventArgs ("PushingStarted");

            if (PushingStarted != null)
                PushingStarted (this, args);

            git.Exited += delegate {
                _IsSyncing = false;
                _IsPushing = false;

                if (git.ExitCode != 0) {
                    SparkleHelpers.DebugInfo ("Git", "[" + Name + "] Pushing failed.");

                    string unsynced_file_path = SparkleHelpers.CombineMore (LocalPath ,
                        ".git", "has_unsynced_changes");

                    if (!File.Exists (unsynced_file_path))
                        File.Create (unsynced_file_path);

                    _HasUnsyncedChanges = true;

                    args = new SparkleEventArgs ("PushingFailed");

                    if (PushingFailed != null)
                        PushingFailed (this, args);

                    FetchRebaseAndPush ();
                } else {
                    SparkleHelpers.DebugInfo ("Git", "[" + Name + "] Changes pushed.");
                    args = new SparkleEventArgs ("PushingFinished");

                    string unsynced_file_path = SparkleHelpers.CombineMore (LocalPath ,
                        ".git", "has_unsynced_changes");

                    if (File.Exists (unsynced_file_path))
                        File.Delete (unsynced_file_path);

                    _HasUnsyncedChanges = false;

                    if (PushingFinished != null)
                        PushingFinished (this, args);

                    if (Listener.Client.IsConnected) {
                        Listener.Announce (_CurrentHash);
                    } else {
                        AnnounceQueue++;
                        SparkleHelpers.DebugInfo ("Irc", "[" + Name + "] Could not deliver notification, added it to the queue");
                     }
                }

            };

            git.Start ();
            git.WaitForExit ();
        }
开发者ID:derflocki,项目名称:SparkleShare,代码行数:63,代码来源:SparkleRepo.cs

示例9: Fetch

        // Fetches changes from the remote repository
        public void Fetch()
        {
            _IsSyncing  = true;
            _IsFetching = true;

            RemoteTimer.Stop ();

            SparkleHelpers.DebugInfo ("Git", "[" + Name + "] Fetching changes...");
            SparkleGit git = new SparkleGit (LocalPath, "fetch -v origin master");

            SparkleEventArgs args = new SparkleEventArgs ("FetchingStarted");

            if (FetchingStarted != null)
                FetchingStarted (this, args);

            git.Exited += delegate {
                SparkleHelpers.DebugInfo ("Git", "[" + Name + "] Changes fetched.");

                _IsSyncing   = false;
                _IsFetching  = false;
                _CurrentHash = GetCurrentHash ();

                if (git.ExitCode != 0) {
                    _ServerOnline = false;

                    args = new SparkleEventArgs ("FetchingFailed");

                    if (FetchingFailed != null)
                        FetchingFailed (this, args);
                } else {
                    _ServerOnline = true;

                    args = new SparkleEventArgs ("FetchingFinished");

                    if (FetchingFinished != null)
                        FetchingFinished (this, args);
                }

                RemoteTimer.Start ();
            };

            git.Start ();
            git.WaitForExit ();
        }
开发者ID:derflocki,项目名称:SparkleShare,代码行数:45,代码来源:SparkleRepo.cs

示例10: Commit

        // Commits the made changes
        private void Commit(string message)
        {
            if (!AnyDifferences)
                return;

            SparkleGit git = new SparkleGit (LocalPath, "commit -m \"" + message + "\"");
            git.Start ();
            git.WaitForExit ();

            SparkleHelpers.DebugInfo ("Commit", "[" + Name + "] " + message);

            // Collect garbage pseudo-randomly. Turn off for
            // now: too resource heavy.
            // if (DateTime.Now.Second % 10 == 0)
            //     CollectGarbage ();
        }
开发者ID:ktze,项目名称:SparkleShare,代码行数:17,代码来源:SparkleRepoGit.cs

示例11: SyncUp

        public override bool SyncUp()
        {
            Add ();

            string message = FormatCommitMessage ();
            Commit (message);

            SparkleGit git = new SparkleGit (LocalPath, "push origin master");

            git.Start ();
            git.WaitForExit ();

            if (git.ExitCode == 0)
                return true;
            else
                return false;
        }
开发者ID:ktze,项目名称:SparkleShare,代码行数:17,代码来源:SparkleRepoGit.cs

示例12: SyncDown

        public override bool SyncDown()
        {
            SparkleGit git = new SparkleGit (LocalPath, "fetch -v origin master");

            git.Start ();
            git.WaitForExit ();

            if (git.ExitCode == 0) {
                Rebase ();
                return true;
            } else {
                return false;
            }
        }
开发者ID:ktze,项目名称:SparkleShare,代码行数:14,代码来源:SparkleRepoGit.cs

示例13: SyncUpNotes

        public override void SyncUpNotes()
        {
            while (Status != SyncStatus.Idle) {
                System.Threading.Thread.Sleep (5 * 20);
            }

            SparkleGit git_push = new SparkleGit (LocalPath, "push origin refs/notes/*");
            git_push.Start ();
            git_push.WaitForExit ();

            if (git_push.ExitCode == 0) {
                SparkleHelpers.DebugInfo ("Git", "[" + Name + "] Notes pushed");

            } else {
                HasUnsyncedChanges = true;
                SparkleHelpers.DebugInfo ("Git", "[" + Name + "] Pushing notes failed, trying again later");
            }

            SparkleAnnouncement announcement = new SparkleAnnouncement (Identifier, SHA1 (DateTime.Now.ToString ()));
            base.listener.Announce (announcement);
        }
开发者ID:iainlane,项目名称:SparkleShare,代码行数:21,代码来源:SparkleRepoGit.cs

示例14: GetChangeSets

        // Returns a list of the latest change sets
        public override List<SparkleChangeSet> GetChangeSets(int count)
        {
            if (count < 1)
                count = 30;

            List <SparkleChangeSet> change_sets = new List <SparkleChangeSet> ();

            SparkleGit git_log = new SparkleGit (LocalPath, "log -" + count + " --raw -M --date=iso --show-notes=*");
            Console.OutputEncoding = System.Text.Encoding.Unicode;
            git_log.Start ();

            // Reading the standard output HAS to go before
            // WaitForExit, or it will hang forever on output > 4096 bytes
            string output = git_log.StandardOutput.ReadToEnd ();
            git_log.WaitForExit ();

            string [] lines       = output.Split ("\n".ToCharArray ());
            List <string> entries = new List <string> ();

            int j = 0;
            string entry = "", last_entry = "";
            foreach (string line in lines) {
                if (line.StartsWith ("commit") && j > 0) {
                    entries.Add (entry);
                    entry = "";
                }

                entry += line + "\n";
                j++;

                last_entry = entry;
            }

            entries.Add (last_entry);

            Regex merge_regex = new Regex (@"commit ([a-z0-9]{40})\n" +
                                "Merge: .+ .+\n" +
                                "Author: (.+) <(.+)>\n" +
                                "Date:   ([0-9]{4})-([0-9]{2})-([0-9]{2}) " +
                                "([0-9]{2}):([0-9]{2}):([0-9]{2}) .([0-9]{4})\n" +
                                "*", RegexOptions.Compiled);

            Regex non_merge_regex = new Regex (@"commit ([a-z0-9]{40})\n" +
                                "Author: (.+) <(.+)>\n" +
                                "Date:   ([0-9]{4})-([0-9]{2})-([0-9]{2}) " +
                                "([0-9]{2}):([0-9]{2}):([0-9]{2}) (.[0-9]{4})\n" +
                                "*", RegexOptions.Compiled);

            foreach (string log_entry in entries) {
                Regex regex;
                bool is_merge_commit = false;

                if (log_entry.Contains ("\nMerge: ")) {
                    regex = merge_regex;
                    is_merge_commit = true;
                } else {
                    regex = non_merge_regex;
                }

                Match match = regex.Match (log_entry);

                if (match.Success) {
                    SparkleChangeSet change_set = new SparkleChangeSet ();

                    change_set.Folder        = Name;
                    change_set.Revision      = match.Groups [1].Value;
                    change_set.UserName      = match.Groups [2].Value;
                    change_set.UserEmail     = match.Groups [3].Value;
                    change_set.IsMerge       = is_merge_commit;
                    change_set.SupportsNotes = true;

                    change_set.Timestamp = new DateTime (int.Parse (match.Groups [4].Value),
                        int.Parse (match.Groups [5].Value), int.Parse (match.Groups [6].Value),
                        int.Parse (match.Groups [7].Value), int.Parse (match.Groups [8].Value),
                        int.Parse (match.Groups [9].Value));

                    string time_zone     = match.Groups [10].Value;
                    int our_offset       = TimeZone.CurrentTimeZone.GetUtcOffset(DateTime.Now).Hours;
                    int their_offset     = int.Parse (time_zone.Substring (0, 3));
                    change_set.Timestamp = change_set.Timestamp.AddHours (their_offset * -1);
                    change_set.Timestamp = change_set.Timestamp.AddHours (our_offset);

                    string [] entry_lines = log_entry.Split ("\n".ToCharArray ());

                    foreach (string entry_line in entry_lines) {
                        if (entry_line.StartsWith (":")) {

                            string change_type = entry_line [37].ToString ();
                            string file_path   = entry_line.Substring (39);
                            string to_file_path;

                            if (change_type.Equals ("A")) {
                                change_set.Added.Add (file_path);

                            } else if (change_type.Equals ("M")) {
                                change_set.Edited.Add (file_path);

                            } else if (change_type.Equals ("D")) {
                                change_set.Deleted.Add (file_path);
//.........这里部分代码省略.........
开发者ID:iainlane,项目名称:SparkleShare,代码行数:101,代码来源:SparkleRepoGit.cs

示例15: AddNote

        public override void AddNote(string revision, string note)
        {
            string url = SparkleConfig.DefaultConfig.GetUrlForFolder (Name);

            if (url.StartsWith ("git") || url.StartsWith ("http"))
                return;

            int timestamp = (int) (DateTime.UtcNow - new DateTime (1970, 1, 1)).TotalSeconds;

            // Create the note in one line for easier merging
            note = "<note>" +
                   "  <user>" +
                   "    <name>" + SparkleConfig.DefaultConfig.UserName + "</name>" +
                   "    <email>" + SparkleConfig.DefaultConfig.UserEmail + "</email>" +
                   "  </user>" +
                   "  <timestamp>" + timestamp + "</timestamp>" +
                   "  <body>" + note + "</body>" +
                   "</note>";

            string note_namespace = SHA1 (timestamp.ToString () + note);
            SparkleGit git_notes = new SparkleGit (LocalPath,
                "notes --ref=" + note_namespace + " append -m \"" + note + "\" " + revision);
            git_notes.Start ();
            git_notes.WaitForExit ();

            SparkleHelpers.DebugInfo ("Git", "[" + Name + "] Added note to " + revision);
            SyncUpNotes ();
        }
开发者ID:iainlane,项目名称:SparkleShare,代码行数:28,代码来源:SparkleRepoGit.cs


注:本文中的SparkleLib.SparkleGit类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。