lib/itamae/resource/git.rb in itamae-1.0.0.beta41 vs lib/itamae/resource/git.rb in itamae-1.0.0.beta42

- old
+ new

@@ -11,33 +11,32 @@ define_attribute :revision, type: String def pre_action case @current_action when :sync - @attributes[:exist?] = true + attributes.exist = true end end def set_current_attributes - exist = run_specinfra(:check_file_is_directory, destination) - @current_attributes[:exist?] = exist + current.exist = run_specinfra(:check_file_is_directory, attributes.destination) end def action_sync(options) ensure_git_available new_repository = false - if run_specinfra(:check_file_is_directory, destination) + if run_specinfra(:check_file_is_directory, attributes.destination) run_command_in_repo(['git', 'fetch', 'origin']) else - run_command(['git', 'clone', repository, destination]) + run_command(['git', 'clone', attributes.repository, attributes.destination]) new_repository = true end - target = if revision - get_revision(revision) + target = if attributes.revision + get_revision(attributes.revision) else run_command_in_repo("git ls-remote origin HEAD | cut -f1").stdout.strip end if new_repository || target != get_revision('HEAD') @@ -63,10 +62,10 @@ raise "`git` command is not available. Please install git." end end def run_command_in_repo(*args) - run_command(*args, cwd: destination) + run_command(*args, cwd: attributes.destination) end def current_branch run_command_in_repo("git rev-parse --abbrev-ref HEAD").stdout.strip end