Skip to content
This repository has been archived by the owner on Feb 12, 2023. It is now read-only.

Commit

Permalink
#44 Added support for relative paths ($(MSBuildProjectDirectory)\..) …
Browse files Browse the repository at this point in the history
…for the solution directory
  • Loading branch information
GeertvanHorrik committed Nov 9, 2014
1 parent eaaef20 commit 47d3e06
Show file tree
Hide file tree
Showing 3 changed files with 112 additions and 150 deletions.
65 changes: 1 addition & 64 deletions doc/history.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,67 +10,4 @@ For more information about issues or new feature requests, please visit:

Project website: https://github.com/CatenaLogic/GitLink/

**********************************************************

==================
Version 1.4.0
==================

Release date:
=============
2014/xx/xx

Added/fixed:
============
(x) #8 Console stays red after an error occurs

**********************************************************


==================
Version 1.2.0/1.3.0
==================

Release date:
=============
2014/04/20

Added/fixed:
============
(*) #7 Show relative paths to make to file names easier to read
(x) #5 When an error occurs, the console application will no longer wait for a key input press to prevent
it from blocking a build

**********************************************************


==================
Version 1.1.0
==================

Release date:
=============
2014/04/19

Added/fixed:
============
(+) #1 Created Chocolatey package for easier deployment
(+) #2 Added support for VB projects
(+) #3 Created NuGet package for deployment when being referenced from code

**********************************************************


==================
Version 1.0.0
==================

Release date:
=============
2014/04/17

Added/fixed:
============
First initial release

**********************************************************
**********************************************************
18 changes: 18 additions & 0 deletions src/GitLink.Tests/ContextFacts.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

namespace GitLink.Tests
{
using System;
using Catel.Test;
using GitLink.Providers;
using NUnit.Framework;
Expand Down Expand Up @@ -72,6 +73,23 @@ public void SucceedsForValidContext()
// should not throw
context.ValidateContext();
}

[TestCase(@".", @"c:\")]
[TestCase(@"C:\MyDirectory\", @"C:\MyDirectory\")]
[TestCase(@"C:\MyDirectory\..", @"C:\")]
[TestCase(@"C:\MyDirectory\..\TestDirectory\", @"C:\TestDirectory\")]
public void ExpandsDirectoryIfRequired(string solutionDirectory, string expectedValue)
{
Environment.CurrentDirectory = @"c:\";

var context = new Context(new ProviderManager());
context.TargetUrl = "https://github.com/CatenaLogic/GitLink.git";
context.SolutionDirectory = solutionDirectory;

context.ValidateContext();

Assert.AreEqual(expectedValue, context.SolutionDirectory);
}
}
}
}
179 changes: 93 additions & 86 deletions src/GitLink/Context.cs
Original file line number Diff line number Diff line change
@@ -1,89 +1,96 @@
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="Context.cs" company="CatenaLogic">
// Copyright (c) 2014 - 2014 CatenaLogic. All rights reserved.
// </copyright>
// --------------------------------------------------------------------------------------------------------------------


namespace GitLink
{
using Catel;
using Catel.Logging;
using Providers;

public class Context
{
private static readonly ILog Log = LogManager.GetCurrentClassLogger();

private readonly IProviderManager _providerManager;
private IProvider _provider;

public Context(IProviderManager providerManager)
{
Argument.IsNotNull(() => providerManager);

_providerManager = providerManager;

Authentication = new Authentication();
ConfigurationName = "Release";
}

public bool IsHelp { get; set; }

public string LogFile { get; set; }

public string SolutionDirectory { get; set; }

public string ConfigurationName { get; set; }

public Authentication Authentication { get; private set; }

public IProvider Provider
{
get
{
if (_provider == null)
{
_provider = _providerManager.GetProvider(TargetUrl);
}

return _provider;
}
set
{
_provider = value;
}
}

public string TargetUrl { get; set; }

public string TargetBranch { get; set; }

// --------------------------------------------------------------------------------------------------------------------
// <copyright file="Context.cs" company="CatenaLogic">
// Copyright (c) 2014 - 2014 CatenaLogic. All rights reserved.
// </copyright>
// --------------------------------------------------------------------------------------------------------------------


namespace GitLink
{
using System;
using Catel;
using Catel.IO;
using Catel.Logging;
using Providers;

public class Context
{
private static readonly ILog Log = LogManager.GetCurrentClassLogger();

private readonly IProviderManager _providerManager;
private IProvider _provider;

public Context(IProviderManager providerManager)
{
Argument.IsNotNull(() => providerManager);

_providerManager = providerManager;

Authentication = new Authentication();
ConfigurationName = "Release";
}

public bool IsHelp { get; set; }

public string LogFile { get; set; }

public string SolutionDirectory { get; set; }

public string ConfigurationName { get; set; }

public Authentication Authentication { get; private set; }

public IProvider Provider
{
get
{
if (_provider == null)
{
_provider = _providerManager.GetProvider(TargetUrl);
}

return _provider;
}
set
{
_provider = value;
}
}

public string TargetUrl { get; set; }

public string TargetBranch { get; set; }

public string ShaHash { get; set; }

public string SolutionFile { get; set; }

public void ValidateContext()
{
if (string.IsNullOrEmpty(SolutionDirectory))
{
Log.ErrorAndThrowException<GitLinkException>("Solution directory is missing");
}

if (string.IsNullOrEmpty(ConfigurationName))
{
Log.ErrorAndThrowException<GitLinkException>("Configuration name is missing");
}

if (string.IsNullOrEmpty(TargetUrl))
{
Log.ErrorAndThrowException<GitLinkException>("Target url is missing");
}

if (Provider == null)
{
Log.ErrorAndThrowException<GitLinkException>("Cannot determine git provider");
}
}
}
public string SolutionFile { get; set; }

public void ValidateContext()
{
if (!string.IsNullOrWhiteSpace(SolutionDirectory))
{
SolutionDirectory = Path.GetFullPath(SolutionDirectory, Environment.CurrentDirectory);
}

if (string.IsNullOrEmpty(SolutionDirectory))
{
Log.ErrorAndThrowException<GitLinkException>("Solution directory is missing");
}

if (string.IsNullOrEmpty(ConfigurationName))
{
Log.ErrorAndThrowException<GitLinkException>("Configuration name is missing");
}

if (string.IsNullOrEmpty(TargetUrl))
{
Log.ErrorAndThrowException<GitLinkException>("Target url is missing");
}

if (Provider == null)
{
Log.ErrorAndThrowException<GitLinkException>("Cannot determine git provider");
}
}
}
}

0 comments on commit 47d3e06

Please sign in to comment.