예제 #1
0
        public override IEnumerable<SourceTagInfo> GetChildUrls(BuildContext ctx, SourceInfo source)
        {
            // URL syntax:
            // url|t<name>,b<name>,...

            List<string> selBranches = new List<string> ();
            List<string> selTags = new List<string> ();

            if (source.Branches != null) {
                foreach (string b in source.Branches.Split (new char[] {','}, StringSplitOptions.RemoveEmptyEntries))
                    selBranches.Add (b.Trim ());
            }

            if (source.Tags != null) {
                foreach (string b in source.Tags.Split (new char[] {','}, StringSplitOptions.RemoveEmptyEntries))
                    selTags.Add (b.Trim ());
            }

            if (selBranches.Count == 0 && selTags.Count == 0)
                selBranches.Add ("master");

            UpdateRepo (ctx, source.Id, source.Url, null);

            string gitDir = GetGitPath (ctx, source.Id);
            string remotePrefix = "origin/";

            if (selBranches.Count > 0) {
                foreach (string b in RunCommand (gitDir, "branch -r", null)) {
                    if (b.Length < 3)
                        continue;
                    string br = b.Substring (2);
                    int i = br.IndexOf (" -> ");
                    if (i != -1)
                        br = br.Substring (0, i);
                    string branchName = br;
                    if (br.StartsWith (remotePrefix))
                        branchName = br.Substring (remotePrefix.Length);

                    if (Util.FindMatch (branchName, selBranches)) {
                        string rev = GetCurrentRevision (gitDir, br);
                        yield return new SourceTagInfo () { Url = source.Url + "|b" + br, Name = branchName, LastRevision = rev };
                    }
                }
            }

            if (selTags.Count > 0) {
                foreach (string t in RunCommand (gitDir, "tag", null)) {
                    if (t.Trim ().Length == 0)
                        continue;
                    if (Util.FindMatch (t, selTags)) {
                        string rev = GetCurrentRevision (gitDir, t);
                        yield return new SourceTagInfo () { Url = source.Url + "|t" + t, Name = t, LastRevision = rev };
                    }
                }
            }
        }
예제 #2
0
        public override IEnumerable<SourceTagInfo> GetChildUrls(BuildContext ctx, SourceInfo source)
        {
            StringBuilder output = new StringBuilder ();
            StringBuilder error = new StringBuilder ();
            string url = source.Url;

            if (!url.EndsWith ("/*")) {
                BuildService.RunCommand (SubversionCommand, "info --xml " + url, output, error, Timeout);
                XmlDocument doc = new XmlDocument ();
                doc.LoadXml (output.ToString ());
                XmlElement elem = (XmlElement) doc.SelectSingleNode ("/info/entry");
                if (elem == null) {
                    elem = (XmlElement)doc.SelectSingleNode ("/info");
                    if (elem != null)
                        throw new Exception (elem.InnerText);
                    else if (error.Length > 0)
                        throw new Exception (error.ToString ());
                    else
                        throw new Exception ("Error while getting repository information");
                }
                yield return new SourceTagInfo () { Url = url, Name = elem.GetAttribute ("path"), LastRevision = elem.GetAttribute ("revision") };
            }
            else {
                url = url.Substring (0, url.Length - 2);
                BuildService.RunCommand (SubversionCommand, "ls --xml " + url, output, error, Timeout);
                XmlDocument doc = new XmlDocument ();
                try {
                    doc.LoadXml (output.ToString ());
                }
                catch {
                    if (error.Length > 0)
                        throw new Exception (error.ToString ());
                    else
                        throw new Exception ("Error while getting repository information");
                }
                foreach (XmlElement elem in doc.SelectNodes ("/lists/list/entry")) {
                    string name = elem["name"].InnerText;
                    string revision = elem["commit"].GetAttribute ("revision");
                    yield return new SourceTagInfo () { Url = url + "/" + name, Name = name, LastRevision = revision };

                }
            }
        }
예제 #3
0
        public override IEnumerable<SourceTagInfo> GetChildUrls(BuildContext ctx, SourceInfo source)
        {
            List<string> selTags = new List<string> ();

            if (source.Tags != null) {
                foreach (string b in source.Tags.Split (new char[] {','}, StringSplitOptions.RemoveEmptyEntries))
                    selTags.Add (b.Trim ());
            }

            UpdateRepo (ctx, source.Id, source.Url, null);

            string bzrDir = GetBzrPath (ctx, source.Id);

            if (selTags.Count > 0) {
                foreach (string t in RunCommand (bzrDir, "tags", null)) {
                    int i = t.IndexOf (' ');
                    string tn = t.Substring (0, i);
                    if (Util.FindMatch (t, selTags)) {
                        string rev = t.Substring (i+1).Trim ();
                        yield return new SourceTagInfo () { Url = source.Url + "|t" + tn, Name = tn, LastRevision = rev };
                    }
                }
            } else {
                int i = source.Url.LastIndexOf ('/');
                string rev = RunCommand (bzrDir, "revno", null).FirstOrDefault () ?? "Unknown";
                yield return new SourceTagInfo () { Url = source.Url, Name = source.Url.Substring (i+1), LastRevision = rev };
            }
        }
예제 #4
0
 public abstract IEnumerable<SourceTagInfo> GetChildUrls(BuildContext ctx, SourceInfo source);