Exemplo n.º 1
0
        private void UpdatedStatusReceived(string updatedStatus)
        {
            _commandIsRunning = false;

            if (CurrentStatus != WorkingStatus.Started)
            {
                return;
            }

            if (_statusIsUpToDate)
            {
                var allChangedFiles = GitCommandHelpers.GetAllChangedFilesFromString(Module, updatedStatus);
                Image = _commitIconProvider.GetCommitIcon(allChangedFiles);

                if (allChangedFiles.Count == 0)
                {
                    Text = CommitTranslatedString;
                }
                else
                {
                    Text = string.Format(CommitTranslatedString + " ({0})", allChangedFiles.Count.ToString());
                }
            }
            else
            {
                UpdateImmediately();
            }
        }
Exemplo n.º 2
0
        /// <summary>
        ///   Loads the unstaged output.
        ///   This method is passed in to the SetTextCallBack delegate
        ///   to set the Text property of textBox1.
        /// </summary>
        private void LoadUnstagedOutput()
        {
            var allChangedFiles = GitCommandHelpers.GetAllChangedFilesFromString(_gitGetUnstagedCommand.Output.ToString());

            var unStagedFiles = new List <GitItemStatus>();
            var stagedFiles   = new List <GitItemStatus>();

            foreach (var fileStatus in allChangedFiles)
            {
                if (fileStatus.IsStaged)
                {
                    stagedFiles.Add(fileStatus);
                }
                else
                {
                    unStagedFiles.Add(fileStatus);
                }
            }

            Unstaged.GitItemStatuses = null;
            Unstaged.GitItemStatuses = stagedFiles;
            Staged.GitItemStatuses   = null;
            Staged.GitItemStatuses   = unStagedFiles;

            Loading.Visible       = false;
            LoadingStaged.Visible = false;

            EnableStageButtons(true);
            workingToolStripMenuItem.Enabled = true;

            var inTheMiddleOfConflictedMerge = GitCommandHelpers.InTheMiddleOfConflictedMerge();

            SolveMergeconflicts.Visible = inTheMiddleOfConflictedMerge;
        }
Exemplo n.º 3
0
        private void UpdatedStatusReceived(string updatedStatus)
        {
            if (CurrentStatus != WorkingStatus.Started)
            {
                return;
            }

            if (_statusIsUpToDate)
            {
                var allChangedFiles         = GitCommandHelpers.GetAllChangedFilesFromString(Module, updatedStatus);
                var stagedCount             = allChangedFiles.Count(status => status.IsStaged);
                var unstagedCount           = allChangedFiles.Count - stagedCount;
                var unstagedSubmodulesCount = allChangedFiles.Count(status => status.IsSubmodule && !status.IsStaged);

                Image = GetStatusIcon(stagedCount, unstagedCount, unstagedSubmodulesCount);

                if (allChangedFiles.Count == 0)
                {
                    Text = CommitTranslatedString;
                }
                else
                {
                    Text = string.Format(CommitTranslatedString + " ({0})", allChangedFiles.Count.ToString());
                }
            }
            else
            {
                UpdateImmediately();
            }
        }
