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

Commit 5913776

Browse files
authored
Merge branch 'master' into fixes/1948-search-white-space
2 parents 871c112 + d5d223a commit 5913776

File tree

7 files changed

+147
-33
lines changed

7 files changed

+147
-33
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
<ProjectConfiguration>
22
<Settings>
3+
<AdditionalFilesToIncludeForProject>
4+
<Value>xlf\**.*</Value>
5+
</AdditionalFilesToIncludeForProject>
36
<PreviouslyBuiltSuccessfully>True</PreviouslyBuiltSuccessfully>
47
</Settings>
58
</ProjectConfiguration>

src/GitHub.App/Services/RepositoryCloneService.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,20 @@ public async Task CloneRepository(
121121
try
122122
{
123123
await vsGitServices.Clone(cloneUrl, repositoryPath, true, progress);
124+
124125
await usageTracker.IncrementCounter(x => x.NumberOfClones);
126+
127+
var repositoryUrl = new UriString(cloneUrl).ToRepositoryUrl();
128+
var isDotCom = HostAddress.IsGitHubDotComUri(repositoryUrl);
129+
if (isDotCom)
130+
{
131+
await usageTracker.IncrementCounter(x => x.NumberOfGitHubClones);
132+
}
133+
else
134+
{
135+
// If it isn't a GitHub URL, assume it's an Enterprise URL
136+
await usageTracker.IncrementCounter(x => x.NumberOfEnterpriseClones);
137+
}
125138
}
126139
catch (Exception ex)
127140
{

src/GitHub.App/ViewModels/Dialog/Clone/RepositoryCloneViewModel.cs

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ public class RepositoryCloneViewModel : ViewModelBase, IRepositoryCloneViewModel
2323
readonly IOperatingSystem os;
2424
readonly IConnectionManager connectionManager;
2525
readonly IRepositoryCloneService service;
26+
readonly IUsageService usageService;
27+
readonly IUsageTracker usageTracker;
2628
readonly IReadOnlyList<IRepositoryCloneTabViewModel> tabs;
2729
string path;
2830
IRepositoryModel previousRepository;
@@ -34,13 +36,17 @@ public RepositoryCloneViewModel(
3436
IOperatingSystem os,
3537
IConnectionManager connectionManager,
3638
IRepositoryCloneService service,
39+
IUsageService usageService,
40+
IUsageTracker usageTracker,
3741
IRepositorySelectViewModel gitHubTab,
3842
IRepositorySelectViewModel enterpriseTab,
3943
IRepositoryUrlViewModel urlTab)
4044
{
4145
this.os = os;
4246
this.connectionManager = connectionManager;
4347
this.service = service;
48+
this.usageService = usageService;
49+
this.usageTracker = usageTracker;
4450

4551
GitHubTab = gitHubTab;
4652
EnterpriseTab = enterpriseTab;
@@ -119,6 +125,33 @@ public async Task InitializeAsync(IConnection connection)
119125
}
120126

121127
this.WhenAnyValue(x => x.SelectedTabIndex).Subscribe(x => tabs[x].Activate().Forget());
128+
129+
// Users in group A will see the URL tab by default
130+
if (await IsGroupA().ConfigureAwait(false))
131+
{
132+
SelectedTabIndex = 2;
133+
}
134+
135+
switch (SelectedTabIndex)
136+
{
137+
case 0:
138+
usageTracker.IncrementCounter(model => model.NumberOfCloneViewGitHubTab).Forget();
139+
break;
140+
case 1:
141+
usageTracker.IncrementCounter(model => model.NumberOfCloneViewEnterpriseTab).Forget();
142+
break;
143+
case 2:
144+
usageTracker.IncrementCounter(model => model.NumberOfCloneViewUrlTab).Forget();
145+
break;
146+
}
147+
}
148+
149+
// Put 50% of users in group A
150+
async Task<bool> IsGroupA()
151+
{
152+
var userGuid = await usageService.GetUserGuid().ConfigureAwait(false);
153+
var lastByte = userGuid.ToByteArray().Last();
154+
return lastByte % 2 == 0;
122155
}
123156

124157
void BrowseForDirectory()

src/GitHub.Exports/Models/UsageModel.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,11 @@ public class MeasuresModel
8686
public int ExecuteToggleInlineCommentMarginCommand { get; set; }
8787
public int NumberOfPullRequestFileMarginToggleInlineCommentMargin { get; set; }
8888
public int NumberOfPullRequestFileMarginViewChanges { get; set; }
89+
public int NumberOfCloneViewGitHubTab { get; set; }
90+
public int NumberOfCloneViewEnterpriseTab { get; set; }
91+
public int NumberOfCloneViewUrlTab { get; set; }
92+
public int NumberOfGitHubClones { get; set; }
93+
public int NumberOfEnterpriseClones { get; set; }
8994
}
9095
}
9196
}

