Checking out a particular revision to a temp folder

30 views
Skip to first unread message

Tiernan OToole

unread,
Jul 4, 2011, 4:56:36 PM7/4/11
to GitSharp
Good morning all.

I have been trying to figure this out all day, and i have nearly given
up... then i found this group, so hopefully someone here can help...

I have built a very basic Post-Update script in a bare git repo, which
writes the given Revision Hash to a text file. The plan for that text
file is as follows:

Have a Windows EXE running, watching that folder for new text files.
when a new one comes in, read the hash, create a temp folder, checkout
the given code to that temp folder for that hash
then it will run msbuild on the sln and put the results somewhere (the
idea would be deploy to a website, something silular to what AppHarbor
does, but locally)

I have gotten the upto the creating of the temp folder, and the
msbuild parts pretty much working, but the problem is the git sync
part...

At the moment, i am tempted to just use a Process in .NET and kick off
git.exe to do the job, but i would like to try and do this in
gitsharp.

Any ideas?

I have an open repo on github at https://github.com/tiernano/GitPushMSBuild.
the code GitBuilder/program.cs file is where the "magic should happen"
if anyone can tell me what i am doing wrong (Getting a Null Reference
Exception).

Thanks in advance.

--Tiernan

Meinrad Recheis

unread,
Jul 5, 2011, 3:19:35 AM7/5/11
to gits...@googlegroups.com

Hi Tiernan,

Have you thought about checking out GitSharp source code and debugging into that code to find out where the exception comes from?
You could learn a lot and maybe give something back to the open source community by fixing the problem if it was easy to fix for you.

Welcome to the awesome world of open source software! ;)

Cheers,
-- Henon

Tiernan OToole

unread,
Jul 5, 2011, 4:28:30 AM7/5/11
to gits...@googlegroups.com
Ok, so i found a problem, or it could be a feature...

In the file named TransportLocal.cs, in the Gitsharp.Core/Transport directory, the following code is written:

    public override IFetchConnection openFetch()
        {
            throw new NotImplementedException();
        }

        public override IPushConnection openPush()
        {
            throw new NotImplementedException();
        }

        public override void close()
        {
            throw new NotImplementedException();
        }

The code i have is as follows:

GitSharp.Commands.CheckoutCommand checkout = new GitSharp.Commands.CheckoutCommand() { Arguments = new List<string>() { contents , "-f"}, Repository = Git.Clone(repoistory, tempDir) };
            checkout.Execute();

When i call that, it calls the OpenFetch block, which then throws an exception... Any ideas?

--Tiernan

Meinrad Recheis

unread,
Jul 5, 2011, 12:02:26 PM7/5/11
to gits...@googlegroups.com
On Tue, Jul 5, 2011 at 10:28 AM, Tiernan OToole <lsma...@gmail.com> wrote:
Ok, so i found a problem, or it could be a feature...

In the file named TransportLocal.cs, in the Gitsharp.Core/Transport directory, the following code is written:

    public override IFetchConnection openFetch()
        {
            throw new NotImplementedException();
        }

        public override IPushConnection openPush()
        {
            throw new NotImplementedException();
        }

        public override void close()
        {
            throw new NotImplementedException();
        }

The code i have is as follows:

GitSharp.Commands.CheckoutCommand checkout = new GitSharp.Commands.CheckoutCommand() { Arguments = new List<string>() { contents , "-f"}, Repository = Git.Clone(repoistory, tempDir) };
            checkout.Execute();

When i call that, it calls the OpenFetch block, which then throws an exception... Any ideas?

does it happen in Clone or in Checkout? If it happens in Clone, is the repository local or remote and what protocol are you using for clone?
Checkout  should work, but you better use something like this:

new Repository("<path>").Get<Branch>("master").Checkout()

hth,
-- henon

[...]

Tiernan OToole

unread,
Jul 5, 2011, 1:18:50 PM7/5/11
to gits...@googlegroups.com
Its happening on checkout. i have figured i will need a working folder, in a temp location, and need to do a check out to that folder. I will try that code and see how it works.

--
For infos about GitSharp visit http://www.eqqon.com/index.php/GitSharp
To join this group visit http://groups.google.com/group/gitsharp
Reply all
Reply to author
Forward
0 new messages