Skip to content

Commit

Permalink
Merge pull request #383 from microsoft/staging
Browse files Browse the repository at this point in the history
Release - 4/23/24
  • Loading branch information
EricJohnson327 authored Apr 22, 2024
2 parents ad208ab + d73afd7 commit 8298c31
Show file tree
Hide file tree
Showing 116 changed files with 999 additions and 2,274 deletions.
23 changes: 0 additions & 23 deletions GitHubExtension.sln
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "scripts", "scripts", "{A371
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GitHubExtension.Test", "test\GitHubExtension\GitHubExtension.Test.csproj", "{D8EFDB34-7019-4807-AE97-1B50891F345D}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DevHome.Logging", "src\Logging\DevHome.Logging.csproj", "{FEEEDA62-F746-4160-A3A8-1EE74137F8AB}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "scripts", "scripts", "{E4D6AB24-08F6-4352-9BB8-8E92148DA618}"
ProjectSection(SolutionItems) = preProject
test\scripts\CleanDevHome.ps1 = test\scripts\CleanDevHome.ps1
Expand Down Expand Up @@ -195,26 +193,6 @@ Global
{D8EFDB34-7019-4807-AE97-1B50891F345D}.Release|x64.Build.0 = Release|x64
{D8EFDB34-7019-4807-AE97-1B50891F345D}.Release|x86.ActiveCfg = Release|x86
{D8EFDB34-7019-4807-AE97-1B50891F345D}.Release|x86.Build.0 = Release|x86
{FEEEDA62-F746-4160-A3A8-1EE74137F8AB}.Debug|Any CPU.ActiveCfg = Debug|x64
{FEEEDA62-F746-4160-A3A8-1EE74137F8AB}.Debug|Any CPU.Build.0 = Debug|x64
{FEEEDA62-F746-4160-A3A8-1EE74137F8AB}.Debug|ARM.ActiveCfg = Debug|x64
{FEEEDA62-F746-4160-A3A8-1EE74137F8AB}.Debug|ARM.Build.0 = Debug|x64
{FEEEDA62-F746-4160-A3A8-1EE74137F8AB}.Debug|arm64.ActiveCfg = Debug|arm64
{FEEEDA62-F746-4160-A3A8-1EE74137F8AB}.Debug|arm64.Build.0 = Debug|arm64
{FEEEDA62-F746-4160-A3A8-1EE74137F8AB}.Debug|x64.ActiveCfg = Debug|x64
{FEEEDA62-F746-4160-A3A8-1EE74137F8AB}.Debug|x64.Build.0 = Debug|x64
{FEEEDA62-F746-4160-A3A8-1EE74137F8AB}.Debug|x86.ActiveCfg = Debug|x86
{FEEEDA62-F746-4160-A3A8-1EE74137F8AB}.Debug|x86.Build.0 = Debug|x86
{FEEEDA62-F746-4160-A3A8-1EE74137F8AB}.Release|Any CPU.ActiveCfg = Release|x64
{FEEEDA62-F746-4160-A3A8-1EE74137F8AB}.Release|Any CPU.Build.0 = Release|x64
{FEEEDA62-F746-4160-A3A8-1EE74137F8AB}.Release|ARM.ActiveCfg = Release|x64
{FEEEDA62-F746-4160-A3A8-1EE74137F8AB}.Release|ARM.Build.0 = Release|x64
{FEEEDA62-F746-4160-A3A8-1EE74137F8AB}.Release|arm64.ActiveCfg = Release|arm64
{FEEEDA62-F746-4160-A3A8-1EE74137F8AB}.Release|arm64.Build.0 = Release|arm64
{FEEEDA62-F746-4160-A3A8-1EE74137F8AB}.Release|x64.ActiveCfg = Release|x64
{FEEEDA62-F746-4160-A3A8-1EE74137F8AB}.Release|x64.Build.0 = Release|x64
{FEEEDA62-F746-4160-A3A8-1EE74137F8AB}.Release|x86.ActiveCfg = Release|x86
{FEEEDA62-F746-4160-A3A8-1EE74137F8AB}.Release|x86.Build.0 = Release|x86
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand All @@ -227,7 +205,6 @@ Global
{8E1764CB-2FFC-4F23-9FC0-BDE84E519319} = {5BDF2709-4299-49C3-B971-B10747F2925D}
{A371A158-E88C-48D1-9397-22844DDC2EF4} = {10E87373-ADA7-408F-9879-0F6BF101BE87}
{D8EFDB34-7019-4807-AE97-1B50891F345D} = {429CEDBA-88C4-4315-9EA1-50AB6DF8855C}
{FEEEDA62-F746-4160-A3A8-1EE74137F8AB} = {5BDF2709-4299-49C3-B971-B10747F2925D}
{E4D6AB24-08F6-4352-9BB8-8E92148DA618} = {429CEDBA-88C4-4315-9EA1-50AB6DF8855C}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
Expand Down
2 changes: 1 addition & 1 deletion build/azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ parameters:
- release

