[libgit2-glib] Bind ggit_message_prettify



commit 44e21cd47c6ff1cf5c754513aaaad63594c615fe
Author: Jesse van den Kieboom <jessevdk gmail com>
Date:   Fri Jun 28 21:39:49 2013 +0200

    Bind ggit_message_prettify

 libgit2-glib/Makefile.am    |    2 +
 libgit2-glib/ggit-message.c |   56 +++++++++++++++++++++++++++++++++++++++++++
 libgit2-glib/ggit-message.h |   35 ++++++++++++++++++++++++++
 3 files changed, 93 insertions(+), 0 deletions(-)
---
diff --git a/libgit2-glib/Makefile.am b/libgit2-glib/Makefile.am
index 26b7e4b..a91d6d2 100644
--- a/libgit2-glib/Makefile.am
+++ b/libgit2-glib/Makefile.am
@@ -37,6 +37,7 @@ INST_H_FILES =                                \
        ggit-index-entry.h              \
        ggit-index-entry-resolve-undo.h \
        ggit-main.h                     \
+       ggit-message.h                  \
        ggit-native.h                   \
        ggit-object.h                   \
        ggit-object-factory.h           \
@@ -86,6 +87,7 @@ C_FILES =                             \
        ggit-index-entry.c              \
        ggit-index-entry-resolve-undo.c \
        ggit-main.c                     \
+       ggit-message.c                  \
        ggit-native.c                   \
        ggit-object.c                   \
        ggit-object-factory.c           \
diff --git a/libgit2-glib/ggit-message.c b/libgit2-glib/ggit-message.c
new file mode 100644
index 0000000..ba9814c
--- /dev/null
+++ b/libgit2-glib/ggit-message.c
@@ -0,0 +1,56 @@
+/*
+ * ggit-message.c
+ * This file is part of libgit2-glib
+ *
+ * Copyright (C) 2013 - Jesse van den Kieboom
+ *
+ * libgit2-glib is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * libgit2-glib is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with libgit2-glib. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "ggit-message.h"
+#include <git2.h>
+#include <string.h>
+
+/**
+ * ggit_message_prettify:
+ * @message: the message.
+ * @strip_comments: whether to strip comments.
+ *
+ * Prettify a commit message by removing excess whitespace and making sure the
+ * last line ends with a newline. If @strip_comments is %TRUE, then lines
+ * starting with a '#' will be removed.
+ *
+ * Returns: the prettified message.
+ *
+ */
+gchar *
+ggit_message_prettify (const gchar *message,
+                       gboolean     strip_comments)
+{
+       gchar *ret;
+       gint len;
+       gchar *d;
+
+       len = strlen (message) * 2;
+       ret = g_new0 (gchar, len);
+
+       git_message_prettify (ret, len, message, strip_comments);
+
+       d = g_strdup (ret);
+       g_free (ret);
+
+       return d;
+}
+
+/* ex:set ts=8 noet: */
diff --git a/libgit2-glib/ggit-message.h b/libgit2-glib/ggit-message.h
new file mode 100644
index 0000000..fbd3ff1
--- /dev/null
+++ b/libgit2-glib/ggit-message.h
@@ -0,0 +1,35 @@
+/*
+ * ggit-message.h
+ * This file is part of libgit2-glib
+ *
+ * Copyright (C) 2013 - Jesse van den Kieboom
+ *
+ * libgit2-glib is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * libgit2-glib is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with libgit2-glib. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef __GGIT_MESSAGE_H__
+#define __GGIT_MESSAGE_H__
+
+#include <glib.h>
+
+G_BEGIN_DECLS
+
+gchar *ggit_message_prettify (const gchar *message,
+                              gboolean     strip_comments);
+
+G_END_DECLS
+
+#endif /* __GGIT_MESSAGE_H__ */
+
+/* ex:set ts=8 noet: */


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]