[gnome-builder] git: trim refs/heads/ from branch display
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] git: trim refs/heads/ from branch display
- Date: Sun, 5 May 2019 23:36:26 +0000 (UTC)
commit 7951927bd801265109433b0f366dc35a59c918ea
Author: Christian Hergert <chergert redhat com>
Date: Sun May 5 16:35:54 2019 -0700
git: trim refs/heads/ from branch display
src/plugins/git/gbp-git-branch.c | 23 ++++++++++++++++++-----
src/plugins/git/gbp-git-branch.h | 2 +-
src/plugins/git/gbp-git-vcs.c | 6 +++---
3 files changed, 22 insertions(+), 9 deletions(-)
---
diff --git a/src/plugins/git/gbp-git-branch.c b/src/plugins/git/gbp-git-branch.c
index a937890bc..f3e00b03d 100644
--- a/src/plugins/git/gbp-git-branch.c
+++ b/src/plugins/git/gbp-git-branch.c
@@ -23,25 +23,38 @@
#include "config.h"
#include <libide-vcs.h>
+#include <string.h>
#include "gbp-git-branch.h"
struct _GbpGitBranch
{
GObject parent_instance;
- gchar *name;
+ gchar *id;
};
+static gchar *
+gbp_git_branch_get_id (IdeVcsBranch *branch)
+{
+ return g_strdup (GBP_GIT_BRANCH (branch)->id);
+}
+
static gchar *
gbp_git_branch_get_name (IdeVcsBranch *branch)
{
- return g_strdup (GBP_GIT_BRANCH (branch)->name);
+ const gchar *id = GBP_GIT_BRANCH (branch)->id;
+
+ if (id && g_str_has_prefix (id, "refs/heads/"))
+ id += strlen ("refs/heads/");
+
+ return g_strdup (id);
}
static void
vcs_branch_iface_init (IdeVcsBranchInterface *iface)
{
iface->get_name = gbp_git_branch_get_name;
+ iface->get_id = gbp_git_branch_get_id;
}
G_DEFINE_TYPE_WITH_CODE (GbpGitBranch, gbp_git_branch, G_TYPE_OBJECT,
@@ -52,7 +65,7 @@ gbp_git_branch_finalize (GObject *object)
{
GbpGitBranch *self = (GbpGitBranch *)object;
- g_clear_pointer (&self->name, g_free);
+ g_clear_pointer (&self->id, g_free);
G_OBJECT_CLASS (gbp_git_branch_parent_class)->finalize (object);
}
@@ -71,12 +84,12 @@ gbp_git_branch_init (GbpGitBranch *self)
}
GbpGitBranch *
-gbp_git_branch_new (const gchar *name)
+gbp_git_branch_new (const gchar *id)
{
GbpGitBranch *self;
self = g_object_new (GBP_TYPE_GIT_BRANCH, NULL);
- self->name = g_strdup (name);
+ self->id = g_strdup (id);
return g_steal_pointer (&self);
}
diff --git a/src/plugins/git/gbp-git-branch.h b/src/plugins/git/gbp-git-branch.h
index a5ac9edb1..b7518d611 100644
--- a/src/plugins/git/gbp-git-branch.h
+++ b/src/plugins/git/gbp-git-branch.h
@@ -28,6 +28,6 @@ G_BEGIN_DECLS
G_DECLARE_FINAL_TYPE (GbpGitBranch, gbp_git_branch, GBP, GIT_BRANCH, GObject)
-GbpGitBranch *gbp_git_branch_new (const gchar *name);
+GbpGitBranch *gbp_git_branch_new (const gchar *id);
G_END_DECLS
diff --git a/src/plugins/git/gbp-git-vcs.c b/src/plugins/git/gbp-git-vcs.c
index b74641e59..772958d0d 100644
--- a/src/plugins/git/gbp-git-vcs.c
+++ b/src/plugins/git/gbp-git-vcs.c
@@ -143,7 +143,7 @@ gbp_git_vcs_switch_branch_async (IdeVcs *vcs,
{
GbpGitVcs *self = (GbpGitVcs *)vcs;
g_autoptr(IdeTask) task = NULL;
- g_autofree gchar *branch_name = NULL;
+ g_autofree gchar *branch_id = NULL;
g_assert (IDE_IS_MAIN_THREAD ());
g_assert (GBP_IS_GIT_VCS (self));
@@ -153,10 +153,10 @@ gbp_git_vcs_switch_branch_async (IdeVcs *vcs,
task = ide_task_new (self, cancellable, callback, user_data);
ide_task_set_source_tag (task, gbp_git_vcs_switch_branch_async);
- branch_name = ide_vcs_branch_get_name (branch);
+ branch_id = ide_vcs_branch_get_id (branch);
ipc_git_repository_call_switch_branch (self->repository,
- branch_name,
+ branch_id,
cancellable,
gbp_git_vcs_switch_branch_cb,
g_steal_pointer (&task));
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]