Added branch name to Assembly Info
This commit is contained in:
parent
053c730799
commit
a1f112e62f
|
@ -0,0 +1,23 @@
|
||||||
|
using FluentAssertions;
|
||||||
|
using NUnit.Framework;
|
||||||
|
using NzbDrone.Common.EnvironmentInfo;
|
||||||
|
|
||||||
|
namespace NzbDrone.Common.Test.EnvironmentInfo
|
||||||
|
{
|
||||||
|
[TestFixture]
|
||||||
|
public class BuildInfoFixture
|
||||||
|
{
|
||||||
|
[Test]
|
||||||
|
public void should_return_version()
|
||||||
|
{
|
||||||
|
BuildInfo.Version.Major.Should().BeOneOf(2, 10);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void should_get_branch()
|
||||||
|
{
|
||||||
|
BuildInfo.Branch.Should().NotBe("unknow");
|
||||||
|
BuildInfo.Branch.Should().NotBeNullOrWhiteSpace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -76,6 +76,7 @@
|
||||||
<Compile Include="DiskTests\IsParentFixtureBase.cs" />
|
<Compile Include="DiskTests\IsParentFixtureBase.cs" />
|
||||||
<Compile Include="DiskTests\DiskTransferServiceFixture.cs" />
|
<Compile Include="DiskTests\DiskTransferServiceFixture.cs" />
|
||||||
<Compile Include="EnsureTest\PathExtensionFixture.cs" />
|
<Compile Include="EnsureTest\PathExtensionFixture.cs" />
|
||||||
|
<Compile Include="EnvironmentInfo\BuildInfoFixture.cs" />
|
||||||
<Compile Include="EnvironmentProviderTest.cs" />
|
<Compile Include="EnvironmentProviderTest.cs" />
|
||||||
<Compile Include="EnvironmentTests\EnvironmentProviderTest.cs" />
|
<Compile Include="EnvironmentTests\EnvironmentProviderTest.cs" />
|
||||||
<Compile Include="EnvironmentTests\StartupArgumentsFixture.cs" />
|
<Compile Include="EnvironmentTests\StartupArgumentsFixture.cs" />
|
||||||
|
|
|
@ -1,12 +1,35 @@
|
||||||
using System;
|
using System;
|
||||||
|
using System.Diagnostics;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
|
|
||||||
namespace NzbDrone.Common.EnvironmentInfo
|
namespace NzbDrone.Common.EnvironmentInfo
|
||||||
{
|
{
|
||||||
public static class BuildInfo
|
public static class BuildInfo
|
||||||
{
|
{
|
||||||
public static Version Version => Assembly.GetExecutingAssembly().GetName().Version;
|
static BuildInfo()
|
||||||
|
{
|
||||||
|
var assembly = Assembly.GetExecutingAssembly();
|
||||||
|
|
||||||
|
Version = assembly.GetName().Version;
|
||||||
|
|
||||||
|
var attributes = assembly.GetCustomAttributes(true);
|
||||||
|
|
||||||
|
Branch = "unknow";
|
||||||
|
|
||||||
|
var config = attributes.OfType<AssemblyConfigurationAttribute>().FirstOrDefault();
|
||||||
|
if (config != null)
|
||||||
|
{
|
||||||
|
Branch = config.Configuration;
|
||||||
|
}
|
||||||
|
|
||||||
|
Release = $"{Version}-{Branch}";
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Version Version { get; }
|
||||||
|
public static String Branch { get; }
|
||||||
|
public static string Release { get; }
|
||||||
|
|
||||||
public static DateTime BuildDateTime
|
public static DateTime BuildDateTime
|
||||||
{
|
{
|
||||||
|
|
|
@ -44,12 +44,14 @@ namespace NzbDrone.Common.Instrumentation.Sentry
|
||||||
{
|
{
|
||||||
Compression = true,
|
Compression = true,
|
||||||
Environment = RuntimeInfo.IsProduction ? "production" : "development",
|
Environment = RuntimeInfo.IsProduction ? "production" : "development",
|
||||||
Release = BuildInfo.Version.ToString(),
|
Release = BuildInfo.Release
|
||||||
};
|
};
|
||||||
|
|
||||||
_client.Tags.Add("osfamily", OsInfo.Os.ToString());
|
_client.Tags.Add("osfamily", OsInfo.Os.ToString());
|
||||||
_client.Tags.Add("runtime", PlatformInfo.Platform.ToString().ToLower());
|
_client.Tags.Add("runtime", PlatformInfo.Platform.ToString().ToLower());
|
||||||
_client.Tags.Add("culture", Thread.CurrentThread.CurrentCulture.Name);
|
_client.Tags.Add("culture", Thread.CurrentThread.CurrentCulture.Name);
|
||||||
|
_client.Tags.Add("branch", BuildInfo.Branch);
|
||||||
|
_client.Tags.Add("version", BuildInfo.Version.ToString());
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void Write(LogEventInfo logEvent)
|
protected override void Write(LogEventInfo logEvent)
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
[assembly: AssemblyConfiguration("")]
|
// Gets updated at build time by TeamCity to branch name
|
||||||
|
[assembly: AssemblyConfiguration("debug")]
|
||||||
|
|
||||||
[assembly: AssemblyCompany("sonarr.tv")]
|
[assembly: AssemblyCompany("sonarr.tv")]
|
||||||
[assembly: AssemblyProduct("NzbDrone")]
|
[assembly: AssemblyProduct("NzbDrone")]
|
||||||
[assembly: AssemblyCopyright("GNU General Public v3")]
|
[assembly: AssemblyCopyright("GNU General Public v3")]
|
||||||
|
|
Loading…
Reference in New Issue