git_fonky 0.5.0 → 0.6.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 +4 -4
- data/lib/git_fonky/branch.rb +13 -0
- data/lib/git_fonky/command.rb +6 -10
- data/lib/git_fonky/message_formatter.rb +26 -0
- data/lib/git_fonky/repo_dir.rb +43 -18
- data/lib/git_fonky/repo_names.rb +3 -0
- data/lib/git_fonky/reporter.rb +26 -32
- data/lib/git_fonky/version.rb +1 -1
- data/lib/git_fonky.rb +3 -3
- metadata +6 -4
- data/lib/git_fonky/work_repo_names.rb +0 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 076cf7e6f05362ab912197732e48649abffb67bfaf179cd55916fda375f26115
|
4
|
+
data.tar.gz: 2a6005c936aa4fa6b3e4d4a19eeb4de34fd836483b128dc151d78fe0c631dd75
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d6d39a6139345648528b1520806bbf782df65fda3c46f2ec9c10b52c58454819a96ca4e3da40db4c92d338e9a514373c1f7db70e2ad53cce97f9476c74cb3afe
|
7
|
+
data.tar.gz: dc39a274c029ddf4aeb00a4ccd8bc5aca0e979818bc2277969d4ee6303395de858ea5202bb1b61b76da4f55e89983f3b630c5ae5dfc20f7dcea5bf33d544c8b0
|
data/lib/git_fonky/command.rb
CHANGED
@@ -1,10 +1,9 @@
|
|
1
1
|
module GitFonky
|
2
2
|
class Command
|
3
|
-
|
3
|
+
attr_accessor :branch_name
|
4
4
|
|
5
|
-
def initialize(
|
6
|
-
@
|
7
|
-
@reporter = reporter
|
5
|
+
def initialize(branch_name = nil)
|
6
|
+
@branch_name = branch_name
|
8
7
|
end
|
9
8
|
|
10
9
|
def current_branch
|
@@ -12,18 +11,15 @@ module GitFonky
|
|
12
11
|
end
|
13
12
|
|
14
13
|
def fetch_upstream
|
15
|
-
|
16
|
-
`git fetch upstream #{repo_dir.branch} 2>&1`
|
14
|
+
`git fetch upstream #{branch_name} 2>&1`
|
17
15
|
end
|
18
16
|
|
19
17
|
def pull_upstream
|
20
|
-
|
21
|
-
`git pull upstream #{repo_dir.branch} 2>&1`
|
18
|
+
`git pull upstream #{branch_name} 2>&1`
|
22
19
|
end
|
23
20
|
|
24
21
|
def push_to_origin
|
25
|
-
|
26
|
-
`git push origin #{repo_dir.branch} 2>&1`
|
22
|
+
`git push origin #{branch_name} 2>&1`
|
27
23
|
end
|
28
24
|
end
|
29
25
|
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module GitFonky
|
2
|
+
class MessageFormatter
|
3
|
+
def message_with_border(**params)
|
4
|
+
border = calculate_border_for(params[:msg], params.delete(:border_char) { "*" })
|
5
|
+
output_border_and_msg(border: border, **params)
|
6
|
+
end
|
7
|
+
|
8
|
+
private
|
9
|
+
|
10
|
+
def calculate_border_for(msg, border_char)
|
11
|
+
border_char * (msg.length + 20)
|
12
|
+
end
|
13
|
+
|
14
|
+
def output_border_and_msg(border:, msg:, sub_msg: nil, io_stream: STDERR, warn: true)
|
15
|
+
io_stream.puts border
|
16
|
+
io_stream.puts warning_header.center(border.length) if warn
|
17
|
+
io_stream.puts msg.center(border.length)
|
18
|
+
io_stream.puts sub_msg.center(border.length) if sub_msg
|
19
|
+
io_stream.puts border
|
20
|
+
end
|
21
|
+
|
22
|
+
def warning_header
|
23
|
+
"WARNING"
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
data/lib/git_fonky/repo_dir.rb
CHANGED
@@ -1,37 +1,62 @@
|
|
1
|
-
require_relative "
|
1
|
+
require_relative "branch"
|
2
2
|
require_relative "command"
|
3
|
+
require_relative "reporter"
|
3
4
|
|
4
5
|
module GitFonky
|
5
6
|
class RepoDir
|
6
|
-
attr_reader :command, :dirname, :reporter
|
7
|
+
attr_reader :branch, :command, :dirname, :reporter
|
7
8
|
|
8
|
-
def initialize(dirname)
|
9
|
+
def initialize(dirname, command = Command, branch = Branch, reporter = Reporter)
|
9
10
|
@dirname = dirname
|
10
|
-
@
|
11
|
-
@
|
11
|
+
@command = command.new
|
12
|
+
@branch = branch.new(@command.current_branch)
|
13
|
+
@command.branch_name = @branch.name
|
14
|
+
@reporter = reporter.new(@dirname, @branch.name)
|
12
15
|
end
|
13
16
|
|
14
|
-
def
|
15
|
-
|
17
|
+
def self.sync(dirname)
|
18
|
+
Dir.chdir(dirname) do
|
19
|
+
new(dirname).sync
|
20
|
+
end
|
16
21
|
end
|
17
22
|
|
18
23
|
def sync
|
19
|
-
|
20
|
-
|
21
|
-
|
24
|
+
catch(:skip_repo) do
|
25
|
+
announce_sync_attempt
|
26
|
+
fetch
|
27
|
+
pull
|
28
|
+
push
|
29
|
+
announce_sync_success
|
30
|
+
end
|
31
|
+
end
|
22
32
|
|
23
|
-
|
24
|
-
command.pull_upstream
|
33
|
+
private
|
25
34
|
|
26
|
-
|
35
|
+
def announce_sync_attempt
|
36
|
+
branch.valid? ? reporter.announce_sync_attempt : throw(:skip_repo, reporter.invalid_branch_msg)
|
37
|
+
end
|
27
38
|
|
28
|
-
|
29
|
-
|
30
|
-
|
39
|
+
def fetch
|
40
|
+
command.fetch_upstream
|
41
|
+
process_successful? ? reporter.announce("fetched") : throw(:skip_repo, reporter.failed_fetch_msg)
|
42
|
+
end
|
43
|
+
|
44
|
+
def pull
|
45
|
+
command.pull_upstream
|
46
|
+
process_successful? ? reporter.announce("pulled") : throw(:skip_repo, reporter.failed_pull_msg)
|
47
|
+
end
|
48
|
+
|
49
|
+
def push
|
50
|
+
command.push_to_origin
|
51
|
+
process_successful? ? reporter.announce("pushed", "to", "origin") : throw(:skip_repo, reporter.failed_push_msg)
|
52
|
+
end
|
53
|
+
|
54
|
+
def announce_sync_success
|
55
|
+
reporter.announce_sync_success
|
31
56
|
end
|
32
57
|
|
33
|
-
def
|
34
|
-
|
58
|
+
def process_successful?
|
59
|
+
$?.success?
|
35
60
|
end
|
36
61
|
end
|
37
62
|
end
|
data/lib/git_fonky/reporter.rb
CHANGED
@@ -1,57 +1,51 @@
|
|
1
|
+
require_relative "message_formatter"
|
1
2
|
module GitFonky
|
2
3
|
class Reporter
|
3
|
-
attr_reader :
|
4
|
+
attr_reader :formatter, :repo_name, :repo_branch
|
4
5
|
|
5
|
-
def initialize(
|
6
|
-
@
|
6
|
+
def initialize(repo_name, repo_branch, formatter = MessageFormatter)
|
7
|
+
@repo_name = repo_name
|
8
|
+
@repo_branch = repo_branch
|
9
|
+
@formatter = formatter.new
|
7
10
|
end
|
8
11
|
|
9
12
|
def announce(action, direction = "from", remote = "upstream")
|
10
|
-
puts "-----> #{action} #{direction} #{remote} #{
|
13
|
+
STDERR.puts "-----> #{action} #{direction} #{remote} #{repo_branch}"
|
11
14
|
end
|
12
15
|
|
13
|
-
def
|
14
|
-
puts "-----> Successfully
|
16
|
+
def announce_sync_success
|
17
|
+
puts "-----> Successfully synced #{repo_name} | #{repo_branch} branch"
|
15
18
|
end
|
16
19
|
|
17
|
-
def
|
18
|
-
msg = "
|
19
|
-
|
20
|
-
|
21
|
-
output_border_and_msg(border, msg, warn: false)
|
20
|
+
def announce_sync_attempt
|
21
|
+
msg = "Attempting to sync -> #{repo_name} | #{repo_branch} branch "
|
22
|
+
formatter.message_with_border(msg: msg, border_char: "=", warn: false)
|
22
23
|
end
|
23
24
|
|
24
25
|
def invalid_branch_msg
|
25
26
|
msg = "You are not on the main/master branch. Please checkout the main/master branch and try again."
|
26
|
-
sub_msg = "-----> skipping #{
|
27
|
-
|
28
|
-
|
29
|
-
output_border_and_msg(border, msg, sub_msg)
|
27
|
+
sub_msg = "-----> skipping #{repo_name} | #{repo_branch} branch <-----"
|
28
|
+
formatter.message_with_border(msg: msg, sub_msg: sub_msg)
|
30
29
|
end
|
31
30
|
|
32
|
-
def
|
33
|
-
msg = "-----> Failed to
|
34
|
-
|
35
|
-
|
36
|
-
output_border_and_msg(border, msg)
|
31
|
+
def failed_fetch_msg
|
32
|
+
msg = "-----> Failed to fetch from upstream #{repo_branch}. Moving on to next repo. <-----"
|
33
|
+
formatter.message_with_border(msg: msg)
|
37
34
|
end
|
38
35
|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
border_char * (msg.length + 20)
|
36
|
+
def failed_pull_msg
|
37
|
+
msg = "-----> Failed to pull from upstream #{repo_branch}. Moving on to next repo. <-----"
|
38
|
+
formatter.message_with_border(msg: msg)
|
43
39
|
end
|
44
40
|
|
45
|
-
def
|
46
|
-
|
47
|
-
|
48
|
-
puts msg.center(border.length)
|
49
|
-
puts sub_msg.center(border.length) if sub_msg
|
50
|
-
puts border
|
41
|
+
def failed_push_msg
|
42
|
+
msg = "-----> Failed to push to origin #{repo_branch}. Moving on to next repo. <-----"
|
43
|
+
formatter.message_with_border(msg: msg)
|
51
44
|
end
|
52
45
|
|
53
|
-
def
|
54
|
-
"
|
46
|
+
def failed_sync_msg
|
47
|
+
msg = "-----> Failed to sync #{repo_name} | #{repo_branch}. Moving on to next repo. <-----"
|
48
|
+
formatter.message_with_border(msg: msg)
|
55
49
|
end
|
56
50
|
end
|
57
51
|
end
|
data/lib/git_fonky/version.rb
CHANGED
data/lib/git_fonky.rb
CHANGED
@@ -2,15 +2,15 @@
|
|
2
2
|
|
3
3
|
require_relative "git_fonky/version"
|
4
4
|
require_relative "git_fonky/repo_dir"
|
5
|
-
require_relative "git_fonky/
|
5
|
+
require_relative "git_fonky/repo_names"
|
6
6
|
|
7
7
|
module GitFonky
|
8
8
|
class Error < StandardError; end
|
9
9
|
|
10
10
|
def self.sync_repos
|
11
11
|
Dir.chdir "#{Dir.home}/code" do
|
12
|
-
|
13
|
-
RepoDir.
|
12
|
+
REPO_NAMES.each do |dir|
|
13
|
+
RepoDir.sync(dir)
|
14
14
|
puts "\n\n\n"
|
15
15
|
end
|
16
16
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: git_fonky
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Collin Jilbert
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-12-
|
11
|
+
date: 2023-12-26 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Do 'em all at once.
|
14
14
|
email:
|
@@ -27,11 +27,13 @@ files:
|
|
27
27
|
- bin/gfonk
|
28
28
|
- git_fonky.gemspec
|
29
29
|
- lib/git_fonky.rb
|
30
|
+
- lib/git_fonky/branch.rb
|
30
31
|
- lib/git_fonky/command.rb
|
32
|
+
- lib/git_fonky/message_formatter.rb
|
31
33
|
- lib/git_fonky/repo_dir.rb
|
34
|
+
- lib/git_fonky/repo_names.rb
|
32
35
|
- lib/git_fonky/reporter.rb
|
33
36
|
- lib/git_fonky/version.rb
|
34
|
-
- lib/git_fonky/work_repo_names.rb
|
35
37
|
- sig/git_fonky.rbs
|
36
38
|
homepage: https://github.com/cjilbert504/git_fonky
|
37
39
|
licenses:
|
@@ -55,7 +57,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
55
57
|
- !ruby/object:Gem::Version
|
56
58
|
version: '0'
|
57
59
|
requirements: []
|
58
|
-
rubygems_version: 3.
|
60
|
+
rubygems_version: 3.5.1
|
59
61
|
signing_key:
|
60
62
|
specification_version: 4
|
61
63
|
summary: Sync all of your git repos with one command.
|