-
Notifications
You must be signed in to change notification settings - Fork 117
Fixed the Validation for bbs-shared-home and archive-path #1327
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
4e6a04b
ad1004a
110c30a
be2b9da
d302f8b
58bf290
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
using System; | ||
using System.IO; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We don't have a direct dependency to |
||
using System.Runtime.InteropServices; | ||
using System.Threading.Tasks; | ||
using OctoshiftCLI.BbsToGithub.Services; | ||
|
@@ -51,7 +52,8 @@ public async Task Handle(MigrateRepoCommandArgs args) | |
} | ||
|
||
ValidateOptions(args); | ||
|
||
ValidateBbsSharedHome(args); | ||
ValidateArchivePath(args); | ||
var exportId = 0L; | ||
var migrationSourceId = ""; | ||
|
||
|
@@ -123,6 +125,46 @@ public async Task Handle(MigrateRepoCommandArgs args) | |
} | ||
} | ||
|
||
private void ValidateBbsSharedHome(MigrateRepoCommandArgs args) | ||
{ | ||
if (!string.IsNullOrEmpty(args.BbsSharedHome)) | ||
{ | ||
if (IsRunningOnBitbucketServer()) | ||
{ | ||
if (!Directory.Exists(args.BbsSharedHome)) | ||
{ | ||
throw new OctoshiftCliException($"Invalid --bbs-shared-home path: '{args.BbsSharedHome}'. Directory does not exist."); | ||
} | ||
} | ||
else | ||
{ | ||
if (!Directory.Exists(args.BbsSharedHome)) | ||
{ | ||
throw new OctoshiftCliException($"Invalid --bbs-shared-home path: '{args.BbsSharedHome}'. Directory does not exist."); | ||
} | ||
} | ||
} | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A few things here:
if (args.ShouldUploadArchive() && args.ArchivePath.IsNullOrWhiteSpace())
{
if (args.BbsSharedHome.HasValue() && !_fileSystemProvider.DirectoryExists(args.BbsSharedHome)
{
throw new OctoshiftCliException($"Invalid --bbs-shared-home path: '{args.BbsSharedHome}'. Directory does not exist.");
} Note the use of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hi @ArinGhazarian, |
||
|
||
private void ValidateArchivePath(MigrateRepoCommandArgs args) | ||
{ | ||
if (!string.IsNullOrEmpty(args.ArchivePath)) | ||
{ | ||
if (!File.Exists(args.ArchivePath)) | ||
{ | ||
throw new OctoshiftCliException($"Invalid --archive-path: '{args.ArchivePath}'. File does not exist."); | ||
} | ||
_log.LogInformation($"Archive path for upload: {args.ArchivePath}"); | ||
} | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A few notes here too:
|
||
|
||
|
||
private bool IsRunningOnBitbucketServer() | ||
{ | ||
return Environment.GetEnvironmentVariable("BITBUCKET_SERVER") != null; | ||
} | ||
|
||
|
||
private string GetSourceExportArchiveAbsolutePath(string bbsSharedHomeDirectory, long exportId) | ||
{ | ||
if (bbsSharedHomeDirectory.IsNullOrWhiteSpace()) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove this test as it doesn't test any of the changes introduced in this PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure