Rugged和Grack:在推送之前找到提交

时间:2015-06-16 07:05:18

标签: ruby-on-rails git gitlab rack rugged

我正在使用rugged进行git相关操作(使用Web界面初始化repo)和gitlab-grack来实现http-backend CGI。它工作正常,我能够做推,拉等。但是,我想找到每次推动后改变的blob(我必须对这些对象进行一些处理)。这样做的一种方法是:

  • 在推送之前从refs / head / brach_name 文件中读取头文件
  • 执行推送
  • 查找推送前提交和diff推送之后更改的所有文件

我无法从请求中找到branch_name。推送:

git push http://localhost:3000/addie/cards.git master:newone

生成以下机架请求:

#<Rack::Request:0x007fb1881e24b8 @env={"CONTENT_LENGTH"=>"449", "CONTENT_TYPE"=>"application/x-git-receive-pack-request", "GATEWAY_INTERFACE"=>"CGI/1.1", "PATH_INFO"=>"/addie/cards.git/git-receive-pack", "QUERY_STRING"=>"", "REMOTE_ADDR"=>"127.0.0.1", "REMOTE_HOST"=>"127.0.0.1", "REQUEST_METHOD"=>"POST", "REQUEST_URI"=>"http://localhost:3000/addie/cards.git/git-receive-pack", "SCRIPT_NAME"=>"", "SERVER_NAME"=>"localhost", "SERVER_PORT"=>"3000", "SERVER_PROTOCOL"=>"HTTP/1.1", "SERVER_SOFTWARE"=>"WEBrick/1.3.1 (Ruby/2.2.1/2015-02-26)", "HTTP_AUTHORIZATION"=>"Basic YWRkaWU6c2VjcmV0cGFzc3dvcmQ=", "HTTP_USER_AGENT"=>"git/2.1.0", "HTTP_HOST"=>"localhost:3000", "HTTP_ACCEPT_ENCODING"=>"gzip", "HTTP_ACCEPT"=>"application/x-git-receive-pack-result", "rack.version"=>[1, 2], "rack.input"=>#<StringIO:0x007fb18819e128>, "rack.errors"=>#<IO:<STDERR>>, "rack.multithread"=>false, "rack.multiprocess"=>false, "rack.run_once"=>false, "rack.url_scheme"=>"http", "HTTP_VERSION"=>"HTTP/1.1", "REQUEST_PATH"=>"/addie/cards.git/git-receive-pack", "ORIGINAL_FULLPATH"=>"/addie/cards.git/git-receive-pack", "ORIGINAL_SCRIPT_NAME"=>"", "action_dispatch.routes"=>#<ActionDispatch::Routing::RouteSet:0x000000008285e8>, "action_dispatch.parameter_filter"=>[:password], "action_dispatch.redirect_filter"=>[], "action_dispatch.secret_token"=>nil, "action_dispatch.secret_key_base"=>"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", "action_dispatch.show_exceptions"=>true, "action_dispatch.show_detailed_exceptions"=>true, "action_dispatch.logger"=>#<ActiveSupport::Logger:0x00000004746298 @progname="omniauth", @level=0, @default_formatter=#<Logger::Formatter:0x00000004746220 @datetime_format=nil>, @formatter=#<ActiveSupport::Logger::SimpleFormatter:0x00000003db90e0 @datetime_format=nil>, @logdev=#<Logger::LogDevice:0x000000047461d0 @shift_size=nil, @shift_age=nil, @filename=nil, @dev=#<File:/home/addie/GlitterGallery/log/development.log>, @mutex=#<Logger::LogDevice::LogDeviceMutex:0x00000004746180 @mon_owner=nil, @mon_count=0, @mon_mutex=#<Mutex:0x00000004746130>>>, @thread_hash_level_key=:"ThreadSafeLogger#37368140@level">, "action_dispatch.backtrace_cleaner"=>#<Rails::BacktraceCleaner:0x007fb19002b770 @filters=[#<Proc:0x007fb19002b6a8@/home/addie/GlitterGallery/vendor/ruby/2.2.0/gems/railties-4.1.9/lib/rails/backtrace_cleaner.rb:10>, #<Proc:0x007fb19002b680@/home/addie/GlitterGallery/vendor/ruby/2.2.0/gems/railties-4.1.9/lib/rails/backtrace_cleaner.rb:11>, #<Proc:0x007fb19002b658@/home/addie/GlitterGallery/vendor/ruby/2.2.0/gems/railties-4.1.9/lib/rails/backtrace_cleaner.rb:12>, #<Proc:0x007fb19002b310@/home/addie/GlitterGallery/vendor/ruby/2.2.0/gems/railties-4.1.9/lib/rails/backtrace_cleaner.rb:24>], @silencers=[#<Proc:0x007fb19002b2e8@/home/addie/GlitterGallery/vendor/ruby/2.2.0/gems/railties-4.1.9/lib/rails/backtrace_cleaner.rb:15>]>, "action_dispatch.key_generator"=>#<ActiveSupport::CachingKeyGenerator:0x007fb19002b180 @key_generator=#<ActiveSupport::KeyGenerator:0x007fb19002b1a8 @secret="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", @iterations=1000>, @cache_keys=#<ThreadSafe::Cache:0x007fb19002b158 @backend={}, @default_proc=nil>>, "action_dispatch.http_auth_salt"=>"http authentication", "action_dispatch.signed_cookie_salt"=>"signed cookie", "action_dispatch.encrypted_cookie_salt"=>"encrypted cookie", "action_dispatch.encrypted_signed_cookie_salt"=>"signed encrypted cookie", "action_dispatch.cookies_serializer"=>nil, "ROUTES_4276980_SCRIPT_NAME"=>"", "action_dispatch.request_id"=>"3e2cf532-80d7-4d28-9714-d920105e16bb", "action_dispatch.remote_ip"=>#<ActionDispatch::RemoteIp::GetIp:0x007fb18819c300 @env={...}, @check_ip=true, @proxies=/
      ^127\.0\.0\.1$                | # localhost IPv4
      ^::1$                         | # localhost IPv6
      ^fc00:                        | # private IPv6 range fc00
      ^10\.                         | # private IPv4 range 10.x.x.x
      ^172\.(1[6-9]|2[0-9]|3[0-1])\.| # private IPv4 range 172.16.0.0 .. 172.31.255.255
      ^192\.168\.                     # private IPv4 range 192.168.x.x
    /x>, "rack.session"=>#<ActionDispatch::Request::Session:0x7fb1881cc4b0 not yet loaded>, "rack.session.options"=>#<ActionDispatch::Request::Session::Options:0x007fb1881cc460 @by=#<ActionDispatch::Session::ActiveRecordStore:0x000000047b0990 @app=#<ActionDispatch::Flash:0x000000047b09e0 @app=#<ActionDispatch::ParamsParser:0x000000047b0b70 @app=#<Rack::Head:0x000000047b0b98 @app=#<Rack::ConditionalGet:0x000000047b0bc0 @app=#<Rack::ETag:0x000000047b0be8 @app=#<Warden::Manager:0x000000047b0d00 @config={:default_scope=>:user, :scope_defaults=>{}, :default_strategies=>{:user=>[:rememberable, :database_authenticatable]}, :intercept_401=>false, :failure_app=>#<Devise::Delegator:0x00000004224710>}, @app=#<OmniAuth::Builder:0x00000005454688 @options=nil, @run=#<ActionDispatch::Static:0x00000005454908 @app=#<ActionDispatch::Routing::RouteSet:0x000000008285e8>, @file_handler=#<ActionDispatch::FileHandler:0x000000054548e0 @root="/home/addie/GlitterGallery/vendor/ruby/2.2.0/bundler/gems/ratyrate-b705610b3c6f/vendor", @compiled_root=/^\/home\/addie\/GlitterGallery\/vendor\/ruby\/2\.2\.0\/bundler\/gems\/ratyrate\-b705610b3c6f\/vendor/, @file_server=#<Rack::File:0x000000054546d8 @root="/home/addie/GlitterGallery/vendor/ruby/2.2.0/bundler/gems/ratyrate-b705610b3c6f/vendor", @headers=nil, @default_mime="text/plain">, @ext="{,.html,/index.html}">>, @map=nil, @use=[#<Proc:0x00000005454160@/home/addie/GlitterGallery/vendor/ruby/2.2.0/gems/rack-1.5.2/lib/rack/builder.rb:86>, #<Proc:0x000000047cbab0@/home/addie/GlitterGallery/vendor/ruby/2.2.0/gems/rack-1.5.2/lib/rack/builder.rb:86>, #<Proc:0x000000047cb6c8@/home/addie/GlitterGallery/vendor/ruby/2.2.0/gems/rack-1.5.2/lib/rack/builder.rb:86>, #<Proc:0x000000047cadb8@/home/addie/GlitterGallery/vendor/ruby/2.2.0/gems/rack-1.5.2/lib/rack/builder.rb:86>, #<Proc:0x000000047b0d28@/home/addie/GlitterGallery/vendor/ruby/2.2.0/gems/rack-1.5.2/lib/rack/builder.rb:86>]>>, @cache_control="max-age=0, private, must-revalidate", @no_cache_control="no-cache">>>, @parsers={#<Mime::Type:0x000000020d9f60 @synonyms=["text/x-json", "application/jsonrequest"], @symbol=:json, @string="application/json">=>:json}>>, @default_options={:path=>"/", :domain=>nil, :expire_after=>nil, :secure=>false, :httponly=>true, :defer=>false, :renew=>false}, @key="_session_id", @cookie_only=true>, @env={...}, @delegate={:path=>"/", :domain=>nil, :expire_after=>nil, :secure=>false, :httponly=>true, :defer=>false, :renew=>false}>, "action_dispatch.request.content_type"=>#<Mime::Type:0x007fb1881cc258 @synonyms=[], @symbol=nil, @string="application/x-git-receive-pack-request">, "warden"=>Warden::Proxy:70200234762460 @config={:default_scope=>:user, :scope_defaults=>{}, :default_strategies=>{:user=>[:rememberable, :database_authenticatable]}, :intercept_401=>false, :failure_app=>#<Devise::Delegator:0x00000004224710>}, "action_dispatch.request.path_parameters"=>{}}>

我不确定我想要看什么。如何将master:newone部分转移到所有混乱中?每次推送后找到文件的任何其他方式也可以为我工作。

0 个答案:

没有答案