public async Task BadgeFile_VerifyBadgesUpdatedAfterDeleteAll() { // Arrange using (var packagesFolder = new TestFolder()) using (var target = new TestFolder()) using (var cache = new LocalCache()) { var log = new TestLogger(); var fileSystem = new PhysicalFileSystem(cache, UriUtility.CreateUri(target.Root)); var settings = new LocalSettings(); var context = new SleetContext() { Token = CancellationToken.None, LocalSettings = settings, Log = log, Source = fileSystem, SourceSettings = new FeedSettings() { BadgesEnabled = true } }; // Initial packages var identities = new HashSet <PackageIdentity>() { new PackageIdentity("a", NuGetVersion.Parse("2.0.0")) }; foreach (var id in identities) { var testPackage = new TestNupkg(id.Id, id.Version.ToFullString()); var zipFile = testPackage.Save(packagesFolder.Root); } // Push await InitCommand.InitAsync(context); await PushCommand.RunAsync(context.LocalSettings, context.Source, new List <string>() { packagesFolder.Root }, false, false, context.Log); // Remove await DeleteCommand.RunAsync(context.LocalSettings, context.Source, "a", "2.0.0", "test", true, context.Log); // Validate var validateOutput = await ValidateCommand.RunAsync(context.LocalSettings, context.Source, context.Log); validateOutput.Should().BeTrue(); // read output var stablePath = Path.Combine(target.Root, "badges/v/a.svg"); var prePath = Path.Combine(target.Root, "badges/vpre/a.svg"); File.Exists(stablePath).Should().BeFalse(); File.Exists(prePath).Should().BeFalse(); var stablePathJson = Path.Combine(target.Root, "badges/v/a.json"); var prePathJson = Path.Combine(target.Root, "badges/vpre/a.json"); File.Exists(stablePathJson).Should().BeFalse(); File.Exists(prePathJson).Should().BeFalse(); } }
public override void Setup() { // Generate directories and a svn util. rootUrl = new FilePath(FileService.CreateTempDirectory() + Path.DirectorySeparatorChar); rootCheckout = new FilePath(FileService.CreateTempDirectory() + Path.DirectorySeparatorChar); Directory.CreateDirectory(rootUrl.FullPath + "repo.git"); repoLocation = "file:///" + rootUrl.FullPath + "repo.git"; // Initialize the bare repo. InitCommand ci = new InitCommand(); ci.SetDirectory(new Sharpen.FilePath(rootUrl.FullPath + "repo.git")); ci.SetBare(true); ci.Call(); FileRepository bare = new FileRepository(new Sharpen.FilePath(rootUrl.FullPath + "repo.git")); string branch = Constants.R_HEADS + "master"; RefUpdate head = bare.UpdateRef(Constants.HEAD); head.DisableRefLog(); head.Link(branch); // Check out the repository. Checkout(rootCheckout, repoLocation); repo = GetRepo(rootCheckout, repoLocation); DOT_DIR = ".git"; }
public async Task GivenThatABaseUriChangesVerifyValidationFails() { using (var target = new TestFolder()) using (var cache = new LocalCache()) { var log = new TestLogger(); var settings = new LocalSettings(); var fileSystem1 = new PhysicalFileSystem(cache, UriUtility.CreateUri(target.Root), UriUtility.CreateUri("https://tempuri.org/")); var fileSystem2 = new PhysicalFileSystem(cache, UriUtility.CreateUri(target.Root), UriUtility.CreateUri("https://tempuri.org/b/")); await InitCommand.RunAsync(settings, fileSystem1, log); await SourceUtility.EnsureBaseUriMatchesFeed(fileSystem1, log, CancellationToken.None); InvalidDataException foundEx = null; try { await SourceUtility.EnsureBaseUriMatchesFeed(fileSystem2, log, CancellationToken.None); } catch (InvalidDataException ex) { foundEx = ex; } foundEx.Message.Should().Contain("https://tempuri.org/"); } }
public void TestInit_UseDefault() { HostEnvironment.EnvironmentSettings.DefaultProvider = "unpkg"; InitCommand command = new InitCommand(HostEnvironment); command.Configure(null); int result = command.Execute("-y"); Assert.AreEqual(0, result); string libmanFilePath = Path.Combine(WorkingDir, HostEnvironment.EnvironmentSettings.ManifestFileName); Assert.IsTrue(File.Exists(libmanFilePath)); string contents = File.ReadAllText(libmanFilePath); string expectedContents = @"{ ""version"": ""1.0"", ""defaultProvider"": ""unpkg"", ""libraries"": [] }"; Assert.AreEqual(StringHelper.NormalizeNewLines(expectedContents), StringHelper.NormalizeNewLines(contents)); }
public static async Task CreateCatalogAsync(string root, string feedRoot, string nupkgFolder, Uri baseUri, ILogger log) { using (var cache = new LocalCache()) { var sleetConfig = CreateSleetConfig(root, feedRoot, baseUri); var settings = LocalSettings.Load(sleetConfig); var fileSystem = FileSystemFactory.CreateFileSystem(settings, cache, "feed"); var success = await InitCommand.RunAsync(settings, fileSystem, enableCatalog : true, enableSymbols : false, log : log, token : CancellationToken.None); if (success != true) { throw new InvalidOperationException("Catalog init failed"); } if (Directory.GetFiles(nupkgFolder).Any()) { success = await PushCommand.PushPackages(settings, fileSystem, new List <string>() { nupkgFolder }, false, false, log, CancellationToken.None); if (success != true) { throw new InvalidOperationException("Push failed"); } } } }
public LoadingWindowViewModel(Window window) { _window = window; InitCommand = ReactiveCommand.Create(Init); InitCommand.Execute().Subscribe(); }
public Application() { List<Book> books = new List<Book> (); books.Add(new Book ("Object Thinking","Dr.David West",1990,"ISBN1990")); books.Add(new Book ("Cakes, Puddings + Category Theory","a",2015,"ISBN2015")); Biblotica app = new Biblotica (books); InputParser parser = new InputParser (app); _shouldContinue = true; ConsoleView view = new ConsoleView (); InitCommand startCommand = new InitCommand (); startCommand.Execute (); startCommand.WriteResultDataToView (view); while(_shouldContinue) { Console.WriteLine ("Input:"); string input = Console.ReadLine (); ICommand command = parser.Parse (input); if (command is ExitCommand) { _shouldContinue = false; } command.Execute(); command.WriteResultDataToView(view); } }
public async Task GivenAStorageAccountVerifyPushSucceeds() { using (var packagesFolder = new TestFolder()) using (var testContext = new AmazonS3TestContext()) { await testContext.InitAsync(); var testPackage = new TestNupkg("packageA", "1.0.0"); var zipFile = testPackage.Save(packagesFolder.Root); var result = await InitCommand.RunAsync(testContext.LocalSettings, testContext.FileSystem, enableCatalog : true, enableSymbols : true, log : testContext.Logger, token : CancellationToken.None); result &= await PushCommand.RunAsync(testContext.LocalSettings, testContext.FileSystem, new List <string>() { zipFile.FullName }, force : false, skipExisting : false, log : testContext.Logger); result &= await ValidateCommand.RunAsync(testContext.LocalSettings, testContext.FileSystem, testContext.Logger); result.Should().BeTrue(); await testContext.CleanupAsync(); } }
public async void StartEncode(JsonEncodeObject jobToStart) { InitCommand initCommand = new InitCommand { EnableDiskLogging = true, AllowDisconnectedWorker = false, DisableLibDvdNav = this.configuration.IsDvdNavDisabled, EnableHardwareAcceleration = true, LogDirectory = DirectoryUtilities.GetLogDirectory(), LogVerbosity = configuration.Verbosity }; initCommand.LogFile = Path.Combine(initCommand.LogDirectory, string.Format("activity_log.worker.{0}.txt", GeneralUtilities.ProcessId)); JsonSerializerSettings settings = new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore }; string job = JsonConvert.SerializeObject(new EncodeCommand { InitialiseCommand = initCommand, EncodeJob = jobToStart }, Formatting.None, settings); await this.MakeHttpJsonPostRequest("StartEncode", job); this.MonitorEncodeProgress(); }
private void Initialise(InitCommand command) { if (this.handbrakeInstance == null) { this.handbrakeInstance = new HandBrakeInstance(); } if (this.logHandler == null) { this.logHandler = new LogHandler(command.LogDirectory, command.LogFile, command.EnableDiskLogging); } if (!command.AllowDisconnectedWorker) { this.instanceWatcher = new InstanceWatcher(this); this.instanceWatcher.Start(5000); } this.handbrakeInstance.Initialize(command.LogVerbosity, command.EnableHardwareAcceleration); this.handbrakeInstance.EncodeCompleted += this.HandbrakeInstance_EncodeCompleted; if (command.DisableLibDvdNav) { HandBrakeUtils.SetDvdNav(true); // TODO check this is correct } }
public override void Setup () { // Generate directories and a svn util. rootUrl = new FilePath (FileService.CreateTempDirectory () + Path.DirectorySeparatorChar); rootCheckout = new FilePath (FileService.CreateTempDirectory () + Path.DirectorySeparatorChar); Directory.CreateDirectory (rootUrl.FullPath + "repo.git"); repoLocation = "file:///" + rootUrl.FullPath + "repo.git"; // Initialize the bare repo. InitCommand ci = new InitCommand (); ci.SetDirectory (new Sharpen.FilePath (rootUrl.FullPath + "repo.git")); ci.SetBare (true); ci.Call (); FileRepository bare = new FileRepository (new Sharpen.FilePath (rootUrl.FullPath + "repo.git")); string branch = Constants.R_HEADS + "master"; RefUpdate head = bare.UpdateRef (Constants.HEAD); head.DisableRefLog (); head.Link (branch); // Check out the repository. Checkout (rootCheckout, repoLocation); repo = GetRepo (rootCheckout, repoLocation); DOT_DIR = ".git"; }
public static async Task Main(string[] args) { var config = new ConfigurationBuilder() .SetBasePath(Directory.GetCurrentDirectory()) .AddJsonFile("appsettings.json") .Build(); var appSettings = config.GetSection("AppSettings").Get <AppSettings>(); InitCommand.DoInit(appSettings); while (true) { try { Console.WriteLine($"Running commands, start at {DateTime.Now.ToShortTimeString()}"); await Task.WhenAll( Run(appSettings), Task.Delay(60 * 60 * 1000)); Console.WriteLine($"Finished run at {DateTime.Now.ToShortTimeString()}"); } catch (Exception excep) { Console.Error.WriteLine(excep.Message); await Task.Delay(60 * 60 * 1000); } } }
public void Execute_ShouldUseDefaultValues_WhenNoInputIsGiven() { var factory = Container.Resolve <IGitDependFileFactory>(); var console = Container.Resolve <IConsole>(); var fileSystem = Container.Resolve <IFileSystem>(); var config = new GitDependFile(); string dir = Lib1Directory; ReturnCode loadCode = ReturnCode.Success; factory.Arrange(f => f.LoadFromDirectory(Arg.AnyString, out dir, out loadCode)) .Returns(config); fileSystem.Arrange(f => f.File.WriteAllText(Arg.AnyString, Arg.AnyString)) .MustBeCalled(); int index = 0; string[] responses = { "", "" }; console.Arrange(c => c.ReadLine()) .Returns(() => responses[index++]); var options = new InitSubOptions(); var instance = new InitCommand(options); var code = instance.Execute(); Assert.AreEqual(ReturnCode.Success, code, "Invalid Return Code"); fileSystem.Assert("WriteAllText should have been caleld"); Assert.AreEqual("make.bat", config.Build.Script, "Invalid Build Script"); Assert.AreEqual("artifacts/NuGet/Debug", config.Packages.Directory, "Invalid Packages Directory"); }
public void TestInit_Interactive() { TestInputReader reader = HostEnvironment.InputReader as TestInputReader; reader.Inputs.Add("DefaultProvider", "cdnjs"); reader.Inputs.Add("DefaultDestination:", "wwwroot"); InitCommand command = new InitCommand(HostEnvironment); command.Configure(null); int result = command.Execute(); Assert.AreEqual(0, result); string libmanFilePath = Path.Combine(WorkingDir, HostEnvironment.EnvironmentSettings.ManifestFileName); Assert.IsTrue(File.Exists(libmanFilePath)); string contents = File.ReadAllText(libmanFilePath); string expectedContents = @"{ ""version"": ""1.0"", ""defaultProvider"": ""cdnjs"", ""libraries"": [] }"; Assert.AreEqual(StringHelper.NormalizeNewLines(expectedContents), StringHelper.NormalizeNewLines(contents)); }
private static async Task InternalMain(string[] args, PackageHelper packageHelper) { // now uses 'verbs' so each verb is a command // // e.g umbpack init or umbpack push // // these are handled by the Command classes. var parser = new Parser(with => { with.HelpWriter = null; // with.HelpWriter = Console.Out; with.AutoVersion = false; with.CaseSensitive = false; }); // TODO: could load the verbs by interface or class var parserResults = parser.ParseArguments <PackOptions, PushOptions, InitOptions>(args); parserResults .WithParsed <PackOptions>(opts => PackCommand.RunAndReturn(opts).Wait()) .WithParsed <PushOptions>(opts => PushCommand.RunAndReturn(opts, packageHelper).Wait()) .WithParsed <InitOptions>(opts => InitCommand.RunAndReturn(opts)) .WithNotParsed(async errs => await DisplayHelp(parserResults, errs)); }
public async Task GivenThatIWantToDestroyAFeedVerifyAFeedWithNupkgsSucceeds() { using (var packagesFolder = new TestFolder()) using (var target = new TestFolder()) using (var cache = new LocalCache()) using (var cache2 = new LocalCache()) using (var outputFolder = new TestFolder()) { var log = new TestLogger(); var fileSystem = new PhysicalFileSystem(cache, UriUtility.CreateUri(target.Root)); var fileSystem2 = new PhysicalFileSystem(cache2, UriUtility.CreateUri(target.Root)); var settings = new LocalSettings(); var root = new DirectoryInfo(target); await InitCommand.RunAsync(settings, fileSystem, enableCatalog : true, enableSymbols : true, log : log, token : CancellationToken.None); var packageA = new TestNupkg("a", "1.0"); var packageB = new TestNupkg("b", "2.0.0-beta+blah"); packageA.Save(packagesFolder.Root); packageB.Save(packagesFolder.Root); await PushCommand.RunAsync(settings, fileSystem, new List <string>() { packagesFolder }, false, false, log); var success = await DestroyCommand.RunAsync(settings, fileSystem2, log); var files = root.GetFiles("*", SearchOption.AllDirectories); var dirs = root.GetDirectories(); success.ShouldBeEquivalentTo(true, "the command should exit without errors"); files.Length.ShouldBeEquivalentTo(0, "all files should be gone"); dirs.Length.ShouldBeEquivalentTo(0, "all directories should be gone"); } }
public override void Setup () { // Generate directories and a svn util. RemotePath = new FilePath (FileService.CreateTempDirectory () + Path.DirectorySeparatorChar); LocalPath = new FilePath (FileService.CreateTempDirectory () + Path.DirectorySeparatorChar); Directory.CreateDirectory (RemotePath.FullPath + "repo.git"); RemoteUrl = "file:///" + RemotePath.FullPath + "repo.git"; // Initialize the bare repo. var ci = new InitCommand (); ci.SetDirectory (new Sharpen.FilePath (RemotePath.FullPath + "repo.git")); ci.SetBare (true); ci.Call (); var bare = new FileRepository (new Sharpen.FilePath (RemotePath.FullPath + "repo.git")); string branch = Constants.R_HEADS + "master"; RefUpdate head = bare.UpdateRef (Constants.HEAD); head.DisableRefLog (); head.Link (branch); // Check out the repository. Checkout (LocalPath, RemoteUrl); Repo = GetRepo (LocalPath, RemoteUrl); DotDir = ".git"; }
public override void Setup() { // Generate directories and a svn util. RemotePath = new FilePath(FileService.CreateTempDirectory() + Path.DirectorySeparatorChar); LocalPath = new FilePath(FileService.CreateTempDirectory() + Path.DirectorySeparatorChar); Directory.CreateDirectory(RemotePath.FullPath + "repo.git"); RemoteUrl = "file:///" + RemotePath.FullPath + "repo.git"; // Initialize the bare repo. var ci = new InitCommand(); ci.SetDirectory(new Sharpen.FilePath(RemotePath.FullPath + "repo.git")); ci.SetBare(true); ci.Call(); var bare = new FileRepository(new Sharpen.FilePath(RemotePath.FullPath + "repo.git")); string branch = Constants.R_HEADS + "master"; RefUpdate head = bare.UpdateRef(Constants.HEAD); head.DisableRefLog(); head.Link(branch); // Check out the repository. Checkout(LocalPath, RemoteUrl); Repo = GetRepo(LocalPath, RemoteUrl); DotDir = ".git"; }
public async Task SubFeed_InitTwoFeedsDestroyOneVerifyFirst() { using (var target = new TestFolder()) using (var cache = new LocalCache()) using (var cache2 = new LocalCache()) { var log = new TestLogger(); var settings = new LocalSettings(); var feedSettings = new FeedSettings(); var rootFeedA = UriUtility.CreateUri(target.Root, "feedA"); var rootFeedB = UriUtility.CreateUri(target.Root, "feedB"); var fileSystem = new PhysicalFileSystem(cache, rootFeedA, rootFeedA, feedSubPath: "feedA"); var fileSystem2 = new PhysicalFileSystem(cache2, rootFeedB, rootFeedB, feedSubPath: "feedB"); // Init feeds var success = await InitCommand.InitAsync(settings, fileSystem, feedSettings, log, CancellationToken.None); success &= await InitCommand.InitAsync(settings, fileSystem2, feedSettings, log, CancellationToken.None); // Destroy feed 2 success &= await DestroyCommand.Destroy(settings, fileSystem2, log, CancellationToken.None); // Validate feed 1 success &= await ValidateCommand.Validate(settings, fileSystem, log, CancellationToken.None); success.Should().BeTrue(); target.RootDirectory.GetFiles().Should().BeEmpty(); target.RootDirectory.GetDirectories().Select(e => e.Name).ShouldBeEquivalentTo(new[] { "feedA" }); } }
static void Main(string[] args) { if (args.Length == 0) { PrintUsageHeader(); PrintUsage(); Environment.Exit(-1); } ICommand command = null; switch (args[0]) { case StartElectronCommand.COMMAND_NAME: command = new StartElectronCommand(args.Skip(1).ToArray()); break; case BuildCommand.COMMAND_NAME: command = new BuildCommand(args.Skip(1).ToArray()); break; case InitCommand.COMMAND_NAME: command = new InitCommand(args.Skip(1).ToArray()); break; case VersionCommand.COMMAND_NAME: command = new VersionCommand(args.Skip(1).ToArray()); break; case "--help": case "--h": case "help": PrintUsageHeader(); if (args.Length > 1) { PrintUsage(args[1]); } else { PrintUsage(); } break; default: Console.Error.WriteLine($"Unknown command {args[0]}"); PrintUsage(); Environment.Exit(-1); break; } if (command != null) { var success = command.ExecuteAsync().Result; if (!success) { Environment.Exit(-1); } } }
private void Initialise(InitCommand command) { if (this.handbrakeInstance == null) { this.handbrakeInstance = new HandBrakeInstance(); } if (this.logHandler == null) { this.logHandler = new LogHandler(command.LogDirectory, command.LogFile, command.EnableDiskLogging); } if (!command.AllowDisconnectedWorker) { ConsoleOutput.WriteLine("Worker: Disconnected worker monitoring enabled!", ConsoleColor.White, true); this.instanceWatcher = new InstanceWatcher(this); this.instanceWatcher.Start(5000); } this.completedState = null; this.handbrakeInstance.Initialize(command.LogVerbosity, !command.EnableHardwareAcceleration); this.handbrakeInstance.EncodeCompleted += this.HandbrakeInstance_EncodeCompleted; if (command.EnableLibDvdNav) { HandBrakeUtils.SetDvdNav(true); } }
/// <summary> /// Initializes a new instance for the <see cref="AddContactViewModel" /> class. /// </summary> public ServisAddContactViewModel(INavigation navigation, Model.Requests.ServisOdaberiTerminRequest request) { NaciniPlacanjaListHeight = NaciniPlacanja.Count * 112; this.SubmitCommand = new Command(this.SubmitButtonClicked); this.InitCommand = new Command(async() => await this.Init()); InitCommand.Execute(null); this.Navigation = navigation; Request = request; DetaljiListViewHeight = Request.Kolicina * 265; var TipoviList = new ObservableCollection <string>(); foreach (Model.Tip item in Enum.GetValues(typeof(Model.Tip))) { TipoviList.Add(item.ToString()); } for (int i = 0; i < Request.Kolicina; i++) { DetaljiServisa.Add(new DetaljiServisaMobile() { DetaljiText = "Detalji bicikla " + (i + 1) + " za servis", TipoviBicikala = TipoviList }); } }
public void OnInitCommand(InitCommand cmd) { View.InputView.Joystick.onMove.AddListener(OnJoyStickMove); View.InputView.JumpBtn.onDown.AddListener(OnClickDownJumpBtn); View.InputView.MeltBtn.onDown.AddListener(OnClickDownMeltBtn); View.InputView.PauseBtn.onDown.AddListener(OnPauseBtn); }
public async Task UpgradeUtility_VerifyMatchingVersionOfCapabilityWorksAsync() { using (var packagesFolder = new TestFolder()) using (var target = new TestFolder()) using (var cache = new LocalCache()) { var log = new TestLogger(); var fileSystem = new PhysicalFileSystem(cache, UriUtility.CreateUri(target.Root)); var settings = new LocalSettings(); var context = new SleetContext() { Token = CancellationToken.None, LocalSettings = settings, Log = log, Source = fileSystem, SourceSettings = new FeedSettings() { CatalogEnabled = true } }; // Init await InitCommand.InitAsync(context); // Change index.json var indexJsonPath = Path.Combine(target.Root, "index.json"); var json = JObject.Parse(File.ReadAllText(indexJsonPath)); json["sleet:capabilities"] = "schema:1.0.0"; File.WriteAllText(indexJsonPath, json.ToString()); var fileSystem2 = new PhysicalFileSystem(cache, UriUtility.CreateUri(target.Root)); await UpgradeUtility.EnsureCompatibility(fileSystem2, log, CancellationToken.None); } }
private void RunEncodeInitProcess(JsonEncodeObject jobToStart) { InitCommand initCommand = new InitCommand { EnableDiskLogging = false, AllowDisconnectedWorker = false, DisableLibDvdNav = !this.userSettingService.GetUserSetting <bool>(UserSettingConstants.DisableLibDvdNav), EnableHardwareAcceleration = true, LogDirectory = DirectoryUtilities.GetLogDirectory(), LogVerbosity = this.userSettingService.GetUserSetting <int>(UserSettingConstants.Verbosity) }; initCommand.LogFile = Path.Combine(initCommand.LogDirectory, string.Format("activity_log.worker.{0}.txt", GeneralUtilities.ProcessId)); JsonSerializerSettings settings = new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore }; string job = JsonConvert.SerializeObject(new EncodeCommand { InitialiseCommand = initCommand, EncodeJob = jobToStart }, Formatting.None, settings); var task = Task.Run(async() => await this.MakeHttpJsonPostRequest("StartEncode", job)); task.Wait(); this.MonitorEncodeProgress(); }
public static LocalGitRepository Init(string targetLocalPath, string url) { InitCommand ci = new InitCommand(); ci.SetDirectory(targetLocalPath); ci.Call(); LocalGitRepository repo = new LocalGitRepository(Path.Combine(targetLocalPath, Constants.DOT_GIT)); string branch = Constants.R_HEADS + "master"; RefUpdate head = repo.UpdateRef(Constants.HEAD); head.DisableRefLog(); head.Link(branch); if (url != null) { RemoteConfig remoteConfig = new RemoteConfig(repo.GetConfig(), "origin"); remoteConfig.AddURI(new URIish(url)); string dst = Constants.R_REMOTES + remoteConfig.Name; RefSpec wcrs = new RefSpec(); wcrs = wcrs.SetForceUpdate(true); wcrs = wcrs.SetSourceDestination(Constants.R_HEADS + "*", dst + "/*"); remoteConfig.AddFetchRefSpec(wcrs); remoteConfig.Update(repo.GetConfig()); } // we're setting up for a clone with a checkout repo.GetConfig().SetBoolean("core", null, "bare", false); repo.GetConfig().Save(); return(repo); }
public void OnInitCommand(InitCommand cmd) { StoragePoint storagePoint = Model.StoragePoint; Vector3 returnPos = Vector3.zero; if (storagePoint != null && storagePoint.Chapter == Model.MapIndex) { returnPos = storagePoint.Postion; } else { returnPos = Model.Map.BornPoint.position; } View.PlayerView.Player.transform.position = returnPos; //设置Player的出生点 View.PlayerView.PlayerRenderer.color = Model.Map.PlayerColor; //设置Player的初始数据 Model.MeltStatus = false; Model.AttachedObject = null; Model.Offset = Vector2.zero; Model.Jump = false; Model.CurrentStayMeltAreas = new LinkedList <MeltArea>(); Model.LastExitMeltArea = null; Model.LastJumpReqTime = float.MinValue; Model.LastMeltReqTime = float.MinValue; Model.StayedGround = null; Model.LastMeltOutTime = float.MinValue; }
private static void ExecAction(object obj) { ICommand command = null; switch (obj) { case InitArgs args: var settings = new ProjectSettings(args.ProjectName, args.RootDirectory, args.IssueUrl); command = new InitCommand(settings); break; case AddArgs args: var changeLogEntry = new ChangeLogEntry(args.Description, args.Author, args.IssueId, args.Type); command = new AddCommand(changeLogEntry); break; case MergeArgs _: command = new MergeCommand(); break; } if (command != null) { command.Execute(); } }
public static async Task CreateCatalogAsync(string root, string feedRoot, string nupkgFolder, Uri baseUri, int catalogPageSize, ILogger log) { using (var cache = new LocalCache()) { var sleetConfig = CreateSleetConfig(root, feedRoot, baseUri); var settings = LocalSettings.Load(sleetConfig); var fileSystem = FileSystemFactory.CreateFileSystem(settings, cache, "feed"); var feedSettings = await FeedSettingsUtility.GetSettingsOrDefault(fileSystem, log, CancellationToken.None); feedSettings.CatalogEnabled = true; feedSettings.SymbolsEnabled = false; feedSettings.CatalogPageSize = catalogPageSize; var success = await InitCommand.InitAsync(settings, fileSystem, feedSettings, log, CancellationToken.None); if (success != true) { throw new InvalidOperationException("Catalog init failed"); } if (Directory.GetFiles(nupkgFolder).Any()) { success = await PushCommand.PushPackages(settings, fileSystem, new List <string>() { nupkgFolder }, false, false, log, CancellationToken.None); if (success != true) { throw new InvalidOperationException("Push failed"); } } } }
public async Task Symbols_VerifyFilesExistAfterPush() { using (var testContext = new SleetTestContext()) { var context = testContext.SleetContext; context.SourceSettings.SymbolsEnabled = true; var testPackage = new TestNupkg("packageA", "1.0.0"); testPackage.Files.Clear(); testPackage.AddFile("lib/net45/SymbolsTestA.dll", TestUtility.GetResource("SymbolsTestAdll").GetBytes()); testPackage.AddFile("lib/net45/SymbolsTestA.pdb", TestUtility.GetResource("SymbolsTestApdb").GetBytes()); testPackage.AddFile("lib/net45/SymbolsTestB.dll", TestUtility.GetResource("SymbolsTestBdll").GetBytes()); testPackage.AddFile("lib/net45/SymbolsTestB.pdb", TestUtility.GetResource("SymbolsTestBpdb").GetBytes()); var zipFile = testPackage.Save(testContext.Packages); // run commands await InitCommand.InitAsync(context); // add package await PushCommand.RunAsync(context.LocalSettings, context.Source, new List <string>() { zipFile.FullName }, false, false, context.Log); // validate var validateOutput = await ValidateCommand.RunAsync(context.LocalSettings, context.Source, context.Log); validateOutput.Should().BeTrue(); } }
public async Task FileSystemLock_VerifyMessageFromSettings() { using (var target = new TestFolder()) using (var cache = new LocalCache()) { var log = new TestLogger(); var fileSystem = new PhysicalFileSystem(cache, UriUtility.CreateUri(target.Root)); var settings = new LocalSettings(); settings.FeedLockMessage = "FROMSETTINGS!!"; var lockMessage = Guid.NewGuid().ToString(); await InitCommand.RunAsync(settings, fileSystem, log); var lockObj = await SourceUtility.VerifyInitAndLock(settings, fileSystem, lockMessage, log, CancellationToken.None); lockObj.IsLocked.Should().BeTrue(); var path = Path.Combine(target.Root, ".lock"); var json = JObject.Parse(File.ReadAllText(path)); json["message"].ToString().Should().Be("FROMSETTINGS!!"); json["date"].ToString().Should().NotBeNullOrEmpty(); json["pid"].ToString().Should().NotBeNullOrEmpty(); } }
private void Connect() { Debug.Log("about to connect on '" + brokerHostname + "'"); // Forming a certificate based on a TextAsset //X509Certificate cert = new X509Certificate(); //Debug.Log("allah"+ certificate.bytes); //cert.Import(certificate.bytes); //Debug.Log("Using the certificate '" + cert + "'"); client = new MqttClient(brokerHostname); string clientId = Guid.NewGuid().ToString(); Debug.Log("About to connect using '" + userName + "' / '" + password + "'"); try { client.Connect(clientId, userName, password); } catch (Exception e) { Debug.LogError("Connection error: " + e); } //Richiesta di inizializzazione initCmd = new InitCommand { type = 1 }; msg = JsonUtility.ToJson(initCmd); Publish("unity", msg); }
public async Task Symbols_AddSymbolsPackageWithNoValidSymbolsVerifyFeed() { using (var testContext = new SleetTestContext()) { var context = testContext.SleetContext; context.SourceSettings.SymbolsEnabled = true; var symbols = new Symbols(context); var packageIndex = new PackageIndex(context); var catalog = new Catalog(context); var autoComplete = new AutoComplete(context); var flatContainer = new FlatContainer(context); var registrations = new Registrations(context); var search = new Search(context); // Create package var pkgA = new TestNupkg("a", "1.0.0"); pkgA.Nuspec.IsSymbolPackage = true; var zip = pkgA.Save(testContext.Packages); var pkgInput = testContext.GetPackageInput(zip); // Init var success = await InitCommand.RunAsync( testContext.SleetContext.LocalSettings, testContext.SleetContext.Source, enableCatalog : true, enableSymbols : true, log : testContext.SleetContext.Log, token : CancellationToken.None); // Push success &= await PushCommand.RunAsync( testContext.SleetContext.LocalSettings, testContext.SleetContext.Source, new List <string>() { zip.FullName }, force : false, skipExisting : false, log : testContext.SleetContext.Log); // Validate success &= await ValidateCommand.RunAsync( testContext.SleetContext.LocalSettings, testContext.SleetContext.Source, testContext.SleetContext.Log); success.Should().BeTrue(); // The nupkg should exist, but there should not be any assets added. (await symbols.GetSymbolsPackagesAsync()).Should().BeEmpty(); (await packageIndex.GetSymbolsPackagesAsync()).Should().NotBeEmpty(); // Verify nupkg exists var nupkgPath = Path.Combine(testContext.Target, "symbols", "packages", "a", "1.0.0", "a.1.0.0.symbols.nupkg"); File.Exists(nupkgPath).Should().BeTrue(); // Verify package details var detailsPath = Path.Combine(testContext.Target, "symbols", "packages", "a", "1.0.0", "package.json"); File.Exists(detailsPath).Should().BeTrue(); } }
public virtual void TestInitRepository() { FilePath directory = CreateTempDirectory("testInitRepository"); InitCommand command = new InitCommand(); command.SetDirectory(directory); Repository repository = command.Call().GetRepository(); AddRepoToClose(repository); NUnit.Framework.Assert.IsNotNull(repository); }
public void CreateRepository(Project project) { var cmd = new InitCommand { GitDirectory = Path.Combine(GitSettings.RepositoriesPath, project.Name), Quiet = false, Bare = true }; cmd.Execute(); }
public virtual void TestInitNonEmptyRepository() { FilePath directory = CreateTempDirectory("testInitRepository2"); FilePath someFile = new FilePath(directory, "someFile"); someFile.CreateNewFile(); NUnit.Framework.Assert.IsTrue(someFile.Exists()); NUnit.Framework.Assert.IsTrue(directory.ListFiles().Length > 0); InitCommand command = new InitCommand(); command.SetDirectory(directory); Repository repository = command.Call().GetRepository(); AddRepoToClose(repository); NUnit.Framework.Assert.IsNotNull(repository); }
public virtual void TestInitBareRepository() { try { FilePath directory = CreateTempDirectory("testInitBareRepository"); InitCommand command = new InitCommand(); command.SetDirectory(directory); command.SetBare(true); Repository repository = command.Call().GetRepository(); AddRepoToClose(repository); NUnit.Framework.Assert.IsNotNull(repository); NUnit.Framework.Assert.IsTrue(repository.IsBare); } catch (Exception e) { NUnit.Framework.Assert.Fail(e.Message); } }
public void Explicit_path_is_preferred() { // it should override global fallback Git.Commands.GitDirectory = "abc/def/ghi"; var init = new InitCommand() { GitDirectory = "xyz" }; Assert.AreEqual(Path.GetFullPath(Path.Combine(init.GitDirectory, ".git")), init.ActualDirectory); // it should override env var Git.Commands.GitDirectory = null; string tempGitDir = System.Environment.GetEnvironmentVariable("GIT_DIR"); try { System.Environment.SetEnvironmentVariable("GIT_DIR", "uvw"); Assert.AreEqual(Path.GetFullPath(Path.Combine(init.GitDirectory, ".git")), init.ActualDirectory); } finally { System.Environment.SetEnvironmentVariable("GIT_DIR", tempGitDir); } }
public void Init() { //Initializing a new repository in the current directory (if GID_DIR environment variable is not set) Git.Init("."); //Initializing a new repository in the specified location Git.Init("path/to/repo"); //Initializing a new repository with options var cmd = new InitCommand { GitDirectory ="path/to/repo", Quiet = false, Bare = true }; cmd.Execute(); }
public void InitCommand_Should_Notify_Initialization_With_Welcome_Message() { InitCommand command = new InitCommand (); CommandResult result = command.Execute (); Assert.AreEqual ("Welcome", result.Data); }
void execute() { var cmd = new InitCommand(); cmd.Execute(theInput); }
public void Init_honors_environment_variable_GIT_DIR() { //Store GIT_DIR value temporarily string tempGitDir = System.Environment.GetEnvironmentVariable("GIT_DIR"); try { var path = Path.Combine(Directory.GetCurrentDirectory(), "test1"); System.Environment.SetEnvironmentVariable("GIT_DIR", path); var init = new InitCommand(); Commands.GitDirectory = null; // override fallback Assert.AreEqual(Path.Combine(path, ".git"), init.ActualDirectory); } finally { //Reset GIT_DIR value to initial value before the test System.Environment.SetEnvironmentVariable("GIT_DIR", tempGitDir); } }
public void Init_Honors_CurrentDirectory() { string tempGitDir = System.Environment.GetEnvironmentVariable("GIT_DIR"); try { //current directory is returned only if global fallback and envvar are null Git.Commands.GitDirectory = null; // override fallback System.Environment.SetEnvironmentVariable("GIT_DIR", null); // override environment var path = Directory.GetCurrentDirectory(); var init = new InitCommand(); Assert.AreEqual(Path.Combine(Directory.GetCurrentDirectory(), ".git"), init.ActualDirectory); } finally { System.Environment.SetEnvironmentVariable("GIT_DIR", tempGitDir); } }
public void Init_honors_global_fallback_gitdir() { //Verify specified directory var path = Path.Combine(Directory.GetCurrentDirectory(), "test"); Git.Commands.GitDirectory = path; // <--- cli option --git_dir sets this global variable. it is a fallback value for all commands var init = new InitCommand(); Assert.AreEqual(Path.Combine(path, ".git"), init.ActualDirectory); }
/// <summary> /// Initializes a repository. Use GitDirectory to specify the location. Default is the current directory. /// </summary> /// <param name="path"></param> /// <param name="bare"></param> /// <returns></returns> public static Repository Init(string path, bool bare) { var cmd = new InitCommand() { GitDirectory=path, Bare = bare }; return Init(cmd); }
/// <summary> /// Initializes a repository in the current location using the provided git command's options. /// </summary> /// <param name="cmd"></param> /// <returns></returns> public static Repository Init(InitCommand cmd) { cmd.Execute(); return cmd.Repository; }
public static FileRepository Init (string targetLocalPath, string url, IProgressMonitor monitor) { InitCommand ci = new InitCommand (); ci.SetDirectory (targetLocalPath); var git = ci.Call (); FileRepository repo = (FileRepository) git.GetRepository (); string branch = Constants.R_HEADS + "master"; RefUpdate head = repo.UpdateRef (Constants.HEAD); head.DisableRefLog (); head.Link (branch); RemoteConfig remoteConfig = new RemoteConfig (repo.GetConfig (), "origin"); remoteConfig.AddURI (new URIish (url)); string dst = Constants.R_REMOTES + remoteConfig.Name; RefSpec wcrs = new RefSpec(); wcrs = wcrs.SetForceUpdate (true); wcrs = wcrs.SetSourceDestination (Constants.R_HEADS + "*", dst + "/*"); remoteConfig.AddFetchRefSpec (wcrs); // we're setting up for a clone with a checkout repo.GetConfig().SetBoolean ("core", null, "bare", false); remoteConfig.Update (repo.GetConfig()); repo.GetConfig().Save(); return repo; }
public static FileRepository Clone (string targetLocalPath, string url, IProgressMonitor monitor) { // Initialize InitCommand ci = new InitCommand (); ci.SetDirectory (targetLocalPath); var git = ci.Call (); FileRepository repo = (FileRepository) git.GetRepository (); string branch = Constants.R_HEADS + "master"; string remoteName = "origin"; RefUpdate head = repo.UpdateRef (Constants.HEAD); head.DisableRefLog (); head.Link (branch); RemoteConfig remoteConfig = new RemoteConfig (repo.GetConfig (), remoteName); remoteConfig.AddURI (new URIish (url)); string dst = Constants.R_REMOTES + remoteConfig.Name; RefSpec wcrs = new RefSpec(); wcrs = wcrs.SetForceUpdate (true); wcrs = wcrs.SetSourceDestination (Constants.R_HEADS + "*", dst + "/*"); remoteConfig.AddFetchRefSpec (wcrs); // we're setting up for a clone with a checkout repo.GetConfig().SetBoolean ("core", null, "bare", false); remoteConfig.Update (repo.GetConfig()); repo.GetConfig().Save(); // Fetch Transport tn = Transport.Open (repo, remoteName); FetchResult r; try { r = tn.Fetch(new GitMonitor (monitor), null); } finally { tn.Close (); } // Create the master branch // branch is like 'Constants.R_HEADS + branchName', we need only // the 'branchName' part String branchName = branch.Substring (Constants.R_HEADS.Length); git.BranchCreate ().SetName (branchName).SetUpstreamMode (CreateBranchCommand.SetupUpstreamMode.TRACK).SetStartPoint ("origin/master").Call (); // Checkout DirCache dc = repo.LockDirCache (); try { RevWalk rw = new RevWalk (repo); ObjectId remCommitId = repo.Resolve (remoteName + "/" + branchName); RevCommit remCommit = rw.ParseCommit (remCommitId); DirCacheCheckout co = new DirCacheCheckout (repo, null, dc, remCommit.Tree); co.Checkout (); } catch { dc.Unlock (); throw; } return repo; }
public static void Init(InitCommand command) { command.Execute(); }