Exemplo n.º 4
0
 public void TestGetAllChangedFilesFromString()
 {
     {//git diff -M -C -z --cached --name-status
         string statusString         = "\r\nwarning: LF will be replaced by CRLF in CustomDictionary.xml.\r\nThe file will have its original line endings in your working directory.\r\nwarning: LF will be replaced by CRLF in FxCop.targets.\r\nThe file will have its original line endings in your working directory.\r\nM\0testfile.txt\0";
         List <GitItemStatus> status = GitCommandHelpers.GetAllChangedFilesFromString(statusString, true);
         Assert.IsTrue(status.Count == 1);
         Assert.IsTrue(status[0].Name == "testfile.txt");
     }
     {//git diff -M -C -z --cached --name-status
         string statusString         = "\0\r\nwarning: LF will be replaced by CRLF in CustomDictionary.xml.\r\nThe file will have its original line endings in your working directory.\r\nwarning: LF will be replaced by CRLF in FxCop.targets.\r\nThe file will have its original line endings in your working directory.\r\nM\0testfile.txt\0";
         List <GitItemStatus> status = GitCommandHelpers.GetAllChangedFilesFromString(statusString, true);
         Assert.IsTrue(status.Count == 1);
         Assert.IsTrue(status[0].Name == "testfile.txt");
     }
     {//git diff -M -C -z --cached --name-status
         string statusString         = "\0\nwarning: LF will be replaced by CRLF in CustomDictionary.xml.\nThe file will have its original line endings in your working directory.\nwarning: LF will be replaced by CRLF in FxCop.targets.\nThe file will have its original line endings in your working directory.\nM\0testfile.txt\0";
         List <GitItemStatus> status = GitCommandHelpers.GetAllChangedFilesFromString(statusString, true);
         Assert.IsTrue(status.Count == 1);
         Assert.IsTrue(status[0].Name == "testfile.txt");
     }
     {//git diff -M -C -z --cached --name-status
         string statusString         = "M  testfile.txt\0\nwarning: LF will be replaced by CRLF in CustomDictionary.xml.\nThe file will have its original line endings in your working directory.\nwarning: LF will be replaced by CRLF in FxCop.targets.\nThe file will have its original line endings in your working directory.\n";
         List <GitItemStatus> status = GitCommandHelpers.GetAllChangedFilesFromString(statusString, true);
         Assert.IsTrue(status.Count == 1);
         Assert.IsTrue(status[0].Name == "testfile.txt");
     }
     { //git status --porcelain --untracked-files=no -z
         string statusString         = "M  adfs.h\0M  dir.c\0\r\nwarning: LF will be replaced by CRLF in adfs.h.\nThe file will have its original line endings in your working directory.\nwarning: LF will be replaced by CRLF in dir.c.\nThe file will have its original line endings in your working directory.";
         List <GitItemStatus> status = GitCommandHelpers.GetAllChangedFilesFromString(statusString, false);
         Assert.IsTrue(status.Count == 2);
         Assert.IsTrue(status[0].Name == "adfs.h");
         Assert.IsTrue(status[1].Name == "dir.c");
     }
 }
Exemplo n.º 5
0
        private void onData()
        {
            List <GitItemStatus> unstaged = GitCommandHelpers.GetAllChangedFilesFromString
                                            (
                gitGetUnstagedCommand.Output.ToString()
                                            );
            List <GitItemStatus> staged = GitCommandHelpers.GetStagedFiles();

            if (staged.Count == 0 && unstaged.Count == 0)
            {
                Image = ICON_CLEAN;
            }
            else
            {
                if (staged.Count == 0)
                {
                    Image = ICON_DIRTY;
                }
                else if (unstaged.Count == 0)
                {
                    Image = ICON_STAGED;
                }
                else
                {
                    Image = ICON_MIXED;
                }
            }

            Text = string.Format("{0} changes", staged.Count + unstaged.Count);
        }
Exemplo n.º 6
0
        private void UpdatedStatusReceived(string updatedStatus)
        {
            // Adjust the interval between updates. (This does not affect an update already scheculed).
            _currentUpdateInterval = Math.Max(MinUpdateInterval, 3 * (Environment.TickCount - _previousUpdateTime));
            _commandIsRunning      = false;

            if (CurrentStatus != GitStatusMonitorState.Running)
            {
                return;
            }

            var allChangedFiles = GitCommandHelpers.GetAllChangedFilesFromString(Module, updatedStatus);

            OnGitWorkingDirectoryStatusChanged(new GitWorkingDirectoryStatusEventArgs(allChangedFiles.Where(item => !item.IsIgnored)));
            if (_ignoredFilesPending)
            {
                _ignoredFilesPending = false;
                _ignoredFiles        = new HashSet <string>(allChangedFiles.Where(item => item.IsIgnored).Select(item => item.Name).ToArray());
                if (_statusIsUpToDate)
                {
                    _ignoredFilesAreStale = false;
                }
            }

            if (!_statusIsUpToDate)
            {
                // Still not up-to-date, but present what received, GetAllChangedFilesCmd() is the heavy command
                CalculateNextUpdateTime(UpdateDelay);
            }
        }
