yanapiri 0.3.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: '0693d55c2926d49f024324e341b2a72b7e7bf7b726e220152aaf862ab3eaa52d'
4
- data.tar.gz: b8d9156cc3de8c17a3d6c47afd6fe94c92e0c32855e7d30e29d58c4053a7d973
3
+ metadata.gz: dddfec46b22192f03ce76dfc7e5edd1123b19fe5fe01a36085f9cfe9ba84d2e9
4
+ data.tar.gz: 9b0862c9821ef7607b08856db8a80d80ceb061d03dce1a29c3dfcdfc62749260
5
5
  SHA512:
6
- metadata.gz: 88efae31854130a2cdb26f769a0f8a12c4104bd34a9a87498307bad9ef9c946a068f609e8bdc5e023e98e236777f6fcbf93184b4bbad18bf86265f25447bff3a
7
- data.tar.gz: 7a9e3f178ad6ba469f3f18397e9743f9a75c9937620e35e50cf1a5bdaab75970fe0117c01177e5ca1e9e371876d4a1969ad48d86587378c20864162e3ae86091
6
+ metadata.gz: c7a4ed25e2ad9ff0dcddbed6082ca4b77761259c3888aad37b5a258784d605643847eeb5df04983f4458157c75e931ef8cf11cc47c9385c603e5117786d3c1cc
7
+ data.tar.gz: f23e8c0839c0f25281323a3ac6ed17c6fa18efd31c17799d1704c272ff72ca3f656d859f3c4368c05035c5c5ffe343d71a6b7eea4b61d5ea50c130710510fd7c
data/.grenrc CHANGED
@@ -3,7 +3,7 @@
3
3
  "onlyMilestones": false,
4
4
  "groupBy": false,
5
5
  "template": {
6
- "issue": "- [{{text}}]({{url}}) {{name}}"
6
+ "issue": "- {{name}}. ([{{text}}]({{url}}))"
7
7
  },
8
8
  "changelogFilename": "CHANGELOG.md"
9
9
  }
@@ -214,6 +214,7 @@ es-AR:
214
214
  am: am
215
215
  formats:
216
216
  default: "%a, %d de %b de %Y a las %H:%M:%S %Z"
217
+ human: "%d/%m/%Y a las %H:%M"
217
218
  long: "%A, %d de %B de %Y a las %I:%M %p"
218
219
  short: "%d de %b a las %H:%M hrs"
219
220
  pm: pm
data/lib/yanapiri/bot.rb CHANGED
@@ -28,8 +28,8 @@ module Yanapiri
28
28
  if not entrega.hay_cambios?
29
29
  crear_issue_advertencia! entrega
30
30
  else
31
- entrega.crear_branch! 'base', entrega.commit_base
32
- entrega.crear_branch! 'entrega', 'master'
31
+ entrega.crear_branch_base!
32
+ entrega.crear_branch_entrega!
33
33
  transformaciones.select {|t| t.aplica? entrega}.each {|t| t.transformar! entrega, self}
34
34
  publicar_cambios! entrega
35
35
  crear_pull_request! entrega
@@ -61,6 +61,8 @@ module Yanapiri
61
61
  def commit!(repo, mensaje)
62
62
  repo.add
63
63
  repo.commit mensaje, author: git_author
64
+ rescue Git::GitExecuteError
65
+ # no se pudo commitear porque no había cambios
64
66
  end
65
67
 
66
68
  def aplanar_commits!(repo)
data/lib/yanapiri/cli.rb CHANGED
@@ -26,8 +26,9 @@ module Yanapiri
26
26
  say '¡Kamisaraki! Yo soy Yanapiri, tu ayudante, y necesito algunos datos antes de empezar:', :bold
27
27
 
28
28
  config = OpenStruct.new
29
- config.github_token = ask 'Token de GitHub (lo necesito para armar los pull requests):'
30
- config.orga = ask 'Organización por defecto:'
29
+ config.github_token = ask 'Token de GitHub (lo necesito para armar los pull requests):', default: options.github_token
30
+ config.orga = ask 'Organización por defecto:', default: options.orga
31
+ leer_opciones_comunes! config
31
32
 
32
33
  begin
33
34
  bot = crear_bot config
@@ -42,7 +43,8 @@ module Yanapiri
42
43
  def init
43
44
  config = OpenStruct.new
44
45
  config.orga = ask 'Nombre de la organización:', default: File.basename(Dir.pwd)
45
- success "De ahora en más, trabajaré con la organización #{config.orga} siempre que estés dentro de esta carpeta."
46
+ leer_opciones_comunes! config
47
+ success "De ahora en más, trabajaré con la organización #{config.orga} siempre que estés dentro de esta carpeta. Al corregir, utilizaré el modo #{config.modo_estricto ? 'estricto' : 'relajado'} y #{config.renombrar_proyecto_wollok ? '' : 'no '}renombraré los proyectos Wollok."
46
48
  dump_local_config! config
47
49
  end
48
50
 
@@ -82,6 +84,7 @@ module Yanapiri
82
84
  option :commit_base, {required: true, aliases: :b}
83
85
  option :fecha_limite, {default: Time.now.to_s, aliases: :l}
84
86
  option :renombrar_proyecto_wollok, {type: :boolean, default: true}
87
+ option :modo_estricto, {type: :boolean, default: false}
85
88
  def corregir(nombre)
86
89
  foreach_entrega(nombre) do |entrega|
87
90
  @bot.preparar_correccion! entrega, options.renombrar_proyecto_wollok ? [TransformacionWollok] : []
@@ -132,7 +135,7 @@ module Yanapiri
132
135
 
