[gitg/wip/fetch: 8/9] Implement basic fetch
- From: Jesse van den Kieboom <jessevdk src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gitg/wip/fetch: 8/9] Implement basic fetch
- Date: Tue, 23 Dec 2014 17:37:59 +0000 (UTC)
commit 6192dc2b62b09450ee9e3aa73cde890807415003
Author: Jesse van den Kieboom <jessevdk gmail com>
Date: Tue Dec 23 17:41:47 2014 +0100
Implement basic fetch
gitg/gitg-ref-action-fetch.vala | 158 +++++++++++++++++++++++----------------
1 files changed, 93 insertions(+), 65 deletions(-)
---
diff --git a/gitg/gitg-ref-action-fetch.vala b/gitg/gitg-ref-action-fetch.vala
index e936e60..43f2162 100644
--- a/gitg/gitg-ref-action-fetch.vala
+++ b/gitg/gitg-ref-action-fetch.vala
@@ -22,71 +22,99 @@ namespace Gitg
class RefActionFetch : GitgExt.UIElement, GitgExt.Action, GitgExt.RefAction, Object
{
- // Do this to pull in config.h before glib.h (for gettext...)
- private const string version = Gitg.Config.VERSION;
-
- public GitgExt.Application? application { owned get; construct set; }
- public GitgExt.RefActionInterface action_interface { get; construct set; }
- public Gitg.Ref reference { get; construct set; }
- private Gitg.Ref? d_remote;
-
- public RefActionFetch(GitgExt.Application application,
- GitgExt.RefActionInterface action_interface,
- Gitg.Ref reference)
- {
- Object(application: application,
- action_interface: action_interface,
- reference: reference);
-
- var branch = reference as Ggit.Branch;
-
- if (branch != null)
- {
- try
- {
- d_remote = branch.get_upstream() as Gitg.Ref;
- } catch {}
- }
- else if (reference.parsed_name.remote_name != null)
- {
- d_remote = reference;
- }
- }
-
- public string id
- {
- owned get { return "/org/gnome/gitg/ref-actions/fetch"; }
- }
-
- public string display_name
- {
- owned get
- {
- if (d_remote != null)
- {
- return _("Fetch from %s").printf(d_remote.parsed_name.remote_name);
- }
- else
- {
- return "";
- }
- }
- }
-
- public string description
- {
- owned get { return _("Fetch remote objects from %s").printf(d_remote.parsed_name.remote_name); }
- }
-
- public bool available
- {
- get { return d_remote != null; }
- }
-
- public void activate()
- {
- // TODO
- }
+ // Do this to pull in config.h before glib.h (for gettext...)
+ private const string version = Gitg.Config.VERSION;
+
+ public GitgExt.Application? application { owned get; construct set; }
+ public GitgExt.RefActionInterface action_interface { get; construct set; }
+ public Gitg.Ref reference { get; construct set; }
+
+ private Gitg.Ref? d_remote_ref;
+ private Gitg.Remote? d_remote;
+
+ public RefActionFetch(GitgExt.Application application,
+ GitgExt.RefActionInterface action_interface,
+ Gitg.Ref reference)
+ {
+ Object(application: application,
+ action_interface: action_interface,
+ reference: reference);
+
+ var branch = reference as Ggit.Branch;
+
+ if (branch != null)
+ {
+ try
+ {
+ d_remote_ref = branch.get_upstream() as Gitg.Ref;
+ } catch {}
+ }
+ else if (reference.parsed_name.remote_name != null)
+ {
+ d_remote_ref = reference;
+ }
+
+ if (d_remote_ref != null)
+ {
+ d_remote = application.remote_lookup.lookup(d_remote_ref.parsed_name.remote_name);
+ }
+ }
+
+ public string id
+ {
+ owned get { return "/org/gnome/gitg/ref-actions/fetch"; }
+ }
+
+ public string display_name
+ {
+ owned get
+ {
+ if (d_remote != null)
+ {
+ return _("Fetch from %s").printf(d_remote_ref.parsed_name.remote_name);
+ }
+ else
+ {
+ return "";
+ }
+ }
+ }
+
+ public string description
+ {
+ owned get { return _("Fetch remote objects from
%s").printf(d_remote_ref.parsed_name.remote_name); }
+ }
+
+ public bool available
+ {
+ get { return d_remote != null; }
+ }
+
+ public void activate()
+ {
+ Ggit.Signature sig;
+
+ try
+ {
+ sig = application.repository.get_signature_with_environment(application.environment);
+ }
+ catch (Error e)
+ {
+ stderr.printf("Failed to get signature: %s\n", e.message);
+ return;
+ }
+
+ d_remote.fetch.begin(sig, null, (obj, res) =>{
+ try
+ {
+ d_remote.fetch.end(res);
+ }
+ catch (Error e)
+ {
+ stderr.printf("Failed to fetch: %s\n", e.message);
+ }
+ });
+ }
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]