Merge branch 'guange_dev' into sw_new_course

sw_new_course
sw 10 years ago
commit f6d122e37f

@ -6,6 +6,7 @@ unless RUBY_PLATFORM =~ /w32/
gem 'iconv'
end
gem 'grack', path:'./lib/grack'
gem 'rest-client'
gem "mysql2", "= 0.3.18"
gem 'redis-rails'

@ -127,19 +127,18 @@ update
end
else # 原逻辑
##xianbo
params[:repository_scm] = "Git"
@root_path=RepositoriesHelper::ROOT_PATH
@repository_name=User.current.login.to_s+"/"+params[:repository][:identifier]+".git"
@project_path=@root_path+"htdocs/"+@repository_name
@repository_tag=params[:repository][:upassword] || params[:repository][:password]
@repository_tag=params[:repository][:upassword] || params[:repository][:password] || '1234'
@repo_name=User.current.login.to_s+"_"+params[:repository][:identifier]
logger.info "htpasswd -mb "+@root_path+"htdocs/user.passwd "+@repo_name+": "+@repository_tag
logger.info "the value of create repository"+@root_path+": "+@repository_name+": "+@project_path+": "+@repo_name
attrs = pickup_extra_info
if((@repository_tag!="")&&params[:repository_scm]=="Git")
params[:repository][:url]=@project_path
end
###xianbo
@repository = Repository.factory(params[:repository_scm])
@repository = Repository.factory(params[:repository_scm]||"Git")
@repository.safe_attributes = params[:repository]
if attrs[:attrs_extra].keys.any?
@repository.merge_extra_info(attrs[:attrs_extra])
@ -278,7 +277,8 @@ update
@course_tag = params[:course]
project_path_cut = RepositoriesHelper::PROJECT_PATH_CUT
ip = RepositoriesHelper::REPO_IP_ADDRESS
@repos_url = "http://"+@repository.login.to_s+"_"+@repository.identifier.to_s+"@"+ip.to_s+
# @repos_url = "http://"+@repository.login.to_s+"_"+@repository.identifier.to_s+"@"+ip.to_s+
@repos_url = "http://#{Setting.host_name}/#{@repository.login.to_s}/#{@repository.identifier.to_s}.git"
@repository.url.slice(project_path_cut, @repository.url.length).to_s
if @course_tag == 1
render :action => 'show', :layout => 'base_courses'

@ -19,7 +19,7 @@
module RepositoriesHelper
if Rails.env.development?
ROOT_PATH="/tmp/" if Rails.env.development?
ROOT_PATH="/private/tmp/"
else
ROOT_PATH="/home/pdl/redmine-2.3.2-0/apache2/"
end

@ -62,15 +62,6 @@
<%= labelled_form_for :repository, @repository, :url =>project_repositories_path(@project),:html => {:id => 'repository-form',:method=>"post"} do |f| %>
<div id="pro_st_edit_ku" class="pro_st_edit_ku">
<ul>
<li >
<label class="label02"><%=l(:label_scm)%></label>
<%= select_tag('repository_scm',
options_for_select(["Git"],@repository.class.name.demodulize),
:data => {:remote => true, :method => 'get'})%>
<% if @repository && ! @repository.class.scm_available %>
<span class="c_grey"><%= l(:text_scm_command_not_available) %></span>
<% end %>
</li>
<% unless judge_main_repository(@project) %>
<li>
<label class="label02"><%=l(:field_repository_is_default)%></label>
@ -84,11 +75,6 @@
<span class="c_grey"><%=l(:text_length_between,:min=>1,:max=>254)<<l(:text_project_identifier_info) %></span>
<% end %>
</li>
<li >
<label class="label02"><span class="c_red">*</span><%=l(:label_password)%></label>
<%= f.password_field :upassword, :label=> "", :no_label => true %>
<span class="c_grey"><%= l(:label_upassword_info)%></span>
</li>
<div class="cl"></div>
</ul>
<a href="#" onclick="$('#repository-form').submit();" class="blue_btn fl ml110"><%=l(:button_save)%></a>

