예제 #1
0
        public override SourceControlItemInfoDetails GetInfo(string path, ref string error)
        {
            string relativePath = string.Empty;

            try
            {
                relativePath = System.IO.Path.GetFullPath(path);
                relativePath = relativePath.Substring(SolutionFolder.Count());

                SourceControlItemInfoDetails SCIID = new SourceControlItemInfoDetails();
                using (var repo = new LibGit2Sharp.Repository(RepositoryRootFolder))
                {
                    SCIID.ShowFileInfo          = true;
                    SCIID.FilePath              = System.IO.Path.GetFullPath(path);
                    SCIID.FileWorkingDirectory  = repo.Info.WorkingDirectory;
                    SCIID.HasUnpushedCommits    = " " + (repo.Head.TrackingDetails.AheadBy > 1).ToString();
                    SCIID.HasUncommittedChanges = "False";
                    SCIID.FileState             = " " + FileStatus.Ignored.ToString();
                    foreach (var item in repo.RetrieveStatus())
                    {
                        if (Path.GetFullPath(path) == Path.GetFullPath(Path.Combine(RepositoryRootFolder, item.FilePath)))
                        {
                            if (item.State != FileStatus.Ignored)
                            {
                                SCIID.HasUncommittedChanges = "true";
                            }
                            SCIID.FileState = " " + item.State;
                        }
                    }

                    SCIID.ShowChangeInfo     = true;
                    SCIID.LastChangeAuthor   = " " + repo.Head.Tip.Author;
                    SCIID.LastChangeCommiter = " " + repo.Head.Tip.Committer;
                    //SCIID.LastChangeMessage = " " + repo.Head.Tip.Message;
                    //SCIID.LastChangeRevision = " " + repo.Refs.Head
                    SCIID.LastChangeRevision = " " + repo.Head.Tip.Sha;
                }
                return(SCIID);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.StackTrace);
                return(null);
            }
        }
예제 #2
0
        public override bool Lock(string Path, string lockComment, ref string error)
        {
            if (client == null)
            {
                Init();
            }
            bool result = false;

            try
            {
                string relativePath = System.IO.Path.GetFullPath(Path);
                relativePath = relativePath.Substring(SolutionFolder.Count() - 1);

                Uri targetUri = new Uri(SourceControlURL + relativePath);
                result = client.RemoteLock(targetUri, lockComment);
            }
            catch (Exception e)
            {
                error = e.Message + Environment.NewLine + e.InnerException;
                return(false);
            }
            return(result);
        }