Ejemplo n.º 1
0
        /// <summary>
        /// Creates and executes a push script to upload commits to the repository's server
        /// TODO: add notification to inform about queued commits
        /// </summary>
        private void ButtonPushCommits_Click(object sender, EventArgs e)
        {
            RepoDetails local = ReposConfig.GetInstance().GetSelected();

            if (local == null)
            {
                DialogUtil.Message("Push Error", "Please select a repository to push commits to.");
                return;
            }

            ServerDetails remote = ServersConfig.GetInstance().GetServerDetailsByName(local.GetServer());

            if (remote == null)
            {
                DialogUtil.Message("Push Error", "Server \"" + local.GetServer() + "\" is not available");
                return;
            }

            ScriptBuilder.PushScript(local, remote);
            Executable exe = new Executable("expect.exe", "push.lua").Start();

            exe.WaitForExit();

            EventManager.Fire(EventCode.REFRESH_CHANGES);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Creates and executes a commit script based on the currently selected repository.
        /// </summary>
        private void ButtonCommitChanges_Click(object sender, EventArgs e)
        {
            string commitmsg = TextBoxCommitMessage.Text;

            if (commitmsg.Equals("") || commitmsg.Equals(ApplicationConstant.COMMIT_GREYTEXT))
            {
                DialogUtil.Message("Commit Error", "Please add a commit message before committing.");
                return;
            }

            RepoDetails repo = ReposConfig.GetInstance().GetSelected();

            if (repo == null)
            {
                DialogUtil.Message("Commit Error", "Please select a repository to commit to.");
                return;
            }

            ScriptBuilder.CommitScript(repo, TextBoxCommitMessage.Text);
            Executable exe = new Executable("expect.exe", "commit.lua").Start();

            exe.WaitForExit();

            TextBoxCommitMessage.Text = ""; // will not show greytext
            TextBoxCommitMessage_Validate(TextBoxCommitMessage, e);
            EventManager.Fire(EventCode.REFRESH_CHANGES);
        }
Ejemplo n.º 3
0
        private void ButtonFetch_Click(object sender, EventArgs e)
        {
            RepoDetails local = ReposConfig.GetInstance().GetSelected();

            if (local == null)
            {
                DialogUtil.Message("Please select a repository before fetching.");
                return;
            }

            ServerDetails remote = ServersConfig.GetInstance().GetServerDetailsByName(local.GetServer());

            if (remote == null)
            {
                DialogUtil.Message("Server \"" + local.GetServer() + "\" is not available.");
                return;
            }

            // build and execute script
            ScriptBuilder.FetchScript(local, remote);
            Executable exe = new Executable("expect.exe", "fetch.lua").Start();

            exe.WaitForExit();                            // hold thread till update

            EventManager.Fire(EventCode.REFRESH_CHANGES); // refresh changelist
        }
Ejemplo n.º 4
0
 private void MenuItemShowVersion_Click(object sender, EventArgs e)
 {
     DialogUtil.Message("Version",
                        "Git Utility\n" +
                        "SSH Repository Tool\n" +
                        "Nullpointer Works © 2020\n\n" +
                        "Version: " + ApplicationConstant.APP_VERSION);
 }
Ejemplo n.º 5
0
        /*
         * Add a local repository to the git server
         */
        private void MenuItemAddLocalRepo_Click(object sender, EventArgs e)
        {
            string res = DialogUtil.BrowseFolder("Select an existing repository to upload to the git server.");

            if (res == null)
            {
                return;
            }
            if (FileUtil.Exists(res))
            {
                if (!FileUtil.Exists(res + @"\.git"))
                {
                    DialogUtil.Message("Invalid Repository", "This directory is not initialized as a Git repository.");
                    return;
                }
                ReposConfig cnf        = ReposConfig.GetInstance();
                string      folderName = Path.GetFileName(res);
                cnf.AddRepoDetails(folderName, "", folderName, res, false);
                DialogUtil.Message("Repository Added", "Don't forget to set a remote server in the repository configuration.");
                EventManager.Fire(EventCode.REFRESH_REPOS);
            }
        }
Ejemplo n.º 6
0
        // =================================================================
        //              UI Events
        // =================================================================

        /// <summary>
        /// When creating a new repository two things need to happen. The
        /// server needs to setup a bare repo and the local directory needs
        /// to be linked to the remote repo.
        /// </summary>
        private void ButtonAccept_Click(object sender, EventArgs e)
        {
            // error checks
            string repoName = TextBoxRepoName.Text;

            if (repoName == null)
            {
                return;
            }
            if (repoName.Equals(""))
            {
                return;
            }
            if (repoName.Equals("Repository Name"))
            {
                return;
            }

            string localDir = TextBoxLocalDirectory.Text;

            if (localDir == null)
            {
                return;
            }
            if (localDir.Equals(""))
            {
                return;
            }

            string server = ComboBoxSelectServer.GetItemText(ComboBoxSelectServer.SelectedItem);

            if (server == null)
            {
                return;
            }
            if (server.Equals(""))
            {
                return;
            }
            localDir = localDir.Replace(@"\", "/") + "/" + repoName;

            // get server details
            ListItem      listitem = (ListItem)(ComboBoxSelectServer.SelectedItem);
            ServerDetails sd       = listitem.Details;

            // connect to server to setup the remote repo
            RemoteManager rman   = RemoteManager.GetInstance();
            IRemote       remote = rman.Connect(sd);

            if (!remote.IsConnected()) // error
            {
                DialogUtil.Message("Error: Cannot connect to remote repository");
                return;
            }

            IStream stream  = remote.GetStream();
            string  repoLoc = sd.GetLocation() + "/" + repoName;

            stream.Execute("mkdir -p " + repoLoc);
            stream.Execute("cd " + repoLoc);
            bool success = stream.Execute("git init --bare");

            if (!success) // error
            {
                DialogUtil.Message("Error: Could not execute command");
                return;
            }

            // make local directory
            Directory.CreateDirectory(localDir);

            if (!Directory.Exists(localDir)) // error
            {
                DialogUtil.Message("Error: Could not create local repository");
                return;
            }

            // make and run the script for initializing a new local repo
            string      remoteDir = sd.GetServerLoginString() + "/" + repoName;
            RepoDetails repo      = new RepoDetails(repoName, sd.GetName(), remoteDir, localDir);
            string      script    = ScriptBuilder.NewScript(repo);
            Executable  exe       = new Executable("expect.exe", script).Start();

            exe.WaitForExit();

            // add new repo to configuration
            ReposConfig.GetInstance().AddRepoDetails(repo, false);
            ReposConfig.GetInstance().Save();

            // done. now close and fire refresh event
            EventManager.Fire(EventCode.REFRESH_REPOS);
            ProperClose();
        }
        // =================================================================
        //              UI Events
        // =================================================================

        private void ButtonAccept_Click(object sender, EventArgs e)
        {
            // error checks
            string repoName = TextBoxRepoName.Text;

            if (repoName == null)
            {
                return;
            }
            if (repoName.Equals(""))
            {
                return;
            }
            if (repoName.Equals("Repository Name"))
            {
                return;
            }

            string localDir = TextBoxLocalDirectory.Text;

            if (localDir == null)
            {
                return;
            }
            if (localDir.Equals(""))
            {
                return;
            }
            localDir = localDir.Replace(@"\", "/");

            string server = ComboBoxSelectServer.GetItemText(ComboBoxSelectServer.SelectedItem);

            if (server == null)
            {
                return;
            }
            if (server.Equals(""))
            {
                return;
            }


            // get server details
            ListItem      listitem = (ListItem)(ComboBoxSelectServer.SelectedItem);
            ServerDetails sd       = listitem.Details;

            // check to see if sevrer is available
            RemoteManager rman   = RemoteManager.GetInstance();
            IRemote       remote = rman.Connect(sd);

            if (!remote.IsConnected()) // error
            {
                DialogUtil.Message("Error: Cannot connect to remote repository");
                return;
            }

            // make and run the script for downloading the selected repository
            string      remoteDir = sd.GetServerLoginString() + "/" + repoName;
            RepoDetails repo      = new RepoDetails(repoName, sd.GetName(), remoteDir, localDir);
            string      script    = ScriptBuilder.CloneScript(repo, sd);
            Executable  exe       = new Executable("expect.exe", script).Start();

            exe.WaitForExit();

            // add new repo to configuration
            ReposConfig.GetInstance().AddRepoDetails(repo, false);
            ReposConfig.GetInstance().Save();

            // done. now close and fire refresh event
            EventManager.Fire(EventCode.REFRESH_REPOS);
            ProperClose();
        }