Skip to content
This repository was archived by the owner on Jun 21, 2023. It is now read-only.

Commit accbeaf

Browse files
committed
Merge master into release/1.0.99.7
2 parents 455e6e3 + d847435 commit accbeaf

File tree

144 files changed

+3026
-1940
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

144 files changed

+3026
-1940
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ build/
2020

2121
# Roslyn cache directories
2222
*.ide/
23+
.vs/
2324

2425
# MSTest test Results
2526
[Tt]est[Rr]esult*/

ISSUE_TEMPLATE.md

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
Hello! Please read the contributing guidelines before submitting an issue.
2+
3+
- GitHub Extension version:
4+
- Visual Studio version:
5+
6+
__What happened__ (with steps, logs and screenshots, if possible)

appveyor.yml

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
version: '{build}'
2+
install:
3+
- ps: >-
4+
$full_build = Test-Path env:GHFVS_KEY
5+
6+
git submodule init
7+
8+
if ($full_build) {
9+
$fileContent = "-----BEGIN RSA PRIVATE KEY-----`n"
10+
$fileContent += $env:GHFVS_KEY.Replace(' ', "`n")
11+
$fileContent += "`n-----END RSA PRIVATE KEY-----`n"
12+
Set-Content c:\users\appveyor\.ssh\id_rsa $fileContent
13+
} else {
14+
git submodule deinit script
15+
}
16+
17+
git submodule update
18+
19+
nuget restore GitHubVS.sln
20+
build_script:
21+
- cmd: msbuild "GitHubVS.sln" /logger:"C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll" /p:Configuration=Release /p:DeployExtension=false /verbosity:minimal /p:VisualStudioVersion=14.0
22+
test_script:
23+
- ps: >-
24+
scripts\Run-Nunit.ps1 TrackingCollectionTests 180 Release -AppVeyor
25+
26+
scripts\Run-Xunit.ps1 UnitTests 180 Release -AppVeyor

script

scripts/Run-NUnit.ps1