Exemplo n.º 7
0
        private void onData()
        {
            if (CurrentStatus != WorkingStatus.Started)
            {
                return;
            }

            List <GitItemStatus> allChangedFiles =
                GitCommandHelpers.GetAllChangedFilesFromString(gitGetUnstagedCommand.Output.ToString());

            var stagedCount   = allChangedFiles.FindAll(status => status.IsStaged).Count;
            var unstagedCount = allChangedFiles.FindAll(status => !status.IsStaged).Count;

            if (stagedCount == 0 && unstagedCount == 0)
            {
                Image = ICON_CLEAN;
            }
            else
            {
                if (stagedCount == 0)
                {
                    Image = ICON_DIRTY;
                }
                else if (unstagedCount == 0)
                {
                    Image = ICON_STAGED;
                }
                else
                {
                    Image = ICON_MIXED;
                }
            }

            Text = string.Format("{0} changes", allChangedFiles.Count);
        }
Exemplo n.º 8
0
        private void onData()
        {
            if (CurrentStatus != WorkingStatus.Started)
            {
                return;
            }

            List <GitItemStatus> allChangedFiles =
                GitCommandHelpers.GetAllChangedFilesFromString(gitGetUnstagedCommand.Output.ToString());

            var stagedCount             = allChangedFiles.FindAll(status => status.IsStaged).Count;
            var unstagedCount           = allChangedFiles.FindAll(status => !status.IsStaged).Count;
            var unstagedSubmodulesCount = allChangedFiles.FindAll(status => status.IsSubmodule && !status.IsStaged).Count;

            if (stagedCount == 0 && unstagedCount == 0)
            {
                Image = ICON_CLEAN;
            }
            else
            {
                if (stagedCount == 0)
                {
                    if (unstagedCount != unstagedSubmodulesCount)
                    {
                        Image = ICON_DIRTY;
                    }
                    else
                    {
                        Image = ICON_DIRTY_SUBMODULES;
                    }
                }
                else if (unstagedCount == 0)
                {
                    Image = ICON_STAGED;
                }
                else
                {
                    Image = ICON_MIXED;
                }
            }

            if (allChangedFiles.Count == 0)
            {
                Text = CommitTranslatedString;
            }
            else
            {
                Text = string.Format(CommitTranslatedString + " ({0})", allChangedFiles.Count.ToString());
            }
        }
Exemplo n.º 9
0
        public void ShowDialogWhenChanges()
        {
            Initialize();
            while (_gitGetUnstagedCommand.IsRunning)
            {
                Thread.Sleep(200);
            }

            var allChangedFiles = GitCommandHelpers.GetAllChangedFilesFromString(_gitGetUnstagedCommand.Output.ToString());

            if (allChangedFiles.Count > 0)
            {
                ShowDialog();
            }
            else
            {
                DisposeGitGetUnstagedCommand();
            }
        }
Exemplo n.º 10
0
        private void UpdatedStatusReceived(string updatedStatus)
        {
            _commandIsRunning = false;

            if (CurrentStatus != GitStatusMonitorState.Running)
            {
                return;
            }

            if (_statusIsUpToDate)
            {
                var allChangedFiles = GitCommandHelpers.GetAllChangedFilesFromString(Module, updatedStatus);
                OnGitWorkingDirectoryStatusChanged(new GitWorkingDirectoryStatusEventArgs(allChangedFiles));
            }
            else
            {
                UpdateImmediately();
            }
        }
