[geany/geany-plugins] f09ff8: GeanyVC: Report a completion status of the commit command

nomadbyte git-noreply at xxxxx
Wed Sep 29 17:35:37 UTC 2021


Branch:      refs/heads/master
Author:      nomadbyte <nomadbyte at users.noreply.github.com>
Committer:   nomadbyte <nomadbyte at users.noreply.github.com>
Date:        Fri, 13 Nov 2020 06:17:42 UTC
Commit:      f09ff821fcd01c154520958e4e052c3a6cd0b18f
             https://github.com/geany/geany-plugins/commit/f09ff821fcd01c154520958e4e052c3a6cd0b18f

Log Message:
-----------
GeanyVC: Report a completion status of the commit command


Modified Paths:
--------------
    geanyvc/src/geanyvc.c
    geanyvc/src/vc_git.c

Modified: geanyvc/src/geanyvc.c
28 lines changed, 27 insertions(+), 1 deletions(-)
===================================================================
@@ -591,6 +591,12 @@ execute_command(const VC_RECORD * vc, gchar ** std_out, gchar ** std_err, const
 	return ret;
 }
 
+static gint
+get_command_exit_status(gint exit_code)
+{
+	return (SPAWN_WIFEXITED(exit_code) ? SPAWN_WEXITSTATUS(exit_code) : exit_code);
+}
+
 /* Callback if menu item for a single file was activated */
 static void
 vcdiff_file_activated(G_GNUC_UNUSED GtkMenuItem * menuitem, G_GNUC_UNUSED gpointer gdata)
@@ -1800,8 +1806,28 @@ vccommit_activated(G_GNUC_UNUSED GtkMenuItem * menuitem, G_GNUC_UNUSED gpointer
 		gtk_tree_model_foreach(model, get_commit_files_foreach, &selected_files);
 		if (!EMPTY(message) && selected_files)
 		{
-			execute_command(vc, NULL, NULL, dir, VC_COMMAND_COMMIT, selected_files,
+			gchar *err_output = NULL;
+			gint exit_code;
+
+			exit_code = execute_command(vc, NULL, &err_output, dir, VC_COMMAND_COMMIT, selected_files,
 					message);
+
+			if (err_output)
+			{
+				gint status = get_command_exit_status(exit_code);
+
+				/* - log the commit error (may be a very long message) into the Message Window
+				   - overwrite the status bar with a more concise message
+				*/
+				g_warning("geanyvc: vccommit_activated: Commit failed (status:%d).", status);
+				ui_set_statusbar(TRUE, _("Commit failed (status: %d, error: %s)."), status, err_output);
+				ui_set_statusbar(FALSE, _("Commit failed; see status in the Message window."));
+				g_free(err_output);
+			}
+			else
+			{
+				ui_set_statusbar(FALSE, _("Changes committed."));
+			}
 			free_text_list(selected_files);
 		}
 		g_free(message);


Modified: geanyvc/src/vc_git.c
2 lines changed, 1 insertions(+), 1 deletions(-)
===================================================================
@@ -49,7 +49,7 @@ git_commit(G_GNUC_UNUSED gchar ** std_out, G_GNUC_UNUSED gchar ** std_err, const
 		commit = g_slist_prepend(commit, (gchar *) tmp->data + len + 1);
 	}
 
-	ret = execute_custom_command(base_dir, argv, NULL, NULL, NULL, base_dir, commit, message);
+	ret = execute_custom_command(base_dir, argv, NULL, NULL, std_err, base_dir, commit, message);
 	g_slist_free(commit);
 	g_free(base_dir);
 	return ret;



--------------
This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).


More information about the Plugins-Commits mailing list