public static Uri GenerateGravatarUrl(this GitHubCommit x) { if (x == null) { return(null); } try { if (x.Author != null && !string.IsNullOrEmpty(x.Author.AvatarUrl)) { return(new Uri(x.Author.AvatarUrl)); } var inputBytes = Encoding.UTF8.GetBytes(x.Commit.Author.Email.Trim().ToLower()); var hash = MD5.Create().ComputeHash(inputBytes); var sb = new StringBuilder(); for (int i = 0; i < hash.Length; i++) { sb.Append(hash[i].ToString("x2")); } return(new Uri(string.Format("http://www.gravatar.com/avatar/{0}?d={1}", sb, GitHubDefaultGravitar))); } catch { return(null); } }
public CompareResult(string url, string htmlUrl, string permalinkUrl, string diffUrl, string patchUrl, GitHubCommit baseCommit, GitHubCommit mergedBaseCommit, string status, int aheadBy, int behindBy, int totalCommits, IReadOnlyList <GitHubCommit> commits) { Url = url; HtmlUrl = htmlUrl; PermalinkUrl = permalinkUrl; DiffUrl = diffUrl; PatchUrl = patchUrl; BaseCommit = baseCommit; MergedBaseCommit = mergedBaseCommit; Status = status; AheadBy = aheadBy; BehindBy = behindBy; TotalCommits = totalCommits; Commits = commits; }
public static string GenerateCommiterName(this GitHubCommit x) { if (x.Commit.Author != null && !string.IsNullOrEmpty(x.Commit.Author.Name)) { return(x.Commit.Author.Name); } if (x.Commit.Committer != null && !string.IsNullOrEmpty(x.Commit.Committer.Name)) { return(x.Commit.Committer.Name); } if (x.Author != null) { return(x.Author.Login); } return(x.Committer != null ? x.Committer.Login : "******"); }
public CompareResult(string url, string htmlUrl, string permalinkUrl, string diffUrl, string patchUrl, GitHubCommit baseCommit, GitHubCommit mergedBaseCommit, string status, int aheadBy, int behindBy, int totalCommits, IReadOnlyList<GitHubCommit> commits, IReadOnlyList<GitHubCommitFile> files) { Url = url; HtmlUrl = htmlUrl; PermalinkUrl = permalinkUrl; DiffUrl = diffUrl; PatchUrl = patchUrl; BaseCommit = baseCommit; MergedBaseCommit = mergedBaseCommit; Status = status; AheadBy = aheadBy; BehindBy = behindBy; TotalCommits = totalCommits; Commits = commits; Files = files; }
/// <summary> /// Converts an OctoKit repo to a model repo. /// </summary> private GitHubCommit ToModelCommit( Octokit.GitHubCommit commit, string organizationName, string repositoryName) { return(new GitHubCommit ( commit.Sha, organizationName, repositoryName, commit.Author?.Login, commit.Commit.Message, commit.Commit.Committer.Date, Enumerable.ToList <string>(commit.Parents .Select(parent => parent.Sha)) )); }
internal CommitItemViewModel(GitHubCommit commit, Action<CommitItemViewModel> action) { var msg = commit?.Commit?.Message ?? string.Empty; var firstLine = msg.IndexOf("\n", StringComparison.Ordinal); var description = firstLine > 0 ? msg.Substring(0, firstLine) : msg; _description = new Lazy<string>(() => Emojis.FindAndReplace(description)); var time = DateTimeOffset.MinValue; if (commit.Commit.Committer != null) time = commit.Commit.Committer.Date; Time = time.UtcDateTime.Humanize(); Name = commit.GenerateCommiterName(); Avatar = new GitHubAvatar(commit.GenerateGravatarUrl()); Commit = commit; GoToCommand = ReactiveCommand.Create().WithSubscription(_ => action(this)); }
public static string Get_Commit(string app_name, int repo_id, string sha, string token) { string result; try { var client = new GitHubClient(new ProductHeaderValue(app_name)); if (!String.IsNullOrEmpty(token)) { var tokenAuth = new Octokit.Credentials(token); client.Credentials = tokenAuth; } Octokit.GitHubCommit commit = client.Repository.Commit.Get(repo_id, sha).Result; result = JsonConvert.SerializeObject(commit); } catch (Exception ex) { Logger.Log_Error("AustinsFirstProject.Github_Api.Api.Rest_Api_V3.Repositories.Get_Commit failed. Error Msg: " + ex.Message); result = ""; } return(result); }
public CommitViewModel Init(string repositoryOwner, string repositoryName, string node, GitHubCommit commit = null, bool showRepository = false) { RepositoryOwner = repositoryOwner; RepositoryName = repositoryName; Commit = commit; Node = node; ShowRepository = showRepository; return this; }
/// <summary> /// Handles creating an Event object from a GitHub commit which will be streamed into Splunk. /// </summary> /// <param name="githubCommit">The individual GithubCommit object which holds the data for a commit.</param> /// <param name="eventWriter">The EventWriter for streaming events to Splunk.</param> /// <param name="owner">The GitHub repository owner's name.</param> /// <param name="repositoryName">The GitHub repository's name.</param> public async Task StreamCommit(GitHubCommit githubCommit, EventWriter eventWriter, string owner, string repositoryName) { string authorName = githubCommit.Commit.Author.Name; DateTime date = githubCommit.Commit.Author.Date; // Replace any newlines with a space string commitMessage = Regex.Replace(githubCommit.Commit.Message, "\\n|\\r", " "); dynamic json = new JObject(); json.sha = githubCommit.Sha; json.api_url = githubCommit.Url; json.url = "http://github.com/" + owner + "/" + repositoryName + "/commit/" + githubCommit.Sha; json.message = commitMessage; json.author = authorName; json.date = date.ToString(); var commitEvent = new Event(); commitEvent.Stanza = repositoryName; commitEvent.SourceType = "github_commits"; commitEvent.Time = date; commitEvent.Data = json.ToString(Formatting.None); await eventWriter.QueueEventForWriting(commitEvent); }
public GhCommit(GitHubCommit commit) { Message = commit.Commit.Message; if (commit.Author != null) Author = commit.Author.Id; if (commit.Files != null) Files = commit.Files.Select(x => new CommitFile(x)).ToArray(); }
public CommitViewModel Init(string repositoryOwner, string repositoryName, string node, GitHubCommit commit = null) { RepositoryOwner = repositoryOwner; RepositoryName = repositoryName; Commit = commit; Node = node; return this; }