mgit 0.1.2 → 0.2.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,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- Nzc1OTY5YThjMGNhNWI3NGQyYjEwYzA4NGVlMDM1YjIyZTlhMWZiNg==
4
+ Yjg1YmQxYjM1YTZkYTU5Yzg0N2E4MzAwNWZmYTU3ZDQ0MTRhY2I0Yg==
5
5
  data.tar.gz: !binary |-
6
- ZjcyZjUwMjRlOWUzMDQ1YmU5YmJhMDU0ODVlZmRhYzZiYzUyMTJkNQ==
6
+ MmJiYWNkNWNhYmUxMDQwYzBjYzg0Mjc0YjRhMDlkM2QxM2EzZWEzNQ==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- YmNjMzk1ZjI5Yjc1NTRhZDkxZGVkZGIzNmU5MTIxZDYzYjNkYzBiZDQzYjkx
10
- YjUxYTI1MjBjMGViNjc5YTA1ZDcxMTVjN2M3YjEwOTkzZjlmNmRlOTBmYTdl
11
- YzVhNGJhNDEzYzkzZWY2MGRhYTY2YTBkZDM1NGFmZThlMWYzNGQ=
9
+ OWI0ZWRhMWJiYWNjYmM0YTgyMDQyYzkwMjA1OWViY2U1MTY0MDRiN2RjZWY3
10
+ NDQ2ZTIzY2YzODQ5YmI2ZmRiMTkzMmIyM2YxODhhMmZmOTcxMGNlZjBjZDY3
11
+ MTI2MGFjNWNiOGM0ZGQ2MmVjOTMwOGU1MGU0NzljN2UwZjJlNjg=
12
12
  data.tar.gz: !binary |-
13
- MjNjYzkxNDY3NzQ3ZWNiMGU5ZDE3NjJjYzM1ZjUzMDFmOTU2ZDUxYjFmMjcx
14
- ZjA1N2QxMTRiMTQzZTdjMDg3MDZmZGIwYjliNDc2MGU5ZTYzNTMwZGFhZGM4
15
- MWY5NTI5MTYyYTQ4NzUzYWQ4OGYyOGUyMDhjZGY5NGQ5Nzg3OTQ=
13
+ NTQ1MmI2NTA4OGQ2NDRlMjc4YTFlNGY4NWNmNDcwNDY0NjFmMWNkZWI2MDkz
14
+ ZTdmNjNiOGRmMzlhY2RmNTZmODJiOGNiOTY4MjFmYmIyMTU0ZTA3YjJmNTlh
15
+ ZjM2NzhhNmZhNWE4MGFiMzIwNzc5YTBhMmE5YWRmMjBmZjlhODc=
@@ -1,5 +1,6 @@
1
1
  require 'colorize'
2
2
  require 'highline/import'
3
+ require 'xdg'
3
4
 
4
5
  require 'mgit/version'
5
6
  require 'mgit/exceptions'
@@ -11,9 +11,8 @@ module MGit
11
11
 
12
12
  puts "Fast-forward merging branches in repository #{repo.name}...".yellow
13
13
 
14
- tb = tracking_branches
15
- cb = current_branch
16
- tb.each do |b|
14
+ cb = repo.current_branch
15
+ repo.remote_tracking_branches.each do |b, u|
17
16
  `git checkout -q #{b}`
18
17
  `git merge --ff-only @{u}`
19
18
  end
@@ -30,19 +29,5 @@ module MGit
30
29
  end
31
30
 
32
31
  register_command :ffmerge
33
-
34
- private
35
-
36
- def tracking_branches
37
- `git for-each-ref --format='%(refname:short) %(upstream:short)' refs/heads`.
38
- split("\n").
39
- map { |b| b.split(' ') }.
40
- reject { |b| b.size != 2 }.
41
- map(&:first)
42
- end
43
-
44
- def current_branch
45
- `git rev-parse --abbrev-ref HEAD`
46
- end
47
32
  end
48
33
  end
@@ -1,47 +1,34 @@
1
1
  module MGit
2
2
  class LogCommand < Command
3
3
  def execute(args)
4
- raise TooManyArgumentsError.new(self) if args.size > 1
5
-
6
- days = 1
7
-
8
- if args.size == 1
9
- begin
10
- days = Integer(args[0])
11
- rescue ArgumentError => e
12
- raise new CommandUsageError("First argument must be an integer", self)
13
- end
14
- end
15
-
16
4
  Registry.chdir_each do |repo|
