Esempio n. 1
0
        /// <summary>Check latest gitter version on this chanel.</summary>
        /// <returns>Latest gitter version.</returns>
        public Version CheckVersion()
        {
            Version result = null;
            var cmd = new LsRemoteCommand(
                LsRemoteCommand.Heads(),
                LsRemoteCommand.Tags(),
                new CommandParameter(_url));

            GitOutput output;
            try
            {
                output = GitProcess.Execute(new GitInput(cmd));
            }
            catch
            {
                return null;
            }
            if(output.ExitCode != 0)
            {
                return null;
            }
            var parser = new GitParser(output.Output);
            string branchSHA1 = null;
            while(!parser.IsAtEndOfString)
            {
                var sha1	= parser.ReadString(40, 1);
                var refname	= parser.ReadLine();
                if(branchSHA1 == null)
                {
                    if(refname == GitConstants.LocalBranchPrefix + _branch)
                    {
                        branchSHA1 = sha1;
                    }
                }
                else
                {
                    if(sha1 == branchSHA1 &&
                        refname.Length > GitConstants.TagPrefix.Length + 1 &&
                        refname.StartsWith(GitConstants.TagPrefix) &&
                        refname[GitConstants.TagPrefix.Length] == 'v')
                    {
                        var s = GitConstants.TagPrefix.Length + 1;
                        var e = refname.Length - 1;
                        while(s < refname.Length && !char.IsDigit(refname[s])) ++s;
                        while(e > 0 && !char.IsDigit(refname[e])) --e;
                        if(e > s && Version.TryParse(refname.Substring(s, e - s + 1), out result))
                        {
                            break;
                        }
                        else
                        {
                            result = null;
                        }
                    }
                }
            }
            return result;
        }
Esempio n. 2
0
        public IList<RevisionGraphData> ParseRevisionGraph(GitOutput output)
        {
            Assert.IsNotNull(output);

            output.ThrowOnBadReturnCode();
            var parser = new GitParser(output.Output);
            var result = new List<RevisionGraphData>();
            while(!parser.IsAtEndOfString)
            {
                var sha1 = parser.ReadString(40, 1);
                int end = parser.FindNullOrEndOfString();
                int numParents = (end - parser.Position + 1) / 41;
                if(numParents == 0)
                {
                    parser.Position = end + 1;
                    result.Add(new RevisionGraphData(sha1, new string[0]));
                }
                else
                {
                    var parents = new List<string>(numParents);
                    for(int i = 0; i < numParents; ++i)
                    {
                        parents.Add(parser.ReadString(40, 1));
                    }
                    result.Add(new RevisionGraphData(sha1, parents));
                }
            }
            return result;
        }
Esempio n. 3
0
        public IList<NoteData> ParseNotes(GitOutput output)
        {
            Assert.IsNotNull(output);

            output.ThrowOnBadReturnCode();
            var res = new List<NoteData>();
            var notes = output.Output;
            if(notes.Length > 81)
            {
                var parser = new GitParser(notes);
                while(!parser.IsAtEndOfString)
                {
                    var noteSHA1 = parser.ReadString(40, 1);
                    var objectSHA1 = parser.ReadString(40, 1);
                    res.Add(new NoteData(noteSHA1, objectSHA1, null));
                }
            }
            return res;
        }