Exemple #1
0
        public static async Task GetCommitDetailsForPushEvents(GitHubUserData userData)
        {
            foreach (Event evt in userData.GetEventsOfType(EventType.PushEvent).Where(e => e.isPublic))
            {
                PushEventPayload payload = evt.payload as PushEventPayload;
                foreach (Commit commit in payload.Commits)
                {
                    string jsonString = await HttpRequestHelper.DoRequestCommitDetailsAsync(userData.UserName, evt.repository.name, commit.sha);

                    commit.details = JsonConvert.DeserializeObject <CommitDetails>(jsonString, new JsonSerializerSettings
                    {
                        Error = Program.HandleDeserializationError
                    });
                }
            }
        }
        /// <summary>
        /// Returns total lines of code contributed
        /// </summary>
        /// <returns></returns>
        public int GetTotalLinesOfCode()
        {
            int total = 0;

            foreach (Event evt in GetEventsOfType(EventType.PushEvent))
            {
                PushEventPayload payload = evt.payload as PushEventPayload;
                foreach (Commit commit in payload.Commits)
                {
                    if (commit.details != null)
                    {
                        total += commit.details.stats.total;
                    }
                }
            }

            return(total);
        }