Example #1
0
        /// <summary>
        /// Main form initialization method performs operations that may need the main
        /// window to have already been shown since we may invoke its UI handlers
        /// </summary>
        public void Initialize()
        {
            // Load default set of repositories
            ClassWorkspace.Load(null);

            // Load custom tools
            App.CustomTools = ClassCustomTools.Load(DefaultCustomToolsFile);

            // If there are no tools on the list, find some local tools and add them
            if (App.CustomTools.Tools.Count == 0)
            {
                App.CustomTools.Tools.AddRange(ClassCustomTools.FindLocalTools());
            }

            // If there is no current repo, switch the right panel view to Repos
            // Otherwise, restore the last view panel
            ChangeRightPanel(App.Repos.Current == null ?
                             "Repos" :
                             Properties.Settings.Default.viewRightPanel);

            // Usability improvement: When starting the app, check if the global user name
            // and email are defined and if not, open the settings dialog. This helps when
            // starting the app for the first time.
            if (string.IsNullOrEmpty(ClassConfig.GetGlobal("user.name")) &&
                string.IsNullOrEmpty(ClassConfig.GetGlobal("user.email")))
            {
                MenuOptions(null, null);
            }
        }
Example #2
0
 /// <summary>
 /// Initializes repo class with user.name and user.email fields.
 /// Returns True if the repo appears valid and these settings are read.
 /// </summary>
 public bool Init()
 {
     // We assume that a valid git repo will always have core.bare entry
     if (ClassConfig.GetLocal(this, "core.bare") == string.Empty)
     {
         return(false);
     }
     UserName  = ClassConfig.GetLocal(this, "user.name");
     UserEmail = ClassConfig.GetLocal(this, "user.email");
     Status    = new ClassStatus(this);
     return(true);
 }
Example #3
0
        /// <summary>
        /// Configure a given application helper to be a Git diff utility
        /// </summary>
        public static void Configure(AppHelper app)
        {
            // Configure application only if it is valid
            if (app.Name != string.Empty)
            {
                string path = app.Path.Replace('\\', '/');
                string usr  = app.Args.
                              Replace("%1", "$LOCAL").
                              Replace("%2", "$REMOTE");
                string arg = "'" + path + "' " + usr;
                ClassConfig.SetGlobal("difftool." + app.Name + ".path", path);
                ClassConfig.SetGlobal("difftool." + app.Name + ".cmd", arg);

                // TODO: This might be an option: Set our default tool to be the Git gui tool?
                // ClassConfig.SetGlobal("diff.guitool", app.Name);
            }
        }
Example #4
0
        /// <summary>
        /// Main form initialization method performs operations that may need the main
        /// window to have already been shown since we may invoke its UI handlers
        /// </summary>
        public bool Initialize()
        {
            // Load default set of repositories
            // If this is the first time run, initialize the default workspace file name
            if (string.IsNullOrEmpty(Properties.Settings.Default.WorkspaceFile))
            {
                Properties.Settings.Default.WorkspaceFile = Path.Combine(App.AppHome, "repos.giw");
            }
            string name = Properties.Settings.Default.WorkspaceFile;

            if (File.Exists(name))              // Even if the workspace does not exist at this point
            {
                if (!ClassWorkspace.Load(name)) // still use it's name and continue running since it
                {
                    return(false);              // will be saved on a program exit
                }
            }
            // Load custom tools
            App.CustomTools = ClassCustomTools.Load(DefaultCustomToolsFile);

            // If there are no tools on the list, find some local tools and add them
            if (App.CustomTools.Tools.Count == 0)
            {
                App.CustomTools.Tools.AddRange(ClassCustomTools.FindLocalTools());
            }

            // If there is no current repo, switch the right panel view to Repos
            // Otherwise, restore the last view panel
            ChangeRightPanel(App.Repos.Current == null ?
                             "Repos" :
                             Properties.Settings.Default.viewRightPanel);

            // Usability improvement: When starting the app, check if the global user name
            // and email are defined and if not, open the settings dialog. This helps when
            // starting the app for the first time.
            if (string.IsNullOrEmpty(ClassConfig.GetGlobal("user.name")) &&
                string.IsNullOrEmpty(ClassConfig.GetGlobal("user.email")))
            {
                MenuOptions(null, null);
            }
            return(true);
        }