+62
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
<#
2+
.SYNOPSIS
3+
Runs NUnit
4+
#>
5+
6+
[CmdletBinding()]
7+
Param(
8+
[Parameter(Mandatory=$true)]
9+
[ValidateNotNullOrEmpty()]
10+
[string]
11+
$Project,
12+
[int]
13+
$TimeoutDuration,
14+
[string]
15+
$Configuration,
16+
[switch]
17+
$AppVeyor = $false
18+
)
19+
20+
$rootDirectory = Split-Path (Split-Path $MyInvocation.MyCommand.Path)
21+
Push-Location $rootDirectory
22+
$dll = "src\$Project\bin\$Configuration\$Project.dll"
23+
24+
if ($AppVeyor) {
25+
$nunitDirectory = Join-Path $rootDirectory packages\NUnit.Runners.2.6.4\tools
26+
$consoleRunner = Join-Path $nunitDirectory nunit-console-x86.exe
27+
$args = "-noshadow", "-framework:net-4.5", "-exclude:Timings", $dll
28+
[object[]] $output = "$consoleRunner " + ($args -join " ")
29+
& $consoleRunner ($args | %{ "`"$_`"" })
30+
if($LastExitCode -ne 0) {
31+
$host.SetShouldExit($LastExitCode)
32+
}
33+
} else {
34+
$nunitDirectory = Join-Path $rootDirectory packages\NUnit.Runners.2.6.4\tools
35+
$consoleRunner = Join-Path $nunitDirectory nunit-console-x86.exe
36+
37+
$xml = Join-Path $rootDirectory "nunit-$Project.xml"
38+
$outputPath = [System.IO.Path]::GetTempFileName()
39+
40+
$args = "-noshadow", "-xml:$xml", "-framework:net-4.5", "-exclude:Timings", $dll
41+
[object[]] $output = "$consoleRunner " + ($args -join " ")
42+
43+
$process = Start-Process -PassThru -NoNewWindow -RedirectStandardOutput $outputPath $consoleRunner ($args | %{ "`"$_`"" })
44+
Wait-Process -InputObject $process -Timeout $TimeoutDuration -ErrorAction SilentlyContinue
45+
if ($process.HasExited) {
46+
$output += Get-Content $outputPath
47+
$exitCode = $process.ExitCode
48+
} else {
49+
$output += "Tests timed out. Backtrace:"
50+
$output += Get-DotNetStack $process.Id
51+
$exitCode = 9999
52+
}
53+
54+
Stop-Process -InputObject $process
55+
Remove-Item $outputPath
56+
Pop-Location
57+
58+
$result = New-Object System.Object
59+
$result | Add-Member -Type NoteProperty -Name Output -Value $output
60+
$result | Add-Member -Type NoteProperty -Name ExitCode -Value $exitCode
61+
$result
62+
}

scripts/Run-XUnit.ps1

+62
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
<#
2+
.SYNOPSIS
3+
Runs xUnit
4+
#>
5+
6+
[CmdletBinding()]
7+
Param(
8+
[Parameter(Mandatory=$true)]
9+
[ValidateNotNullOrEmpty()]
10+
[string]
11+
$Project,
12+
[int]
13+
$TimeoutDuration,
14+
[string]
15+
$Configuration,
16+
[switch]
17+
$AppVeyor = $false
18+
)
19+
20+
$rootDirectory = Split-Path (Split-Path $MyInvocation.MyCommand.Path)
21+
Push-Location $rootDirectory
22+
23+
$dll = "src\$Project\bin\$Configuration\$Project.dll"
24+
25+
if ($AppVeyor) {
26+
$xunitDirectory = Join-Path $rootDirectory packages\xunit.runner.console.2.1.0\tools
27+
$consoleRunner = Join-Path $xunitDirectory xunit.console.x86.exe
28+
$args = $dll, "-noshadow", "-parallel", "all", "-appveyor"
29+
[object[]] $output = "$consoleRunner " + ($args -join " ")
30+
& $consoleRunner ($args | %{ "`"$_`"" })
31+
if($LastExitCode -ne 0) {
32+
$host.SetShouldExit($LastExitCode)
33+
}
34+
} else {
35+
$xunitDirectory = Join-Path $rootDirectory packages\xunit.runner.console.2.1.0\tools
36+
$consoleRunner = Join-Path $xunitDirectory xunit.console.x86.exe
37+
$xml = Join-Path $rootDirectory "nunit-$Project.xml"
38+
$outputPath = [System.IO.Path]::GetTempFileName()
39+
40+
$args = $dll, "-noshadow", "-xml", $xml, "-parallel", "all"
41+
42+
[object[]] $output = "$consoleRunner " + ($args -join " ")
43+
44+
$process = Start-Process -PassThru -NoNewWindow -RedirectStandardOutput $outputPath $consoleRunner ($args | %{ "`"$_`"" })
45+
Wait-Process -InputObject $process -Timeout $TimeoutDuration -ErrorAction SilentlyContinue
46+
if ($process.HasExited) {
47+
$output += Get-Content $outputPath
48+
$exitCode = $process.ExitCode
49+
} else {
50+
$output += "Tests timed out. Backtrace:"
51+
$output += Get-DotNetStack $process.Id
52+
$exitCode = 9999
53+
}
54+
Stop-Process -InputObject $process
55+
Remove-Item $outputPath
56+
Pop-Location
57+
58+
$result = New-Object System.Object
59+
$result | Add-Member -Type NoteProperty -Name Output -Value $output
60+
$result | Add-Member -Type NoteProperty -Name ExitCode -Value $exitCode
61+
$result
62+
}

src/DesignTimeStyleHelper/DesignTimeStyleHelper.csproj

+3
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,9 @@
120120
</Page>
121121
</ItemGroup>
122122
<ItemGroup>
123+
<Compile Include="..\common\SolutionInfo.cs">
124+
<Link>Properties\SolutionInfo.cs</Link>
125+
</Compile>
123126
<Compile Include="Properties\AssemblyInfo.cs">
124127
<SubType>Code</SubType>
125128
</Compile>
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,8 @@
11
using System.Reflection;
2-
using System.Resources;
3-
using System.Runtime.CompilerServices;
4-
using System.Runtime.InteropServices;
52
using System.Windows;
63

7-
// General Information about an assembly is controlled through the following
8-
// set of attributes. Change these attribute values to modify the information
9-
// associated with an assembly.
104
[assembly: AssemblyTitle("DesignTimeStyleHelper")]
11-
[assembly: AssemblyDescription("")]
12-
[assembly: AssemblyConfiguration("")]
13-
[assembly: AssemblyCompany("")]
14-
[assembly: AssemblyProduct("DesignTimeStyleHelper")]
15-
[assembly: AssemblyCopyright("Copyright © 2015")]
16-
[assembly: AssemblyTrademark("")]
17-
[assembly: AssemblyCulture("")]
18-
19-
// Setting ComVisible to false makes the types in this assembly not visible
20-
// to COM components. If you need to access a type in this assembly from
21-
// COM, set the ComVisible attribute to true on that type.
22-
[assembly: ComVisible(false)]
5+
[assembly: AssemblyDescription("Helper app for UI testing")]
236

247
//In order to begin building localizable applications, set
258
//<UICulture>CultureYouAreCodingWith</UICulture> in your .csproj file
@@ -39,17 +22,3 @@
3922
//(used if a resource is not found in the page,
4023
// app, or any theme specific resource dictionaries)
4124
)]
42-
43-
44-
// Version information for an assembly consists of the following four values:
45-
//
46-
// Major Version
47-
// Minor Version
48-
// Build Number
49-
// Revision
50-
//
51-
// You can specify all the values or you can default the Build and Revision Numbers
52-
// by using the '*' as shown below:
53-
// [assembly: AssemblyVersion("1.0.*")]
54-
[assembly: AssemblyVersion("1.0.0.0")]
55-
[assembly: AssemblyFileVersion("1.0.0.0")]

src/GitHub.App/Api/ApiClient.cs

+10-5
Original file line numberDiff line numberDiff line change
@@ -232,20 +232,25 @@ public IObservable<PullRequest> GetPullRequestsForRepository(string owner, strin
232232
{
233233
return gitHubClient.PullRequest.GetAllForRepository(owner, name,
234234
new PullRequestRequest {
235-
State = ItemState.All,
235+
State = ItemStateFilter.All,
236236
SortProperty = PullRequestSort.Updated,
237237
SortDirection = SortDirection.Descending
238238
});
239239
}
240240

241-
public IObservable<Branch> GetBranches(string owner, string repo)
241+
public IObservable<PullRequest> CreatePullRequest(NewPullRequest pullRequest, string owner, string repo)
242242
{
243-
return gitHubClient.Repository.GetAllBranches(owner, repo);
243+
return gitHubClient.PullRequest.Create(owner, repo, pullRequest);
244244
}
245245

246-
public IObservable<PullRequest> CreatePullRequest(NewPullRequest pullRequest, string owner, string repo)
246+
public IObservable<Repository> GetRepositories()
247247
{
248-
return gitHubClient.PullRequest.Create(owner, repo, pullRequest);
248+
return gitHubClient.Repository.GetAllForCurrent();
249+
}
250+
251+
public IObservable<Branch> GetBranches(string owner, string repo)
252+
{
253+
return gitHubClient.Repository.GetAllBranches(owner, repo);
249254
}
250255
}
251256
}

src/GitHub.App/Caches/CacheIndex.cs

+5
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@ namespace GitHub.Caches
1010
{
1111
public class CacheIndex
1212
{
13+
public const string PRPrefix = "index:pr";
14+
public const string RepoPrefix = "index:repos";
15+
public const string GitIgnoresPrefix = "index:ignores";
16+
public const string LicensesPrefix = "index:licenses";
17+
1318
public static CacheIndex Create(string key)
1419
{
1520
return new CacheIndex { IndexKey = key };

src/GitHub.App/Extensions/AkavacheExtensions.cs

+9-12
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ public static IObservable<T> GetAndFetchLatestFromIndex<T>(
166166
this IBlobCache blobCache,
167167
string key,
168168
Func<IObservable<T>> fetchFunc,
169-
Action<string> removedItemsCallback,
169+
Action<T> removedItemsCallback,
170170
TimeSpan refreshInterval,
171171
TimeSpan maxCacheDuration)
172172
where T : CacheItem
@@ -194,35 +194,31 @@ public static IObservable<T> GetAndFetchLatestFromIndex<T>(
194194
static IObservable<T> GetAndFetchLatestFromIndex<T>(this IBlobCache This,
195195
string key,
196196
Func<IObservable<T>> fetchFunc,
197-
Action<string> removedItemsCallback,
197+
Action<T> removedItemsCallback,
198198
Func<DateTimeOffset, bool> fetchPredicate = null,
199199
DateTimeOffset? absoluteExpiration = null,
200200
bool shouldInvalidateOnError = false)
201201
where T : CacheItem
202202
{
203203
var idx = Observable.Defer(() => This.GetOrCreateObject(key, () => CacheIndex.Create(key))).Replay().RefCount();
204-
204+
205205

206206
var fetch = idx
207207
.Select(x => Tuple.Create(x, fetchPredicate == null || !x.Keys.Any() || fetchPredicate(x.UpdatedAt)))
208208
.Where(predicateIsTrue => predicateIsTrue.Item2)
209209
.Select(x => x.Item1)
210210
.Select(index => index.Clear())
211-
.SelectMany(index =>
212-
{
213-
var fetchObs = fetchFunc()
211+
.SelectMany(index => fetchFunc()
214212
.Catch<T, Exception>(ex =>
215213
{
216214
var shouldInvalidate = shouldInvalidateOnError ?
217215
This.InvalidateObject<CacheIndex>(key) :
218216
Observable.Return(Unit.Default);
219217
return shouldInvalidate.SelectMany(__ => Observable.Throw<T>(ex));
220-
});
221-
222-
return fetchObs
218+
})
223219
.SelectMany(x => x.Save<T>(This, key, absoluteExpiration))
224-
.Do(x => index.Add(key, x));
225-
});
220+
.Do(x => index.Add(key, x))
221+
);
226222

227223
var cache = idx
228224
.SelectMany(index => This.GetObjects<T>(index.Keys.ToList()))
@@ -237,7 +233,8 @@ static IObservable<T> GetAndFetchLatestFromIndex<T>(this IBlobCache This,
237233
var list = index.OldKeys.Except(index.Keys);
238234
if (!list.Any())
239235
return;
240-
foreach (var d in list)
236+
var removed = await This.GetObjects<T>(list);
237+
foreach (var d in removed.Values)
241238
removedItemsCallback(d);
242239
await This.InvalidateObjects<T>(list);
243240
})

src/GitHub.App/Factories/RepositoryHostFactory.cs

+5-2
Original file line numberDiff line numberDiff line change
@@ -19,28 +19,31 @@ public class RepositoryHostFactory : IRepositoryHostFactory
1919
readonly IAvatarProvider avatarProvider;
2020
readonly ITwoFactorChallengeHandler twoFactorChallengeHandler;
2121
readonly CompositeDisposable hosts = new CompositeDisposable();
22+
readonly IUsageTracker usage;
2223

2324
[ImportingConstructor]
2425
public RepositoryHostFactory(
2526
IApiClientFactory apiClientFactory,
2627
IHostCacheFactory hostCacheFactory,
2728
ILoginCache loginCache,
2829
IAvatarProvider avatarProvider,
29-
ITwoFactorChallengeHandler twoFactorChallengeHandler)
30+
ITwoFactorChallengeHandler twoFactorChallengeHandler,
31+
IUsageTracker usage)
3032
{
3133
this.apiClientFactory = apiClientFactory;
3234
this.hostCacheFactory = hostCacheFactory;
3335
this.loginCache = loginCache;
3436
this.avatarProvider = avatarProvider;
3537
this.twoFactorChallengeHandler = twoFactorChallengeHandler;
38+
this.usage = usage;
3639
}
3740

3841
public IRepositoryHost Create(HostAddress hostAddress)
3942
{
4043
var apiClient = apiClientFactory.Create(hostAddress);
4144
var hostCache = hostCacheFactory.Create(hostAddress);
4245
var modelService = new ModelService(apiClient, hostCache, avatarProvider);
43-
var host = new RepositoryHost(apiClient, modelService, loginCache, twoFactorChallengeHandler);
46+
var host = new RepositoryHost(apiClient, modelService, loginCache, twoFactorChallengeHandler, usage);
4447
hosts.Add(host);
4548
return host;
4649
}

src/GitHub.App/GitHub.App.csproj

+1-5
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
<DefineConstants>DEBUG;TRACE</DefineConstants>
3131
<ErrorReport>prompt</ErrorReport>
3232
<WarningLevel>4</WarningLevel>
33-
<RunCodeAnalysis>false</RunCodeAnalysis>
33+
<RunCodeAnalysis>true</RunCodeAnalysis>
3434
<CodeAnalysisRuleSet>..\common\GitHubVS.ruleset</CodeAnalysisRuleSet>
3535
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
3636
<CodeAnalysisIgnoreGeneratedCode>true</CodeAnalysisIgnoreGeneratedCode>
@@ -119,9 +119,6 @@
119119
<None Include="..\..\script\Key.snk" Condition="$(Buildtype) == 'Internal'">
120120
<Link>Key.snk</Link>
121121
</None>
122-
<Compile Include="..\..\script\src\MetricsService.cs" Condition="$(Buildtype) == 'Internal'">
123-
<Link>Services\MetricsService.cs</Link>
124-
</Compile>
125122
<Compile Include="Caches\CacheIndex.cs" />
126123
<Compile Include="Caches\CacheItem.cs" />
127124
<Compile Include="Caches\ImageCache.cs" />
@@ -196,7 +193,6 @@
196193
<Compile Include="Services\StandardUserErrors.cs" />
197194
<Compile Include="Controllers\UIController.cs" />
198195
<Compile Include="Services\Translation.cs" />
199-
<Compile Include="Services\UsageTracker.cs" />
200196
<Compile Include="UserErrors\PublishRepositoryUserError.cs" />
201197
<Compile Include="UserErrors\PrivateRepositoryOnFreeAccountUserError.cs" />
202198
<Compile Include="UserErrors\PrivateRepositoryQuotaExceededUserError.cs" />

0 commit comments

Comments
 (0)