/ / Libgit2Sharp: शुरुआती (पहले) प्रतिबद्ध से जुड़े फाइलें प्राप्त करें - सी #, गिट, libgit2, libgit2sharp

Libgit2Sharp: शुरुआती (पहले) प्रतिबद्ध से जुड़े फाइलें प्राप्त करें - सी #, गिट, libgit2, libgit2sharp

मैं उन फ़ाइलों को पुनर्प्राप्त कैसे कर सकता हूं जो एक भंडार की पहली (प्रारंभिक) प्रतिबद्धता का हिस्सा थे?

मैं वर्तमान में पता लगाने के लिए निम्नलिखित का उपयोग कर रहा हूंफाइलें जो प्रतिबद्धता का हिस्सा हैं (और यह काम करती है)। हालांकि, चूंकि विधि को दो मानकों की आवश्यकता है, इसलिए मुट्ठी प्रतिबद्धता का हिस्सा होने वाली फ़ाइलों को प्राप्त करने के लिए मुझे क्या करना चाहिए? या क्या मुझे एक और तरीका है जिसका उपयोग करने की ज़रूरत है?

    repo.Diff.Compare<TreeChanges>(repo.Commits.ElementAt(i).Tree, repo.Commits.ElementAt(i + 1).Tree)

धन्यवाद!

उत्तर:

उत्तर № 1 के लिए 1

आप फाइलों को पकड़ने के लिए प्रारंभिक पेड़ और एक शून्य पेड़ के बीच आसानी से एक अंतर ले सकते हैं:

foreach (TreeEntryChanges change in repo.Diff.Compare<TreeChanges>(null, commit.Tree))
{
Console.WriteLine("t{0} :t{1}", change.Status, change.Path);
}

जवाब के लिए 0 № 2

मैं निम्नलिखित का उपयोग करके अपनी आवश्यकता को प्राप्त करने में सक्षम था:

                    //The tree object corresponding to the first commit in the repo
Tree firstCommit = repo.Lookup<Tree>(repo.Commits.ElementAt(i).Tree.Sha);
//The tree object corresponding to the last commit in the repo
Tree lastCommit = repo.Lookup<Tree>(repo.Commits.ElementAt(0).Tree.Sha);


var changes = repo.Diff.Compare<TreeChanges>(lastCommit, firstCommit);
foreach (var item in changes)
{
if (item.Status != ChangeKind.Deleted)
{
//...This object (i.e. item) corresponds to a file that was part of the first (initial) commit...
}
}

अगर कोई बेहतर तरीका है तो मुझे बताएं ...