Example #5
0
        /// <summary>
        /// Configure a given application helper to be a Git merge utility
        /// </summary>
        public static void Configure(AppHelper app)
        {
            // Configure application only if it is valid
            if (app.Name != string.Empty)
            {
                string path = app.Path.Replace('\\', '/');
                string usr  = app.Args.
                              Replace("%1", "$BASE").
                              Replace("%2", "$LOCAL").
                              Replace("%3", "$REMOTE").
                              Replace("%4", "$MERGED");
                string arg = "'" + path + "' " + usr;
                ClassConfig.SetGlobal("mergetool." + app.Name + ".path", path);
                ClassConfig.SetGlobal("mergetool." + app.Name + ".cmd", arg);
                ClassConfig.SetGlobal("mergetool." + app.Name + ".trustExitCode", "false");

                // Set the default merge tool
                ClassConfig.SetGlobal("merge.tool", app.Name);
                ClassConfig.SetGlobal("mergetool.keepBackup", "false");
            }
        }
Example #6
0
        /// <summary>
        /// Main form initialization method performs operations that may need the main
        /// window to have already been shown since we may invoke its UI handlers
        /// Optionally, open an existing git repo at the path given in the initRepo argument
        /// </summary>
        public bool Initialize(string initRepo)
        {
            // Load default set of repositories
            // If this is the first time run, initialize the default workspace file name
            if (string.IsNullOrEmpty(Properties.Settings.Default.WorkspaceFile))
            {
                Properties.Settings.Default.WorkspaceFile = Path.Combine(App.AppHome, "repos.giw");
            }
            string name = Properties.Settings.Default.WorkspaceFile;

            if (File.Exists(name))              // Even if the workspace does not exist at this point
            {
                if (!ClassWorkspace.Load(name)) // still use it's name and continue running since it
                {
                    return(false);              // will be saved on a program exit
                }
            }
            // Load custom tools
            App.CustomTools = ClassCustomTools.Load(DefaultCustomToolsFile);

            // If there are no tools on the list, find some local tools and add them
            if (App.CustomTools.Tools.Count == 0)
            {
                App.CustomTools.Tools.AddRange(ClassCustomTools.FindLocalTools());
            }

            // If there is no current repo, switch the right panel view to Repos
            // Otherwise, restore the last view panel
            ChangeRightPanel(App.Repos.Current == null ?
                             "Repos" :
                             Properties.Settings.Default.viewRightPanel);

            // The user requested to open a specific repo with the --repo command line argument
            if (initRepo != null)
            {
                try
                {
                    ClassRepo repo = App.Repos.Find(initRepo);
                    if (repo == null)
                    {
                        repo = App.Repos.Add(ClassCommandLine.initRepo);
                    }
                    App.Repos.SetCurrent(repo);
                    ChangeRightPanel("Revisions"); // Set the right pane to "Revisions" tab
                    App.PrintStatusMessage("Opening repo " + repo, MessageType.General);
                }
                catch (Exception ex)
                {
                    App.PrintLogMessage("Unable to open repo: " + ex.Message, MessageType.Error);
                    App.PrintStatusMessage(ex.Message, MessageType.Error);
                }
            }

            // Usability improvement: When starting the app, check if the global user name
            // and email are defined and if not, open the settings dialog. This helps when
            // starting the app for the first time.
            if (string.IsNullOrEmpty(ClassConfig.GetGlobal("user.name")) &&
                string.IsNullOrEmpty(ClassConfig.GetGlobal("user.email")))
            {
                MenuOptions(null, null);
            }

            return(true);
        }