Skip to content

Commit

Permalink
Merge branch 'additions'
Browse files Browse the repository at this point in the history
* additions:
  (GH-50) Added null check
  • Loading branch information
gep13 committed Apr 20, 2015
2 parents 5866297 + f146cd8 commit 0a62a53
Showing 1 changed file with 16 additions and 27 deletions.
43 changes: 16 additions & 27 deletions Source/GitHubReleaseManager.Cli/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ private static async Task CreateReleaseFromInputFile(GitHubClient github, string
await AddAssets(github, assets, release);
}

private static async Task AddAssets(GitHubClient github, string owner, string repository, string tagName, IList<string> assetPaths)
private static async Task AddAssets(GitHubClient github, string owner, string repository, string tagName, IList<string> assets)
{
var releases = await github.Release.GetAll(owner, repository);

Expand All @@ -269,21 +269,7 @@ private static async Task AddAssets(GitHubClient github, string owner, string re
return;
}

foreach (var assetPath in assetPaths)
{
if (!File.Exists(assetPath))
{
continue;
}

var upload = new ReleaseAssetUpload
{
FileName = Path.GetFileName(assetPath),
ContentType = "application/octet-stream",
RawData = File.Open(assetPath, FileMode.Open)
};
await github.Release.UploadAsset(release, upload);
}
await AddAssets(github, assets, release);
}

private static async Task<string> ExportReleases(GitHubClient github, string owner, string repository, string tagName, Config configuration)
Expand Down Expand Up @@ -329,21 +315,24 @@ private static async Task PublishRelease(GitHubClient github, string owner, stri

private static async Task AddAssets(GitHubClient github, IList<string> assets, Release release)
{
foreach (var asset in assets)
if (assets != null)
{
if (!File.Exists(asset))
foreach (var asset in assets)
{
continue;
}
if (!File.Exists(asset))
{
continue;
}

var upload = new ReleaseAssetUpload
{
FileName = Path.GetFileName(asset),
ContentType = "application/octet-stream",
RawData = File.Open(asset, FileMode.Open)
};
var upload = new ReleaseAssetUpload
{
FileName = Path.GetFileName(asset),
ContentType = "application/octet-stream",
RawData = File.Open(asset, FileMode.Open)
};

await github.Release.UploadAsset(release, upload);
await github.Release.UploadAsset(release, upload);
}
}
}

Expand Down

0 comments on commit 0a62a53

Please sign in to comment.