Class: Rebuild

Inherits:
Repository show all
Extended by:
ClassMethods
Includes:
Assertions, Constants, Examples
Defined in:
app/models/rebuild.rb

Defined Under Namespace

Modules: Assertions, ClassMethods, Constants, Examples

Constant Summary

Constants included from Examples

Examples::Source

Constants included from Constants

Constants::Temporary

Constants included from Repository::Constants

Repository::Constants::Error_classification, Repository::Constants::README_start_text, Repository::Constants::Root_directory, Repository::Constants::Source, Repository::Constants::Temporary

Instance Attribute Summary

Attributes inherited from Repository

#deserving_branch, #grit_repo, #path, #recent_test

Instance Method Summary collapse

Methods included from Assertions

#assert_post_conditions, #assert_pre_conditions

Methods inherited from Repository

#commit_to_branch, #confirm_branch_switch, #corruption_fsck, #corruption_gc, #corruption_rebase, #current_branch_name?, #edited_superset_of_testing, #error_score?, #force_change, #inspect, #revert_changes, #safely_visit_branch, #shell_command, #something_to_commit?, #stage_files, #standardize_position!, #testing_superset_of_passed, #unit_names?, #validate_commit

Methods included from Repository::ClassMethods

#create_empty, #create_if_missing, #create_test_repository, #delete_existing, #replace_or_create

Constructor Details

#initialize(url) ⇒ Rebuild

subshell (cd_command=ShellCommands.new(“cd #Rebuild::Constants::Temporaryrecover”)).assert_post_conditions puts “cd_command=#Rebuild.cd_commandcd_command.inspect”


19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'app/models/rebuild.rb', line 19

def initialize(url)
	@url=url
	@path=url
	source_path=@path
	temporary_path=Temporary+'recover'
	if File.exists?(@path) then
		command_string='rsync '+Shellwords.escape(source_path)+' '+Shellwords.escape(temporary_path)
		ShellCommands.new(command_string).assert_post_conditions #uncorrupted old backup to start
	else
		command_string='cp -a '+Shellwords.escape(source_path)+' '+Shellwords.escape(temporary_path)
		ShellCommands.new(command_string).assert_post_conditions #uncorrupted old backup to start
	end #if
	standardize_position
end

Instance Method Details

#add_commits(from_repository, last_commit_to_add, branch, history_options = '--squash -Xthiers ') ⇒ Object

initialize_branch


54
55
56
57
58
# File 'app/models/rebuild.rb', line 54

def add_commits(from_repository, last_commit_to_add, branch, history_options='--squash -Xthiers ')
	Clean_Example.git_command("fetch file://"+repository+" "+name)
	Clean_Example.git_command("checkout  #{branch}").assert_post_conditions
	Clean_Example.git_command("merge #{history_options} "+" -m "+name.to_s+commit.to_s).assert_post_conditions
end

#fetch_commits(name, commit, repository_file) ⇒ Object

standardize_position


46
47
48
# File 'app/models/rebuild.rb', line 46

def fetch_commits(name, commit, repository_file)
	Clean_Example.git_command("fetch file://"+repository+" "+name)
end

#git_command(git_subcommand) ⇒ Object

initialize


33
34
35
36
37
38
39
# File 'app/models/rebuild.rb', line 33

def git_command(git_subcommand)
	ret=ShellCommands.new("cd #{Shellwords.escape(@path)}; git "+git_subcommand)
	if $VERBOSE && git_subcommand != 'status' then
		ShellCommands.new("cd #{Shellwords.escape(@path)}; git status").inspect
	end #if
	ret
end

#initialize_branch(name, commit, repository_file) ⇒ Object

fetch_commits


49
50
51
52
# File 'app/models/rebuild.rb', line 49

def initialize_branch(name, commit, repository_file)
	Clean_Example.git_command("fetch file://"+repository+" "+name)
	Clean_Example.git_command("symbolic-link #{name.to_s} "+commit.to_s).assert_post_conditions
end

#standardize_positionObject

git_command


40
41
42
43
44
45
# File 'app/models/rebuild.rb', line 40

def standardize_position
	git_command("rebase --abort")
	git_command("merge --abort")
	git_command("stash save").assert_post_conditions
	git_command("checkout master")
end