takeltau 0.36.4 → 0.38.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4c0db25372597ae69bc88e04f9c090185e824a7fe3812750cbf166dcada2a590
4
- data.tar.gz: 9c200e4060b553b646edeac2501998d098fb65b66ca190c8afe3594144ebee03
3
+ metadata.gz: 5a5ea68fdc1d3340cb871a3abdd21675c99508c0b5ac0095e3c2cfe675bf983e
4
+ data.tar.gz: 561785ba66192b34f594165be501296afc90825a889559fb2ff5f02e2637db89
5
5
  SHA512:
6
- metadata.gz: 3a58b2a5872aa15a5dc9a29896972e10948772fc0285d467f1e544f63ffe31c3596814eab7d14b09753dab945bab136542bf0e6b9e927d5bbfe9612827a27f60
7
- data.tar.gz: 7334186d9ef1323d0828a0862b0333883d156634c173dadc3c8230b01baf231142bae48894baf47438350a51b645243f8c70f4c5b558039e135a1e8417f1c273
6
+ metadata.gz: 0bcdb05348ba4b8e416a9326578301f8518ef8b51dc74ec822b7547a27dde30f5a712f14bf5cd05495fd44fbf9d94a30abb55659ff143768612e03717d495425
7
+ data.tar.gz: 576340ebafa4c5bb4f170aee9d9bffb2e30aec58ab4d669bfcd66b2ef18f76d885bd41e7d825561a9921fe4eee262fe9833bbe8e76bf040ed13ee3801e1bb373
data/README.md CHANGED
@@ -168,7 +168,21 @@ to overwrite defaults like:
168
168
  docker_repo: takelage-mock
