public void Load(string userName, string password) { var connection = new Connection(new ProductHeaderValue("TestApp", "0.0.1")); //connection.Credentials = new Credentials(userName, password); var client = new GitHubClient(connection); var rxClient = new ObservableGitHubClient(client); //rxClient.Repository.GetAllForUser(userName) // .SelectMany(x => rxClient.Issue.GetAllForRepository(x.Id)) // .ObserveOn(RxApp.MainThreadScheduler) // .Subscribe(x => Items.Add(x.Title)); //var user = rxClient.User.Get(userName).Wait(); //rxClient.User.Get(userName).SelectMany(user => //{ // return rxClient.Issue.GetAllForRepository("GitHub", "VisualStudio") // .Where(i => i.Assignee?.Id == user.Id); //}).ObserveOn(RxApp.MainThreadScheduler) // .Subscribe(x => Items.Add(x.Title)); rxClient.User.Get(userName) .Select(x => x.Id) .SelectMany(userId => rxClient.Issue.GetAllForRepository("GitHub", "VisualStudio") .Where(x => x.Assignee?.Id == userId)) .ObserveOn(RxApp.MainThreadScheduler) .Subscribe(x => Items.Add(x.Title)); }
public async Task MarksNotificationsReadForRepositoryId() { var repositoryId = 7528679; var client = new ObservableGitHubClient(Helper.GetAuthenticatedClient()); await client.Activity.Notifications.MarkAsReadForRepository(repositoryId); }
public async Task MarksNotificationsRead() { var owner = "octokit"; var repo = "octokit.net"; var client = new ObservableGitHubClient(Helper.GetAuthenticatedClient()); await client.Activity.Notifications.MarkAsReadForRepository(owner, repo); }
public ObservableIssueTimelineClientTests() { var github = Helper.GetAuthenticatedClient(); _client = new ObservableGitHubClient(github); var reponame = Helper.MakeNameWithTimestamp("public-repo"); _context = github.CreateRepositoryContext(new NewRepository(reponame)).Result; }
static void Main(string[] args) { Console.WriteLine("Start"); var cred = Environment.GetEnvironmentVariable("GitCred"); var client = new ObservableGitHubClient( new Octokit.ProductHeaderValue("bnayae"), new InMemoryCredentialStore( new Octokit.Credentials(cred))); client.User.Followers.GetAllFollowing("bnayae").Subscribe(v => Console.WriteLine(v.Login)); Console.ReadKey(); }
static void Main(string[] args) { string token = Environment.GetEnvironmentVariable("GITHUB_TOKEN") ?? "nope"; Console.WriteLine("GitHub token first few chars: " + token.Substring(0, 3)); Console.WriteLine($"PullRequest number is {Environment.GetEnvironmentVariable("SYSTEM_PULLREQUEST_PULLREQUESTNUMBER") ?? "nonumber"}"); var credentials = new InMemoryCredentialStore(new Credentials(token)); var client = new ObservableGitHubClient(new ProductHeaderValue("ophion"), credentials); var pullID = 2; var pr = client.PullRequest.Get("lucasmeijer", "bot_experiment", pullID).Subscribe(async a => { // if (a.Mergeable != true) // throw new Exception("This PR is not reporting itself as mergable"); var mergeCommit = a.MergeCommitSha; var queryCommit = client.Repository.Commit.Get("lucasmeijer", "bot_experiment", mergeCommit).Subscribe(commit => { var referenceCommit = commit.Parents.First(p => p != a.Head); Console.WriteLine($"##vso[task.setvariable variable=PullRequestBase;isOutput=true]{referenceCommit.Sha}"); Console.WriteLine($"##vso[task.setvariable variable=TestMergeCommit;isOutput=true]{commit.Sha}"); Console.WriteLine($"##vso[task.setvariable variable=PullID;isOutput=true]{pullID}"); Console.WriteLine($"referenceCommit is {referenceCommit.Sha}"); Console.WriteLine($"testMergeCommit is {commit.Sha}"); Console.WriteLine($"Base is {a.Base.Sha}"); Console.WriteLine($"Head is {a.Head.Sha}"); Console.WriteLine($"Title is: {a.Title}"); }, onCompleted: () => Environment.Exit(0) ); }, onError: (e) => { Console.WriteLine("ERROR!!! " + e); Environment.Exit(1); }); Console.ReadLine(); }
/// <summary> /// Pulls down commit data from GitHub and creates events for each commit, which are then streamed to Splunk. /// </summary> /// <remarks> /// This function will be invoked once for each instance of the modular input, though that invocation /// may or may not be in separate processes, depending on how the modular input is configured. It should /// extract the arguments it needs from <tt>inputDefinition</tt>, then write events to <tt>eventWriter</tt> /// (which is thread safe). /// </remarks> /// <param name="inputDefinition">The definition for this instance of the GitHub input, representing a GitHub repository.</param> /// <param name="eventWriter">An object that handles writing events to Splunk.</param> public override async Task StreamEventsAsync(InputDefinition inputDefinition, EventWriter eventWriter) { var owner = ((SingleValueParameter)inputDefinition.Parameters["Owner"]).ToString(); var repository = ((SingleValueParameter)inputDefinition.Parameters["Repository"]).ToString(); var checkpointFilePath = Path.Combine(inputDefinition.CheckpointDirectory, owner + " " + repository + ".txt"); var productHeader = new ProductHeaderValue("splunk-sdk-csharp-github-commits"); ObservableGitHubClient client; if (!inputDefinition.Parameters.ContainsKey("Token") || String.IsNullOrWhiteSpace(((SingleValueParameter)inputDefinition.Parameters["Token"]).ToString())) { client = new ObservableGitHubClient(productHeader); } else { client = new ObservableGitHubClient(productHeader, new InMemoryCredentialStore(new Credentials(((SingleValueParameter)inputDefinition.Parameters["Token"]).ToString()))); } var shaKeys = new HashSet <string>(); var fileReader = new StreamReader(File.Open(checkpointFilePath, System.IO.FileMode.OpenOrCreate)); string line; while (!String.IsNullOrWhiteSpace(line = await fileReader.ReadLineAsync())) { shaKeys.Add(line); } fileReader.Close(); bool done = false; var fileWriter = new StreamWriter(checkpointFilePath); // Use Rx to stream an event for each commit as they come in client.Repository.Commits.GetAll(owner, repository).Subscribe( async githubCommit => { if (!shaKeys.Contains(githubCommit.Sha)) { await StreamCommit(githubCommit, eventWriter, owner, repository); await fileWriter.WriteLineAsync(githubCommit.Sha); // Write to the checkpoint file shaKeys.Add(githubCommit.Sha); await eventWriter.LogAsync(Severity.Info, repository + " indexed a Github commit with sha: " + githubCommit.Sha); } }, async e => { //error handing goes here await eventWriter.LogAsync(Severity.Error, e.GetType() + " - " + e.StackTrace); }, () => { //completion handling goes here fileWriter.Close(); done = true; } ); // Wait for Rx subscribe to finish above while (!done) { await Task.Delay(100); } }
public async Task MarksNotificationsRead() { var client = new ObservableGitHubClient(Helper.GetAuthenticatedClient()); await client.Activity.Notifications.MarkAsRead(); }