示例#1
0
        protected async override Task RunCommandAsync()
        {
            bool   explicitInclude = HasModifier(explicitIncludeModifier);
            string ignoreSetup     = GetArgumentValue(ignoreList);

            List <string> packageFiles = fileService.GetWorkingDirectoryFiles(ignoreSetup.Split(','));

            FolderVersionEntry version = await versioningService.CreateInitialVersion(packageFiles.ToArray <string>());

            string packageName = uiService.RequestValue($"Enter package name: ");
            string packageHash = hashService.ComputeFilesHash(packageFiles);

            configService.CreateConfig(packageName, packageHash);

            await onlineStoreService.PushPackageAsync($"{packageName}@initial", version);
        }
示例#2
0
文件: TagCommand.cs 项目: alexi-t/spm
        protected async override Task RunCommandAsync()
        {
            PackageConfiguration config = null;

            if (!configService.TryGetConfig(out config))
            {
                uiService.AddMessage("No config inited, can not compute diff");
                return;
            }

            string newTag = await GetTagName(config);

            Dictionary <string, string> actualPathToHashMap = new Dictionary <string, string>();

            foreach (var filePath in fileService.GetWorkingDirectoryFiles(config.ExcludePaths))
            {
                actualPathToHashMap.Add(filePath, hashService.ComputeFileHash(filePath));
            }

            Dictionary <string, string> tagPathToHashMap =
                await onlineStoreService.GetPackageFilesAtVersionAsync(config.Name, config.Tag);

            bool hasChanges =
                tagPathToHashMap.Keys.Except(actualPathToHashMap.Keys).Any() ||
                actualPathToHashMap.Keys.Except(tagPathToHashMap.Keys).Any();

            if (!hasChanges)
            {
                foreach (var pathToHashMap in tagPathToHashMap)
                {
                    if (actualPathToHashMap[pathToHashMap.Key] != pathToHashMap.Value)
                    {
                        hasChanges = true;
                        break;
                    }
                }
            }

            if (!hasChanges)
            {
                uiService.AddMessage("No difference with previous version. Can not add tag");
                return;
            }

            FolderVersionEntry folderVersion = versioningService.CreateDiff(tagPathToHashMap, actualPathToHashMap);

            ConsoleColor?statusToColor(FileHistoryType status)
            {
                switch (status)
                {
                case FileHistoryType.Added:
                    return(ConsoleColor.Green);

                case FileHistoryType.Modified:
                    return(ConsoleColor.Yellow);

                case FileHistoryType.Deleted:
                    return(ConsoleColor.Red);

                default:
                    return(null);
                }
            }

            uiService.AddMessage($"Created {config.Name}@{newTag}");
            uiService.AddMessage("List of changes:");
            foreach (FileHistoryEntry fileHistoryEntry in folderVersion.Files)
            {
                uiService.AddMessage(
                    message: $"\t[{fileHistoryEntry.EditType.ToString().ToLower()}]\t{Path.GetFileName(fileHistoryEntry.Path)}",
                    color: statusToColor(fileHistoryEntry.EditType));
            }

            configService.SetTag(newTag);

            await onlineStoreService.PushPackageAsync($"{config.Name}@{newTag}", folderVersion);
        }