public ToolTemplateGenerator() { Refs.Add(typeof(CompilerErrorCollection).Assembly.Location); Refs.Add(typeof(DescriptionAttribute).Assembly.Location); Refs.Add(typeof(List <>).Assembly.Location); Refs.Add(typeof(HashSet <>).Assembly.Location); }
/// <summary> /// Checkout the specified <see cref = "Branch" />, reference or SHA. /// </summary> /// <param name = "committishOrBranchSpec">A revparse spec for the commit or branch to checkout.</param> /// <param name="checkoutOptions"><see cref = "CheckoutOptions" /> controlling checkout behavior.</param> /// <param name="onCheckoutProgress"><see cref = "CheckoutProgressHandler" /> that checkout progress is reported through.</param> /// <returns>The <see cref = "Branch" /> that was checked out.</returns> public Branch Checkout(string committishOrBranchSpec, CheckoutOptions checkoutOptions, CheckoutProgressHandler onCheckoutProgress) { Ensure.ArgumentNotNullOrEmptyString(committishOrBranchSpec, "committishOrBranchSpec"); Branch branch = TryResolveBranch(committishOrBranchSpec); if (branch != null) { return(Checkout(branch, checkoutOptions, onCheckoutProgress)); } var previousHeadName = Info.IsHeadDetached ? Head.Tip.Sha : Head.Name; Commit commit = LookupCommit(committishOrBranchSpec); CheckoutTree(commit.Tree, checkoutOptions, onCheckoutProgress); // Update HEAD. Refs.UpdateTarget("HEAD", commit.Id.Sha); if (committishOrBranchSpec != "HEAD") { LogCheckout(previousHeadName, commit.Id, committishOrBranchSpec); } return(Head); }
/// <summary> /// Creates a commit object that represents the current /// state of the index, writes the commit to the `objects` directory /// and points `HEAD` at the commit. /// </summary> public static string Commit(CommitOptions options) { Files.AssertInRepo(); Config.AssertNotBare(); // Write a tree object that represents the current state of the // index. var treeHash = WriteTree(); var headDesc = Refs.IsHeadDetached() ? "detached HEAD" : Refs.HeadBranchName(); // If the hash of the new tree is the same as the hash of the tree // that the `HEAD` commit points at, abort because there is // nothing new to commit. if (Refs.Hash("HEAD") != null && treeHash == Objects.TreeHash(Objects.Read(Refs.Hash("HEAD")))) { throw new Exception("# On " + headDesc + "\nnothing to commit, working directory clean"); } // Abort if the repository is in the merge state and there are // unresolved merge conflicts. string[] conflictedPaths = Index.ConflictedPaths(); if (Core.Merge.IsMergeInProgress() && conflictedPaths.Length > 0) { throw new Exception( string.Join("\n", conflictedPaths.Select(p => "U " + p)) + "\ncannot commit because you have unmerged files"); } // Otherwise, do the commit. // If the repository is in the merge state, use a pre-written // merge commit message. If the repository is not in the // merge state, use the message passed with `-m`. var m = Core.Merge.IsMergeInProgress() ? Files.Read(Path.Combine(Files.GitletPath(), "MERGE_MSG")) : options.m; // Write the new commit to the `objects` directory. var commitHash = Objects.WriteCommit(treeHash, m, Refs.CommitParentHashes()); // Point `HEAD` at new commit. UpdateRef("HEAD", commitHash); // If `MERGE_HEAD` exists, the repository was in the merge // state. Remove `MERGE_HEAD` and `MERGE_MSG`to exit the merge // state. Report that the merge is complete. if (Core.Merge.IsMergeInProgress()) { File.Delete(Path.Combine(Files.GitletPath(), "MERGE_MSG")); Refs.Rm("MERGE_HEAD"); return("Merge made by the three-way strategy"); } // Repository was not in the merge state, so just report that // the commit is complete. return("[" + headDesc + " " + commitHash + "] " + m); }
private static int _ClrObjectFinalizer(IntPtr L) { var idx = _GetCLRReference(L, 1); Refs.DelRef(idx); return(0); }
public void RemoveRef(Referee r) { if (Refs.Contains(r)) { Refs.Remove(r); } }
public void AddRef(Referee r) { if (!Refs.Contains(r)) { Refs.Add(r); } }
private static void UpdateRef(string refToUpdate, string refToUpdateTo) { Files.AssertInRepo(); // Get the hash that `refToUpdateTo` points at. var hash = Refs.Hash(refToUpdateTo); // Abort if `refToUpdateTo` does not point at a hash. if (!Objects.Exists(hash)) { throw new Exception(refToUpdateTo + " not a valid SHA1"); } // Abort if `refToUpdate` does not match the syntax of a ref. if (!Refs.IsRef(refToUpdate)) { throw new Exception("cannot lock the ref " + refToUpdate); } // Abort if `hash` points to an object in the `objects` directory // that is not a commit. if (Objects.Type(Objects.Read(hash)) != "commit") { var branch = Refs.TerminalRef(refToUpdate); throw new Exception(branch + " cannot refer to non-commit object " + hash + "\n"); } // Otherwise, set the contents of the file that the ref represents // to `hash`. Refs.Write(Refs.TerminalRef(refToUpdate), hash); }
private bool ContainsCircularRefRec(SheetCell cell, HashSet <SheetCell> curChain) { if (curChain.Contains(cell)) { return(true); } if (Refs.ContainsKey(cell) && Refs[cell].Count > 0) { curChain.Add(cell); foreach (var cellRef in Refs[cell]) { // create a duplicate HashSet for every new possible walk on the graph of cells. // this is so that cells that reference multiple values that don't contain // crefs wont cause false positives if (ContainsCircularRefRec(cellRef, new HashSet <SheetCell>(curChain))) { return(true); } } } return(false); }
/// <summary> /// Checkout the tip commit of the specified <see cref = "Branch" /> object. If this commit is the /// current tip of the branch, will checkout the named branch. Otherwise, will checkout the tip commit /// as a detached HEAD. /// </summary> /// <param name="branch">The <see cref = "Branch" /> to check out. </param> /// <param name="checkoutOptions"><see cref = "CheckoutOptions" /> controlling checkout behavior.</param> /// <param name="onCheckoutProgress"><see cref = "CheckoutProgressHandler" /> that checkout progress is reported through.</param> /// <returns>The <see cref = "Branch" /> that was checked out.</returns> public Branch Checkout(Branch branch, CheckoutOptions checkoutOptions, CheckoutProgressHandler onCheckoutProgress) { Ensure.ArgumentNotNull(branch, "branch"); // Make sure this is not an unborn branch. if (branch.Tip == null) { throw new OrphanedHeadException( string.Format(CultureInfo.InvariantCulture, "The tip of branch '{0}' is null. There's nothing to checkout.", branch.Name)); } CheckoutTree(branch.Tip.Tree, checkoutOptions, onCheckoutProgress); // Update HEAD. if (!branch.IsRemote && string.Equals(Refs[branch.CanonicalName].TargetIdentifier, branch.Tip.Id.Sha, StringComparison.OrdinalIgnoreCase)) { Refs.UpdateTarget("HEAD", branch.CanonicalName); } else { Refs.UpdateTarget("HEAD", branch.Tip.Id.Sha); } return(Head); }
public object ToCLR(int index = -1) { var type = Type(index); switch (type) { case LuaType.Boolean: return(ToBool(index)); case LuaType.LightUserdata: return(ToLightUserdata(index)); case LuaType.Nil: return(null); case LuaType.None: return(null); case LuaType.Number: return(_ToNumber(index)); case LuaType.String: return(ToString(index)); case LuaType.Userdata: int refidx; try { refidx = _GetCLRReference(index); } catch { return(ToUserdata(index)); } return(Refs.GetRef(refidx)); case LuaType.Function: return("[function]"); case LuaType.Table: return("[table]"); default: throw new LuaException($"Unsupported Lua->CLR conversion for type {type}"); } }
////////////////////////// //*** CLR REFERENCES ***// ////////////////////////// private int _MakeCLRReference(object o) { var refidx = Refs.AddRef(o); OwnedRefs.Add(refidx); return(refidx); }
private void LogCommit(Commit commit, bool amendPreviousCommit, bool isHeadOrphaned, bool isMergeCommit) { // Compute reflog message string reflogMessage = "commit"; if (isHeadOrphaned) { reflogMessage += " (initial)"; } else if (amendPreviousCommit) { reflogMessage += " (amend)"; } else if (isMergeCommit) { reflogMessage += " (merge)"; } reflogMessage = string.Format("{0}: {1}", reflogMessage, commit.MessageShort); var headRef = Refs.Head; // in case HEAD targets a symbolic reference, log commit on the targeted direct reference if (headRef is SymbolicReference) { Refs.Log(headRef.ResolveToDirectReference()).Append(commit.Id, reflogMessage, commit.Committer); } // Log commit on HEAD Refs.Log(headRef).Append(commit.Id, reflogMessage, commit.Committer); }
/// <summary> /// Internal implementation of Checkout that expects the ID of the checkout target /// to already be in the form of a canonical branch name or a commit ID. /// </summary> /// <param name="tree">The <see cref="Tree"/> to checkout.</param> /// <param name="checkoutModifiers"><see cref="CheckoutModifiers"/> controlling checkout behavior.</param> /// <param name="onCheckoutProgress"><see cref="CheckoutProgressHandler"/> that checkout progress is reported through.</param> /// <param name="checkoutNotificationOptions"><see cref="CheckoutNotificationOptions"/> to manage checkout notifications.</param> /// <param name="headTarget">Target for the new HEAD.</param> /// <param name="refLogHeadSpec">The spec which will be written as target in the reflog.</param> /// <param name="writeReflogEntry">Will a reflog entry be created.</param> private void Checkout( Tree tree, CheckoutModifiers checkoutModifiers, CheckoutProgressHandler onCheckoutProgress, CheckoutNotificationOptions checkoutNotificationOptions, string headTarget, string refLogHeadSpec, bool writeReflogEntry) { var previousHeadName = Info.IsHeadDetached ? Head.Tip.Sha : Head.Name; var opts = new CheckoutOptions { CheckoutModifiers = checkoutModifiers, OnCheckoutProgress = onCheckoutProgress, CheckoutNotificationOptions = checkoutNotificationOptions }; CheckoutTree(tree, null, opts); Refs.UpdateTarget("HEAD", headTarget); if (writeReflogEntry) { LogCheckout(previousHeadName, Head.Tip.Id, refLogHeadSpec); } }
/// <summary> /// Sets the current <see cref="Head"/> to the specified commit and optionally resets the <see cref="Index"/> and /// the content of the working tree to match. /// </summary> /// <param name = "resetOptions">Flavor of reset operation to perform.</param> /// <param name = "shaOrReferenceName">The sha or reference canonical name of the target commit object.</param> public void Reset(ResetOptions resetOptions, string shaOrReferenceName) { Ensure.ArgumentNotNullOrEmptyString(shaOrReferenceName, "shaOrReferenceName"); if (resetOptions.Has(ResetOptions.Mixed) && Info.IsBare) { throw new LibGit2Exception("Mixed reset is not allowed in a bare repository"); } GitObject commit = Lookup(shaOrReferenceName, GitObjectType.Any, LookUpOptions.ThrowWhenNoGitObjectHasBeenFound | LookUpOptions.DereferenceResultToCommit | LookUpOptions.ThrowWhenCanNotBeDereferencedToACommit); //TODO: Check for unmerged entries string refToUpdate = Info.IsHeadDetached ? "HEAD" : Head.CanonicalName; Refs.UpdateTarget(refToUpdate, commit.Sha); if (resetOptions == ResetOptions.Soft) { return; } Index.ReplaceContentWithTree(((Commit)commit).Tree); if (resetOptions == ResetOptions.Mixed) { return; } throw new NotImplementedException(); }
/// <summary> /// Sets the current <see cref = "Head" /> to the specified commit and optionally resets the <see cref = "Index" /> and /// the content of the working tree to match. /// </summary> /// <param name = "resetOptions">Flavor of reset operation to perform.</param> /// <param name = "shaOrReferenceName">The sha or reference canonical name of the target commit object.</param> public void Reset(ResetOptions resetOptions, string shaOrReferenceName) { Ensure.ArgumentNotNullOrEmptyString(shaOrReferenceName, "shaOrReferenceName"); if (resetOptions.Has(ResetOptions.Mixed) && Info.IsBare) { throw new LibGit2Exception("Mixed reset is not allowed in a bare repository"); } var commit = LookupCommit(shaOrReferenceName); //TODO: Check for unmerged entries string refToUpdate = Info.IsHeadDetached ? "HEAD" : Head.CanonicalName; Refs.UpdateTarget(refToUpdate, commit.Sha); if (resetOptions == ResetOptions.Soft) { return; } Index.ReplaceContentWithTree(commit.Tree); if (resetOptions == ResetOptions.Mixed) { return; } throw new NotImplementedException(); }
public void AddAssembly(Assembly asm) { if (ExistsRef(asm)) { return; } Refs.Add(asm); }
/// <summary> /// Sets the current <see cref="Head"/> to the specified commit and optionally resets the <see cref="Index"/> and /// the content of the working tree to match. /// </summary> /// <param name="resetOptions">Flavor of reset operation to perform.</param> /// <param name="commit">The target commit object.</param> public void Reset(ResetOptions resetOptions, Commit commit) { Ensure.ArgumentNotNull(commit, "commit"); Proxy.git_reset(handle, commit.Id, resetOptions); Refs.Log(Refs.Head).Append(commit.Id, string.Format("reset: moving to {0}", commit.Sha)); }
private void LogCheckout(string previousHeadName, ObjectId newHeadTip, string newHeadSpec) { // Compute reflog message string reflogMessage = string.Format("checkout: moving from {0} to {1}", previousHeadName, newHeadSpec); // Log checkout Refs.Log(Refs.Head).Append(newHeadTip, reflogMessage); }
public Data(Refs refs, ItemHealthKit.Data healthKit, int pointsWhenKilled, Probability <ItemType> probItem) { this.refs = refs; this.healthKit = healthKit; this.pointsWhenKilled = pointsWhenKilled; this.probItem = probItem; }
public TemplateGenerator() { Refs.Add(typeof(TextTransformation).Assembly.Location); Refs.Add(typeof(Uri).Assembly.Location); Refs.Add(typeof(File).Assembly.Location); Refs.Add(typeof(StringReader).Assembly.Location); Imports.Add("System"); }
public Data(Refs refs, float xMagnitude, float xSpeed, float yMagnitude, float ySpeed) { this.refs = refs; this.xMagnitude = xMagnitude; this.xSpeed = xSpeed; this.yMagnitude = yMagnitude; this.ySpeed = ySpeed; }
public TemplateGenerator() { ReferencePaths.Add(Path.GetDirectoryName(typeof(int).Assembly.Location).Replace("Microsoft.NETCore.App", "Microsoft.AspNetCore.App")); Refs.Add(typeof(TextTransformation).Assembly.Location); Refs.Add(typeof(Uri).Assembly.Location); Refs.Add(typeof(File).Assembly.Location); Refs.Add(typeof(StringReader).Assembly.Location); Imports.Add("System"); }
/// <summary> /// Adds a ref, only if it won't cause any issues to the template generator /// </summary> /// <param name="re">ref to add</param> private void SafeAddRef(string re) { if (string.IsNullOrWhiteSpace(re)) { return; } Refs.Add(re); }
// set reference to object // inherit parent lookup, but can only add to lookup in this node internal void SetRef(int index, IList <int> value) { Logger.WriteLine(4, "Setref node {0} {1} = {{{2}}}", Location, index, value.Join()); if (Refs == null) { var refs = FindRefs(); Refs = (refs == null) ? new Dictionary <int, IList <int> >() : new Dictionary <int, IList <int> >(refs); } Refs.Add(index, value); }
public Data(Refs refs, bool punchable, int damage, int pointsWhenPunched, Color color, float angle, float speed) { this.refs = refs; this.punchable = punchable; this.damage = damage; this.pointsWhenPunched = pointsWhenPunched; this.color = color; this.angle = angle; this.speed = speed; }
private static int _ConstructorInvoke(IntPtr L) { // upvalues: // 1 - LuaState // 2 - LuaCLRConstructorProxy // 3 - binding_flags (as int) // args: // 1 - type // ... - params var state = Refs.GetRef <LuaState>( _GetCLRReference(L, Lua.lua_upvalueindex(1)) ); var method = Refs.GetRef <LuaCLRConstructorProxy>( _GetCLRReference(L, Lua.lua_upvalueindex(2)) ); var binding_flags = (BindingFlags)(int)Lua.lua_tointeger(L, Lua.lua_upvalueindex(3)); Type type = Refs.GetRef <Type>(_GetCLRReference(L, 1)); var params_offset = 1; var params_len = Lua.lua_gettop(L) - params_offset; var params_ary = new object[params_len]; var params_begin = 1 + params_offset; for (int i = params_begin; i <= params_len + params_offset; i++) { var param = ConvertToCLR(L, i); params_ary[i - (params_begin)] = param; } method.Type = type; object result = null; try { result = method.Invoke(null, binding_flags, params_ary); } catch (Exception e) { state.PushBool(false); //state.Push($"[{e.GetType()}] {e.Message}"); state.PushCLR(e); return(2); } // ErrorMechanism.lua protocol: // return 2 values // 1 - flag (true - success, false - failure) // 2 - error string or return value state.PushBool(true); state.Push(result); return(2); }
public Data(Refs refs, VolleyData volley, float secondsBetweenVolleys, float volleyDirectionDeltaPerShot, float projectileLeftSpeed) { this.refs = refs; this.volley = volley; this.secondsBetweenVolleys = secondsBetweenVolleys; this.volleyDirectionDeltaPerShot = volleyDirectionDeltaPerShot; this.projectileLeftSpeed = projectileLeftSpeed; }
public void SetModel(ModelRef modelRef) { if (modelRef.Model is not Entity entity) { throw new InvalidOperationException("ModelRef must be an entity"); } var keyProperty = entity.AllProperties.Single(p => p.IsKey); FinalType = keyProperty.Type; Refs.Add(ParameterEntityRef.Create(entity.Name + GitLabClientGenerator.ToPropertyName(keyProperty.Name), keyProperty.Type)); Refs.Add(ParameterEntityRef.Create(entity.Name, modelRef, keyProperty.Name)); }
public bool MatchesSearchString(string searchString) { if (Refs.Any(gitHead => gitHead.Name.ToLower().Contains(searchString))) { return(true); } if ((searchString.Length > 2) && Guid.StartsWith(searchString, StringComparison.CurrentCultureIgnoreCase)) { return(true); } return((Author != null && Author.StartsWith(searchString, StringComparison.CurrentCultureIgnoreCase)) || Subject.ToLower().Contains(searchString)); }
private void FastForward(Commit fastForwardCommit) { var checkoutOpts = new CheckoutOptions { CheckoutModifiers = CheckoutModifiers.None, }; CheckoutTree(fastForwardCommit.Tree, null, checkoutOpts); var reference = Refs.Head.ResolveToDirectReference(); Refs.UpdateTarget(reference, fastForwardCommit.Id.Sha); // TODO: Update Reflog... }
public Refs() { Refs.ins_ = this; }