Exemplo n.º 1
0
        private string ReadActualVersion(PackageInfoMetaData info)
        {
            if (!File.Exists(info.VersionFile))
            {
                return(null);
            }

            using (var rd = File.OpenText(info.VersionFile))
            {
                var data = rd.ReadLine()?.Split(':') ?? new string[] { null };
                return(data.Length > 1 ? data.Last()?.Trim(): "");
            }
        }
Exemplo n.º 2
0
        public override bool Execute()
        {
            var infoItems = (Items ?? Array.Empty <ITaskItem>())
                            .Select(x => new TaskItem(x))
                            .Cast <ITaskItem>().ToList();

            var dupes = string.Join("; ",
                                    infoItems.GroupBy(x => x.ItemSpec).Where(x => x.Count() > 1).Select(x => x.Key));

            if (!string.IsNullOrWhiteSpace(dupes))
            {
                throw new Exception("Duplicate packages found: " + dupes);
            }

            infoItems = AppendMissingItemsFromFileSystem(infoItems);

            using (var sh1 = SHA1.Create())
            {
                foreach (var item in infoItems)
                {
                    var info = new PackageInfoMetaData(item);

                    info.VersionFile = Path.Combine(Root, info.ItemSpec + ".ver");

                    info.Actual = ReadActualVersion(info);

                    info.WorkTreeFolder = Path.Combine(Root, info.ItemSpec);

                    info.WorkTreeCommit = GetWorkTreeCommitFromVersion(info.Version);

                    GetCloneFolderName(sh1, item);
                }
            }

            Info = infoItems.ToArray();

            return(true);
        }