Skip to content
This repository has been archived by the owner on Apr 16, 2020. It is now read-only.

Commit

Permalink
use a sourcelink.compile file (#182)
Browse files Browse the repository at this point in the history
* compile for netcoreapp 1.1
fix #157

* switch to sourcelink.compile file #175

* File.OpenStream for netstandard 1.4

* back to netcoreapp1.0 #157
  • Loading branch information
ctaggart authored Mar 26, 2017
1 parent bc0b031 commit 47589a7
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 18 deletions.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,7 @@ lib/*.dll
.vs/
packages.config
.vscode/launch.json
launchSettings.json
launchSettings.json
launchSettings.json
/*.txt
*.user
15 changes: 11 additions & 4 deletions SourceLink.Create.GitHub/CreateTask.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,21 @@ public override bool Execute()
url = GetRepoUrl(origin);
}

var compileFile = IO.Path.ChangeExtension(File, ".compile");
using(var sw = new IO.StreamWriter(IO.File.OpenWrite(compileFile)))
{
if (Sources != null)
{
foreach (var source in Sources)
sw.WriteLine(source);
}
}

var sbArgs = new StringBuilder();
sbArgs.Append("sourcelink-git create" + gitOption);
sbArgs.Append(" -u \"" + url + "\"");
sbArgs.Append(" -f \"" + File + "\"");
if (Sources != null) {
foreach (var source in Sources)
sbArgs.Append(" -s \"" + source + "\"");
}

if (!string.IsNullOrEmpty(NotInGit))
{
sbArgs.Append(" --notingit \"" + NotInGit + "\"");
Expand Down
2 changes: 1 addition & 1 deletion build.ps1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
$version = '2.0.2' # the version under development, update after a release
$version = '2.1.0' # the version under development, update after a release
$versionSuffix = '-a115' # manually incremented for local builds

function isVersionTag($tag){
Expand Down
17 changes: 5 additions & 12 deletions dotnet-sourcelink-git/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,7 @@ public static void Create(CommandLineApplication command)
command.Description = "creates the Source Link JSON file";
var dirOption = command.Option("-d|--dir <directory>", "the directory to look for the git repository", CommandOptionType.SingleValue);
var fileOption = command.Option("-f|--file <file>", "the sourcelink.json file to write", CommandOptionType.SingleValue);
//var embedOption = command.Option("-e|--embed <file>", "the sourcelink.embed file to write", CommandOptionType.SingleValue);
var urlOption = command.Option("-u|--url <url>", "URL for downloading the source files, use {0} for commit and * for path", CommandOptionType.SingleValue);
var sourceOption = command.Option("-s|--source <url>", "source file to verify checksum in git repository", CommandOptionType.MultipleValue);
var notInGitOption = command.Option("--notingit <option>", "embed, warn, or error when a source file is not in git. embed is default", CommandOptionType.SingleValue);
var hashMismatchOption = command.Option("--hashmismatch <option>", "embed, warn, or error when a source file hash does not match git. embed is default", CommandOptionType.SingleValue);
var noAutoLfOption = command.Option("--noautolf", "disable changing the line endings to match the git repository", CommandOptionType.NoValue);
Expand Down Expand Up @@ -136,12 +134,7 @@ public static void Create(CommandLineApplication command)
return 1;
}

if (!fileOption.HasValue())
{
Console.Error.WriteLine("--file option required");
return 2;
}
var file = fileOption.Value();
var file = fileOption.HasValue() ? fileOption.Value() : "sourcelink.json";

if (!urlOption.HasValue())
{
Expand All @@ -152,9 +145,11 @@ public static void Create(CommandLineApplication command)
var commit = GetCommit(repoPath);
url = url.Replace("{commit}", commit);

if (sourceOption.HasValue())
var compileFile = Path.ChangeExtension(file, ".compile");
if (File.Exists(compileFile))
{
var files = sourceOption.Values.Select(source => new SourceFile { FilePath = source });
var compileFiles = File.ReadAllLines(compileFile);
var files = compileFiles.Select(source => new SourceFile { FilePath = source });

using (var repo = new Repository(repoPath))
using (var sha1 = SHA1.Create())
Expand Down Expand Up @@ -263,8 +258,6 @@ public static void Create(CommandLineApplication command)
js.Serialize(sw, json);
}

//var embedFile = embedOption.Value();
//if (String.IsNullOrEmpty(embedFile))
var embedFile = Path.ChangeExtension(file, ".embed");
if (embedFiles.Count > 0)
{
Expand Down

0 comments on commit 47589a7

Please sign in to comment.