Skip to content

Commit

Permalink
huge refactoring to version 2.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
jrfaller committed Jun 27, 2015
1 parent 24875d9 commit 2d0f166
Show file tree
Hide file tree
Showing 33 changed files with 1,019 additions and 1,188 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
/InstalledFiles
/pkg/
/spec/reports/
/spec/dgit/.dgit/
/spec/dgit/sources/
/test/tmp/
/test/version_tmp/
/tmp/
Expand Down
12 changes: 4 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Diggit ![Build Status](https://travis-ci.org/jrfaller/diggit.svg?branch=master) [![Coverage Status](https://coveralls.io/repos/jrfaller/diggit/badge.svg?branch=master)](https://coveralls.io/r/jrfaller/diggit?branch=master) [![Inline docs](http://inch-ci.org/github/jrfaller/diggit.svg?branch=master)](http://inch-ci.org/github/jrfaller/diggit)
# Diggit

A neat ruby tool to analyse Git repositories
A ruby tool to analyze Git repositories

# Installation

Expand Down Expand Up @@ -36,10 +36,6 @@ A join is performed after all analyses of all repositories have been performed.

## Running analyses

Once diggit is configured you can perform the analyses. First, you have to clone the repositories by using `dgit perform clones`. Then you can launch the analyses by using `dgit perform analyses`. Finally, the joins are executed via the command `dgit perform joins`.
Once diggit is configured you can perform the analyses. First, you have to clone the repositories by using `dgit clones perform`. Then you can launch the analyses by using `dgit analyses perform`. Finally, the joins are executed via the command `dgit joins perform`. You can use the `mode` option to handle the cleaning of joins or analyses.

At all time, you can check the status of your diggit folder by using `dgit status`. If you want more info on the status of a given repository, you can use the `dgit sources info https://github.com/jrfaller/diggit.git` command.

## Cleaning up

If something is going wrong, you can always delete the results of the joins by using the command `dgit clean joins` and of the analysis with the command `dgit clean analyses`.
At all time, you can check the status of your diggit folder by using `dgit status`.
189 changes: 187 additions & 2 deletions bin/dgit
Original file line number Diff line number Diff line change
@@ -1,6 +1,191 @@
#!/usr/bin/env ruby
# encoding: utf-8

require_relative '../lib/diggit_cli.rb'
require 'gli'
require_relative '../lib/dgit'

Diggit::Cli::DiggitCli.start(ARGV)
include GLI::App

program_desc 'A git repository analysis tool.'

version Diggit::VERSION

subcommand_option_handling :normal
arguments :strict

desc 'Init a diggit folder.'
skips_pre
command :init do |c|
c.action do |_global_options, _options, _args|
Diggit::Dig.init_dir
Log.ok "Diggit folder initialized."
end
end

desc 'Display the status of the diggit folder.'
command :status do |c|
c.action do |_global_options, _options, _args|
Log.info "Config"
Log.info "======"
Log.info "- Analyses: #{Diggit::Dig.it.config.get_analyses.join(', ')}"
Log.info "- Joins: #{Diggit::Dig.it.config.get_joins.join(', ')}"
Log.info ""
Log.info "Journal"
Log.info "======="
Log.info "- New sources:"
Log.indent do
Log.ok "* Ok: #{Diggit::Dig.it.journal.sources_by_state(:new).size}"
Log.error "* Error: #{Diggit::Dig.it.journal.sources_by_state(:new, true).size}"
end
Log.info "- Cloned sources:"
Log.indent do
Log.ok "* Ok: #{Diggit::Dig.it.journal.sources_by_state(:cloned).size}"
Log.error "* Error: #{Diggit::Dig.it.journal.sources_by_state(:cloned, true).size}"
end
end
end

desc 'Manage the sources of the diggit folder.'
command :sources do |c|
c.desc 'List the sources.'
c.command :list do |list|
list.action do |_global_options, _options, _args|
sources = Diggit::Dig.it.journal.sources
sources.each_index do |idx|
msg = "#{idx} #{sources[idx].url} (#{sources[idx].state})"
sources[idx].error? ? Log.error(msg) : Log.ok(msg)
end
end
end
c.desc 'Add a source.'
c.arg_name 'url'
c.command :add do |add|
add.action do |_global_options, _options, args|
Diggit::Dig.it.journal.add_source args[0]
end
end
c.desc 'Import sources from a file.'
c.arg_name 'file'
c.command :import do |import|
import.action do |_global_options, _options, args|
File.open(args[0]).each { |line| Diggit::Dig.it.journal.add_source(line) }
end
end
c.default_command :list
end

desc 'Manage the joins of the diggit folder.'
command :joins do |c|
c.desc 'List the joins'
c.command :list do |list|
list.action do |_global_options, _options, _args|
Diggit::Dig.it.config.get_joins.each { |a| Log.info a.name }
end
end
c.desc 'Add add join.'
c.arg_name 'name'
c.command :add do |add|
add.action do |_global_options, _options, args|
Diggit::Dig.it.config.add_join args[0]
end
end
c.desc 'Perform joins.'
c.command :perform do |perform|
perform.flag [:s, :sources], desc: "list of sources", type: Array, default_value: []
perform.flag [:a, :analyses], desc: "list of analyses", type: Array, default_value: []
perform.flag [:m, :mode], desc: "running mode",
must_match: { "run" => :run, "clean" => :clean, "rerun" => :rerun }, default_value: :run
perform.action do |_global_options, options, _args|
Diggit::Dig.it.join(options[:s], options[:a], options[:m])
end
end
c.default_command :list
end

desc 'Manage the analyses of the diggit folder.'
command :analyses do |c|
c.desc 'List the analyses'
c.command :list do |list|
list.action do |_global_options, _options, _args|
Diggit::Dig.it.config.get_analyses.each { |a| Log.info a.name }
end
end
c.desc 'Add an analysis.'
c.arg_name 'name'
c.command :add do |add|
add.action do |_global_options, _options, args|
Diggit::Dig.it.config.add_analysis args[0]
end
end
c.desc 'Perform analyses.'
c.command :perform do |perform|
perform.flag [:s, :sources], desc: "list of sources", type: Array, default_value: []
perform.flag [:a, :analyses], desc: "list of analyses", type: Array, default_value: []
perform.flag [:m, :mode], desc: "running mode",
must_match: { "run" => :run, "clean" => :clean, "rerun" => :rerun }, default_value: :run
perform.action do |_global_options, options, _args|
Diggit::Dig.it.analyze(options[:s], options[:a], options[:m])
end
end
c.default_command :list
end

desc 'Manage clone actions.'
command :clone do |c|
c.desc 'Perform the clones.'
c.command :perform do |perform|
perform.flag [:s, :sources], desc: "list of sources", type: Array, default_value: []
perform.action do |_global_options, options, _args|
Diggit::Dig.it.clone(*options[:s])
end
end
c.default_command :perform
end

desc 'Display errors.'
command :errors do |c|
c.desc 'Display the list of errors.'
c.command :list do |list|
list.action do |_global_options, _options, _args|
sources = Diggit::Dig.it.journal.sources
sources.each_index do |idx|
msg = "#{idx} #{sources[idx].url} (#{sources[idx].state})"
Log.error msg if sources[idx].error?
end
end
end
c.desc 'Display a source error.'
c.arg_name 'id'
c.command :show do |show|
show.action do |_global_options, _options, args|
source = Diggit::Dig.it.journal.sources_by_ids(args[0].to_i)[0]
Log.ok "Error summary for source #{args[0]}"
error = source.error
Log.info "URL: #{source.url}"
Log.info "State: #{source.state}"
Log.info "Error:"
Log.indent do
Log.error error[:message]
Log.info error[:backtrace].join("\n")
end
end
end
c.default_command :list
end

pre do |_global, _command, _options, _args|
Diggit::Dig.init
end

post do |_global, _command, _options, _args|
# Post logic here, skips_post to skip commands
end

on_error do |exception|
Log.error "Error running diggit."
Log.error exception.message
Log.info exception.backtrace.join("\n")
false
end

exit run(ARGV)
15 changes: 7 additions & 8 deletions diggit.gemspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Gem::Specification.new do |spec|
spec.name = 'diggit'
spec.version = '1.0.3'
spec.version = '2.0.0'
spec.summary = "A Git repository analysis tool."
spec.authors = ["Jean-Rémy Falleri", "Matthieu Foucault"]
spec.email = 'jr.falleri@gmail.com'
Expand All @@ -9,19 +9,18 @@ Gem::Specification.new do |spec|
spec.description = <<-END
The Diggit repository analysis tool is a neat swiss knife to enable the analysis of many Git repositories.
END

spec.require_paths = ['lib']
spec.files = ['README.md', 'LICENSE', 'bin/dgit'] + Dir['lib/*.rb'] + Dir['spec/*.rb'] + Dir['includes/**/*.rb']
spec.files = ['README.md', 'LICENSE', 'bin/dgit'] + Dir['lib/**/*.rb'] + Dir['spec/**/*.rb'] + Dir['includes/**/*.rb']
spec.executables << 'dgit'
spec.bindir = 'bin'
spec.required_ruby_version = '~> 2.1'
spec.add_runtime_dependency 'rugged', '~> 0.21'
spec.add_runtime_dependency 'oj', '~> 2.10'
spec.add_runtime_dependency 'thor', '~> 0.19'
spec.add_runtime_dependency 'mongo', '~> 1.11'
spec.add_runtime_dependency 'rinruby', '~> 2.0'
spec.add_development_dependency 'rake', '~> 10.4'
spec.add_runtime_dependency 'gli', '~> 2.13'
spec.add_runtime_dependency 'formatador', '~> 0.2'
spec.add_runtime_dependency 'mongo', '~> 2.0'
spec.add_development_dependency 'rspec', '~> 3.1'
spec.add_development_dependency 'yard', '~> 0.8'
spec.add_development_dependency 'coveralls', '~> 0.8'
spec.add_development_dependency 'rake', '~> 10.4'
spec.add_development_dependency 'coveralls', '~> 0.8'
end
26 changes: 0 additions & 26 deletions includes/addons/db.rb

This file was deleted.

21 changes: 0 additions & 21 deletions includes/addons/sources_options.rb

This file was deleted.

21 changes: 0 additions & 21 deletions includes/analyses/activity.rb

This file was deleted.

51 changes: 0 additions & 51 deletions includes/analyses/cloc.rb

This file was deleted.

0 comments on commit 2d0f166

Please sign in to comment.