Exemplo n.º 11
0
        public override bool Execute(GitUIBaseEventArgs args)
        {
            var module = (GitModule)args.GitModule;

            int exitCode;

            exitCode = args.GitModule.RunGitCmdResult("submodule update --init --recursive").ExitCode;

            allChangesCmd = allChangesCmd ?? GitCommands.GitCommandHelpers.GetAllChangedFilesCmd(true, UntrackedFilesMode.All, IgnoreSubmodulesMode.All);;

            // öncelikle bekleyen hiçbir değişiklik olmadığından emin oluyoruz

            var cmdResult    = args.GitModule.RunGitCmdResult(allChangesCmd);
            var statusString = cmdResult.StdError;

            exitCode = cmdResult.ExitCode;
            var changedFiles = GitCommandHelpers.GetAllChangedFilesFromString(module, statusString);

            if (changedFiles.Count != 0)
            {
                MessageBox.Show("Commit edilmeyi bekleyen dosyalarınız var. Lütfen yeni bir feature branch oluşturmadan önce bu dosyaları commit ediniz!");
                return(false);
            }

            // feature branch i için uygun bir isim alalım. bu master, test, ya da mevcut bir branch ten farklı olmalı
            string featureBranchName = "";

            while (featureBranchName.IsNullOrEmpty())
            {
                if (Dialogs.Prompt("Yeni bir feature branch oluşturulacak. Bunun için master branch'e geçilip, son değişiklikler pull ile alınacak." +
                                   "\n\nLütfen oluşturmak istediğiniz branch'e bir isim veriniz", "Yeni Feature Branch Oluşturma", ref featureBranchName) != DialogResult.OK)
                {
                    return(false);
                }

                if (featureBranchName != null)
                {
                    featureBranchName = featureBranchName.Trim();
                    if (featureBranchName != null &&
                        module.GetRefs().Any(x => String.Compare(x.Name, featureBranchName, StringComparison.OrdinalIgnoreCase) == 0))
                    {
                        Dialogs.Alert("Girdiğiniz branch ismine sahip başka bir branch var, lütfen başka bir isim giriniz!");
                        featureBranchName = null;
                    }
                }
            }

            // master branch inde değilsek ona geçelim
            var branch = args.GitModule.GetSelectedBranch().ToLowerInvariant();

            if (branch != "master")
            {
                var switchBranchCmd = GitCommandHelpers.CheckoutCmd("master", LocalChangesAction.DontChange);
                exitCode = args.GitModule.RunGitCmdResult(switchBranchCmd).ExitCode;

                branch = args.GitModule.GetSelectedBranch().ToLowerInvariant();
                if (branch != "master")
                {
                    MessageBox.Show("Master branch'ine geçiş yapılamadı. İşleme devam edilemiyor!");
                    return(false);
                }
            }

            // master a direk commit olmadığını varsayıyoruz, dolayısıyla rebase e gerek yok, sadece pull yapalım.
            // rebase yaparsak bazı merge commitleriyle ilgili kayıp yaşanabilir
            // bu arada eğer local te bir şekilde master da commit varsa (merkezde olmayan??) branch bir önceki committen alınmış olur
            var pullCmd = module.PullCmd("origin", "master", "master", false);

            cmdResult = args.GitModule.RunGitCmdResult(pullCmd);
            var pullResult = cmdResult.StdError;

            exitCode = cmdResult.ExitCode;

            if (exitCode != 0)
            {
                MessageBox.Show("Pull işlemi esnasında şu hata alındı:\n" +
                                pullResult + "\nExitCode:" + exitCode);
                return(true);
            }

            // feature branch oluştur
            var checkoutCmd = "checkout -b " + featureBranchName;

            cmdResult = args.GitModule.RunGitCmdResult(checkoutCmd);
            var checkoutResult = cmdResult.StdError;

            exitCode = cmdResult.ExitCode;

            if (exitCode != 0)
            {
                MessageBox.Show("Branch oluşturma işlemi esnasında şu hata alındı:\n" +
                                checkoutResult + "\nExitCode:" + exitCode);
                return(true);
            }

            MessageBox.Show(String.Format("{0} feature branch'i başarıyla oluşturuldu.", featureBranchName));

            return(true);
        }
Exemplo n.º 12
0
        public override bool Execute(GitUIBaseEventArgs args)
        {
            var       module        = (GitModule)args.GitModule;
            var       allChangesCmd = GitCommandHelpers.GetAllChangedFilesCmd(true, UntrackedFilesMode.All, IgnoreSubmodulesMode.All);;
            CmdResult cmdResult;
            var       exitCode = args.GitModule.RunGitCmdResult("submodule update --init --recursive").ExitCode;

            // öncelikle bekleyen hiçbir değişiklik olmadığından emin oluyoruz
            var status       = args.GitModule.RunGitCmdResult(allChangesCmd);
            var statusString = status.StdOutput;

            exitCode = status.ExitCode;
            var changedFiles = GitCommandHelpers.GetAllChangedFilesFromString(module, statusString);

            if (changedFiles.Count != 0)
            {
                MessageBox.Show("Commit edilmeyi bekleyen dosyalarınız var. Lütfen TEST işleminden önce bu dosyaları commit ediniz!");
                return(false);
            }

            // bunun bir feature branch i olmasını kontrol et
            var featureBranch = (args.GitModule.GetSelectedBranch() ?? "").ToLowerInvariant();

            if (featureBranch.IsNullOrEmpty() || featureBranch == "master" || featureBranch == "test")
            {
                MessageBox.Show("Bu işlem master ya da test branch lerinde yapılamaz!");
                return(false);
            }

            // son kez onay alalım
            if (!Dialogs.Confirm("Bulunduğunuz branch, TEST'e gönderilecek.\n\n" +
                                 "Devam etmek istiyor musunuz?"))
            {
                return(true);
            }

            // origin deki son değişikliklerden haberdar ol
            var fetchCmd     = module.FetchCmd("origin", "", "");
            var fetchResultX = args.GitModule.RunGitCmdResult(fetchCmd);

            exitCode = fetchResultX.ExitCode;
            if (exitCode != 0)
            {
                MessageBox.Show("Fetch işlemi esnasında şu hata alındı:\n" +
                                fetchResultX.StdError + "\nExitCode:" + exitCode);
                return(false);
            }

            // remote branch varsa, son değişiklikleri pull edelim
            var remoteBranchExists = module.GetRefs(false, true).Any(x => x.Name == featureBranch & x.IsRemote);

            if (remoteBranchExists)
            {
                var pullFeatureCmd = module.PullCmd("origin", featureBranch, featureBranch, false);
                cmdResult = args.GitModule.RunGitCmdResult(pullFeatureCmd);
                var pullFeatureResult = cmdResult.StdError;
                exitCode = cmdResult.ExitCode;

                if (exitCode != 0)
                {
                    MessageBox.Show("Feature pull işlemi esnasında şu hata alındı:\n" +
                                    pullFeatureResult + "\nExitCode:" + exitCode);
                    return(true);
                }
            }

            // test branch ine geçiş yap
            var switchBranchCmd = GitCommandHelpers.CheckoutCmd("test", LocalChangesAction.DontChange);

            exitCode = args.GitModule.RunGitCmdResult(switchBranchCmd).ExitCode;

            var currentBranch = args.GitModule.GetSelectedBranch().ToLowerInvariant();

            if (currentBranch != "test")
            {
                MessageBox.Show("Test branch'ine geçiş yapılamadı. İşleme devam edilemiyor!");
                return(true);
            }

            // varsa test teki son değişiklikleri al
            // test e direk commit olmayacağı varsayıldığından rebase e gerek yok.
            var pullCmd = module.PullCmd("origin", "test", "test", false);

            cmdResult = args.GitModule.RunGitCmdResult(pullCmd);
            var pullResult = cmdResult.StdError;

            exitCode = cmdResult.ExitCode;

            if (exitCode != 0)
            {
                MessageBox.Show("Test'ten pull işlemi esnasında şu hata alındı:\n" +
                                pullResult + "\nExitCode:" + exitCode);
                return(true);
            }

            // feature branch i test e birleştir
            var mergeCmd = GitCommandHelpers.MergeBranchCmd(featureBranch, allowFastForward: false, squash: false, noCommit: false, strategy: "");

            cmdResult = args.GitModule.RunGitCmdResult(mergeCmd);
            var mergeResult = cmdResult.StdError;

            exitCode = cmdResult.ExitCode;

            if (exitCode != 0)
            {
                MessageBox.Show("Merge işlemi esnasında şu hata alındı:\n" +
                                mergeResult + "\nExitCode:" + exitCode);
                return(true);
            }

            MessageBox.Show(String.Format("{0} feature branch'i başarıyla TEST'e merge edildi.\n\nLütfen projeyi son haliyle TEST'teyken " +
                                          "build edip, PUSH işlemi yapınız.", featureBranch));

            Clipboard.SetText("Gerekli kontroller yapılmıştır, gerçek ortama çıkarılabilir mi?");

            return(true);
        }
        public override bool Execute(GitUIBaseEventArgs args)
        {
            var module        = (GitModule)args.GitModule;
            var allChangesCmd = GitCommands.GitCommandHelpers.GetAllChangedFilesCmd(true, UntrackedFilesMode.All, IgnoreSubmodulesMode.All);;

            int exitCode;

            exitCode = args.GitModule.RunGitCmdResult("submodule update --init --recursive").ExitCode;

            var resultString = args.GitModule.RunGitCmdResult(allChangesCmd);
            var statusString = resultString.StdOutput;
            var changedFiles = GitCommandHelpers.GetAllChangedFilesFromString(module, statusString);

            if (changedFiles.Count != 0)
            {
                MessageBox.Show("Commit edilmeyi bekleyen dosyalarınız var. Lütfen işlemden önce bu dosyaları commit ediniz!");
                return(false);
            }

            var currentBranch = (args.GitModule.GetSelectedBranch() ?? "").ToLowerInvariant();

            // master branch inde değilsek ona geçelim
            var branch = currentBranch;

            if (branch != "master")
            {
                var switchBranchCmd = GitCommandHelpers.CheckoutCmd("master", LocalChangesAction.DontChange);
                exitCode = args.GitModule.RunGitCmdResult(switchBranchCmd).ExitCode;

                branch = args.GitModule.GetSelectedBranch().ToLowerInvariant();
                if (branch != "master")
                {
                    MessageBox.Show("Master branch'ine geçiş yapılamadı. İşleme devam edilemiyor!");
                    return(false);
                }
            }

            // master a direk commit olmadığını varsayıyoruz, dolayısıyla rebase e gerek yok, sadece pull yapalım.
            // rebase yaparsak bazı merge commitleriyle ilgili kayıp yaşanabilir
            // bu arada eğer local te bir şekilde master da commit varsa (merkezde olmayan??) branch bir önceki committen alınmış olur
            var pullCmd    = module.PullCmd("origin", "master", "master", false);
            var cmdResult  = args.GitModule.RunGitCmdResult(pullCmd);
            var pullResult = cmdResult.StdError;

            exitCode = cmdResult.ExitCode;

            if (exitCode != 0)
            {
                MessageBox.Show("Pull işlemi esnasında şu hata alındı:\n" +
                                pullResult + "\nExitCode:" + exitCode);
                return(true);
            }

            currentBranch = (args.GitModule.GetSelectedBranch() ?? "").ToLowerInvariant();
            if (currentBranch.IsNullOrEmpty() || currentBranch.ToLowerInvariant() != "master")
            {
                MessageBox.Show("Bu işlem master branch'inde yapılmalıdır!");
                return(false);
            }

            var featureMergeHash = Clipboard.GetText();

            if (Dialogs.Prompt("Canlıya gönderilecek feature branch'in TEST'e birleştirildiği commit hash'ini giriniz",
                               "Feature Branch Merge", ref featureMergeHash) != DialogResult.OK)
            {
                return(false);
            }

            var mergeInfo  = module.ShowSha1(featureMergeHash);
            var mergeLines = mergeInfo.Split(new char[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries);

            if (mergeLines.Length < 3 ||
                !mergeLines[0].StartsWith("commit ", StringComparison.OrdinalIgnoreCase) ||
                !mergeLines[1].StartsWith("Merge: ", StringComparison.OrdinalIgnoreCase) ||
                !mergeLines[2].StartsWith("Author: ", StringComparison.OrdinalIgnoreCase) ||
                !mergeLines[4].Trim().StartsWith("Merge branch '", StringComparison.OrdinalIgnoreCase) ||
                mergeLines[4].IndexOf("' into", StringComparison.OrdinalIgnoreCase) < 0)
            {
                Dialogs.Alert("Merge commit'i yerine aşağıdaki sonuç bulundu:\n\n" +
                              mergeInfo);
                return(false);
            }

            var mergeTitle = mergeLines[4].Trim();

            mergeTitle = mergeTitle.Substring("Merge branch '".Length);
            var mergeIntoIdx = mergeTitle.IndexOf("' into");
            var branchName   = mergeTitle.Substring(0, mergeIntoIdx);

            var info  = module.ShowSha1(featureMergeHash + "^2");
            var lines = info.Split(new char[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries);

            if (lines.Length < 3 ||
                ((!lines[0].StartsWith("commit ", StringComparison.OrdinalIgnoreCase) ||
                  !lines[1].StartsWith("Author: ", StringComparison.OrdinalIgnoreCase)) &&
                 (!lines[0].StartsWith("commit ", StringComparison.OrdinalIgnoreCase) ||
                  !lines[1].StartsWith("Merge: ", StringComparison.OrdinalIgnoreCase) ||
                  !lines[2].StartsWith("Author: ", StringComparison.OrdinalIgnoreCase) ||
                  info.Contains("' into test") ||
                  info.Contains("' into 'test"))))
            {
                Dialogs.Alert("Birleştirilen feature branch'i yerine aşağıdaki sonuç bulundu:\n\n" +
                              info);
                return(false);
            }

            var author = lines[1].Trim().Substring("Author: ".Length).Trim();
            var commit = lines[0].Trim().Substring("commit ".Length).Trim();

            var tagName   = "published-" + branchName;
            var tagResult = module.Tag(tagName, commit, false, false);

            if (!tagResult.IsNullOrWhiteSpace())
            {
                Dialogs.Alert("TAG RESULT: " + tagResult);
            }

            var pushTagCmd = GitCommandHelpers.PushTagCmd("origin", tagName, false);

            cmdResult = args.GitModule.RunGitCmdResult(pushTagCmd);
            var pushTagResult = cmdResult.StdError;

            exitCode = cmdResult.ExitCode;

            if (exitCode != 0)
            {
                MessageBox.Show("Tag push işlemi esnasında şu hata alındı:\n" + pushTagResult + "\nExitCode:" + exitCode);
                return(true);
            }

            var mergeCmd = GitCommandHelpers.MergeBranchCmd(commit, true, true, true, null);

            cmdResult = args.GitModule.RunGitCmdResult(mergeCmd);
            var mergeResult = cmdResult.StdError;

            exitCode = cmdResult.ExitCode;

            if (exitCode != 0 && exitCode != 128)
            {
                MessageBox.Show("Merge işlemi esnasında şu hata alındı:\n" + mergeResult + "\nExitCode:" + exitCode);
                return(true);
            }

            var gitDirectory = args.GitModule.GetGitDirectory();
            var msg          = File.ReadAllText(Path.Combine(gitDirectory, "SQUASH_MSG"));

            msg = "Publish Branch '" + branchName + "'\n\n" + msg;
            var msgFile = Path.Combine(gitDirectory, "SQUASH_MSG2");

            File.WriteAllText(msgFile, msg);
            try
            {
                var commitCmd = "commit --author=\"" + author + "\" --file=\"" + msgFile.Replace("\\", "/") + "\"";
                cmdResult = args.GitModule.RunGitCmdResult(commitCmd);
                var commitResult = cmdResult.StdError;
                exitCode = cmdResult.ExitCode;

                if (exitCode != 0)
                {
                    MessageBox.Show("Commit işlemi esnasında şu hata alındı:\n" + commitResult + "\nExitCode:" + exitCode);
                    return(true);
                }
            }
            finally
            {
                File.Delete(msgFile);
            }

            MessageBox.Show(String.Format("{0} feature branch'i başarıyla MASTER'a merge edildi.\n\nDeğişiklikleri inceleyip sürüm çıkabilirsiniz.", branchName));

            return(true);
        }
        public override bool Execute(GitUIBaseEventArgs args)
        {
            var module        = (GitModule)args.GitModule;
            var allChangesCmd = GitCommands.GitCommandHelpers.GetAllChangedFilesCmd(true, UntrackedFilesMode.All, IgnoreSubmodulesMode.All);

            int exitCode;

            exitCode = args.GitModule.RunGitCmdResult("submodule update --init --recursive").ExitCode;

            // öncelikle bekleyen hiçbir değişiklik olmadığından emin oluyoruz
            var statusStringX = args.GitModule.RunGitCmdResult(allChangesCmd);
            var changedFiles  = GitCommandHelpers.GetAllChangedFilesFromString(module, statusStringX.StdOutput);

            if (changedFiles.Count != 0)
            {
                MessageBox.Show("Commit edilmeyi bekleyen dosyalarınız var. Lütfen işlemden önce bu dosyaları commit ediniz!");
                return(false);
            }

            // bunun bir feature branch i olmasını kontrol et
            var featureBranch = (args.GitModule.GetSelectedBranch() ?? "").ToLowerInvariant();

            if (featureBranch.IsNullOrEmpty() || featureBranch == "master" || featureBranch == "test")
            {
                MessageBox.Show("Bu işlem master ya da test branch lerinde yapılamaz!");
                return(false);
            }

            // origin deki son değişikliklerden haberdar ol
            var fetchCmd    = module.FetchCmd("origin", "", "");
            var cmdResult   = args.GitModule.RunGitCmdResult(fetchCmd);
            var fetchResult = cmdResult.StdError;

            exitCode = cmdResult.ExitCode;

            if (exitCode != 0)
            {
                MessageBox.Show("Fetch işlemi esnasında şu hata alındı:\n" +
                                fetchResult + "\nExitCode:" + exitCode);
                return(false);
            }

            // remote branch varsa, son değişiklikleri pull edelim
            var remoteBranchExists = module.GetRefs(false, true).Any(x => x.Name == featureBranch & x.IsRemote);

            if (remoteBranchExists)
            {
                var pullFeatureCmd = module.PullCmd("origin", featureBranch, featureBranch, false);
                cmdResult = args.GitModule.RunGitCmdResult(pullFeatureCmd);

                var pullFeatureResult = cmdResult.StdError;
                exitCode = cmdResult.ExitCode;

                if (exitCode != 0)
                {
                    MessageBox.Show("Feature pull işlemi esnasında şu hata alındı:\n" +
                                    pullFeatureResult + "\nExitCode:" + exitCode);
                    return(true);
                }
            }

            var switchBranchCmd = GitCommandHelpers.CheckoutCmd("master", LocalChangesAction.DontChange);

            exitCode = args.GitModule.RunGitCmdResult(switchBranchCmd).ExitCode;

            var currentBranch = args.GitModule.GetSelectedBranch().ToLowerInvariant();

            if (currentBranch != "master")
            {
                MessageBox.Show("Master branch'ine geçiş yapılamadı. İşleme devam edilemiyor!");
                return(true);
            }

            var pullCmd = module.PullCmd("origin", "master", "master", false);

            cmdResult = args.GitModule.RunGitCmdResult(pullCmd);
            var pullResult = cmdResult.StdError;

            exitCode = cmdResult.ExitCode;

            if (exitCode != 0)
            {
                MessageBox.Show("Pull işlemi esnasında şu hata alındı:\n" +
                                pullResult + "\nExitCode:" + exitCode);
                return(true);
            }

            switchBranchCmd = GitCommandHelpers.CheckoutCmd(featureBranch, LocalChangesAction.DontChange);
            exitCode        = args.GitModule.RunGitCmdResult(switchBranchCmd).ExitCode;

            currentBranch = args.GitModule.GetSelectedBranch();
            if (currentBranch != featureBranch)
            {
                MessageBox.Show("Feature branch'ine geri geçiş yapılamadı. İşleme devam edilemiyor!");
                return(true);
            }

            // master'ı feature branch e birleştir
            var mergeCmd = GitCommandHelpers.MergeBranchCmd("master", allowFastForward: true, squash: false, noCommit: false, strategy: "");

            cmdResult = args.GitModule.RunGitCmdResult(mergeCmd);
            var mergeResult = cmdResult.StdError;

            exitCode = cmdResult.ExitCode;

            if (exitCode != 0)
            {
                MessageBox.Show("Merge işlemi esnasında şu hata alındı:\n" +
                                mergeResult + "\nExitCode:" + exitCode);
                return(true);
            }

            if (remoteBranchExists)
            {
                // varsa local deki değişikliği hemen merkeze gönderelim
                var pushFeatureCmd = GitCommandHelpers.PushTagCmd("origin", featureBranch, false);
                cmdResult = args.GitModule.RunGitCmdResult(pushFeatureCmd);
                var pushFeatureResult = cmdResult.StdError;
                exitCode = cmdResult.ExitCode;


                if (exitCode != 0)
                {
                    MessageBox.Show("Push feature işlemi esnasında şu hata alındı:\n" +
                                    pushFeatureResult + "\nExitCode:" + exitCode);
                    return(true);
                }
            }

            MessageBox.Show(String.Format("{0} feature branch'i başarıyla master'daki değişiklikler ile güncellendi.", featureBranch));

            return(true);
        }