Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor code for maintainabilty #206

Merged
merged 8 commits into from
Jan 24, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
# This configuration was generated by
# `rubocop --auto-gen-config`
# on 2021-10-08 19:19:01 UTC using RuboCop version 1.22.1.
# on 2021-10-18 07:54:09 UTC using RuboCop version 1.22.1.
# The point is for the user to remove these configuration records
# one by one as the offenses are removed from the code base.
# Note that changes in the inspected code, or installation of new
# versions of RuboCop, may require this file to be generated again.

# Offense count: 9
# Offense count: 8
# Configuration parameters: IgnoredMethods, CountRepeatedAttributes.
Metrics/AbcSize:
Max: 60

# Offense count: 2
# Configuration parameters: CountComments, CountAsOne.
Metrics/ClassLength:
Max: 131
Max: 134

# Offense count: 4
# Configuration parameters: IgnoredMethods.
Metrics/CyclomaticComplexity:
Max: 15

# Offense count: 16
# Offense count: 15
# Configuration parameters: CountComments, CountAsOne, ExcludedMethods, IgnoredMethods.
Metrics/MethodLength:
Max: 34
Expand Down
2 changes: 1 addition & 1 deletion features/cli.feature
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ Feature: CLI
"""
And a git_base option appended to "modulesync.yml" for local tests
And a directory named "moduleroot"
When I run `msync update --noop --namespace fakenamespace --branch command-line-branch`
When I run `msync update --verbose --noop --namespace fakenamespace --branch command-line-branch`
Then the exit status should be 0
And the output should contain:
"""
Expand Down
4 changes: 2 additions & 2 deletions features/update.feature
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,7 @@ Feature: update
Scenario: When running update without changes
Given a basic setup with a puppet module "puppet-test" from "fakenamespace"
And a directory named "moduleroot"
When I run `msync update --message "Running without changes"`
When I run `msync update --verbose --message "Running without changes"`
Then the exit status should be 0
And the stdout should contain "There were no changes in 'modules/fakenamespace/puppet-test'. Not committing."
And the puppet module "puppet-test" from "fakenamespace" should have no commits made by "Aruba"
Expand Down Expand Up @@ -727,7 +727,7 @@ Feature: update
"""
source '<%= @configs['gem_source'] %>'
"""
When I run `msync update -m "Update Gemfile"`
When I run `msync update --verbose -m "Update Gemfile"`
Then the exit status should be 0
And the output should contain "Using repository's default branch: develop"
And the puppet module "puppet-test" from "fakenamespace" should have only 1 commit made by "Aruba"
Expand Down
2 changes: 1 addition & 1 deletion features/update/bump_version.feature
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Feature: Bump a new version after an update
"""
<%= @configs['content'] %>
"""
When I run `msync update --message "Add new-file" --bump --changelog --tag`
When I run `msync update --verbose --message "Add new-file" --bump --changelog --tag`
Then the exit status should be 0
And the file named "modules/fakenamespace/puppet-test/new-file" should contain "aruba"
And the stdout should contain:
Expand Down
5 changes: 5 additions & 0 deletions lib/modulesync/cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,11 @@ class Base < Thor
:desc => 'Branch name to make the changes in.' \
' Defaults to the default branch of the upstream repository, but falls back to "master".',
:default => CLI.defaults[:branch]
class_option :verbose,
:aliases => '-v',
:desc => 'Verbose mode',
:type => :boolean,
:default => false

desc 'update', 'Update the modules in managed_modules.yml'
option :message,
Expand Down
16 changes: 10 additions & 6 deletions lib/modulesync/repository.rb
Original file line number Diff line number Diff line change
Expand Up @@ -148,20 +148,24 @@ def untracked_unignored_files
def show_changes(options)
checkout_branch(options[:branch])

puts 'Files changed:'
$stdout.puts 'Files changed:'
repo.diff('HEAD', '--').each do |diff|
puts diff.patch
$stdout.puts diff.patch
end

puts 'Files added:'
$stdout.puts 'Files added:'
untracked_unignored_files.each_key do |file|
puts file
$stdout.puts file
end

puts "\n\n"
puts '--------------------------------'
$stdout.puts "\n\n"
$stdout.puts '--------------------------------'

git.diff('HEAD', '--').any? || untracked_unignored_files.any?
end

def puts(*args)
neomilium marked this conversation as resolved.
Show resolved Hide resolved
$stdout.puts(*args) if ModuleSync.options[:verbose]
end
end
end