169
169
  ```
170
170
 
171
- Furthermore, every external command can be reconfigured.
171
+ - You may prefer to interact with
172
+ [mercurial](https://github.com/takelwerk/takelage-doc/blob/main/doc/tau/hg.md)
173
+ through `tau hg`
174
+ in a different branch than `main` in one project so you may add
175
+ to your *takelage.yml*:
176
+
177
+
178
+ ```yaml
179
+ ---
180
+ git_hg_repo: my_git_hg_branch
181
+ ```
182
+
183
+ Furthermore,
184
+ [every external command](https://github.com/takelwerk/takelage-cli/blob/main/lib/takeltau/default.yml)
185
+ can be reconfigured.
172
186
 
173
187
  ### Project Files
174
188
 
@@ -23,14 +23,13 @@ cmd_git_check_clean_git_status: 'git status --porcelain'
23
23
  cmd_git_check_hg_get_git_branch: 'git symbolic-ref HEAD'
24
24
  cmd_git_check_workspace_git_repo: 'git -C %{dir} rev-parse'
25
25
  cmd_git_check_workspace_pwd: 'pwd'
26
- cmd_git_lib_git_add_all: 'git add --all'
27
26
  cmd_git_lib_git_add_hg_dirs: 'git add \*/.hg/\*'
28
27
  cmd_git_lib_git_commit: 'git commit --message="%{message}"'
29
28
  cmd_git_lib_git_pull_origin: 'git pull origin %{main}'
30
29
  cmd_git_lib_git_push_origin: 'git push origin %{main}'
31
- cmd_hg_list_repos: 'cd %{root}; find * -type d -name ".hg" | parallel -k hg paths default -R {//} -T "hg\ clone\ {url}\ " \; echo {//}'
32
- cmd_hg_pull_repos: 'cd %{root}; find * -type d -name ".hg" | parallel -k echo \; cd {//} \; pwd \; hg pull --update'
33
- cmd_hg_push_repos: 'cd %{root}; find * -type d -name ".hg" | parallel -k echo \; cd {//} \; pwd \; hg commit --addremove --message "Update\ hg\ repos" \; hg bookmark -f main \; hg push'
30
+ cmd_hg_list_repos: 'cd %{root}; find * -type d -name ".hg" | parallel --keep-order hg paths default --repository {//} --template "hg\ clone\ {url}\ " \; echo {//}'
31
+ cmd_hg_pull_repos: 'cd %{root}; find * -type d -name ".hg" | parallel --keep-order echo \; cd {//} \; pwd \; hg pull --update'
32
+ cmd_hg_push_repos: 'cd %{root}; find * -type d -name ".hg" | parallel --keep-order echo \; cd {//} \; pwd \; hg commit --addremove --message "Update\ hg\ repos" \; hg bookmarks --force main \; hg push'
34
33
  cmd_info_status_lib_git_name: 'git -C %{root} config user.name'
35
34
  cmd_info_status_lib_git_email: 'git -C %{root} config user.email'
36
35
  cmd_info_status_lib_git_signingkey: 'git -C %{root} config user.signingKey'
@@ -38,6 +37,7 @@ cmd_info_status_lib_git_key_available: 'gpg --list-key %{key}'
38
37
  cmd_info_status_gopass_root_store: 'gopass config | grep "path" | cut -d " " -f 2'
39
38
  cmd_info_status_gpg_agent: 'gpg-connect-agent /bye'
40
39
  cmd_info_status_gpg_keys: 'gpg --list-keys'
40
+ cmd_info_status_hg_username: 'hg config ui.username'
41
41
  cmd_info_status_ssh_keys: 'ssh-add -l'
42
42
  cmd_info_status_ssh_socket: 'gpgconf --list-dirs agent-ssh-socket'
43
43
  cmd_init_lib_git_init: 'git init && git checkout -b main'
@@ -65,7 +65,10 @@ git_hg_branch: 'main'
65
65
  info_project_main: 'project.yml'
66
66
  info_project_private: 'private/project.yml'
67
67
  login_wait_for_sockets: '0'
68
- mutagen_socket_path_mutagen: '~/.mutagen/daemon/daemon.sock'
69
- mutagen_socket_path_gpg: '~/.gnupg/S.gpg-agent'
70
- mutagen_socket_path_ssh: '~/.gnupg/S.gpg-agent.ssh'
68
+ mutagen_socket_path_mutagen_container: '~/.mutagen/daemon/daemon.sock'
69
+ mutagen_socket_path_mutagen_host: '~/.mutagen/daemon/daemon.sock'
70
+ mutagen_socket_path_gpg_container: '~/.gnupg/S.gpg-agent'
71
+ mutagen_socket_path_gpg_host: '~/.gnupg/S.gpg-agent'
72
+ mutagen_socket_path_ssh_container: '~/.gnupg/S.gpg-agent.ssh'
73
+ mutagen_socket_path_ssh_host: '~/.gnupg/S.gpg-agent.ssh'
71
74
  mutagen_socket_takelage_label: 'type=takelage'
@@ -40,9 +40,12 @@ module Takeltau
40
40
  @hostname = _docker_container_lib_hostname
41
41
  @hostlabel = "hostname=#{@hostname}"
42
42
  @takellabel = config.active['mutagen_socket_takelage_label']
43
- @mutagensock = config.active['mutagen_socket_path_mutagen']
44
- @gpgsock = config.active['mutagen_socket_path_gpg']
45
- @sshsock = config.active['mutagen_socket_path_ssh']
43
+ @mutagensock_container = config.active['mutagen_socket_path_mutagen_container']
44
+ @mutagensock_host = config.active['mutagen_socket_path_mutagen_host']
45
+ @gpgsock_container = config.active['mutagen_socket_path_gpg_container']
46
+ @gpgsock_host = config.active['mutagen_socket_path_gpg_host']
47
+ @sshsock_container = config.active['mutagen_socket_path_ssh_container']
48
+ @sshsock_host = config.active['mutagen_socket_path_ssh_host']
46
49
  end
47
50
  # rubocop:enable Metrics/MethodLength
48
51
  # rubocop:enable Metrics/AbcSize
@@ -10,9 +10,9 @@ module DockerContainerLib
10
10
  def _docker_container_lib_start_sockets
11
11
  return false unless mutagen_check_daemon
12
12
 
13
- mutagen_socket_create 'mutagen', @mutagensock, @mutagensock
14
- mutagen_socket_create 'gpg', @gpgsock, @gpgsock
15
- mutagen_socket_create 'ssh', @sshsock, @sshsock
13
+ mutagen_socket_create 'mutagen', @mutagensock_container, @mutagensock_host
14
+ mutagen_socket_create 'gpg', @gpgsock_container, @gpgsock_host
15
+ mutagen_socket_create 'ssh', @sshsock_container, @sshsock_host
16
16
  end
17
17
 
18
18
  # Create unique docker hostname
@@ -2,23 +2,29 @@
2
2
 
3
3
  # tau git lib
4
4
  module GitLib
5
- # Pull git workspace.
6
- def git_lib_pull_workspace
7
- log.info 'Pulling git workspace'
5
+ # Prepare git workspace.
6
+ # rubocop:disable Metrics/MethodLength
7
+ def git_lib_prepare_git_workspace
8
+ log.debug 'Prepare git workspace'
8
9
 
9
- _git_lib_git_pull_origin_hg
10
- end
10
+ return false unless configured? %w[project_root_dir]
11
11
 
12
- # Push git workspace.
13
- def git_lib_push_workspace(message)
14
- log.info 'Pushing git workspace'
12
+ unless git_check_hg
13
+ log.error 'Not on git hg branch'
14
+ return false
15
+ end
15
16
 
16
- return false unless _git_lib_git_add_all
17
- return false unless _git_lib_git_commit message
18
- return false unless _git_lib_git_pull_origin_hg
17
+ unless git_check_clean
18
+ log.error 'No clean git workspace'
19
+ return false
20
+ end
19
21
 
20
- _git_lib_git_push_origin_hg
22
+ return true if _git_lib_git_pull_origin_hg
23
+
24
+ log.error 'Unable to pull git workspace'
25
+ false
21
26
  end
27
+ # rubocop:enable Metrics/MethodLength
22
28
 
23
29
  # Push git workspace.
24
30
  def git_lib_push_hg_dirs
@@ -29,30 +35,21 @@ module GitLib
29
35
  return false unless _git_lib_git_add_hg_dirs
30
36
  return false unless _git_lib_git_commit message
31
37
 
32
- _git_lib_git_push_origin_hg
33
- end
34
-
35
- private
36
-
37
- # git add all.
38
- def _git_lib_git_add_all
39
- log.debug 'Adding all files to git'
40
-
41
- cmd_git_add_all = config.active['cmd_git_lib_git_add_all']
38
+ return true if _git_lib_git_push_origin_hg
42
39
 
43
- return true if try cmd_git_add_all
44
-
45
- log.error 'Unable to add all files to git'
40
+ log.error 'Unable to git push .hg mercurial directories'
46
41
  false
47
42
  end
48
43
 
44
+ private
45
+
49
46
  # git add hg dirs.
50
47
  def _git_lib_git_add_hg_dirs
51
48
  log.debug 'Adding all .hg mercurial dirs to git'
52
49
 
53
50
  cmd_git_add_hg_dirs = config.active['cmd_git_lib_git_add_hg_dirs']
54
51
 
55
- return true if try cmd_git_add_hg_dirs
52
+ return true if (try cmd_git_add_hg_dirs).exitstatus.zero?
56
53
 
57
54
  log.error 'Unable to add all .hg mercurial dirs to git'
58
55
  false
@@ -67,7 +64,7 @@ module GitLib
67
64
  message: message
68
65
  )
69
66
 
70
- return true if try cmd_git_commit
67
+ return true if (try cmd_git_commit).exitstatus.zero?
71
68
 
72
69
  log.error 'Unable to commit to git'
73
70
  false
@@ -3,37 +3,18 @@
3
3
  # tau hg pull
4
4
  module HgPull
5
5
  # Backend method for hg pull.
6
- # rubocop:disable Metrics/AbcSize
7
- # rubocop:disable Metrics/MethodLength
8
6
  def hg_pull
9
7
  log.debug 'Pull hg repos'
10
8
 
11
- return false unless configured? %w[project_root_dir]
9
+ return false unless git_lib_prepare_git_workspace
12
10
 
13
- unless git_check_hg
14
- log.error 'Not on git hg branch'
11
+ unless _hg_pull_hg_pull_repos
12
+ log.error 'Unable to tau hg pull'
15
13
  return false
16
14
  end
17
15
 
18
- unless git_check_clean
19
- log.error 'No clean git workspace'
20
- return false
21
- end
22
-
23
- unless git_lib_pull_workspace
24
- log.error 'Unable to pull git workspace'
25
- return false
26
- end
27
-
28
- log.info _hg_pull_hg_pull_repos
29
-
30
- return true if git_lib_push_hg_dirs
31
-
32
- log.error 'Unable to push .hg mercurial directories'
33
- false
16
+ git_lib_push_hg_dirs
34
17
  end
35
- # rubocop:enable Metrics/MethodLength
36
- # rubocop:enable Metrics/AbcSize
37
18
 
38
19
  private
39
20
 
@@ -44,6 +25,8 @@ module HgPull
44
25
  root: config.active['project_root_dir']
45
26
  )
46
27
 
47
- run cmd_hg_pull_repos
28
+ stdout, _, exitstatus = run_and_capture cmd_hg_pull_repos
29
+ log.info stdout
30
+ exitstatus.zero?
48
31
  end
49
32
  end
@@ -3,30 +3,18 @@
3
3
  # tau hg push
4
4
  module HgPush
5
5
  # Backend method for hg push.
6
- # rubocop:disable Metrics/MethodLength
7
6
  def hg_push
8
7
  log.debug 'Push hg repos'
9
8
 
10
- return false unless configured? %w[project_root_dir]
9
+ return false unless git_lib_prepare_git_workspace
11
10
 
12
- unless git_check_hg
13
- log.error 'Not on git hg branch'
11
+ unless _hg_push_hg_push_repos
12
+ log.error 'Unable to tau hg push'
14
13
  return false
15
14
  end
16
15
 
17
- unless git_check_clean
18
- log.error 'No clean git workspace'
19
- return false
20
- end
21
-
22
- log.info _hg_push_hg_push_repos
23
-
24
- return true if git_lib_push_workspace 'tau hg push'
25
-
26
- log.error 'Unable to push git workspace'
27
- false
16
+ git_lib_push_hg_dirs
28
17
  end
29
- # rubocop:enable Metrics/MethodLength
30
18
 
31
19
  private
32
20
 
@@ -37,6 +25,8 @@ module HgPush
37
25
  root: config.active['project_root_dir']
38
26
  )
39
27
 
40
- run cmd_hg_push_repos
28
+ stdout, _, exitstatus = run_and_capture cmd_hg_push_repos
29
+ log.info stdout
30
+ exitstatus.zero?
41
31
  end
42
32
  end
@@ -15,6 +15,7 @@ module InfoStatusBar
15
15
  _info_status_bar_git
16
16
  _info_status_bar_gopass
17
17
  _info_status_bar_gpg
18
+ _info_status_bar_hg
18
19
  _info_status_bar_mutagen
19
20
  _info_status_bar_ssh
20
21
 
@@ -62,6 +63,12 @@ module InfoStatusBar
62
63
  @bar_list << ("gpg: #{info_status_gpg ? 'ok'.green : 'no'.red}")
63
64
  end
64
65
 
66
+ # Add git status info to bar.
67
+ def _info_status_bar_hg
68
+ @status_hg = info_status_hg
69
+ @bar_list << ("hg: #{@status_hg ? 'ok'.green : 'no'.red}")
70
+ end
71
+
65
72
  # Add mutagen status info to bar.
66
73
  def _info_status_bar_mutagen
67
74
  @bar_list << ("mutagen: #{mutagen_check_daemon ? 'ok'.green : 'no'.red}")
@@ -16,6 +16,7 @@ module Takeltau
16
16
  include InfoStatusGit
17
17
  include InfoStatusGopass
18
18
  include InfoStatusGPG
19
+ include InfoStatusHg
19
20
  include InfoStatusSSH
20
21
  include InfoStatusBar
21
22
  include MutagenCheckDaemon
@@ -80,6 +81,18 @@ module Takeltau
80
81
  exit info_status_gpg
81
82
  end
82
83
 
84
+ #
85
+ # info status hg
86
+ #
87
+ desc 'hg', 'Check hg status info'
88
+ long_desc <<-LONGDESC.gsub("\n", "\x5")
89
+ Check hg status info
90
+ LONGDESC
91
+ # Check hg status info.
92
+ def hg
93
+ exit info_status_hg
94
+ end
95
+
83
96
  #
84
97
  # info status mutagen
85
98
  #
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ # tau info status hg
4
+ module InfoStatusHg
5
+ # Backend method for info status hg.
6
+ # @return [Boolean] has mercurial been configured?
7
+ def info_status_hg
8
+ log.debug 'Check hg status'
9
+
10
+ unless _info_status_hg_username
11
+ log.error 'hg ui.username is not configured'
12
+ return false
13
+ end
14
+
15
+ log.debug 'hg config is available'
16
+ true
17
+ end
18
+
19
+ private
20
+
21
+ # Check hg username
22
+ def _info_status_hg_username
23
+ status_username = try config.active['cmd_info_status_hg_username']
24
+ status_username.exitstatus.zero?
25
+ end
26
+ end
@@ -5,14 +5,13 @@ module MutagenCheckDaemon
5
5
  # Backend method for mutagen check daemon.
6
6
  # @return [Boolean] is mutagen available?
7
7
  # rubocop:disable Metrics/MethodLength
8
- # rubocop:disable Metrics/AbcSize
9
8
  def mutagen_check_daemon
10
9
  return true if @mutagen_daemon_available
11
10
 
12
- return false unless command_available_else_warn? config.active['cmd_mutagen']
13
-
14
11
  log.debug 'Check mutagen status'
15
12
 
13
+ return false unless _mutagen_check_check_prerequisites
14
+
16
15
  # are we outside of a takelage container?
17
16
  unless _docker_container_lib_check_matrjoschka
18
17
  unless _mutagen_check_daemon_version
@@ -25,11 +24,6 @@ module MutagenCheckDaemon
25
24
  return true
26
25
  end
27
26
 
28
- unless _file_exists? config.active['mutagen_socket_path_mutagen']
29
- log.error 'The mutagen socket is not available'
30
- return false
31
- end
32
-
33
27
  unless _mutagen_check_daemon_host_connection
34
28
  log.error 'A mutagen host connection is not available'
35
29
  return false
@@ -39,11 +33,25 @@ module MutagenCheckDaemon
39
33
  @mutagen_daemon_available = true
40
34
  true
41
35
  end
42
- # rubocop:enable Metrics/AbcSize
43
36
  # rubocop:enable Metrics/MethodLength
44
37
 
45
38
  private
46
39
 
40
+ # Check mutagen prerequisites
41
+ def _mutagen_check_check_prerequisites
42
+ unless _file_exists? config.active['mutagen_socket_path_mutagen_container']
43
+ log.error 'The mutagen socket path in the container is not available'
44
+ return false
45
+ end
46
+
47
+ unless _file_exists? config.active['mutagen_socket_path_mutagen_host']
48
+ log.error 'The mutagen socket path on the host is not available'
49
+ return false
50
+ end
51
+
52
+ command_available_else_error? config.active['cmd_mutagen']
53
+ end
54
+
47
55
  # Check mutagen host connection
48
56
  # rubocop:disable Metrics/MethodLength
49
57
  def _mutagen_check_daemon_host_connection
data/lib/takeltau/version CHANGED
@@ -1 +1 @@
1
- 0.36.4
1
+ 0.38.0
data/lib/takeltau.rb CHANGED
@@ -70,6 +70,7 @@ require_relative 'takeltau/info/status/lib'
70
70
  require_relative 'takeltau/info/status/git'
71
71
  require_relative 'takeltau/info/status/gopass'
72
72
  require_relative 'takeltau/info/status/gpg'
73
+ require_relative 'takeltau/info/status/hg'
73
74
  require_relative 'takeltau/info/status/ssh'
74
75
  require_relative 'takeltau/info/status/bar'
75
76
  require_relative 'takeltau/info/status/cli'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: takeltau
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.36.4
4
+ version: 0.38.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Takelwerk
@@ -244,6 +244,7 @@ files:
244
244
  - lib/takeltau/info/status/git.rb
245
245
  - lib/takeltau/info/status/gopass.rb
246
246
  - lib/takeltau/info/status/gpg.rb
247
+ - lib/takeltau/info/status/hg.rb
247
248
  - lib/takeltau/info/status/lib.rb
248
249
  - lib/takeltau/info/status/ssh.rb
249
250
  - lib/takeltau/init/cli.rb