Ejemplo n.º 1
0
 public static void ShowDiff(string path)
 {
     if (string.IsNullOrEmpty(path) || Repository == null)
     {
         return;
     }
     GitExternalManager.ShowDiff(path);
 }
Ejemplo n.º 2
0
        public static void ShowDiff(string path, Commit commit, [CanBeNull] Commit other)
        {
            TreeEntry entry = commit[path];

            if (entry != null)
            {
                Blob blob = entry.Target as Blob;
                if (blob == null || blob.IsBinary)
                {
                    return;
                }
                string oldFilePath = Application.dataPath.Replace("Assets", "Temp/") + "Git-diff-tmp-file";
                if (!string.IsNullOrEmpty(oldFilePath))
                {
                    using (FileStream file = File.Create(oldFilePath))
                    {
                        blob.GetContentStream().CopyTo(file);
                    }
                }
                string otherFilePath = path;
                if (other != null)
                {
                    TreeEntry otherEntry = other[path];
                    if (otherEntry == null)
                    {
                        return;
                    }
                    Blob otherBlob = otherEntry.Target as Blob;
                    if (otherBlob == null || otherBlob.IsBinary)
                    {
                        return;
                    }
                    otherFilePath = Application.dataPath.Replace("Assets", "Temp/") + "Git-diff-tmp-file-other";
                    if (string.IsNullOrEmpty(otherFilePath))
                    {
                        return;
                    }
                    using (FileStream file = File.Create(otherFilePath))
                    {
                        otherBlob.GetContentStream().CopyTo(file);
                    }
                }

                var asset = AssetDatabase.LoadAssetAtPath(path, typeof(Object));
                GitExternalManager.ShowDiff(Path.GetFileName(path) + " - " + entry.Target.Sha, oldFilePath, Path.GetFileName(path) + " - " + (other == null ? "Working Tree" : other.Id.Sha), otherFilePath, asset != null ? asset.GetType() : null);
            }
        }
Ejemplo n.º 3
0
 public static void ShowDiff(string path, [NotNull] Commit start, [NotNull] Commit end)
 {
     GitExternalManager.ShowDiff(path, start, end);
 }