@ -33,8 +33,9 @@
<div id="repos_git_more">
<br>
<div class=" c_dark f14">
<p color="red">git 克隆和提交的用户名和密码为登录用户名和密码 </p>
<p>项目代码请设置好正确的编码方式utf-8否则中文会出现乱码。</p>
<p>通过cmd命令提示符进入代码对应文件夹的根目录假设当前用户的登录名为user版本库名称为demo需要操作的版本库分支为branch。
<p>通过cmd命令提示符进入代码对应文件夹的根目录
如果是首次提交代码,执行如下命令:</p>
</div>
<div class="repos_explain">
@ -45,19 +46,19 @@
<p>git commit -m "first commit"</p>
<p>git remote add origin
http://user_demo@repository.trustie.net/user/demo.git
<%= @repos_url %>
</p>
<p>git config http.postBuffer 524288000 #设置本地post缓存为500MB</p>
<p>git push -u origin branch:branch</p>
<p>git push -u origin master</p>
</div>
<!--repos_explain end-->
<div class="c_dark f14">
<p>已经有本地库,还没有配置远程地址,打开命令行执行如下:</p>
</div>
<div class="repos_explain">
<p>git remote add origin http://user_demo@repository.trustie.net/user/demo.git</p>
<p>git remote add origin <%= @repos_url %></p>
<p>git add .</p>
@ -65,14 +66,14 @@
<p>git config http.postBuffer 524288000 #设置本地post缓存为500MB</p>
<p>git push -u origin branch:branch</p>
<p>git push -u origin master</p>
</div>
<!--repos_explain end-->
<div class="c_dark f14">
<p>已有远程地址,创建一个远程分支,并切换到该分支,打开命令行执行如下:</p>
</div>
<div class="repos_explain">
<p>git clone http://user_demo@repository.trustie.net/user/demo.git</p>
<p>git clone <%= @repos_url %></p>
<p>git push</p>
@ -86,7 +87,7 @@
</div>
<div class="repos_explain">
<p>git remote add trustie
http://user_demo@repository.trustie.net/user/demo.git
<%= @repos_url %>
</p>
<p>git add .</p>

@ -197,9 +197,12 @@ default:
#max_concurrent_ajax_uploads: 2
#pic_types: "bmp,jpeg,jpg,png,gif"
repository_root_path: '/tmp/htdocs'
# specific configuration options for production environment
# that overrides the default ones
production:
repository_root_path: '/home/pdl/redmine-2.3.2-0/apache2/htdocs'
cookie_domain: ".trustie.net"
rmagick_font_path: /usr/share/fonts/ipa-mincho/ipam.ttf
email_delivery:

