镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content

Implement clone and checkout operations - #107

Closed
Quintus wants to merge 37 commits into
libgit2:developmentfrom
Asquera:implement-clone-checkout
Closed

Quintus wants to merge 37 commits into
libgit2:developmentfrom
Asquera:implement-clone-checkout

Conversation

@Quintus

@Quintus Quintus commented Oct 10, 2012

Copy link
Copy Markdown

Hi there,

as promised here are the clone and checkout operations for Rugged. Have fun! :-)

Note: libgit2 has a kinda confusing API. If you wonder why your cloned repository has no files in it, try doing the clone with strategy: [:default, :create_missing]. Also, when checking out stuff in an existing repository, you may want to use even more aggressive values for strategy so you really check out everything to be found in your target commit. Furthermore, doing a checkout operation will not automatically update the HEAD pointer. (All this is by (libgit2's) design)

Note2: This includes pull request #106.

Marvin

Marvin Gülker added 27 commits October 9, 2012 14:37
…sed.

The behaviour of git_reference_lookup has slightly changed upstream;
instead of returning GIT_ENOTFOUND it now returns GIT_ERROR on invalid
reference names. However, the function git_reference_is_valid_name()
can be used to test whether a given reference name is well-formed. This
function now is available from Ruby as Reference.valid? and is used
inside Repository#create_branch.
However, the underlying libgit2 doesn't support the file:// protocol yet.
The local test is currently skipped (b/c libgit2 doesn't support
local cloning yet), so the bare test would also be skipped if
placed behind it.
It was missing Data_Get_Struct()...
There have been a few fixes regarding clone operations (namely
regarding cloning of repositories with submodules).
I really dislike those.
Hopefully Ruby 1.8 will go soon.
1.8 guys won't profit from concurrency.
Necessary to get the Ruby version under 1.8.
@Quintus

Quintus commented Oct 15, 2012

Copy link
Copy Markdown
Author

This doesn't seem to be a problem specific to my branch, because I get the same build failure when trying to use the official rugged development branch with Bundler. This Gemfile uses development from rugged's own repository:

source "https://rubygems.org"

gem "coderay"
gem "rugged", :git => "git:https://github.com/libgit2/rugged", :branch => "development"

It fails exactly the same way:

$ bundle install
Fetching git:https://github.com/libgit2/rugged
remote: Counting objects: 2458, done.
remote: Compressing objects: 100% (780/780), done.
remote: Total 2458 (delta 1472), reused 2380 (delta 1414)
Receiving objects: 100% (2458/2458), 16.57 MiB | 989 KiB/s, done.
Resolving deltas: 100% (1472/1472), done.
Fetching gem metadata from https://rubygems.org/...
Using coderay (1.0.8) 
Using rugged (0.17.0.b6) from git:https://github.com/libgit2/rugged (at development) with native extensions 
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.

        /Users/quintus/.rvm/rubies/ruby-1.9.3-p194/bin/ruby extconf.rb 
 -- make -f Makefile.embed
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers.  Check the mkmf.log file for more
details.  You may need configuration options.

Provided configuration options:
    --with-opt-dir
    --without-opt-dir
    --with-opt-include
    --without-opt-include=${opt-dir}/include
    --with-opt-lib
    --without-opt-lib=${opt-dir}/lib
    --with-make-prog
    --without-make-prog
    --srcdir=.
    --curdir
    --ruby=/Users/quintus/.rvm/rubies/ruby-1.9.3-p194/bin/ruby
extconf.rb:6:in `sys': ERROR: 'make -f Makefile.embed' failed (RuntimeError)
    from extconf.rb:30:in `block in <main>'
    from extconf.rb:29:in `chdir'
    from extconf.rb:29:in `<main>'


Gem files will remain installed in /Users/quintus/.rvm/gems/ruby-1.9.3-p194/bundler/gems/rugged-824d54847557 for inspection.
Results logged to /Users/quintus/.rvm/gems/ruby-1.9.3-p194/bundler/gems/rugged-824d54847557/ext/rugged/gem_make.out
An error occurred while installing rugged (0.17.0.b6), and Bundler cannot continue.
Make sure that `gem install rugged -v '0.17.0.b6'` succeeds before bundling.

Try cloning the repository without bundler and doing rake compile followed by gem build rugged.gemspec. I suspect the libgit2 submodule not to be initialised correctly otherwise (bundler seems to omit the necessary git submodule update --init step which is done automatically by rake compile). See:

$ ls /Users/quintus/.rvm/gems/ruby-1.9.3-p194/bundler/gems/rugged-824d54847557/vendor/libgit2/
mkmf.log

The whole libgit2 repository is missing there.

Vale,
Marvin

Marvin Gülker added 2 commits October 31, 2012 17:06
Resync with upstream rugged.

Conflicts:
	lib/rugged/repository.rb
	vendor/libgit2
Note that when called with a block, the method will not release
the GVL anymore (without one it does).
@vmg

vmg commented Nov 1, 2012

Copy link
Copy Markdown
Member

Oh wow, sorry this is taking so long. I'll start reviewing this right away! Thanks for the PR, lookin' good!

Marvin Gülker added 7 commits December 6, 2012 10:46
Conflicts:
	ext/rugged/rugged_repo.c
	test/branch_test.rb
	test/reference_test.rb
	test/repo_test.rb
	test/test_helper.rb
Note that bare cloning is in a separate method Repository::clone_repo_bare
now as the Repository::clone method grew without bounds.
@x3ro

x3ro commented Jan 4, 2013

Copy link
Copy Markdown

This would be really nice to have 👍

@davidjrice

Copy link
Copy Markdown

Had a look into this.

Was able to get building using the above instructions to clone gem and manually rake compile. Wondering if not vendoring libgit2 mean bundler could install without manual intervention?

I tried through a few different git transport types with the following results.

  • http success
  • git success
  • git+ssh failure
  • https failure

So far so good on public repos. Private repo support would be awesome. 👍

git+ssh

Rugged::Repository.clone_repo("git@github.com:libgit2/rugged.git", "/tmp/rugged", :strategy => [:safe])
=> Rugged::NetworkErrorTagError: This transport isn't implemented. Sorry

https

Rugged::Repository.clone_repo("https://github.com/libgit2/rugged.git", "/tmp/rugged", :strategy => [:safe])
=> Rugged::OSError: SSL is not supported by this copy of libgit2.: No such file or directory

Should probably work. This is likely down to my local environment (OSX Mountain Lion). Have ensured the following, but to no avail.

brew install openssl
export LDFLAGS=-L/usr/local/opt/openssl/lib
export CPPFLAGS=-I/usr/local/opt/openssl/include
brew install libgit2 --HEAD

@bootstraponline bootstraponline mentioned this pull request Feb 12, 2013
5 tasks
@bootstraponline

Copy link
Copy Markdown

@vmg Have you had time to review this?

@ioquatix

Copy link
Copy Markdown
Contributor

I would like to see this implemented soon, it is a show stopper for my use of rugged.

@arthurschreiber

Copy link
Copy Markdown
Member

What state is this in? One thing that probably will have to go is the GVL unlocking and all the complexity that comes with it. Do you have time to work on that? If not, I'd be happy take your current work and fix it up.

@arthurschreiber arthurschreiber mentioned this pull request Jul 22, 2013
@arthurschreiber

Copy link
Copy Markdown
Member

I'm closing this, as this was open without any activity in the last 5 months, and as most of the functionality has already been implemented.

Thank you for the work!

@xbeta

xbeta commented Oct 9, 2013

Copy link
Copy Markdown

Was thinking about choosing 'rugged' over 'grit', but lack of git+ssh/https support now makes me stay away from using 'rugged' :-(

@ioquatix

Copy link
Copy Markdown
Contributor

Is rugged still missing git+ssh/https support?

@xbeta

xbeta commented Oct 10, 2013

Copy link
Copy Markdown

@ioquatix seems like it, you can try to use the latest version and it does throw that exact same error message

@arthurschreiber

Copy link
Copy Markdown
Member

If you use the changes in #261, cloning via https works. I don't think cloning via ssh was implemented in libgit2, so there's no way for us to support that in rugged yet.

I'll try to get #261 polished and merged ASAP, I didn't know there was such a big demand for this.

@nvloff

nvloff commented Oct 10, 2013

Copy link
Copy Markdown
Contributor

@arthurschreiber libgit2 should have ssh support from libgit2/libgit2#1558

@arthurschreiber

Copy link
Copy Markdown
Member

Ah, right, so it might very well work, as long as you do compile with the changes in #261. I've no need for https/ssh clone support, so I never tried that out myself. Thanks @nvloff!

@arthurschreiber

Copy link
Copy Markdown
Member

Actually, rugged does not support cloning via ssh yet, because we don't expose the needed callbacks to pass the user credentials. I'm working on fixing that, tho.

@gabriel403

Copy link
Copy Markdown

@arthurschreiber did you get cloning via ssh sorted?

@arthurschreiber

Copy link
Copy Markdown
Member

Yes, see #292. It's not yet possible to push or pull via ssh, but there is a PR open for that: #304.

@gabriel403

Copy link
Copy Markdown

Yeh I found the credentials stuff and then ran right into
SSL is not supported by this copy of libgit2 and/or This transport isn't implemented. Sorry
atm I'm stuck just doing it all as backtick execs, glad it's getting there!

@arthurschreiber

Copy link
Copy Markdown
Member

For some of the optional libgit2 features, like SSH support, you need to have some optional dependencies installed. See the list at https://github.com/libgit2/libgit2#optional-dependencies.

If you get those dependencies (make sure you also install their development headers if you're using a package manager to install), you'll need to recompile Rugged. Also, you need to make sure you have CMake installed, else libgit2 won't be compiled with the optional functionality.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.