示例#1
0
        protected override ArgumentString BuildArguments()
        {
            return(new GitArgumentBuilder("tag")
            {
                { CreateTagArguments.Force, "-f" },
                GetArgumentForOperation(),
                { CreateTagArguments.Operation.CanProvideMessage(), $"-F {TagMessageFileName.Quote()}" },
                CreateTagArguments.TagName.Trim().Quote(),
                "--",
                CreateTagArguments.ObjectId
            });

            string?GetArgumentForOperation()
            {
                return(CreateTagArguments.Operation switch
                {
                    /* Lightweight */
                    TagOperation.Lightweight => null,
                    /* Annotate */
                    TagOperation.Annotate => "-a",
                    /* Sign with default GPG */
                    TagOperation.SignWithDefaultKey => "-s",
                    /* Sign with specific GPG */
                    TagOperation.SignWithSpecificKey => $"-u {CreateTagArguments.SignKeyId}",
                    _ => throw new NotSupportedException($"Invalid tag operation: {CreateTagArguments.Operation}")
                });
示例#2
0
        protected override ArgumentBuilder BuildArguments()
        {
            return(new ArgumentBuilder
            {
                "tag",
                { CreateTagArguments.Force, "-f" },
                GetArgumentForOperation(),
                { CreateTagArguments.Operation.CanProvideMessage(), $"-F {TagMessageFileName.Quote()}" },
                CreateTagArguments.TagName.Trim().Quote(),
                "--",
                CreateTagArguments.ObjectId
            });

            string GetArgumentForOperation()
            {
                switch (CreateTagArguments.Operation)
                {
                /* Lightweight */
                case TagOperation.Lightweight:
                    return(null);

                /* Annotate */
                case TagOperation.Annotate:
                    return("-a");

                /* Sign with default GPG */
                case TagOperation.SignWithDefaultKey:
                    return("-s");

                /* Sign with specific GPG */
                case TagOperation.SignWithSpecificKey:
                    return($"-u {CreateTagArguments.SignKeyId}");

                /* Error */
                default:
                    throw new NotSupportedException($"Invalid tag operation: {CreateTagArguments.Operation}");
                }
            }
        }