src/GitHub.VisualStudio/xlf/GitHub.VisualStudio.vsct.zh-CN.xlf

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<xliff xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="urn:oasis:names:tc:xliff:document:1.2" version="1.2" xsi:schemaLocation="urn:oasis:names:tc:xliff:document:1.2 xliff-core-1.2-transitional.xsd">
33
<file datatype="xml" source-language="en" target-language="zh-CN" original="../GitHub.VisualStudio.vsct">
44
<body>
5-
<trans-unit id="addConnectionCommand|ButtonText">
5+
<trans-unit id="addConnectionCommand|ButtonText" approved="yes">
66
<source>&amp;Connect to GitHub</source>
77
<target xml:lang="zh-CN" state="translated">连接至GitHub(&amp;C)</target>
88
<note/>
@@ -12,7 +12,7 @@
1212
<target xml:lang="zh-CN" state="needs-translation">.GitHub.ConnectToGitHub</target>
1313
<note/>
1414
</trans-unit>
15-
<trans-unit id="backCommand|ButtonText">
15+
<trans-unit id="backCommand|ButtonText" approved="yes">
1616
<source>Back</source>
1717
<target xml:lang="zh-CN" state="translated">返回</target>
1818
<note/>
@@ -22,7 +22,7 @@
2222
<target xml:lang="zh-CN" state="needs-translation">.GitHub.Back</target>
2323
<note/>
2424
</trans-unit>
25-
<trans-unit id="copyLinkCommand|ButtonText">
25+
<trans-unit id="copyLinkCommand|ButtonText" approved="yes">
2626
<source>Copy link to clipboard</source>
2727
<target xml:lang="zh-CN" state="translated">复制连结到剪贴簿</target>
2828
<note/>
@@ -32,7 +32,7 @@
3232
<target xml:lang="zh-CN" state="needs-translation">.GitHub.CopyLink</target>
3333
<note/>
3434
</trans-unit>
35-
<trans-unit id="forwardCommand|ButtonText">
35+
<trans-unit id="forwardCommand|ButtonText" approved="yes">
3636
<source>Forward</source>
3737
<target xml:lang="zh-CN" state="translated">转发</target>
3838
<note/>
@@ -42,27 +42,27 @@
4242
<target xml:lang="zh-CN" state="needs-translation">.GitHub.Forward</target>
4343
<note/>
4444
</trans-unit>
45-
<trans-unit id="githubCommand|ButtonText">
45+
<trans-unit id="githubCommand|ButtonText" approved="yes">
4646
<source>View on GitHub</source>
47-
<target xml:lang="zh-CN" state="needs-translation">View on GitHub</target>
47+
<target xml:lang="zh-CN" state="translated">在GitHub上打开</target>
4848
<note/>
4949
</trans-unit>
5050
<trans-unit id="githubCommand|LocCanonicalName">
5151
<source>.GitHub.ViewOnGitHub</source>
5252
<target xml:lang="zh-CN" state="needs-translation">.GitHub.ViewOnGitHub</target>
5353
<note/>
5454
</trans-unit>
55-
<trans-unit id="goToSolutionOrPullRequestFileCommand|ButtonText">
55+
<trans-unit id="goToSolutionOrPullRequestFileCommand|ButtonText" approved="yes">
5656
<source>Go To Solution/PR File</source>
57-
<target xml:lang="zh-CN" state="needs-translation">Go To Solution/PR File</target>
57+
<target xml:lang="zh-CN" state="translated">转到解决方案/PR文件</target>
5858
<note/>
5959
</trans-unit>
6060
<trans-unit id="goToSolutionOrPullRequestFileCommand|LocCanonicalName">
6161
<source>.GitHub.GoToSolutionOrPRFile</source>
6262
<target xml:lang="zh-CN" state="needs-translation">.GitHub.GoToSolutionOrPRFile</target>
6363
<note/>
6464
</trans-unit>
65-
<trans-unit id="helpCommand|ButtonText">
65+
<trans-unit id="helpCommand|ButtonText" approved="yes">
6666
<source>Help</source>
6767
<target xml:lang="zh-CN" state="translated">帮助</target>
6868
<note/>
@@ -72,17 +72,17 @@
7272
<target xml:lang="zh-CN" state="needs-translation">.GitHub.Help</target>
7373
<note/>
7474
</trans-unit>
75-
<trans-unit id="idBlameCommand|ButtonText">
75+
<trans-unit id="idBlameCommand|ButtonText" approved="yes">
7676
<source>Blame</source>
77-
<target xml:lang="zh-CN" state="needs-translation">Blame</target>
77+
<target xml:lang="zh-CN" state="translated">追溯</target>
7878
<note/>
7979
</trans-unit>
8080
<trans-unit id="idBlameCommand|LocCanonicalName">
8181
<source>.GitHub.Blame</source>
8282
<target xml:lang="zh-CN" state="needs-translation">.GitHub.Blame</target>
8383
<note/>
8484
</trans-unit>
85-
<trans-unit id="idCreateGistCommand|ButtonText">
85+
<trans-unit id="idCreateGistCommand|ButtonText" approved="yes">
8686
<source>Create a GitHub Gist</source>
8787
<target xml:lang="zh-CN" state="translated">创建一个GitHub Gist</target>
8888
<note/>
@@ -92,9 +92,9 @@
9292
<target xml:lang="zh-CN" state="needs-translation">.GitHub.CreateGist</target>
9393
<note/>
9494
</trans-unit>
95-
<trans-unit id="idCreateGistEnterpriseCommand|ButtonText">
95+
<trans-unit id="idCreateGistEnterpriseCommand|ButtonText" approved="yes">
9696
<source>Create an Enterprise Gist</source>
97-
<target xml:lang="zh-CN" state="needs-translation">Create an Enterprise Gist</target>
97+
<target xml:lang="zh-CN" state="translated">创建企业Gist</target>
9898
<note/>
9999
</trans-unit>
100100
<trans-unit id="idCreateGistEnterpriseCommand|LocCanonicalName">
@@ -104,12 +104,12 @@
104104
</trans-unit>
105105
<trans-unit id="idGitHubContextMenu|ButtonText">
106106
<source>GitHub</source>
107-
<target xml:lang="zh-CN" state="translated">GitHub</target>
107+
<target xml:lang="zh-CN" state="needs-translation">GitHub</target>
108108
<note/>
109109
</trans-unit>
110110
<trans-unit id="idGitHubContextMenu|CommandName">
111111
<source>GitHub</source>
112-
<target xml:lang="zh-CN" state="translated">GitHub</target>
112+
<target xml:lang="zh-CN" state="needs-translation">GitHub</target>
113113
<note/>
114114
</trans-unit>
115115
<trans-unit id="idGitHubToolbar|ButtonText">
@@ -122,37 +122,37 @@
122122
<target xml:lang="zh-CN" state="needs-translation">Window Toolbar</target>
123123
<note/>
124124
</trans-unit>
125-
<trans-unit id="openFromClipboardCommand|ButtonText">
125+
<trans-unit id="openFromClipboardCommand|ButtonText" approved="yes">
126126
<source>Open from clipboard</source>
127-
<target xml:lang="zh-CN" state="needs-translation">Open from clipboard</target>
127+
<target xml:lang="zh-CN" state="translated">从剪贴板打开</target>
128128
<note/>
129129
</trans-unit>
130130
<trans-unit id="openFromClipboardCommand|LocCanonicalName">
131131
<source>.GitHub.OpenFromClipboard</source>
132132
<target xml:lang="zh-CN" state="needs-translation">.GitHub.OpenFromClipboard</target>
133133
<note/>
134134
</trans-unit>
135-
<trans-unit id="openFromUrlCommand|ButtonText">
135+
<trans-unit id="openFromUrlCommand|ButtonText" approved="yes">
136136
<source>Open from GitHub...</source>
137-
<target xml:lang="zh-CN" state="needs-translation">Open from GitHub...</target>
137+
<target xml:lang="zh-CN" state="translated">从 GitHub 打开...</target>
138138
<note/>
139139
</trans-unit>
140140
<trans-unit id="openFromUrlCommand|LocCanonicalName">
141141
<source>.GitHub.OpenFromUrl</source>
142142
<target xml:lang="zh-CN" state="needs-translation">.GitHub.OpenFromUrl</target>
143143
<note/>
144144
</trans-unit>
145-
<trans-unit id="openLinkCommand|ButtonText">
145+
<trans-unit id="openLinkCommand|ButtonText" approved="yes">
146146
<source>Open on GitHub</source>
147-
<target xml:lang="zh-CN" state="needs-translation">Open on GitHub</target>
147+
<target xml:lang="zh-CN" state="translated">在GitHub上打开</target>
148148
<note/>
149149
</trans-unit>
150150
<trans-unit id="openLinkCommand|LocCanonicalName">
151151
<source>.GitHub.OpenLink</source>
152152
<target xml:lang="zh-CN" state="needs-translation">.GitHub.OpenLink</target>
153153
<note/>
154154
</trans-unit>
155-
<trans-unit id="pullRequestCommand|ButtonText">
155+
<trans-unit id="pullRequestCommand|ButtonText" approved="yes">
156156
<source>Pull Requests</source>
157157
<target xml:lang="zh-CN" state="translated">拉取请求</target>
158158
<note/>
@@ -162,7 +162,7 @@
162162
<target xml:lang="zh-CN" state="needs-translation">.GitHub.PullRequests</target>
163163
<note/>
164164
</trans-unit>
165-
<trans-unit id="refreshCommand|ButtonText">
165+
<trans-unit id="refreshCommand|ButtonText" approved="yes">
166166
<source>Refresh</source>
167167
<target xml:lang="zh-CN" state="translated">刷新</target>
168168
<note/>
@@ -172,7 +172,7 @@
172172
<target xml:lang="zh-CN" state="needs-translation">.GitHub.Refresh</target>
173173
<note/>
174174
</trans-unit>
175-
<trans-unit id="showCurrentPullRequestCommand|ButtonText">
175+
<trans-unit id="showCurrentPullRequestCommand|ButtonText" approved="yes">
176176
<source>Show Current Pull Request</source>
177177
<target xml:lang="zh-CN" state="translated">显示当前推送请求</target>
178178
<note/>
@@ -184,17 +184,17 @@
184184
</trans-unit>
185185
<trans-unit id="showGitHubPaneCommand|ButtonText">
186186
<source>GitHub</source>
187-
<target xml:lang="zh-CN" state="translated">GitHub</target>
187+
<target xml:lang="zh-CN" state="needs-translation">GitHub</target>
188188
<note/>
189189
</trans-unit>
190190
<trans-unit id="showGitHubPaneCommand|LocCanonicalName">
191191
<source>.GitHub.ShowGitHubPane</source>
192192
<target xml:lang="zh-CN" state="needs-translation">.GitHub.ShowGitHubPane</target>
193193
<note/>
194194
</trans-unit>
195-
<trans-unit id="syncSubmodulesCommand|ButtonText">
195+
<trans-unit id="syncSubmodulesCommand|ButtonText" approved="yes">
196196
<source>Sync Submodules</source>
197-
<target xml:lang="zh-CN" state="needs-translation">Sync Submodules</target>
197+
<target xml:lang="zh-CN" state="translated">同步子模块</target>
198198
<note/>
199199
</trans-unit>
200200
<trans-unit id="syncSubmodulesCommand|LocCanonicalName">

