Пример #1
0
        public void Setup()
        {
            _module = Substitute.For <IGitModule>();
            _module.GetGitDirectory().Returns(x => WorkingDir);

            _controller = new GitTagController(_module);
        }
Пример #2
0
        public void Setup()
        {
            _module     = Substitute.For <IGitModule>();
            _uiCommands = Substitute.For <IGitUICommands>();
            _module.GetGitDirectory().Returns(x => WorkingDir);
            _fileSystem = Substitute.For <IFileSystem>();
            _fileSystem.File.Returns(Substitute.For <FileBase>());

            _controller = new GitTagController(_uiCommands, _module, _fileSystem);
        }
Пример #3
0
        public void Setup()
        {
            _tagMessageFile = Path.Combine(_workingDir, "TAGMESSAGE");
            _module         = Substitute.For <IGitModule>();
            _uiCommands     = Substitute.For <IGitUICommands>();
            _module.GetGitDirectory().Returns(x => _workingDir);
            _fileSystem = Substitute.For <IFileSystem>();
            _fileSystem.File.Returns(Substitute.For <FileBase>());

            _controller = new GitTagController(_uiCommands, _module, _fileSystem);
        }
Пример #4
0
        /// <summary>
        /// Create the Tag depending on input parameter.
        /// </summary>
        /// <param name="revision">Commit revision to be tagged</param>
        /// <param name="inputTagName">Name of tag</param>
        /// <param name="force">Force parameter</param>
        /// <param name="operationType">The operation to perform on the tag (Lightweight, Annotate, Sign with defaul key, Sign with specific key)</param>
        /// <param name="tagMessage">Tag Message</param>
        /// <param name="keyId">Specific Key ID to be used instead of default one</param>
        /// <returns>Output string from RunGitCmd.</returns>
        public bool CreateTag(GitCreateTagArgs args, IWin32Window parentForm)
        {
            GitCreateTagCmd createTagCmd = new GitCreateTagCmd(args);

            if (args.OperationType.CanProvideMessage())
            {
                createTagCmd.TagMessageFileName = Path.Combine(_module.GetGitDirectory(), "TAGMESSAGE");
                _fileSystem.File.WriteAllText(createTagCmd.TagMessageFileName, args.TagMessage);
            }

            return(_uiCommands.StartCommandLineProcessDialog(createTagCmd, parentForm));
        }
Пример #5
0
 private static string GetAmendCommitPath(IGitModule module)
 {
     return(Path.Combine(module.GetGitDirectory(), "AMENDCOMMIT"));
 }
Пример #6
0
 private static string GetCommitMessagePath(IGitModule module)
 {
     return(Path.Combine(module.GetGitDirectory(), "COMMITMESSAGE"));
 }
