Skip to content
This repository was archived by the owner on Dec 5, 2024. It is now read-only.

Commit e372d13

Browse files
More fixes around GitRemote
1 parent 30dd822 commit e372d13

File tree

5 files changed

+69
-138
lines changed

5 files changed

+69
-138
lines changed

src/GitHub.Api/Git/GitRemote.cs

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,15 +59,37 @@ public GitRemoteFunction Function
5959
get { return function; }
6060
}
6161

62-
public GitRemote(string name, string url, string login, string user, string token, string host, GitRemoteFunction function)
62+
public GitRemote(string name, string host, string url, GitRemoteFunction function, string user, string login, string token)
6363
{
6464
this.name = name;
6565
this.url = url;
66-
this.login = login;
66+
this.host = host;
67+
this.function = function;
6768
this.user = user;
69+
this.login = login;
6870
this.token = token;
71+
}
72+
73+
public GitRemote(string name, string host, string url, GitRemoteFunction function, string user)
74+
{
75+
this.name = name;
76+
this.url = url;
77+
this.host = host;
78+
this.function = function;
79+
this.user = user;
80+
login = null;
81+
token = null;
82+
}
83+
84+
public GitRemote(string name, string host, string url, GitRemoteFunction function)
85+
{
86+
this.name = name;
87+
this.url = url;
6988
this.host = host;
7089
this.function = function;
90+
this.user = null;
91+
this.login = null;
92+
this.token = null;
7193
}
7294

7395
public GitRemote(string name, string url)

src/GitHub.Api/OutputProcessors/RemoteListOutputProcessor.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ private void ReturnRemote()
9999
currentUrl = currentUrl.Substring(user.Length + 1);
100100
}
101101

102-
RaiseOnEntry(new GitRemote(currentName, currentUrl, null, user, null, host, remoteFunction));
102+
RaiseOnEntry(new GitRemote(currentName, host, currentUrl, remoteFunction, user, null, null));
103103
Reset();
104104
}
105105

src/tests/IntegrationTests/Events/RepositoryManagerTests.cs