@ -28,6 +28,9 @@
RedmineApp::Application.routes.draw do
mount Mobile::API => '/api'
# Enable Grack support
mount Trustie::Grack.new, at: '/', constraints: lambda { |request| /[-\/\w\.]+\.git\//.match(request.path_info) }, via: [:get, :post]
resources :homework_users
resources :no_uses
delete 'no_uses', :to => 'no_uses#delete'

@ -11,7 +11,7 @@
#
# It's strongly recommended to check this file into your version control system.
ActiveRecord::Schema.define(:version => 20150820025358) do
ActiveRecord::Schema.define(:version => 20150820004659) do
create_table "activities", :force => true do |t|
t.integer "act_id", :null => false
@ -1404,15 +1404,6 @@ ActiveRecord::Schema.define(:version => 20150820025358) do
t.integer "fields_bits", :default => 0
end
create_table "user_activities", :force => true do |t|
t.string "act_type"
t.integer "act_id"
t.string "container_type"
t.integer "container_id"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
end
create_table "user_extensions", :force => true do |t|
t.integer "user_id", :null => false
t.date "birthday"
@ -1525,6 +1516,7 @@ ActiveRecord::Schema.define(:version => 20150820025358) do
t.string "identity_url"
t.string "mail_notification", :default => "", :null => false
t.string "salt", :limit => 64
t.integer "gid"
end
add_index "users", ["auth_source_id"], :name => "index_users_on_auth_source_id"

@ -0,0 +1,14 @@
language: ruby
env:
- TRAVIS=true
branches:
only:
- 'master'
rvm:
- 1.9.3-p327
- 2.0.0
before_script:
- "bundle install"
- "git submodule init"
- "git submodule update"
script: "bundle exec rake"

@ -0,0 +1,16 @@
2.0.2
- Revert MR that broke smart HTTP clients.
2.0.1
- Make sure child processes get reaped after popen, again.
2.0.0
- Use safer shell commands and avoid Dir.chdir
- Restrict the environment for shell commands
- Make Grack::Server thread-safe (zimbatm)
- Make sure child processes get reaped after popen
- Verify requested path is actually a Git directory (Ryan Canty)
1.1.0
- Modifies service_rpc to use chunked transfer (https://github.com/gitlabhq/grack/pull/1)

@ -0,0 +1,10 @@
source "http://ruby.taobao.org"
gemspec
group :development do
gem 'byebug'
gem 'rake'
gem 'pry'
gem 'rack-test'
end

@ -0,0 +1,37 @@
PATH
remote: .
specs:
gitlab-grack (2.0.2)
rack (~> 1.5.1)
GEM
remote: http://ruby.taobao.org/
specs:
byebug (4.0.5)
columnize (= 0.9.0)
coderay (1.1.0)
columnize (0.9.0)
metaclass (0.0.1)
method_source (0.8.2)
mocha (0.14.0)
metaclass (~> 0.0.1)
pry (0.10.1)
coderay (~> 1.1.0)
method_source (~> 0.8.1)
slop (~> 3.4)
rack (1.5.2)
rack-test (0.6.2)
rack (>= 1.0)
rake (10.1.0)
slop (3.6.0)
PLATFORMS
ruby
DEPENDENCIES
byebug
gitlab-grack!
mocha (~> 0.11)
pry
rack-test
rake

@ -0,0 +1,95 @@
Grack - Ruby/Rack Git Smart-HTTP Server Handler
===============================================
[![Build Status](https://travis-ci.org/gitlabhq/grack.png)](https://travis-ci.org/gitlabhq/grack)
[![Code Climate](https://codeclimate.com/github/gitlabhq/grack.png)](https://codeclimate.com/github/gitlabhq/grack)
This project aims to replace the builtin git-http-backend CGI handler
distributed with C Git with a Rack application. This reason for doing this
is to allow far more webservers to be able to handle Git smart http requests.
The default git-http-backend only runs as a CGI script, and specifically is
only targeted for Apache 2.x usage (it requires PATH_INFO to be set and
specifically formatted). So, instead of trying to get it to work with
other CGI capable webservers (Lighttpd, etc), we can get it running on nearly
every major and minor webserver out there by making it Rack capable. Rack
applications can run with the following handlers:
* CGI
* FCGI
* Mongrel (and EventedMongrel and SwiftipliedMongrel)
* WEBrick
* SCGI
* LiteSpeed
* Thin
These web servers include Rack handlers in their distributions:
* Ebb
* Fuzed
* Phusion Passenger (which is mod_rack for Apache and for nginx)
* Unicorn
* Puma
With [Warbler](http://caldersphere.rubyforge.org/warbler/classes/Warbler.html),
and JRuby, we can also generate a WAR file that can be deployed in any Java
web application server (Tomcat, Glassfish, Websphere, JBoss, etc).
Since the git-http-backend is really just a simple wrapper for the upload-pack
and receive-pack processes with the '--stateless-rpc' option, it does not
actually re-implement very much.
Dependencies
========================
* Ruby - http://www.ruby-lang.org
* Rack - http://rack.rubyforge.org
* A Rack-compatible web server
* Git >= 1.7 (currently the 'pu' branch)
* Mocha (only for running the tests)
Quick Start
========================
$ gem install rack
$ (edit config.ru to set git project path)
$ rackup --host 127.0.0.1 -p 8080 config.ru
$ git clone http://127.0.0.1:8080/schacon/grit.git
Contributing
========================
If you would like to contribute to the Grack project, I prefer to get
pull-requests via GitHub. You should include tests for whatever functionality
you add. Just fork this project, push your changes to your fork and click
the 'pull request' button. To run the tests, you first need to install the
'mocha' mocking library and initialize the submodule.
$ sudo gem install mocha
$ git submodule init
$ git submodule update
Then you should be able to run the tests with a 'rake' command. You can also
run coverage tests with 'rake rcov' if you have rcov installed.
License
========================
(The MIT License)
Copyright (c) 2009 Scott Chacon <schacon@gmail.com>
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
'Software'), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

@ -0,0 +1,27 @@
#!/usr/bin/env rake
require "bundler/gem_tasks"
task :default => :test
desc "Run the tests."
task :test do
Dir.glob("tests/*_test.rb").each do |f|
system "ruby #{f}"
end
end
desc "Run test coverage."
task :rcov do
system "rcov tests/*_test.rb -i lib/git_http.rb -x rack -x Library -x tests"
system "open coverage/index.html"
end
namespace :grack do
desc "Start Grack"
task :start do
system('./bin/testserver')
end
end
desc "Start everything."
multitask :start => [ 'grack:start' ]

@ -0,0 +1,6 @@
#! /bin/bash
set -e
cd $(dirname "$0")/..
exec /usr/bin/env bundle exec pry -Ilib -r grack

@ -0,0 +1,24 @@
#! /usr/bin/env ruby
libdir = File.absolute_path( File.join( File.dirname(__FILE__), '../lib' ) )
$LOAD_PATH.unshift(libdir) unless $LOAD_PATH.include?(libdir)
Bundler.require(:default, :development)
require 'grack'
require 'rack'
root = File.absolute_path( File.join( File.dirname(__FILE__), '../examples' ) )
app = Grack::Server.new({
project_root: root,
upload_pack: true,
receive_pack:true
})
app1= Rack::Builder.new do
use Grack::Auth do |username, password|
[username, password] == ['123', '455']
end
run app
end
Rack::Server.start app: app1, Port: 3001

@ -0,0 +1 @@
ref: refs/heads/master

@ -0,0 +1,6 @@
[core]
repositoryformatversion = 0
filemode = true
bare = true
ignorecase = true
precomposeunicode = true

@ -0,0 +1 @@
Unnamed repository; edit this file 'description' to name the repository.

@ -0,0 +1,15 @@
#!/bin/sh
#
# An example hook script to check the commit log message taken by
# applypatch from an e-mail message.
#
# The hook should exit with non-zero status after issuing an
# appropriate message if it wants to stop the commit. The hook is
# allowed to edit the commit message file.
#
# To enable this hook, rename this file to "applypatch-msg".
. git-sh-setup
test -x "$GIT_DIR/hooks/commit-msg" &&
exec "$GIT_DIR/hooks/commit-msg" ${1+"$@"}
:

@ -0,0 +1,24 @@
#!/bin/sh
#
# An example hook script to check the commit log message.
# Called by "git commit" with one argument, the name of the file
# that has the commit message. The hook should exit with non-zero
# status after issuing an appropriate message if it wants to stop the
# commit. The hook is allowed to edit the commit message file.
#
# To enable this hook, rename this file to "commit-msg".
# Uncomment the below to add a Signed-off-by line to the message.
# Doing this in a hook is a bad idea in general, but the prepare-commit-msg
# hook is more suited to it.
#
# SOB=$(git var GIT_AUTHOR_IDENT | sed -n 's/^\(.*>\).*$/Signed-off-by: \1/p')
# grep -qs "^$SOB" "$1" || echo "$SOB" >> "$1"
# This example catches duplicate Signed-off-by lines.
test "" = "$(grep '^Signed-off-by: ' "$1" |
sort | uniq -c | sed -e '/^[ ]*1[ ]/d')" || {
echo >&2 Duplicate Signed-off-by lines.
exit 1
}

@ -0,0 +1,8 @@
#!/bin/sh
#
# An example hook script to prepare a packed repository for use over
# dumb transports.
#
# To enable this hook, rename this file to "post-update".
exec git update-server-info

@ -0,0 +1,14 @@
#!/bin/sh
#
# An example hook script to verify what is about to be committed
# by applypatch from an e-mail message.
#
# The hook should exit with non-zero status after issuing an
# appropriate message if it wants to stop the commit.
#
# To enable this hook, rename this file to "pre-applypatch".
. git-sh-setup
test -x "$GIT_DIR/hooks/pre-commit" &&
exec "$GIT_DIR/hooks/pre-commit" ${1+"$@"}
:

@ -0,0 +1,49 @@
#!/bin/sh
#
# An example hook script to verify what is about to be committed.
# Called by "git commit" with no arguments. The hook should
# exit with non-zero status after issuing an appropriate message if
# it wants to stop the commit.
#
# To enable this hook, rename this file to "pre-commit".
if git rev-parse --verify HEAD >/dev/null 2>&1
then
against=HEAD
else
# Initial commit: diff against an empty tree object
against=4b825dc642cb6eb9a060e54bf8d69288fbee4904
fi
# If you want to allow non-ASCII filenames set this variable to true.
allownonascii=$(git config --bool hooks.allownonascii)
# Redirect output to stderr.
exec 1>&2
# Cross platform projects tend to avoid non-ASCII filenames; prevent
# them from being added to the repository. We exploit the fact that the
# printable range starts at the space character and ends with tilde.
if [ "$allownonascii" != "true" ] &&
# Note that the use of brackets around a tr range is ok here, (it's
# even required, for portability to Solaris 10's /usr/bin/tr), since
# the square bracket bytes happen to fall in the designated range.
test $(git diff --cached --name-only --diff-filter=A -z $against |
LC_ALL=C tr -d '[ -~]\0' | wc -c) != 0
then
cat <<\EOF
Error: Attempt to add a non-ASCII file name.
This can cause problems if you want to work with people on other platforms.
To be portable it is advisable to rename the file.
If you know what you are doing you can disable this check using:
git config hooks.allownonascii true
EOF
exit 1
fi
# If there are whitespace errors, print the offending file names and fail.
exec git diff-index --check --cached $against --

@ -0,0 +1,53 @@
#!/bin/sh
# An example hook script to verify what is about to be pushed. Called by "git
# push" after it has checked the remote status, but before anything has been
# pushed. If this script exits with a non-zero status nothing will be pushed.
#
# This hook is called with the following parameters:
#
# $1 -- Name of the remote to which the push is being done
# $2 -- URL to which the push is being done
#
# If pushing without using a named remote those arguments will be equal.
#
# Information about the commits which are being pushed is supplied as lines to
# the standard input in the form:
#
# <local ref> <local sha1> <remote ref> <remote sha1>
#
# This sample shows how to prevent push of commits where the log message starts
# with "WIP" (work in progress).
remote="$1"
url="$2"
z40=0000000000000000000000000000000000000000
while read local_ref local_sha remote_ref remote_sha
do
if [ "$local_sha" = $z40 ]
then
# Handle delete
:
else
if [ "$remote_sha" = $z40 ]
then
# New branch, examine all commits
range="$local_sha"
else
# Update to existing branch, examine new commits
range="$remote_sha..$local_sha"
fi
# Check for WIP commit
commit=`git rev-list -n 1 --grep '^WIP' "$range"`
if [ -n "$commit" ]
then
echo >&2 "Found WIP commit in $local_ref, not pushing"
exit 1
fi
fi
done
exit 0

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save