Skip to content

Commit ec785a0

Browse files
authored
Merge branch 'master' into feature/fix-addin-tool-versions
2 parents 836ed8d + e1a373b commit ec785a0

File tree

2 files changed

+38
-8
lines changed

2 files changed

+38
-8
lines changed

src/DockerBase/Dockerfile

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,22 @@ FROM ubuntu:16.04
22

33
MAINTAINER GitTools Maintainers <[email protected]>
44

5-
# Wheezy doesn't support glibc 2.15 which libgit2sharp requires
6-
# So we are going to install mono on ubuntu instead
7-
RUN apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF
8-
RUN echo "deb http://download.mono-project.com/repo/debian wheezy main" | tee /etc/apt/sources.list.d/mono-xamarin.list
9-
RUN apt-get update && apt-get install libcurl3 tzdata unzip curl git-all mono-complete -y && apt-get -yqq clean
10-
RUN cp /usr/share/zoneinfo/GMT /etc/localtime
5+
# moviong the timezone setting at the top, as this may be the most infrequent change in this file
6+
RUN ln -sfn /usr/share/zoneinfo/GMT /etc/localtime
7+
8+
# Following current install guide from
9+
# http://www.mono-project.com/download/#download-lin on 2017-12-08
10+
# regarding to the repository sources
11+
RUN echo "deb http://download.mono-project.com/repo/ubuntu xenial main" |\
12+
tee /etc/apt/sources.list.d/mono-official.list
13+
14+
# This will do:
15+
# * Accept the repository key
16+
# * Get the current package inventory state
17+
# * Install given packages only with required dependencies
18+
# * Cleanup to reduce Docker image size
19+
RUN apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF &&\
20+
apt-get update &&\
21+
apt-get -y --no-install-recommends install libcurl3 tzdata unzip curl git-all mono-complete &&\
22+
apt-get -yqq clean &&\
23+
rm -rf /var/lib/apt/lists/* /tmp/*

src/GitVersionCore/GitPreparer.cs

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ public class GitPreparer
1515
bool noFetch;
1616
string targetPath;
1717

18+
const string defaultRemoteName = "origin";
19+
1820
public GitPreparer(string targetPath) : this(null, null, null, false, targetPath) { }
1921
public GitPreparer(string targetUrl, string dynamicRepositoryLocation, Authentication authentication, bool noFetch, string targetPath)
2022
{
@@ -76,10 +78,25 @@ public void Initialise(bool normaliseGitDirectory, string currentBranch, bool sh
7678

7779
private void CleanupDuplicateOrigin()
7880
{
81+
var remoteToKeep = defaultRemoteName;
82+
7983
var repo = new Repository(GetDotGitDirectory());
80-
if (repo.Network.Remotes.Any(remote => remote.Name == "origin1"))
84+
85+
// check that we have a remote that matches defaultRemoteName if not take the first remote
86+
if (!repo.Network.Remotes.Any(remote => remote.Name.Equals(defaultRemoteName, StringComparison.InvariantCultureIgnoreCase)))
87+
{
88+
remoteToKeep = repo.Network.Remotes.First().Name;
89+
}
90+
91+
var duplicateRepos = repo.Network
92+
.Remotes
93+
.Where(remote => !remote.Name.Equals(remoteToKeep, StringComparison.InvariantCultureIgnoreCase))
94+
.Select(remote => remote.Name);
95+
96+
// remove all remotes that are considered duplicates
97+
foreach (var repoName in duplicateRepos)
8198
{
82-
repo.Network.Remotes.Remove("origin1");
99+
repo.Network.Remotes.Remove(repoName);
83100
}
84101
}
85102

0 commit comments

Comments
 (0)