Lines changed: 19 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,7 @@ public async Task ShouldDoNothingOnInitialize()
5151
new GitBranch("feature/document", "origin/feature/document", false),
5252
new GitBranch("feature/other-feature", "origin/feature/other-feature", false),
5353
});
54-
Repository.Remotes.Should().BeEquivalentTo(new GitRemote
55-
{
56-
Name = "origin",
57-
Url = "https://github.com/EvilStanleyGoldman/IOTestsRepo.git"
58-
});
54+
Repository.Remotes.Should().BeEquivalentTo(new GitRemote("origin", "https://github.com/EvilStanleyGoldman/IOTestsRepo.git"));
5955
Repository.RemoteBranches.Should().BeEquivalentTo(new[] {
6056
new GitBranch("origin/master", "[None]", false),
6157
new GitBranch("origin/feature/document-2", "[None]", false),
@@ -330,10 +326,7 @@ public async Task ShouldDetectBranchChange()
330326
new GitBranch("feature/document", "origin/feature/document", true),
331327
new GitBranch("feature/other-feature", "origin/feature/other-feature", false),
332328
});
333-
Repository.Remotes.Should().BeEquivalentTo(new GitRemote {
334-
Name = "origin",
335-
Url = "https://github.com/EvilStanleyGoldman/IOTestsRepo.git"
336-
});
329+
Repository.Remotes.Should().BeEquivalentTo(new GitRemote("origin", "https://github.com/EvilStanleyGoldman/IOTestsRepo.git"));
337330
Repository.RemoteBranches.Should().BeEquivalentTo(new[] {
338331
new GitBranch("origin/master", "[None]", false),
339332
new GitBranch("origin/feature/document-2", "[None]", false),
@@ -383,11 +376,7 @@ public async Task ShouldDetectBranchDelete()
383376
new GitBranch("master", "origin/master", true),
384377
new GitBranch("feature/other-feature", "origin/feature/other-feature", false),
385378
});
386-
Repository.Remotes.Should().BeEquivalentTo(new GitRemote
387-
{
388-
Name = "origin",
389-
Url = "https://github.com/EvilStanleyGoldman/IOTestsRepo.git"
390-
});
379+
Repository.Remotes.Should().BeEquivalentTo(new GitRemote("origin","https://github.com/EvilStanleyGoldman/IOTestsRepo.git"));
391380
Repository.RemoteBranches.Should().BeEquivalentTo(new[] {
392381
new GitBranch("origin/master", "[None]", false),
393382
new GitBranch("origin/feature/document-2", "[None]", false),
@@ -439,11 +428,7 @@ public async Task ShouldDetectBranchCreate()
439428
new GitBranch("feature/document2", "[None]", false),
440429
new GitBranch("feature/other-feature", "origin/feature/other-feature", false),
441430
});
442-
Repository.Remotes.Should().BeEquivalentTo(new GitRemote
443-
{
444-
Name = "origin",
445-
Url = "https://github.com/EvilStanleyGoldman/IOTestsRepo.git"
446-
});
431+
Repository.Remotes.Should().BeEquivalentTo(new GitRemote("origin","https://github.com/EvilStanleyGoldman/IOTestsRepo.git"));
447432
Repository.RemoteBranches.Should().BeEquivalentTo(new[] {
448433
new GitBranch("origin/master", "[None]", false),
449434
new GitBranch("origin/feature/document-2", "[None]", false),
@@ -490,11 +475,7 @@ public async Task ShouldDetectBranchCreate()
490475
new GitBranch("feature2/document2", "[None]", false),
491476
new GitBranch("feature/other-feature", "origin/feature/other-feature", false),
492477
});
493-
Repository.Remotes.Should().BeEquivalentTo(new GitRemote
494-
{
495-
Name = "origin",
496-
Url = "https://github.com/EvilStanleyGoldman/IOTestsRepo.git"
497-
});
478+
Repository.Remotes.Should().BeEquivalentTo(new GitRemote("origin","https://github.com/EvilStanleyGoldman/IOTestsRepo.git"));
498479
Repository.RemoteBranches.Should().BeEquivalentTo(new[] {
499480
new GitBranch("origin/master", "[None]", false),
500481
new GitBranch("origin/feature/document-2", "[None]", false),
@@ -531,11 +512,7 @@ public async Task ShouldDetectChangesToRemotes()
531512
new GitBranch("feature/document", "origin/feature/document", false),
532513
new GitBranch("feature/other-feature", "origin/feature/other-feature", false),
533514
});
534-
Repository.Remotes.Should().BeEquivalentTo(new GitRemote
535-
{
536-
Name = "origin",
537-
Url = "https://github.com/EvilStanleyGoldman/IOTestsRepo.git"
538-
});
515+
Repository.Remotes.Should().BeEquivalentTo(new GitRemote("origin","https://github.com/EvilStanleyGoldman/IOTestsRepo.git"));
539516
Repository.RemoteBranches.Should().BeEquivalentTo(new[] {
540517
new GitBranch("origin/master", "[None]", false),
541518
new GitBranch("origin/feature/document-2", "[None]", false),
@@ -615,11 +592,7 @@ public async Task ShouldDetectChangesToRemotes()
615592
new GitBranch("feature/document", "[None]", false),
616593
new GitBranch("feature/other-feature", "[None]", false),
617594
});
618-
Repository.Remotes.Should().BeEquivalentTo(new GitRemote
619-
{
620-
Name = "origin",
621-
Url = "https://github.com/EvilShana/IOTestsRepo.git"
622-
});
595+
Repository.Remotes.Should().BeEquivalentTo(new GitRemote("origin","https://github.com/EvilShana/IOTestsRepo.git"));
623596
Repository.RemoteBranches.Should().BeEmpty();
624597
}
625598