variables:
MSIXVersion: '0.1200'
MSIXVersion: '0.1300'
solution: '**/GitHubExtension.sln'
appxPackageDir: 'AppxPackages'
testOutputArtifactDir: 'TestResults'
Expand Down
2 changes: 1 addition & 1 deletion build/scripts/CreateBuildInfo.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Param(
)

$Major = "0"
$Minor = "12"
$Minor = "13"
$Patch = "99" # default to 99 for local builds

$versionSplit = $Version.Split(".");
Expand Down
16 changes: 10 additions & 6 deletions src/GitHubExtension/Client/GithubClientProvider.cs
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

using DevHome.Logging.Helpers;
using GitHubExtension.DeveloperId;
using Microsoft.Windows.DevHome.SDK;
using Octokit;
using Serilog;

namespace GitHubExtension.Client;

public class GitHubClientProvider
{
private static readonly Lazy<ILogger> _log = new(() => Serilog.Log.ForContext("SourceContext", nameof(GitHubClientProvider)));

private static readonly ILogger Log = _log.Value;

private readonly GitHubClient publicRepoClient;

private static readonly object InstanceLock = new();
Expand Down Expand Up @@ -66,18 +70,18 @@ public async Task<GitHubClient> GetClientForLoggedInDeveloper(bool logRateLimit
GitHubClient client;
if (devIds == null || !devIds.Any())
{
Log.Logger()?.ReportInfo($"No logged in developer, using public GitHub client.");
Log.Information($"No logged in developer, using public GitHub client.");
client = Instance.GetClient();
}
else
{
Log.Logger()?.ReportInfo($"Using authenticated user: {devIds.First().LoginId}");
Log.Information($"Using authenticated user: {devIds.First().LoginId}");
client = devIds.First().GitHubClient;
}

if (client == null)
{
Log.Logger()?.ReportError($"Failed creating GitHubClient.");
Log.Error($"Failed creating GitHubClient.");
return client!;
}

Expand All @@ -86,11 +90,11 @@ public async Task<GitHubClient> GetClientForLoggedInDeveloper(bool logRateLimit
try
{
var miscRateLimit = await client.RateLimit.GetRateLimits();
Log.Logger()?.ReportInfo($"Rate Limit: Remaining: {miscRateLimit.Resources.Core.Remaining} Total: {miscRateLimit.Resources.Core.Limit} Resets: {miscRateLimit.Resources.Core.Reset.ToStringInvariant()}");
Log.Information($"Rate Limit: Remaining: {miscRateLimit.Resources.Core.Remaining} Total: {miscRateLimit.Resources.Core.Limit} Resets: {miscRateLimit.Resources.Core.Reset}");
}
catch (Exception ex)
{
Log.Logger()?.ReportError($"Rate limiting not enabled for server.", ex);
Log.Error(ex, $"Rate limiting not enabled for server.");
}
}

Expand Down
17 changes: 11 additions & 6 deletions src/GitHubExtension/Client/Validation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,17 @@

using GitHubExtension.DataModel;
using Octokit;
using Serilog;

namespace GitHubExtension.Client;

// Validation layer to help parsing GitHub URL.
public static class Validation
{
private static readonly Lazy<ILogger> _log = new(() => Serilog.Log.ForContext("SourceContext", nameof(Validation)));

private static readonly ILogger Log = _log.Value;

private static bool IsValidHttpUri(string uriString, out Uri? uri)
{
return Uri.TryCreate(uriString, UriKind.Absolute, out uri) &&
Expand All @@ -17,15 +22,15 @@ private static bool IsValidHttpUri(string uriString, out Uri? uri)

public static bool IsValidGitHubURL(Uri uri)
{
return IsValidGitHubComURL(uri) || IsValidGitHubEnterpriseServerURL(uri);
return IsValidGitHubComURL(uri) || (IsValidGitHubEnterpriseServerURL(uri) && IsReachableGitHubEnterpriseServerURL(uri).Result);
}

public static bool IsValidGitHubComURL(Uri uri)
{
// Valid GitHub URL has three segments. The first is '/'.
if (uri.Segments.Length < 3 || (!uri.Host.Equals("github.com", StringComparison.OrdinalIgnoreCase) && !uri.Host.Equals("www.github.com", StringComparison.OrdinalIgnoreCase)))
{
Log.Logger()?.ReportDebug($"{uri.OriginalString} is not a valid GitHub uri");
Log.Debug($"{uri.OriginalString} is not a valid GitHub uri");
return false;
}

Expand All @@ -39,7 +44,7 @@ public static bool IsValidGitHubEnterpriseServerURL(Uri server)
// https://docs.github.com/en/[email protected]/admin/configuration/configuring-network-settings/configuring-the-hostname-for-your-instance
if (server.Segments.Length < 3)
{
Log.Logger()?.ReportDebug($"{server.OriginalString} is not a valid GHES repo uri");
Log.Debug($"{server.OriginalString} is not a valid GHES repo uri");
return false;
}

Expand All @@ -56,7 +61,7 @@ public static bool IsValidGitHubURL(string url)
// Above link shows a work around.
if (!IsValidHttpUri(url, out parsedUri) || url == null || parsedUri == null)
{
Log.Logger()?.ReportDebug($"{url} is not a valid http uri");
Log.Debug($"{url} is not a valid http uri");
return false;
}

Expand Down Expand Up @@ -227,13 +232,13 @@ public static async Task<bool> IsReachableGitHubEnterpriseServerURL(Uri server)
var probeResult = await new EnterpriseProbe(new ProductHeaderValue(Constants.DEV_HOME_APPLICATION_NAME)).Probe(server);
if (probeResult != EnterpriseProbeResult.Ok)
{
Log.Logger()?.ReportError($"EnterpriseServer {server.AbsoluteUri} is not reachable");
Log.Error($"EnterpriseServer {server.AbsoluteUri} is not reachable");
return false;
}
}
catch (Exception ex)
{
Log.Logger()?.ReportError($"EnterpriseServer {server.AbsoluteUri} could not be probed.", ex);
Log.Error(ex, $"EnterpriseServer {server.AbsoluteUri} could not be probed.");
return false;
}

Expand Down
6 changes: 5 additions & 1 deletion src/GitHubExtension/DataManager/DataUpdater.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

using Serilog;

namespace GitHubExtension.DataManager;

public class DataUpdater : IDisposable
{
// This is the default interval the timer will run. It is not the interval that we necessarily do work.
private static readonly TimeSpan TimerUpdateInterval = TimeSpan.FromSeconds(5);

private readonly ILogger _logger;
private readonly PeriodicTimer _timer;
private readonly Func<Task> _action;
private CancellationTokenSource _cancelSource;
Expand All @@ -17,6 +20,7 @@ public class DataUpdater : IDisposable

public DataUpdater(TimeSpan interval, Func<Task> action)
{
_logger = Log.Logger.ForContext("SourceContext", nameof(DataUpdater));
_timer = new PeriodicTimer(interval);
_cancelSource = new CancellationTokenSource();
_started = false;
Expand Down Expand Up @@ -64,7 +68,7 @@ protected virtual void Dispose(bool disposing)
{
if (!disposed)
{
DataModel.Log.Logger()?.ReportDebug(ToString(), "Disposing of all Disposable resources.");
_logger.Debug("Disposing of all updater resources.");

if (disposing)
{
Expand Down
Loading

0 comments on commit 8298c31

Please sign in to comment.