Example #1
0
        private TreeEntry GetOrCreateTreeEntry(string name)
        {
            TreeEntry treeEntry;
            Entry     entry;

            if (entries.TryGetValue(name, out entry))
            {
                if (!(entry is TreeEntry))
                {
                    throw new AddEntryException(this, name, entry);
                }
                treeEntry = (TreeEntry)entry;
            }
            else
            {
                treeEntry = new TreeEntry();
                entries.Add(name, treeEntry);
            }
            return(treeEntry);
        }
Example #2
0
 public override bool Execute()
 {
     try {
         TreeEntry root = new TreeEntry();
         foreach (ITaskItem file in Files)
         {
             string treePath = file.GetMetadata("TargetPath");
             bool   isGitObject;
             bool.TryParse(file.GetMetadata("IsGitObject"), out isGitObject);
             root.AddEntry(treePath, isGitObject ? (Entry) new ObjectEntry(file.ItemSpec) : new BlobEntry(treePath, file.ItemSpec));
         }
         Tree = root.Hash;
         return(true);
     } catch (AddEntryException exception) {
         Log.LogErrorFromException(exception);
         return(false);
     } catch (ExitCodeException exception) {
         Log.LogErrorFromException(exception);
         return(false);
     }
 }
 internal AddEntryException(TreeEntry tree, string treePath, Entry entry) : base($"Exception when adding '{treePath}' to tree.")
 {
     Tree     = tree;
     TreePath = treePath;
     Entry    = entry;
 }