@@ -652,15 +625,9 @@ public async Task ShouldDetectChangesToRemotesWhenSwitchingBranches()
652625
new GitBranch("feature/document", "origin/feature/document", false),
653626
new GitBranch("feature/other-feature", "origin/feature/other-feature", false),
654627
});
655-
Repository.Remotes.Should().BeEquivalentTo(new GitRemote
656-
{
657-
Name = "origin",
658-
Url = "https://github.com/EvilStanleyGoldman/IOTestsRepo.git"
659-
}, new GitRemote
660-
{
661-
Name = "another",
662-
Url = "https://another.remote/Owner/Url.git"
663-
});
628+
Repository.Remotes.Should().BeEquivalentTo(
629+
new GitRemote("origin","https://github.com/EvilStanleyGoldman/IOTestsRepo.git"),
630+
new GitRemote("another","https://another.remote/Owner/Url.git"));
664631
Repository.RemoteBranches.Should().BeEquivalentTo(new[] {
665632
new GitBranch("origin/master", "[None]", false),
666633
new GitBranch("origin/feature/document-2", "[None]", false),
@@ -707,15 +674,9 @@ await RepositoryManager.CreateBranch("branch2", "another/master")
707674
new GitBranch("feature/document", "origin/feature/document", false),
708675
new GitBranch("feature/other-feature", "origin/feature/other-feature", false),
709676
});
710-
Repository.Remotes.Should().BeEquivalentTo(new GitRemote
711-
{
712-
Name = "origin",
713-
Url = "https://github.com/EvilStanleyGoldman/IOTestsRepo.git"
714-
}, new GitRemote
715-
{
716-
Name = "another",
717-
Url = "https://another.remote/Owner/Url.git"
718-
});
677+
Repository.Remotes.Should().BeEquivalentTo(
678+
new GitRemote("origin","https://github.com/EvilStanleyGoldman/IOTestsRepo.git"),
679+
new GitRemote("another","https://another.remote/Owner/Url.git"));
719680
Repository.RemoteBranches.Should().BeEquivalentTo(new[] {
720681
new GitBranch("origin/master", "[None]", false),
721682
new GitBranch("origin/feature/document-2", "[None]", false),
@@ -766,15 +727,9 @@ await RepositoryManager.SwitchBranch("branch2")
766727
new GitBranch("feature/document", "origin/feature/document", false),
767728
new GitBranch("feature/other-feature", "origin/feature/other-feature", false),
768729
});
769-
Repository.Remotes.Should().BeEquivalentTo(new GitRemote
770-
{
771-
Name = "origin",
772-
Url = "https://github.com/EvilStanleyGoldman/IOTestsRepo.git"
773-
}, new GitRemote
774-
{
775-
Name = "another",
776-
Url = "https://another.remote/Owner/Url.git"
777-
});
730+
Repository.Remotes.Should().BeEquivalentTo(
731+
new GitRemote("origin","https://github.com/EvilStanleyGoldman/IOTestsRepo.git"),
732+
new GitRemote("another","https://another.remote/Owner/Url.git"));
778733
Repository.RemoteBranches.Should().BeEquivalentTo(new[] {
779734
new GitBranch("origin/master", "[None]", false),
780735
new GitBranch("origin/feature/document-2", "[None]", false),
@@ -840,11 +795,7 @@ public async Task ShouldDetectGitPull()
840795
new GitBranch("feature/document", "origin/feature/document", false),
841796
new GitBranch("feature/other-feature", "origin/feature/other-feature", false),
842797
});
843-
Repository.Remotes.Should().BeEquivalentTo(new GitRemote
844-
{
845-
Name = "origin",
846-
Url = "https://github.com/EvilStanleyGoldman/IOTestsRepo.git"
847-
});
798+
Repository.Remotes.Should().BeEquivalentTo(new GitRemote("origin","https://github.com/EvilStanleyGoldman/IOTestsRepo.git"));
848799
Repository.RemoteBranches.Should().BeEquivalentTo(new[] {
849800
new GitBranch("origin/master", "[None]", false),
850801
new GitBranch("origin/feature/document-2", "[None]", false),
@@ -882,11 +833,7 @@ public async Task ShouldDetectGitFetch()
882833
Repository.LocalBranches.Should().BeEquivalentTo(new[] {
883834
new GitBranch("feature/document", "origin/feature/document", false),
884835
});
885-
Repository.Remotes.Should().BeEquivalentTo(new GitRemote
886-
{
887-
Name = "origin",
888-
Url = "https://github.com/EvilStanleyGoldman/IOTestsRepo.git"
889-
});
836+
Repository.Remotes.Should().BeEquivalentTo(new GitRemote("origin","https://github.com/EvilStanleyGoldman/IOTestsRepo.git"));
890837
Repository.RemoteBranches.Should().BeEquivalentTo(new[] {
891838
new GitBranch("origin/master", "[None]", false),
892839
new GitBranch("origin/feature/document", "[None]", false),
@@ -925,11 +872,7 @@ public async Task ShouldDetectGitFetch()
925872
Repository.LocalBranches.Should().BeEquivalentTo(new[] {
926873
new GitBranch("feature/document", "origin/feature/document", false),
927874
});
928-
Repository.Remotes.Should().BeEquivalentTo(new GitRemote
929-
{
930-
Name = "origin",
931-
Url = "https://github.com/EvilStanleyGoldman/IOTestsRepo.git"
932-
});
875+
Repository.Remotes.Should().BeEquivalentTo(new GitRemote("origin","https://github.com/EvilStanleyGoldman/IOTestsRepo.git"));
933876
Repository.RemoteBranches.Should().BeEquivalentTo(new[] {
934877
new GitBranch("origin/master", "[None]", false),
935878
new GitBranch("origin/feature/document", "[None]", false),

src/tests/IntegrationTests/Process/ProcessManagerIntegrationTests.cs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -126,13 +126,7 @@ public async Task RemoteListTest()
126126
.GetGitRemoteEntries(TestRepoMasterCleanSynchronized)
127127
.StartAsAsync();
128128

129-
gitRemotes.Should().BeEquivalentTo(new GitRemote()
130-
{
131-
Name = "origin",
132-
Url = "https://github.com/EvilStanleyGoldman/IOTestsRepo.git",
133-
Host = "github.com",
134-
Function = GitRemoteFunction.Both
135-
});
129+
gitRemotes.Should().BeEquivalentTo(new GitRemote("origin","https://github.com/EvilStanleyGoldman/IOTestsRepo.git","github.com",GitRemoteFunction.Both));
136130
}
137131

138132
[Test]

src/tests/UnitTests/IO/RemoteListOutputProcessorTests.cs

Lines changed: 24 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,13 @@ public void ShouldParseSingleHttpsBothWaysRemote()
1818
null
1919
};
2020

21+
var name = "origin";
22+
var host = "github.com";
23+
var url = "https://github.com/github/VisualStudio.git";
24+
var function = GitRemoteFunction.Both;
2125
AssertProcessOutput(output, new[]
2226
{
23-
new GitRemote
24-
{
25-
Function = GitRemoteFunction.Both,
26-
Name = "origin",
27-
Host = "github.com",
28-
Url = "https://github.com/github/VisualStudio.git",
29-
}
27+
new GitRemote(name, host, url, function)
3028
});
3129
}
3230

@@ -39,15 +37,13 @@ public void ShouldParseSingleHttpsFetchOnlyRemote()
3937
null
4038
};
4139

40+
var name = "origin";
41+
var function = GitRemoteFunction.Fetch;
42+
var host = "github.com";
43+
var url = "https://github.com/github/VisualStudio.git";
4244
AssertProcessOutput(output, new[]
4345
{
44-
new GitRemote
45-
{
46-
Function = GitRemoteFunction.Fetch,
47-
Name = "origin",
48-
Host = "github.com",
49-
Url = "https://github.com/github/VisualStudio.git",
50-
}
46+
new GitRemote(name, host, url, function)
5147
});
5248
}
5349

@@ -60,15 +56,13 @@ public void ShouldParseSingleHttpsPushOnlyRemote()
6056
null
6157
};
6258

