Esempio n. 1
0
		public bool FetchDiff (Push push)
		{
			string url = null;
			try {
				string response = CachingFetcher.FetchDiff (push.CHAuthID, push.Repository.Owner.Name, push.Repository.Name, ID, out url);
				if (response == null)
					return false;
				
				var jdes = new JsonDeserializer ();
				var wrapper = jdes.Deserialize<CommitWithDiffJsonWrapper> (response);
				if (wrapper != null) {
					var diff = wrapper.Commit;
					if (!diff.FetchBlobs (push)) {
						Log (LogSeverity.Error, "Failed to fetch blobs for commit '{0}' from URL '{1}'", ID, url);
						return false;
					}
					Diff = diff;
				} else {
					Log (LogSeverity.Error, "Failed to fetch diff for commit '{0}' from URL '{1}'", ID, url);
					return false;
				}
			} catch (Exception ex) {
				Log (ex, "Exception while fetching diff for commit '{4}' from URL '{5}'\n{0}", ID, url);
				return false;
			}
			
			CommitWithDiff ret = Diff;
			if (ret == null)
				Log (LogSeverity.Info, "FetchDiff did not fail, but no diff retrieved?");
			
			return ret != null;
		}
Esempio n. 2
0
        public bool FetchBlobs(Push push)
        {
            if (push == null)
            {
                throw new ArgumentNullException("push");
            }

            List <string> added = Added;

            if (added == null || added.Count == 0)
            {
                return(true);
            }

            Blob   blob;
            var    list           = new List <Blob> ();
            string ownerName      = push.Repository.Owner.Name;
            string repositoryName = push.Repository.Name;
            string tree           = Tree;
            string commitSource   = push.CHAuthID;

            foreach (string file in added)
            {
                blob = Fetch(commitSource, repositoryName, ownerName, tree, file);
                if (blob == null)
                {
                    return(false);
                }
                list.Add(blob);
            }

            if (list.Count > 0)
            {
                AddedBlobs = list;
            }
            else
            {
                AddedBlobs = null;
            }

            return(true);
        }
Esempio n. 3
0
        public bool FetchDiff(Push push)
        {
            string url = null;

            try {
                string response = CachingFetcher.FetchDiff(push.CHAuthID, push.Repository.Owner.Name, push.Repository.Name, ID, out url);
                if (response == null)
                {
                    return(false);
                }

                var jdes    = new JsonDeserializer();
                var wrapper = jdes.Deserialize <CommitWithDiffJsonWrapper> (response);
                if (wrapper != null)
                {
                    var diff = wrapper.Commit;
                    if (!diff.FetchBlobs(push))
                    {
                        Log(LogSeverity.Error, "Failed to fetch blobs for commit '{0}' from URL '{1}'", ID, url);
                        return(false);
                    }
                    Diff = diff;
                }
                else
                {
                    Log(LogSeverity.Error, "Failed to fetch diff for commit '{0}' from URL '{1}'", ID, url);
                    return(false);
                }
            } catch (Exception ex) {
                Log(ex, "Exception while fetching diff for commit '{4}' from URL '{5}'\n{0}", ID, url);
                return(false);
            }

            CommitWithDiff ret = Diff;

            if (ret == null)
            {
                Log(LogSeverity.Info, "FetchDiff did not fail, but no diff retrieved?");
            }

            return(ret != null);
        }
Esempio n. 4
0
		public bool FetchBlobs (Push push)
		{
			if (push == null)
				throw new ArgumentNullException ("push");

			List<string> added = Added;
			if (added == null || added.Count == 0)
				return true;

			Blob blob;
			var list = new List<Blob> ();
			string ownerName = push.Repository.Owner.Name;
			string repositoryName = push.Repository.Name;
			string tree = Tree;
			string commitSource = push.CHAuthID;
			
			foreach (string file in added) {
				blob = Fetch (commitSource, repositoryName, ownerName, tree, file);
				if (blob == null)
					return false;
				list.Add (blob);
			}

			if (list.Count > 0)
				AddedBlobs = list;
			else
				AddedBlobs = null;

			return true;
		}
Esempio n. 5
0
        public bool FetchDiff(Push push)
        {
            WebClient client = new WebClient ();
            string url = String.Format ("http://github.com/api/v2/json/commits/show/{0}/{1}/{2}",
                            push.Repository.Owner.Name,
                            push.Repository.Name,
                            ID);

            string response;
            try {
                response = client.DownloadString (url);
                var jdes = new JsonDeserializer ();
                var wrapper = jdes.Deserialize<CommitWithDiffJsonWrapper> (response);
                if (wrapper != null) {
                    var diff = wrapper.Commit;
                    if (!diff.FetchBlobs (push)) {
                        Log (LogSeverity.Error, "Failed to fetch blobs for commit '{0}'", ID);
                        return false;
                    }
                    Diff = diff;
                } else {
                    Log (LogSeverity.Error, "Failed to fetch diff for commit '{0}'", ID);
                    return false;
                }
            } catch (Exception ex) {
                Log (ex);
                return false;
            }

            return Diff != null;
        }
        public bool FetchBlobs(Push push)
        {
            if (push == null)
                throw new ArgumentNullException ("push");

            List<string> added = Added;
            if (added == null || added.Count == 0)
                return true;

            string urlFormat = "http://github.com/api/v2/json/blob/show/{0}/{1}/{2}/{3}";
            string url;
            Blob blob;
            var list = new List<Blob> ();
            WebClient client = new WebClient ();

            foreach (string file in added) {
                url = String.Format (urlFormat, push.Repository.Owner.Name, push.Repository.Name, Tree, file);
                blob = Fetch (client, url, file);
                if (blob == null)
                    return false;
                list.Add (blob);
            }

            if (list.Count > 0)
                AddedBlobs = list;
            else
                AddedBlobs = null;

            return true;
        }