コード例 #1
0
ファイル: AnnotaterGit.cs プロジェクト: jchown/YellowSnowCS
        override public Annotations GetAnnotationsDir(string directory)
        {
            List <FSEntry> files = new List <FSEntry>();

            foreach (var file in Directory.EnumerateFileSystemEntries(directory))
            {
                FileAttributes attr = File.GetAttributes(file);

                string editor = File.GetAccessControl(file).GetOwner(typeof(System.Security.Principal.NTAccount)).ToString();
                long   edited = Epoch.ToLong(File.GetLastAccessTime(file));
                string commitHash = null, authorName = null, authorEmail = null, subject = null;

                //  Get the most recent edit

                Strings arguments = new Strings();
                arguments.Add("log");
                arguments.Add("--pretty=format:ch:%H%nan:%an%nae:%ae%nat:%at%nsj:%sj");
                arguments.Add("-n");
                arguments.Add("1");
                arguments.Add(file.GetFileName());

                Command command = new Command(program, directory, arguments);

                foreach (string output in command.GetOutput())
                {
                    string key   = output.Substring(0, 3);
                    string value = output.Substring(3);
                    if (key == "ch:")
                    {
                        commitHash = value;
                    }
                    else if (key == "ct:")
                    {
                        edited = long.Parse(value);
                    }
                    else if (key == "an:")
                    {
                        authorName = value;
                    }
                    else if (key == "ae:")
                    {
                        authorEmail = value;
                    }
                    else if (key == "sj:")
                    {
                        subject = value;
                    }
                }

                if (commitHash != null)
                {
                    editor = authorName;
                    if (authorEmail != null)
                    {
                        editor += " <" + authorEmail + ">";
                    }
                }

                files.Add(new FSEntry
                {
                    editor   = editor,
                    name     = file,
                    modified = edited
                });
            }

            return(new AnnotationsFS(files));
        }
コード例 #2
0
ファイル: Format.cs プロジェクト: jchown/YellowSnowCS
 internal static object Timestamp(long time)
 {
     return(Epoch.FromLong(time).ToString());
 }