test/GitHub.App.UnitTests/Services/RepositoryCloneServiceTests.cs

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,13 @@ public async Task ClonesToRepositoryPathAsync()
2727
await vsGitServices.Received().Clone("https://github.com/foo/bar", @"c:\dev\bar", true);
2828
}
2929

30-
[Test]
31-
public async Task UpdatesMetricsWhenRepositoryClonedAsync()
30+
[TestCase("https://github.com/foo/bar", 1, nameof(UsageModel.MeasuresModel.NumberOfClones))]
31+
[TestCase("https://github.com/foo/bar", 1, nameof(UsageModel.MeasuresModel.NumberOfGitHubClones))]
32+
[TestCase("https://github.com/foo/bar", 0, nameof(UsageModel.MeasuresModel.NumberOfEnterpriseClones))]
33+
[TestCase("https://enterprise.com/foo/bar", 1, nameof(UsageModel.MeasuresModel.NumberOfClones))]
34+
[TestCase("https://enterprise.com/foo/bar", 1, nameof(UsageModel.MeasuresModel.NumberOfEnterpriseClones))]
35+
[TestCase("https://enterprise.com/foo/bar", 0, nameof(UsageModel.MeasuresModel.NumberOfGitHubClones))]
36+
public async Task UpdatesMetricsWhenRepositoryClonedAsync(string cloneUrl, int numberOfCalls, string counterName)
3237
{
3338
var serviceProvider = Substitutes.ServiceProvider;
3439
var operatingSystem = serviceProvider.GetOperatingSystem();
@@ -37,12 +42,12 @@ public async Task UpdatesMetricsWhenRepositoryClonedAsync()
3742
var usageTracker = Substitute.For<IUsageTracker>();
3843
var cloneService = new RepositoryCloneService(operatingSystem, vsGitServices, graphqlFactory, usageTracker);
3944

40-
await cloneService.CloneRepository("https://github.com/foo/bar", @"c:\dev\bar");
45+
await cloneService.CloneRepository(cloneUrl, @"c:\dev\bar");
4146
var model = UsageModel.Create(Guid.NewGuid());
4247

43-
await usageTracker.Received().IncrementCounter(
48+
await usageTracker.Received(numberOfCalls).IncrementCounter(
4449
Arg.Is<Expression<Func<UsageModel.MeasuresModel, int>>>(x =>
45-
((MemberExpression)x.Body).Member.Name == nameof(model.Measures.NumberOfClones)));
50+
((MemberExpression)x.Body).Member.Name == counterName));
4651
}
4752
}
4853
}

0 commit comments

Comments
 (0)