Ejemplo n.º 1
0
        public void CreateTagWithMessageWritesTagMessageFile()
        {
            var args = new GitCreateTagArgs(TagName, Revision, TagOperation.Annotate, TagMessage);

            _controller.CreateTag(args, null);
            _fileSystem.File.Received(1).WriteAllText(_tagMessageFile, TagMessage);
        }
Ejemplo n.º 2
0
        private int CreateLostFoundTags()
        {
            var selectedLostObjects = Warnings.Rows
                                      .Cast <DataGridViewRow>()
                                      .Select(row => row.Cells[columnIsLostObjectSelected.Index])
                                      .Where(cell => (bool?)cell.Value == true)
                                      .Select(cell => _filteredLostObjects[cell.RowIndex])
                                      .ToList();

            if (selectedLostObjects.Count == 0)
            {
                MessageBox.Show(this, selectLostObjectsToRestoreMessage.Text, selectLostObjectsToRestoreCaption.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return(0);
            }
            var currentTag = 0;

            foreach (var lostObject in selectedLostObjects)
            {
                currentTag++;
                var createTagArgs = new GitCreateTagArgs($"{RestoredObjectsTagPrefix}{currentTag}", lostObject.Hash);
                _gitTagController.CreateTag(createTagArgs, this);
            }

            return(currentTag);
        }
Ejemplo n.º 3
0
        public void Tag_key_id_null(string signKeyId)
        {
            var args = new GitCreateTagArgs(TagName, Revision, TagOperation.SignWithSpecificKey, signKeyId: signKeyId);
            var cmd  = new GitCreateTagCmd(args, _tagMessageFile);

            cmd.Validate();
        }
Ejemplo n.º 4
0
        public void Tag_supported_operation(TagOperation operation)
        {
            var args = new GitCreateTagArgs(TagName, Revision, operation, signKeyId: KeyId, force: true);
            var cmd  = new GitCreateTagCmd(args, _tagMessageFile);

            var actualCmdLine = cmd.ToLine();

            var switches = "";

            switch (operation)
            {
            case TagOperation.Lightweight:
                break;

            case TagOperation.Annotate:
                switches = $" -a -F \"{_tagMessageFile}\"";
                break;

            case TagOperation.SignWithDefaultKey:
                switches = $" -s -F \"{_tagMessageFile}\"";
                break;

            case TagOperation.SignWithSpecificKey:
                switches = $" -u {KeyId} -F \"{_tagMessageFile}\"";
                break;
            }

            var expectedCmdLine = $"tag -f{switches} \"{TagName}\" -- \"{Revision}\"";

            Assert.AreEqual(expectedCmdLine, actualCmdLine);
        }
        public void ToLine_should_throw_if_operation_not_supported()
        {
            var args = new GitCreateTagArgs(TagName, Revision, (TagOperation)10);
            var cmd  = new GitCreateTagCmd(args, TagMessageFile);

            Assert.Throws <NotSupportedException>(() => cmd.ToLine());
        }
        public void Validate_should_throw_for_SignWithSpecificKey_if_tag_keyId_invalid(string signKeyId)
        {
            var args = new GitCreateTagArgs(TagName, Revision, TagOperation.SignWithSpecificKey, signKeyId: signKeyId);
            var cmd  = new GitCreateTagCmd(args, TagMessageFile);

            Assert.Throws <ArgumentException>(() => cmd.Validate());
        }
Ejemplo n.º 7
0
        private string CreateTag()
        {
            GitCreateTagArgs createTagArgs = new GitCreateTagArgs();

            createTagArgs.Revision = commitPickerSmallControl1.SelectedCommitHash;

            if (createTagArgs.Revision.IsNullOrEmpty())
            {
                MessageBox.Show(this, _noRevisionSelected.Text, _messageCaption.Text);
                return(string.Empty);
            }

            createTagArgs.TagName       = textBoxTagName.Text;
            createTagArgs.Force         = ForceTag.Checked;
            createTagArgs.OperationType = GetSelectedOperation(annotate.SelectedIndex);
            createTagArgs.TagMessage    = tagMessage.Text;
            createTagArgs.SignKeyId     = textBoxGpgKey.Text;

            IGitTagController _gitTagController = new GitTagController(UICommands, Module);

            if (!_gitTagController.CreateTag(createTagArgs, this))
            {
                return(string.Empty);
            }

            DialogResult = DialogResult.OK;
            return(textBoxTagName.Text);
        }
        public void Tag_revision_null(string revision)
        {
            var args = new GitCreateTagArgs(TagName, revision);
            var cmd  = new GitCreateTagCmd(args, _tagMessageFile);

            Assert.Throws <ArgumentException>(() => cmd.Validate());
        }
Ejemplo n.º 9
0
        private string CreateTag()
        {
            var objectId = commitPickerSmallControl1.SelectedObjectId;

            if (objectId == null)
            {
                MessageBox.Show(this, _noRevisionSelected.Text, _messageCaption.Text);
                return("");
            }

            var createTagArgs = new GitCreateTagArgs(textBoxTagName.Text,
                                                     objectId,
                                                     GetSelectedOperation(annotate.SelectedIndex),
                                                     tagMessage.Text,
                                                     textBoxGpgKey.Text,
                                                     ForceTag.Checked);
            var success = _gitTagController.CreateTag(createTagArgs, this);

            if (!success)
            {
                return("");
            }

            DialogResult = DialogResult.OK;
            return(textBoxTagName.Text);
        }
Ejemplo n.º 10
0
        public void Tag_operation_not_supported()
        {
            var args = new GitCreateTagArgs(TagName, Revision, (TagOperation)10);
            var cmd  = new GitCreateTagCmd(args, _tagMessageFile);

            cmd.ToLine();
        }
Ejemplo n.º 11
0
        public void Tag_revision_null(string revision)
        {
            var args = new GitCreateTagArgs(TagName, revision);
            var cmd  = new GitCreateTagCmd(args, _tagMessageFile);

            cmd.Validate();
        }
        public void Validate_should_throw_if_tag_revision_invalid(string revision)
        {
            var args = new GitCreateTagArgs(TagName, revision);
            var cmd  = new GitCreateTagCmd(args, TagMessageFile);

            Assert.Throws <ArgumentException>(() => cmd.Validate());
        }
Ejemplo n.º 13
0
        public void CreateTagWithMessageWritesTagMessageFile()
        {
            var args = new GitCreateTagArgs("tagname", "00000", TagOperation.Annotate, "hello world");

            _controller.GetCreateTagCommand(args);

            _fileSystem.File.Received(1).WriteAllText(_tagMessageFile, "hello world");
        }
        public void ToLine_should_render_force_flag(bool force, string expected)
        {
            var args = new GitCreateTagArgs(TagName, Revision, TagOperation.SignWithDefaultKey, TagMessage, KeyId, force);
            var cmd  = new GitCreateTagCmd(args, TagMessageFile);

            var cmdLine = cmd.ToLine();

            Assert.AreEqual(expected, cmdLine);
        }
        public void ToLine_should_render_different_operations(TagOperation operation, string expected)
        {
            var args = new GitCreateTagArgs(TagName, Revision, operation, signKeyId: KeyId, force: true);
            var cmd  = new GitCreateTagCmd(args, TagMessageFile);

            var actualCmdLine = cmd.ToLine();

            Assert.AreEqual(expected, actualCmdLine);
        }
Ejemplo n.º 16
0
        public void CreateTagReturnsCmdResult(bool expectedCmdResult)
        {
            var args = new GitCreateTagArgs(TagName, Revision, TagOperation.Annotate);

            _uiCommands.StartCommandLineProcessDialog(Arg.Any <IGitCommand>(), null).Returns(expectedCmdResult);

            var actualCmdResult = _controller.CreateTag(args, null);

            Assert.AreEqual(expectedCmdResult, actualCmdResult);
        }
Ejemplo n.º 17
0
        public void CreateTagReturnsCmdResult(bool expectedCmdResult)
        {
            GitCreateTagArgs args = CreateDefaultArgs();

            args.OperationType = TagOperation.Annotate;
            _uiCommands.StartCommandLineProcessDialog(Arg.Any <IGitCommand>(), null).Returns(expectedCmdResult);

            bool actualCmdResult = _controller.CreateTag(args, null);

            Assert.AreEqual(expectedCmdResult, actualCmdResult);
        }
Ejemplo n.º 18
0
        private GitCreateTagArgs CreateDefaultArgs()
        {
            GitCreateTagArgs args = new GitCreateTagArgs();

            args.Revision   = Revision;
            args.TagName    = TagName;
            args.TagMessage = TagMessage;
            args.SignKeyId  = KeyId;

            return(args);
        }
Ejemplo n.º 19
0
        public void Tag_sign_with_default_gpg(bool force)
        {
            var args = new GitCreateTagArgs(TagName, Revision, TagOperation.SignWithDefaultKey, TagMessage, KeyId, force);
            var cmd  = new GitCreateTagCmd(args, _tagMessageFile);

            var cmdLine = cmd.ToLine();

            var expectedCmdLine = $"tag{(force ? " -f" : "")} -s -F \"{_tagMessageFile}\" \"{TagName}\" -- \"{Revision}\"";

            Assert.AreEqual(expectedCmdLine, cmdLine);
        }
Ejemplo n.º 20
0
        public void CreateTagWithMessageWritesTagMessageFile()
        {
            GitCreateTagArgs args = CreateDefaultArgs();

            args.OperationType = TagOperation.Annotate;

            _controller.CreateTag(args, null);
            var tagMagPath = Path.Combine(WorkingDir, "TAGMESSAGE");

            _fileSystem.File.Received(1).WriteAllText(tagMagPath, TagMessage);
        }
Ejemplo n.º 21
0
        public void CreateTagUsesGivenArgs()
        {
            var args = new GitCreateTagArgs(TagName, Revision, TagOperation.Lightweight, TagMessage, KeyId);

            _uiCommands.StartCommandLineProcessDialog(Arg.Do <IGitCommand>(
                                                          cmd =>
            {
                var createTagCmd = cmd as GitCreateTagCmd;
                Assert.AreEqual(args, createTagCmd.Arguments);
            }
                                                          ), null);

            _controller.CreateTag(args, null);
            _uiCommands.Received(1).StartCommandLineProcessDialog(Arg.Any <IGitCommand>(), null);
        }
Ejemplo n.º 22
0
        public void CreateTagWithMessageAssignsTagMessageFile()
        {
            var args = new GitCreateTagArgs(TagName, Revision, TagOperation.Annotate);

            _uiCommands.StartCommandLineProcessDialog(Arg.Do <IGitCommand>(
                                                          cmd =>
            {
                var createTagCmd = cmd as GitCreateTagCmd;
                Assert.AreEqual(_tagMessageFile, createTagCmd.TagMessageFileName);
            }
                                                          ), null);

            _controller.CreateTag(args, null);
            _uiCommands.Received(1).StartCommandLineProcessDialog(Arg.Any <IGitCommand>(), null);
        }
Ejemplo n.º 23
0
        public void CreateTagUsesGivenArgs()
        {
            GitCreateTagArgs args = CreateDefaultArgs();

            _uiCommands.StartCommandLineProcessDialog(Arg.Do <IGitCommand>(
                                                          cmd =>
            {
                GitCreateTagCmd createTagCmd = cmd as GitCreateTagCmd;
                Assert.AreEqual(args, createTagCmd.Args);
            }
                                                          ), null);

            _controller.CreateTag(args, null);
            _uiCommands.Received(1).StartCommandLineProcessDialog(Arg.Any <IGitCommand>(), null);
        }
Ejemplo n.º 24
0
        public void CreateTagWithMessageAssignsTagMessageFile()
        {
            GitCreateTagArgs args = CreateDefaultArgs();

            args.OperationType = TagOperation.Annotate;

            _uiCommands.StartCommandLineProcessDialog(Arg.Do <IGitCommand>(
                                                          cmd =>
            {
                GitCreateTagCmd createTagCmd = cmd as GitCreateTagCmd;
                Assert.AreEqual(Path.Combine(WorkingDir, "TAGMESSAGE"), createTagCmd.TagMessageFileName);
            }
                                                          ), null);

            _controller.CreateTag(args, null);
            _uiCommands.Received(1).StartCommandLineProcessDialog(Arg.Any <IGitCommand>(), null);
        }
Ejemplo n.º 25
0
        private string CreateTag()
        {
            if (string.IsNullOrWhiteSpace(commitPickerSmallControl1.SelectedCommitHash))
            {
                MessageBox.Show(this, _noRevisionSelected.Text, _messageCaption.Text);
                return(string.Empty);
            }

            var createTagArgs = new GitCreateTagArgs(textBoxTagName.Text,
                                                     commitPickerSmallControl1.SelectedCommitHash,
                                                     GetSelectedOperation(annotate.SelectedIndex),
                                                     tagMessage.Text,
                                                     textBoxGpgKey.Text,
                                                     ForceTag.Checked);

            if (!_gitTagController.CreateTag(createTagArgs, this))
            {
                return(string.Empty);
            }

            DialogResult = DialogResult.OK;
            return(textBoxTagName.Text);
        }