59+
var name = "origin";
60+
var function = GitRemoteFunction.Fetch;
61+
var host = "github.com";
62+
var url = "https://github.com/github/VisualStudio.git";
6363
AssertProcessOutput(output, new[]
6464
{
65-
new GitRemote
66-
{
67-
Function = GitRemoteFunction.Push,
68-
Name = "origin",
69-
Host = "github.com",
70-
Url = "https://github.com/github/VisualStudio.git",
71-
}
65+
new GitRemote(name, host, url, function)
7266
});
7367
}
7468

@@ -82,16 +76,14 @@ public void ShouldParseSingleSSHRemote()
8276
null
8377
};
8478

79+
var function = GitRemoteFunction.Both;
80+
var name = "origin";
81+
var host = "github.com";
82+
var url = "github.com:StanleyGoldman/VisualStudio.git";
83+
var user = "git";
8584
AssertProcessOutput(output, new[]
8685
{
87-
new GitRemote
88-
{
89-
Function = GitRemoteFunction.Both,
90-
Name = "origin",
91-
Host = "github.com",
92-
Url = "github.com:StanleyGoldman/VisualStudio.git",
93-
User = "git"
94-
},
86+
new GitRemote(name, host, url, function, user)
9587
});
9688
}
9789

@@ -110,29 +102,9 @@ public void ShouldParseMultipleRemotes()
110102

111103
AssertProcessOutput(output, new[]
112104
{
113-
new GitRemote
114-
{
115-
Function = GitRemoteFunction.Both,
116-
Name = "origin",
117-
Host = "github.com",
118-
Url = "https://github.com/github/VisualStudio.git",
119-
},
120-
new GitRemote
121-
{
122-
Function = GitRemoteFunction.Both,
123-
Name = "stanleygoldman",
124-
Host = "github.com",
125-
Url = "github.com:StanleyGoldman/VisualStudio.git",
126-
User = "git"
127-
},
128-
new GitRemote
129-
{
130-
Function = GitRemoteFunction.Fetch,
131-
Name = "fetchOnly",
132-
Host = "github.com",
133-
Url = "github.com:StanleyGoldman/VisualStudio2.git",
134-
User = "git"
135-
},
105+
new GitRemote("origin", "github.com", "https://github.com/github/VisualStudio.git", GitRemoteFunction.Both),
106+
new GitRemote("stanleygoldman", "github.com", "github.com:StanleyGoldman/VisualStudio.git", GitRemoteFunction.Both, "https://github.com/github/VisualStudio.git"),
107+
new GitRemote("fetchOnly", "github.com", "github.com:StanleyGoldman/VisualStudio2.git", GitRemoteFunction.Fetch,"git")
136108
});
137109
}
138110

0 commit comments

Comments
 (0)