Revision 440:6253d777aa12
| app/controllers/sys_controller.rb | ||
|---|---|---|
| 69 | 69 |
render :nothing => true, :status => 404 |
| 70 | 70 |
end |
| 71 | 71 |
|
| 72 |
def clear_repository_cache |
|
| 73 |
project = Project.find(params[:id]) |
|
| 74 |
if project.repository |
|
| 75 |
project.repository.clear_cache |
|
| 76 |
end |
|
| 77 |
render :nothing => true, :status => 200 |
|
| 78 |
rescue ActiveRecord::RecordNotFound |
|
| 79 |
render :nothing => true, :status => 404 |
|
| 80 |
end |
|
| 81 |
|
|
| 72 | 82 |
def set_embedded_active |
| 73 | 83 |
project = Project.find(params[:id]) |
| 74 | 84 |
mods = project.enabled_modules |
| app/models/repository.rb | ||
|---|---|---|
| 203 | 203 |
nil |
| 204 | 204 |
end |
| 205 | 205 |
|
| 206 |
def clear_cache |
|
| 207 |
clear_changesets |
|
| 208 |
end |
|
| 209 |
|
|
| 206 | 210 |
private |
| 207 | 211 |
|
| 208 | 212 |
def before_save |
| config/routes.rb | ||
|---|---|---|
| 237 | 237 |
map.with_options :controller => 'sys' do |sys| |
| 238 | 238 |
sys.connect 'sys/projects.:format', :action => 'projects', :conditions => {:method => :get}
|
| 239 | 239 |
sys.connect 'sys/projects/:id/repository.:format', :action => 'create_project_repository', :conditions => {:method => :post}
|
| 240 |
sys.connect 'sys/projects/:id/external-repository.:format', :action => 'get_external_repo_url', :conditions => {:method => :get}
|
|
| 240 |
sys.connect 'sys/projects/:id/external_repository.:format', :action => 'get_external_repo_url', :conditions => {:method => :get}
|
|
| 241 | 241 |
sys.connect 'sys/projects/:id/embedded.:format', :action => 'set_embedded_active', :conditions => { :method => :post }
|
| 242 |
sys.connect 'sys/projects/:id/repository_cache.:format', :action => 'clear_repository_cache', :conditions => {:method => :post}
|
|
| 242 | 243 |
end |
| 243 | 244 |
|
| 244 | 245 |
# Install the default route as the lowest priority. |
| extra/soundsoftware/convert-external-repos.rb | ||
|---|---|---|
| 62 | 62 |
$http_pass = '' |
| 63 | 63 |
$test = false |
| 64 | 64 |
|
| 65 |
$mirrordir = '/var/mirror' |
|
| 66 |
|
|
| 65 | 67 |
def log(text, options={})
|
| 66 | 68 |
level = options[:level] || 0 |
| 67 | 69 |
puts text unless $quiet or level > $verbose |
| ... | ... | |
| 168 | 170 |
end |
| 169 | 171 |
|
| 170 | 172 |
system($command, project.identifier, repos_path, external_url) |
| 173 |
|
|
| 174 |
$cache_clearance_file = File.join($mirrordir, project.identifier, 'url_changed') |
|
| 175 |
if File.file?($cache_clearance_file) |
|
| 176 |
log("\tproject repo url has changed, requesting cache clearance")
|
|
| 177 |
if project.post(:repository_cache, :key => $api_key) |
|
| 178 |
File.delete($cache_clearance_file) |
|
| 179 |
end |
|
| 180 |
end |
|
| 171 | 181 |
|
| 172 | 182 |
end |
| 173 | 183 |
|
| extra/soundsoftware/update-external-repo.sh | ||
|---|---|---|
| 60 | 60 |
|
| 61 | 61 |
success="" |
| 62 | 62 |
|
| 63 |
# If we have a record of the last successfully updated remote repo |
|
| 64 |
# URL, check it against our current remote URL: if it has changed, we |
|
| 65 |
# will need to start again with a new clone rather than pulling |
|
| 66 |
# updates into the existing local mirror |
|
| 67 |
|
|
| 68 |
successfile="$project_mirror/last_successful_url" |
|
| 69 |
if [ -f "$successfile" ]; then |
|
| 70 |
last=$(cat "$successfile") |
|
| 71 |
if [ x"$last" = x"$remote_repo" ]; then |
|
| 72 |
echo "$$: Remote URL is unchanged from last successful update" |
|
| 73 |
else |
|
| 74 |
echo "$$: Remote URL has changed since last successful update:" |
|
| 75 |
echo "$$: Last URL was $last, current is $remote_repo" |
|
| 76 |
suffix="$$.$(date +%s)" |
|
| 77 |
echo "$$: Moving existing repos to $suffix suffix and starting afresh" |
|
| 78 |
mv "$project_repo_mirror" "$project_repo_mirror"."$suffix" |
|
| 79 |
mv "$local_repo" "$local_repo"."$suffix" |
|
| 80 |
mv "$successfile" "$successfile"."$suffix" |
|
| 81 |
touch "$project_mirror/url_changed" |
|
| 82 |
fi |
|
| 83 |
fi |
|
| 84 |
|
|
| 63 | 85 |
if [ -d "$project_repo_mirror" ]; then |
| 64 | 86 |
|
| 65 | 87 |
# Repo mirror exists: update it |
| ... | ... | |
| 67 | 89 |
|
| 68 | 90 |
if [ -d "$project_repo_mirror/.hg" ]; then |
| 69 | 91 |
"$hg" --config extensions.convert= convert --datesort "$remote_repo" "$project_repo_mirror" && success=true |
| 92 |
if [ -z "$success" ]; then |
|
| 93 |
( cd "$project_repo_mirror" && "$hg" pull "$remote_repo" ) && success=true |
|
| 94 |
fi |
|
| 70 | 95 |
elif [ -d "$project_repo_mirror/.git" ]; then |
| 71 | 96 |
( cd "$project_repo_mirror" && git pull "$remote_repo" master ) && success=true |
| 72 | 97 |
else |
| ... | ... | |
| 96 | 121 |
|
| 97 | 122 |
if [ -n "$success" ]; then |
| 98 | 123 |
echo "$$: Update successful, pulling into local repo at $local_repo" |
| 124 |
if [ ! -d "$local_repo" ]; then |
|
| 125 |
"$hg" init "$local_repo" |
|
| 126 |
fi |
|
| 99 | 127 |
if [ -d "$project_repo_mirror/.git" ]; then |
| 100 |
if [ ! -d "$local_repo" ]; then |
|
| 101 |
"$hg" init "$local_repo" |
|
| 102 |
fi |
|
| 103 |
( cd "$local_repo" && "$hg" --config extensions.hggit= pull "$project_repo_mirror" ) |
|
| 128 |
( cd "$local_repo" && "$hg" --config extensions.hggit= pull "$project_repo_mirror" ) && echo "$remote_repo" > "$successfile" |
|
| 104 | 129 |
else |
| 105 |
( cd "$local_repo" && "$hg" pull "$project_repo_mirror" ) |
|
| 130 |
( cd "$local_repo" && "$hg" pull "$project_repo_mirror" ) && echo "$remote_repo" > "$successfile"
|
|
| 106 | 131 |
fi |
| 107 | 132 |
fi |
Also available in: Unified diff