message-view: bgo #727634 - Cannot copy build output
[anjuta.git] / plugins / git / git-push-command.c
blobfd60da82b96c8d240407c43a3deaaeb42f8d823d
1 /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
2 /*
3 * anjuta
4 * Copyright (C) James Liggett 2008 <jrliggett@cox.net>
5 *
6 * anjuta is free software.
7 *
8 * You may redistribute it and/or modify it under the terms of the
9 * GNU General Public License, as published by the Free Software
10 * Foundation; either version 2 of the License, or (at your option)
11 * any later version.
13 * anjuta is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
16 * See the GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with anjuta. If not, write to:
20 * The Free Software Foundation, Inc.,
21 * 51 Franklin Street, Fifth Floor
22 * Boston, MA 02110-1301, USA.
25 #include "git-push-command.h"
27 struct _GitPushCommandPriv
29 gchar *url;
30 GList *refs;
31 gboolean push_all;
32 gboolean push_tags;
33 gboolean force;
36 G_DEFINE_TYPE (GitPushCommand, git_push_command, GIT_TYPE_COMMAND);
38 static void
39 git_push_command_init (GitPushCommand *self)
41 self->priv = g_new0 (GitPushCommandPriv, 1);
42 git_command_set_check_passwd_prompt (GIT_COMMAND (self), TRUE);
45 static void
46 git_push_command_finalize (GObject *object)
48 GitPushCommand *self;
50 self = GIT_PUSH_COMMAND (object);
52 g_free (self->priv->url);
53 anjuta_util_glist_strings_free (self->priv->refs);
54 g_free (self->priv);
56 G_OBJECT_CLASS (git_push_command_parent_class)->finalize (object);
59 static guint
60 git_push_command_run (AnjutaCommand *command)
62 GitPushCommand *self;
64 self = GIT_PUSH_COMMAND (command);
66 git_command_add_arg (GIT_COMMAND (command), "push");
68 if (self->priv->push_all)
69 git_command_add_arg (GIT_COMMAND (command), "--all");
71 if (self->priv->push_tags)
72 git_command_add_arg (GIT_COMMAND (command), "--tags");
74 if (self->priv->force)
75 git_command_add_arg (GIT_COMMAND (command), "--force");
77 git_command_add_arg (GIT_COMMAND (command), self->priv->url);
79 if (self->priv->refs)
80 git_command_add_list_to_args (GIT_COMMAND (command), self->priv->refs);
82 return 0;
85 static void
86 git_push_command_class_init (GitPushCommandClass *klass)
88 GObjectClass* object_class = G_OBJECT_CLASS (klass);
89 GitCommandClass* parent_class = GIT_COMMAND_CLASS (klass);
90 AnjutaCommandClass* command_class = ANJUTA_COMMAND_CLASS (klass);
92 object_class->finalize = git_push_command_finalize;
93 parent_class->output_handler = git_command_send_output_to_info;
94 command_class->run = git_push_command_run;
98 GitPushCommand *
99 git_push_command_new (const gchar *working_directory,
100 const gchar *url,
101 GList *refs,
102 gboolean push_all,
103 gboolean push_tags,
104 gboolean force)
106 GitPushCommand *self;
108 self = g_object_new (GIT_TYPE_PUSH_COMMAND,
109 "working-directory", working_directory,
110 "single-line-output", TRUE,
111 NULL);
113 self->priv->url = g_strdup (url);
114 self->priv->refs = git_command_copy_string_list (refs);
115 self->priv->push_all = push_all;
116 self->priv->push_tags = push_tags;
117 self->priv->force = force;
119 return self;