133
136
  def foreach_entrega(nombre)
134
137
  foreach_repo(nombre) do |repo, base_path|
135
- yield Entrega.new "#{base_path}/#{repo}", options.commit_base, Time.parse(options.fecha_limite)
138
+ yield Entrega.new "#{base_path}/#{repo}", options.commit_base, Time.parse(options.fecha_limite), options.modo_estricto
136
139
  end
137
140
  end
138
141
 
@@ -170,6 +173,11 @@ module Yanapiri
170
173
  if File.exist? source then YAML.load_file source else {} end
171
174
  end
172
175
 
176
+ def leer_opciones_comunes!(config)
177
+ config.modo_estricto = yes? '¿Usar modo estricto? [y/N]'
178
+ config.renombrar_proyecto_wollok = !(no? '¿Renombrar proyectos Wollok al corregir? [Y/n]')
179
+ end
180
+
173
181
  def options
174
182
  original_options = super
175
183
  defaults_global = load_config global_config_file
@@ -1,17 +1,18 @@
1
1
  module Yanapiri
2
2
  class Entrega
3
3
  attr_reader :id, :fecha_limite, :repo, :commit_base
4
+ delegate :mensaje_pull_request, :commit_entrega, to: :@modo
4
5
 
5
- def initialize(repo_path, commit_base = nil, fecha_limite = nil)
6
+ def initialize(repo_path, commit_base = nil, fecha_limite = nil, modo_estricto = false)
6
7
  @id = File.basename repo_path
7
8
  @fecha_limite = fecha_limite || Time.now + 1.second
8
9
  @commit_base = commit_base || '--max-parents=0 HEAD'
10
+ @modo = (modo_estricto ? ModoEstricto : ModoRelajado).new self
9
11
  @repo = Git.open repo_path
10
12
  end
11
13
 
12
14
  def fuera_de_termino?
13
- @repo.checkout 'master'
14
- @repo.log.since(@fecha_limite.iso8601).any?
15
+ commits_fuera_de_termino.any?
15
16
  end
16
17
 
17
18
  def autor
@@ -23,31 +24,77 @@ module Yanapiri
23
24
  @repo.log.first.author_date
24
25
  end
25
26
 
26
- def mensaje_pull_request
27
- if fuera_de_termino?
28
- "**Ojo:** tu último commit fue el #{formato_humano fecha}, pero la fecha límite era el #{formato_humano fecha_limite}.\n\n¡Tenés que respetar la fecha de entrega establecida! :point_up:"
29
- else
30
- ''
31
- end
27
+ def contiene_archivo?(nombre)
28
+ @repo.chdir { File.exist? nombre }
32
29
  end
33
30
 
31
+ def commits_fuera_de_termino
32
+ @repo.checkout 'master'
33
+ @repo.log.since(@fecha_limite.iso8601)
34
+ end
35
+
36
+ def hay_cambios?
37
+ @repo.log.between(@commit_base, 'master').any?
38
+ end
39
+
40
+ def crear_branch_entrega!
41
+ crear_branch! 'entrega', commit_entrega
42
+ end
43
+
44
+ def crear_branch_base!
45
+ crear_branch! 'base', commit_base
46
+ end
47
+
48
+ private
49
+
34
50
  def crear_branch!(nombre, head)
35
51
  @repo.checkout head
36
52
  @repo.branch(nombre).checkout
37
53
  end
38
54
 
39
- def contiene_archivo?(nombre)
40
- @repo.chdir { File.exist? nombre }
41
- end
55
+ class ModoCorreccion
56
+ delegate_missing_to :@entrega
42
57
 
43
- def hay_cambios?
44
- @repo.log.between(@commit_base, 'master').any?
58
+ def initialize(entrega)
59
+ @entrega = entrega
60
+ end
61
+
62
+ def mensaje_pull_request
63
+ if fuera_de_termino? then mensaje_fuera_de_termino else '' end
64
+ end
65
+
66
+ def mensaje_fuera_de_termino
67
+ "**Ojo:** tu último commit fue el #{formato_humano fecha}, pero la fecha límite era el #{formato_humano fecha_limite}.\n\n¡Tenés que respetar la fecha de entrega establecida! :point_up:"
68
+ end
69
+
70
+ private
71
+
72
+ def formato_humano(fecha)
73
+ I18n.l(fecha, format: :human)
74
+ end
45
75
  end
46
76
 
47
- private
77
+ class ModoEstricto < ModoCorreccion
78
+ def mensaje_fuera_de_termino
79
+ super + "\n\nNo se tuvieron en cuenta los siguientes commits:\n\n#{commits_desestimados}"
80
+ end
81
+
82
+ def commit_entrega
83
+ repo.checkout 'master'
84
+ repo.log.until(fecha_limite.iso8601).first.sha
85
+ end
48
86
 
49
- def formato_humano(fecha)
50
- fecha.strftime("%d/%m/%Y a las %H:%M")
87
+ private
88
+
89
+ def commits_desestimados
90
+ commits_fuera_de_termino.map {|c| "* #{c.message} (#{c.sha})"}.join("\n")
91
+ end
92
+ end
93
+
94
+ class ModoRelajado < ModoCorreccion
95
+ def commit_entrega
96
+ 'master'
97
+ end
51
98
  end
52
99
  end
53
100
  end
@@ -1,3 +1,3 @@
1
1
  module Yanapiri
2
- VERSION = "0.3.0"
2
+ VERSION = "0.4.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: yanapiri
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Federico Aloi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-05-13 00:00:00.000000000 Z
11
+ date: 2019-05-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor