Skip to content

Instantly share code, notes, and snippets.

@hennevogel
Last active November 25, 2015 15:51
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save hennevogel/135fe029162f89d6041d to your computer and use it in GitHub Desktop.
def get_build_flags
build_flags = Hash.new
build_flags['all'] = Array.new
flag = main_object.flags.with_repositories(nil).with_architectures(nil).first
if flag
build_flags['all'] << flag
else
build_flags['all'] << main_object.flags.new( flag: 'build', status: Flag.default_state('build') )
end
main_object.architectures.each do |architecture|
flag = main_object.flags.with_repositories(nil).with_architectures(architecture.id).first
if flag
build_flags['all'] << flag
else
build_flags['all'] << main_object.flags.new( flag: 'build', architecture: architecture, status: build_flags['all'][0].status )
end
end
main_object.repositories.each do |repository|
build_flags[repository.name] = Array.new
flag = main_object.flags.with_repositories(repository.name).with_architectures(nil).first
if flag
build_flags[repository.name] << flag
else
build_flags[repository.name] << main_object.flags.new( flag: 'build', repo: repository.name, status: build_flags['all'][0].status )
end
main_object.architectures.each do |architecture|
flag = main_object.flags.with_repositories(repository.name).with_architectures(architecture.id).first
if flag
build_flags[repository.name] << flag
else
build_flags[repository.name] << main_object.flags.new( flag: 'build',
repo: repository.name,
architecture: architecture,
status: build_flags[repository.name][0].status )
end
end
end
return build_flags
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment