1 /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
4 * Copyright (C) James Liggett 2008 <jrliggett@cox.net>
6 * anjuta is free software.
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)
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-tag-create-command.h"
27 struct _GitTagCreateCommandPriv
35 G_DEFINE_TYPE (GitTagCreateCommand
, git_tag_create_command
, GIT_TYPE_COMMAND
);
38 git_tag_create_command_init (GitTagCreateCommand
*self
)
40 self
->priv
= g_new0 (GitTagCreateCommandPriv
, 1);
44 git_tag_create_command_finalize (GObject
*object
)
46 GitTagCreateCommand
*self
;
48 self
= GIT_TAG_CREATE_COMMAND (object
);
50 g_free (self
->priv
->name
);
51 g_free (self
->priv
->revision
);
52 g_free (self
->priv
->log
);
55 G_OBJECT_CLASS (git_tag_create_command_parent_class
)->finalize (object
);
59 git_tag_create_command_run (AnjutaCommand
*command
)
61 GitTagCreateCommand
*self
;
63 self
= GIT_TAG_CREATE_COMMAND (command
);
65 git_command_add_arg (GIT_COMMAND (command
), "tag");
69 git_command_add_arg (GIT_COMMAND (command
), "-a");
70 git_command_add_arg (GIT_COMMAND (command
), "-m");
71 git_command_add_arg (GIT_COMMAND (command
), self
->priv
->log
);
74 if (self
->priv
->force
)
75 git_command_add_arg (GIT_COMMAND (command
), "-f");
77 git_command_add_arg (GIT_COMMAND (command
), self
->priv
->name
);
79 if (self
->priv
->revision
)
80 git_command_add_arg (GIT_COMMAND (command
), self
->priv
->revision
);
86 git_tag_create_command_class_init (GitTagCreateCommandClass
*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_tag_create_command_finalize
;
93 parent_class
->output_handler
= git_command_send_output_to_info
;
94 command_class
->run
= git_tag_create_command_run
;
99 git_tag_create_command_new (const gchar
*working_directory
,
100 const gchar
*name
, const gchar
*revision
,
101 const gchar
*log
, gboolean force
)
103 GitTagCreateCommand
*self
;
105 self
= g_object_new (GIT_TYPE_TAG_CREATE_COMMAND
,
106 "working-directory", working_directory
,
107 "single-line-output", TRUE
,
110 self
->priv
->name
= g_strdup (name
);
111 self
->priv
->revision
= g_strdup (revision
);
112 self
->priv
->log
= g_strdup (log
);
113 self
->priv
->force
= force
;
119 git_tag_create_command_get_tag_name (GitTagCreateCommand
*self
)
121 return g_strdup (self
->priv
->name
);