Пример #7
0
 private void findLargeFilesFunction()
 {
     try
     {
         var data = GetLargeFiles(threshold);
         Dictionary <string, DateTime> revData = new Dictionary <string, DateTime>();
         foreach (var d in data)
         {
             string   commit = d.Commit.First();
             DateTime date;
             if (!revData.ContainsKey(commit))
             {
                 string revDate = gitCommands.RunGitCmd(string.Format("show -s {0} --format=\"%ci\"", commit));
                 DateTime.TryParse(revDate, out date);
                 revData.Add(commit, date);
             }
             else
             {
                 date = revData[commit];
             }
             GitObject curGitObject;
             if (!list.TryGetValue(d.SHA, out curGitObject))
             {
                 d.LastCommitDate = date;
                 list.Add(d.SHA, d);
                 BranchesGrid.Invoke((Action)(() => { gitObjects.Add(d); }));
             }
             else if (!curGitObject.Commit.Contains(commit))
             {
                 if (curGitObject.LastCommitDate < date)
                 {
                     curGitObject.LastCommitDate = date;
                 }
                 BranchesGrid.Invoke((Action)(() => { gitObjects.ResetItem(gitObjects.IndexOf(curGitObject)); }));
                 curGitObject.Commit.Add(commit);
             }
         }
         string objectsPackDirectory = gitCommands.GetGitDirectory() + "objects/pack/";
         if (Directory.Exists(objectsPackDirectory))
         {
             var packFiles = Directory.GetFiles(objectsPackDirectory, "pack-*.idx");
             foreach (var pack in packFiles)
             {
                 string[] objects = gitCommands.RunGitCmd(string.Concat("verify-pack -v ", pack)).Split('\n');
                 pbRevisions.Invoke((Action)(() => pbRevisions.Value = pbRevisions.Value + (int)((revList.Length * 0.1f) / packFiles.Length)));
                 foreach (var gitobj in objects.Where(x => x.Contains(" blob ")))
                 {
                     string[]  dataFields = gitobj.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
                     GitObject curGitObject;
                     if (list.TryGetValue(dataFields[0], out curGitObject))
                     {
                         int compressedSize = 0;
                         if (Int32.TryParse(dataFields[3], out compressedSize))
                         {
                             curGitObject.compressedSizeInBytes = compressedSize;
                             BranchesGrid.Invoke((Action)(() => { gitObjects.ResetItem(gitObjects.IndexOf(curGitObject)); }));
                         }
                     }
                 }
             }
         }
         pbRevisions.Invoke((Action)(() => pbRevisions.Hide()));
         BranchesGrid.Invoke((Action)(() => BranchesGrid.ReadOnly = false));
     }
     catch
     {
     }
 }
Пример #8
0
        /// <summary>
        /// Create the Tag depending on input parameter.
        /// </summary>
        /// <param name="revision">Commit revision to be tagged</param>
        /// <param name="inputTagName">Name of tag</param>
        /// <param name="force">Force parameter</param>
        /// <param name="operationType">The operation to perform on the tag (Lightweight, Annotate, Sign with defaul key, Sign with specific key)</param>
        /// <param name="tagMessage">Tag Message</param>
        /// <param name="keyId">Specific Key ID to be used instead of default one</param>
        /// <returns>Output string from RunGitCmd.</returns>
        public string CreateTag(string revision, string inputTagName, bool force, TagOperation operationType = TagOperation.Lightweight, string tagMessage = "", string keyId = "")
        {
            if (string.IsNullOrEmpty(revision))
            {
                throw new ArgumentNullException("revision");
            }

            if (string.IsNullOrEmpty(inputTagName))
            {
                throw new ArgumentNullException("tagName");
            }

            string tagMessageFileName = Path.Combine(_module.GetGitDirectory(), "TAGMESSAGE");

            if (operationType.CanProvideMessage())
            {
                File.WriteAllText(tagMessageFileName, tagMessage);
            }

            string tagName = inputTagName.Trim();
            string forced  = force ? "-f" : "";

            string tagSwitch = "";

            switch (operationType)
            {
            /* Lightweight */
            case TagOperation.Lightweight:
                /* tagSwitch is already ok */
                break;

            /* Annotate */
            case TagOperation.Annotate:
                tagSwitch = "-a";
                break;

            /* Sign with default GPG */
            case TagOperation.SignWithDefaultKey:
                tagSwitch = "-s";
                break;

            /* Sign with specific GPG */
            case TagOperation.SignWithSpecificKey:
                if (string.IsNullOrEmpty(keyId))
                {
                    throw new ArgumentNullException("keyId");
                }
                tagSwitch = $"-u {keyId}";
                break;

            /* Error */
            default:
                throw new NotSupportedException("Invalid TagOperation: " + operationType);
            }

            if (operationType.CanProvideMessage())
            {
                tagSwitch = tagSwitch + " -F " + tagMessageFileName.Quote();
            }

            return(_module.RunGitCmd($"tag {forced} {tagSwitch} \"{tagName}\" -- \"{revision}\""));
        }