17
- lc = latest_commits(days)#.sort_by { |c| c[:author] }
18
- next if lc.empty?
19
-
20
- puts "In repository #{repo.name} the following commits were made:".yellow
21
-
22
- longest_name = lc.map { |c| c[:author].size }.max
23
-
24
- lc.each do |c|
25
- puts "#{c[:commit]} #{c[:author].ljust(longest_name, ' ')} #{c[:subject]}"
5
+ repo.remote_tracking_branches.each do |branch, upstream|
6
+ uc = unmerged_commits(branch, upstream)
7
+ next if uc.empty?
8
+
9
+ puts "In repository #{repo.name}, branch #{upstream} the following commits were made:".yellow
10
+ longest_name = uc.map { |c| c[:author].size }.max
11
+ uc.each do |c|
12
+ puts "#{c[:commit]} #{c[:author].ljust(longest_name, ' ')} #{c[:subject]}"
13
+ end
26
14
  end
27
- puts
28
15
  end
29
16
  end
30
17
 
31
18
  def usage
32
- 'log [number_of_days]'
19
+ 'log'
33
20
  end
34
21
 
35
22
  def description
36
- 'what happened since *n* days ago'
23
+ 'show unmerged commits for all remote-tracking branches'
37
24
  end
38
25
 
39
26
  register_command :log
40
27
 
41
28
  private
42
29
 
43
- def latest_commits(days)
44
- `git log --pretty=format:"%h#%an#%s" --reverse --all --since=#{days}.days.ago --relative-date`.
30
+ def unmerged_commits(branch, upstream)
31
+ `git log --pretty=format:"%h#%an#%s" --reverse --relative-date #{branch}..#{upstream}`.
45
32
  split("\n").
46
33
  map { |line| line.split('#') }.
47
34
  map do |words|
@@ -12,9 +12,8 @@ module MGit
12
12
 
13
13
  raise CommandUsageError.new("Couldn't find repository matching '#{ptrn}'.", self) unless repo
14
14
 
15
- name = repo[0]
16
- Repository.remove(name)
17
- puts "Removed repository #{name}.".yellow
15
+ Registry.remove(repo.name)
16
+ puts "Removed repository #{repo.name}.".yellow
18
17
  end
19
18
 
20
19
  def usage
@@ -37,7 +37,7 @@ module MGit
37
37
  private
38
38
 
39
39
  def self.repofile
40
- File.join(Dir.home, '.config/mgit.yml')
40
+ XDG['CONFIG_HOME'].to_path.join('mgit.yml')
41
41
  end
42
42
 
43
43
  def self.load
@@ -9,8 +9,19 @@ module MGit
9
9
  @path = path
10
10
  end
11
11
 
12
- def dirty?
13
- [:index, :dirty, :untracked].any? { |f| flags.include?(f) }
12
+ def current_branch
13
+ in_repo { `git rev-parse --abbrev-ref HEAD` }
14
+ end
15
+
16
+ def remote_tracking_branches
17
+ a = in_repo do
18
+ `git for-each-ref --format='%(refname:short) %(upstream:short)' refs/heads`.
19
+ split("\n").
20
+ map { |b| b.split(' ') }.
21
+ reject { |b| b.size != 2 }
22
+ end
23
+
24
+ Hash[a]
14
25
  end
15
26
 
16
27
  def flags
@@ -50,18 +61,22 @@ module MGit
50
61
  divergence
51
62
  end
52
63
 
64
+ def dirty?
65
+ [:index, :dirty, :untracked].any? { |f| flags.include?(f) }
66
+ end
67
+
53
68
  private
54
69
 
70
+ def in_repo
71
+ Dir.chdir(path) { yield }
72
+ end
73
+
55
74
  def status
56
- @status ||= `git status --short --branch --ignore-submodules`.split("\n")
75
+ @status ||= in_repo { `git status --short --branch --ignore-submodules`.split("\n") }
57
76
  end
58
77
 
59
78
  def status_lines
60
- Dir.chdir(path) do
61
- status.each do |s|
62
- yield s
63
- end
64
- end
79
+ status.each { |s| yield s }
65
80
  end
66
81
  end
67
82
  end
@@ -1,3 +1,3 @@
1
1
  module MGit
2
- VERSION = '0.1.2'
2
+ VERSION = '0.2.0'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mgit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - FlavourSys Technology GmbH
@@ -38,6 +38,20 @@ dependencies:
38
38
  - - ! '>='
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: xdg
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ! '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
41
55
  description: M[eta]Git let's you manage multiple git repositories simultaneously
42
56
  email: technology@flavoursys.com
43
57
  executables: