repo_manager 0.7.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (116) hide show
  1. data/.gemfiles +115 -0
  2. data/.gitattributes +1 -0
  3. data/.gitignore +7 -0
  4. data/.rspec +3 -0
  5. data/.yardopts +11 -0
  6. data/Gemfile +11 -0
  7. data/Gemfile.lock +99 -0
  8. data/Guardfile +63 -0
  9. data/HISTORY.markdown +12 -0
  10. data/LICENSE +20 -0
  11. data/README.markdown +192 -0
  12. data/Rakefile +94 -0
  13. data/TODO.markdown +15 -0
  14. data/VERSION +1 -0
  15. data/bin/repo +151 -0
  16. data/cucumber.yml +28 -0
  17. data/examples/pc_saved_game_backup/.gitignore +2 -0
  18. data/examples/pc_saved_game_backup/INSTALL.markdown +420 -0
  19. data/examples/pc_saved_game_backup/README.markdown +108 -0
  20. data/examples/pc_saved_game_backup/remote/.gitignore +2 -0
  21. data/examples/pc_saved_game_backup/repo_manager/Gemfile +12 -0
  22. data/examples/pc_saved_game_backup/repo_manager/Gemfile.lock +66 -0
  23. data/examples/pc_saved_game_backup/repo_manager/assets/.gitignore +2 -0
  24. data/examples/pc_saved_game_backup/repo_manager/features/support/aruba.rb +15 -0
  25. data/examples/pc_saved_game_backup/repo_manager/features/support/env.rb +11 -0
  26. data/examples/pc_saved_game_backup/repo_manager/features/support/steps.rb +3 -0
  27. data/examples/pc_saved_game_backup/repo_manager/features/tasks/update.feature +144 -0
  28. data/examples/pc_saved_game_backup/repo_manager/global/default/asset.conf +2 -0
  29. data/examples/pc_saved_game_backup/repo_manager/repo.conf +64 -0
  30. data/examples/pc_saved_game_backup/repo_manager/tasks/.gitignore +0 -0
  31. data/examples/pc_saved_game_backup/repo_manager/tasks/remote.rb +57 -0
  32. data/examples/pc_saved_game_backup/repo_manager/tasks/update.rb +65 -0
  33. data/examples/pc_saved_game_backup/saved_games/hearts/save1 +1 -0
  34. data/examples/pc_saved_game_backup/saved_games/hearts/save2 +1 -0
  35. data/examples/pc_saved_game_backup/saved_games/mines/my_profile.ini +1 -0
  36. data/examples/pc_saved_game_backup/saved_games/mines/saves/save1 +1 -0
  37. data/examples/pc_saved_game_backup/saved_games/mines/saves/save2 +1 -0
  38. data/features/actions/git.feature +296 -0
  39. data/features/actions/help.feature +53 -0
  40. data/features/actions/list.feature +624 -0
  41. data/features/actions/path.feature +195 -0
  42. data/features/actions/status.feature +261 -0
  43. data/features/actions/task.feature +127 -0
  44. data/features/assets/configuration.feature +204 -0
  45. data/features/assets/rendering.feature +42 -0
  46. data/features/assets/user_attributes.feature +98 -0
  47. data/features/bin.feature +42 -0
  48. data/features/logger.feature +218 -0
  49. data/features/settings.feature +240 -0
  50. data/features/support/aruba.rb +15 -0
  51. data/features/support/env.rb +11 -0
  52. data/features/support/steps.rb +3 -0
  53. data/features/tasks/add/asset.feature +178 -0
  54. data/features/tasks/generate/init.feature +56 -0
  55. data/lib/repo_manager.rb +36 -0
  56. data/lib/repo_manager/actions.rb +8 -0
  57. data/lib/repo_manager/actions/action_helper.rb +39 -0
  58. data/lib/repo_manager/actions/app_action.rb +30 -0
  59. data/lib/repo_manager/actions/base_action.rb +296 -0
  60. data/lib/repo_manager/actions/git_action.rb +113 -0
  61. data/lib/repo_manager/actions/help_action.rb +52 -0
  62. data/lib/repo_manager/actions/list_action.rb +123 -0
  63. data/lib/repo_manager/actions/path_action.rb +22 -0
  64. data/lib/repo_manager/actions/status_action.rb +192 -0
  65. data/lib/repo_manager/actions/task_action.rb +71 -0
  66. data/lib/repo_manager/app.rb +116 -0
  67. data/lib/repo_manager/assets.rb +3 -0
  68. data/lib/repo_manager/assets/app_asset.rb +15 -0
  69. data/lib/repo_manager/assets/asset_accessors.rb +67 -0
  70. data/lib/repo_manager/assets/asset_configuration.rb +137 -0
  71. data/lib/repo_manager/assets/asset_manager.rb +72 -0
  72. data/lib/repo_manager/assets/base_asset.rb +199 -0
  73. data/lib/repo_manager/assets/repo_asset.rb +30 -0
  74. data/lib/repo_manager/core.rb +2 -0
  75. data/lib/repo_manager/core/array.rb +21 -0
  76. data/lib/repo_manager/core/hash.rb +83 -0
  77. data/lib/repo_manager/errors.rb +10 -0
  78. data/lib/repo_manager/extensions/hash.rb +86 -0
  79. data/lib/repo_manager/git.rb +2 -0
  80. data/lib/repo_manager/git/lib.rb +69 -0
  81. data/lib/repo_manager/git/status.rb +196 -0
  82. data/lib/repo_manager/logger.rb +39 -0
  83. data/lib/repo_manager/settings.rb +98 -0
  84. data/lib/repo_manager/tasks.rb +3 -0
  85. data/lib/repo_manager/tasks/add/asset.rb +213 -0
  86. data/lib/repo_manager/tasks/generate/init.rb +42 -0
  87. data/lib/repo_manager/tasks/generate/templates/config/repo.conf.tt +61 -0
  88. data/lib/repo_manager/tasks/generate/templates/init/assets/.gitignore +0 -0
  89. data/lib/repo_manager/tasks/generate/templates/init/global/default/asset.conf +2 -0
  90. data/lib/repo_manager/tasks/generate/templates/init/tasks/.gitignore +0 -0
  91. data/lib/repo_manager/tasks/task_manager.rb +166 -0
  92. data/lib/repo_manager/tasks/thor_helper.rb +29 -0
  93. data/lib/repo_manager/test/asset_steps.rb +19 -0
  94. data/lib/repo_manager/test/base_steps.rb +152 -0
  95. data/lib/repo_manager/test/repo_api.rb +41 -0
  96. data/lib/repo_manager/test/repo_steps.rb +83 -0
  97. data/lib/repo_manager/test/test_api.rb +88 -0
  98. data/lib/repo_manager/views.rb +2 -0
  99. data/lib/repo_manager/views/app_view.rb +15 -0
  100. data/lib/repo_manager/views/base_view.rb +137 -0
  101. data/lib/repo_manager/views/templates/css/basic.css +26 -0
  102. data/lib/repo_manager/views/templates/default.erb +40 -0
  103. data/lib/repo_manager/views/templates/default.slim +37 -0
  104. data/lib/repo_manager/views/view_helper.rb +55 -0
  105. data/repo_manager.gemspec +75 -0
  106. data/spec/basic_app/actions/action_helper_spec.rb +54 -0
  107. data/spec/basic_app/assets/base_asset_spec.rb +210 -0
  108. data/spec/basic_app/core_spec.rb +78 -0
  109. data/spec/basic_app/settings_spec.rb +64 -0
  110. data/spec/basic_app/views/view_helper_spec.rb +28 -0
  111. data/spec/basic_gem/aruba_helper_spec.rb +33 -0
  112. data/spec/basic_gem/basic_gem_spec.rb +84 -0
  113. data/spec/basic_gem/gemspec_spec.rb +68 -0
  114. data/spec/repo_manager/git_spec.rb +31 -0
  115. data/spec/spec_helper.rb +25 -0
  116. metadata +472 -0
@@ -0,0 +1,108 @@
1
+ Using RepoManager to Backup and Synchronize PC Game Saves
2
+ =====================================================
3
+
4
+ Use case: Backup and synchronization of PC save games folders to a
5
+ central repository (ie Drop Box folder) using Git. Game saves are
6
+ typically scattered across multiple folders and drives.
7
+
8
+ This example demonstrates the following features:
9
+
10
+ * Adding RepoManager user tasks, see repo_manager/tasks/
11
+ * Adding destructive git commands to the default whitelisted non-destructive git commands
12
+ * Testing user tasks with Cucumber, see repo_manager/features/
13
+ * Relative paths (not absolute) in repo_manager/repo.conf making the folder portable
14
+ * Bash completion for repo names, works on Win32 using Cygwin or MSYS Bash
15
+ * Bash function to 'cd' into a repo's working folder
16
+
17
+
18
+ Bootstrapping this example folder
19
+ --------------------------------
20
+
21
+ In order to try out the example commands below, you will need to bootstrap the
22
+ sample data git repositories and create the configuration files using the
23
+ following commands. See [INSTALL.markdown](INSTALL.markdown) for a more
24
+ complete explanation.
25
+
26
+ repo generate:remote mines --path=saved_games/mines/saves
27
+ repo generate:remote hearts --path=saved_games/hearts
28
+
29
+ repo add:asset saved_games/mines/saves --name=mines --force
30
+ repo add:asset saved_games/hearts --force
31
+
32
+
33
+ Get information on configured saved game repositories
34
+ -----------------------------------------------------
35
+
36
+ repo list --short
37
+ repo status --unmodified DOTS
38
+
39
+
40
+ User tasks
41
+ ---------
42
+
43
+ The task 'generate:remote' is a user task, it doesn't ship with RepoManager.
44
+
45
+ To view all the available tasks
46
+
47
+ repo --tasks
48
+
49
+ or just
50
+
51
+ repo -T
52
+
53
+ ### Running tests on user tasks
54
+
55
+ gem install bundler
56
+
57
+ cd repo_manager
58
+ bundle
59
+ bundle exec cucumber
60
+
61
+ Backup
62
+ ------
63
+
64
+ To backup the saved games, we will need another user task. This on is called
65
+ 'action:update'. See [repo_manager/tasks/update.rb](repo_manager/tasks/update.rb)
66
+
67
+ repo action:update
68
+
69
+ Synchronize
70
+ ----------
71
+
72
+ Synchronizing saved games to another PC can be accomplished using Git's 'pull' command.
73
+
74
+ verify working folders are clean, if they are not, either revert them or commit and push
75
+
76
+ repo status
77
+
78
+ pull from remote to all configured repos
79
+
80
+ repo pull
81
+
82
+ Bash completion
83
+ ---------------
84
+
85
+ Handy functions for use under Bash. These work fine on Win32 using
86
+ Git-Bash.
87
+
88
+ * rcd: repo cd (change directory). Wrapper for 'cd', allows for simple cd
89
+ <repo name> to the working folder on the filesystem referenced by the 'path'
90
+ configuration variable.
91
+ * rpushd: repo pushd (push directory). Wrapper for 'pushd'.
92
+
93
+ Clean
94
+ -----
95
+ Resetting this example folder back to its shipping defaults
96
+
97
+ ### Delete the git repositories
98
+
99
+ rm -rf remote/hearts.git
100
+ rm -rf remote/mines.git
101
+
102
+ rm -rf saved_games/mines/saves/.git
103
+ rm -rf saved_games/hearts/.git
104
+
105
+ ### Remove the asset config files
106
+
107
+ rm -rf repo_manager/assets/mines
108
+ rm -rf repo_manager/assets/hearts
@@ -0,0 +1,2 @@
1
+ *
2
+ !.gitignore
@@ -0,0 +1,12 @@
1
+ # this Gemfile is not required for RepoManager normal usage, it exists
2
+ # to support testing tasks in the user 'tasks' folder
3
+ source "http://rubygems.org"
4
+
5
+ gem "repo_manager"
6
+
7
+ gem "bundler", ">= 1.0.14"
8
+ gem "rspec", ">= 2.6.0"
9
+ gem "cucumber", "~> 1.0"
10
+ gem "aruba", "= 0.4.5"
11
+
12
+ gem "win32console", :platforms => [:mingw, :mswin]
@@ -0,0 +1,66 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ aruba (0.4.5)
5
+ bcat (>= 0.6.1)
6
+ childprocess (>= 0.1.9)
7
+ cucumber (>= 0.10.7)
8
+ rdiscount (>= 1.6.8)
9
+ rspec (>= 2.6.0)
10
+ bcat (0.6.2)
11
+ rack (~> 1.0)
12
+ builder (3.0.0)
13
+ childprocess (0.3.4)
14
+ ffi (~> 1.0, >= 1.0.6)
15
+ chronic (0.6.7)
16
+ cucumber (1.2.1)
17
+ builder (>= 2.1.2)
18
+ diff-lcs (>= 1.1.3)
19
+ gherkin (~> 2.11.0)
20
+ json (>= 1.4.6)
21
+ diff-lcs (1.1.3)
22
+ ffi (1.1.0)
23
+ gherkin (2.11.1)
24
+ json (>= 1.4.6)
25
+ git (1.2.5)
26
+ json (1.7.4)
27
+ little-plugger (1.1.3)
28
+ logging (1.7.2)
29
+ little-plugger (>= 1.1.3)
30
+ mustache (0.99.4)
31
+ rack (1.4.1)
32
+ rdiscount (1.6.8)
33
+ repo_manager (0.7.1)
34
+ chronic (>= 0.6.5)
35
+ git (= 1.2.5)
36
+ logging (>= 1.6.2)
37
+ mustache (>= 0.99.4)
38
+ slim (>= 1.0.4)
39
+ term-ansicolor (>= 1.0.4)
40
+ thor (~> 0.15.0)
41
+ rspec (2.11.0)
42
+ rspec-core (~> 2.11.0)
43
+ rspec-expectations (~> 2.11.0)
44
+ rspec-mocks (~> 2.11.0)
45
+ rspec-core (2.11.1)
46
+ rspec-expectations (2.11.2)
47
+ diff-lcs (~> 1.1.3)
48
+ rspec-mocks (2.11.1)
49
+ slim (1.2.2)
50
+ temple (~> 0.4.0)
51
+ tilt (~> 1.3.3)
52
+ temple (0.4.0)
53
+ term-ansicolor (1.0.7)
54
+ thor (0.15.3)
55
+ tilt (1.3.3)
56
+
57
+ PLATFORMS
58
+ ruby
59
+
60
+ DEPENDENCIES
61
+ aruba (= 0.4.5)
62
+ bundler (>= 1.0.14)
63
+ cucumber (~> 1.0)
64
+ repo_manager
65
+ rspec (>= 2.6.0)
66
+ win32console
@@ -0,0 +1,15 @@
1
+ require 'aruba/api'
2
+ require 'fileutils'
3
+
4
+ module Aruba
5
+ module Api
6
+
7
+ # override aruba avoid 'current_ruby' call and make sure
8
+ # that binary run on Win32 without the binstubs
9
+ def detect_ruby(cmd)
10
+ wrapper = which('repo')
11
+ cmd = cmd.gsub(/^repo/, "ruby -S #{wrapper}") if wrapper
12
+ cmd
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,11 @@
1
+ require 'repo_manager'
2
+ require 'aruba/cucumber'
3
+ require 'rspec/expectations'
4
+
5
+ Before do
6
+ @aruba_timeout_seconds = 10
7
+ end
8
+
9
+ Before('@slow_process') do
10
+ @aruba_io_wait_seconds = 2
11
+ end
@@ -0,0 +1,3 @@
1
+ require 'repo_manager/test/base_steps'
2
+ require 'repo_manager/test/asset_steps'
3
+ require 'repo_manager/test/repo_steps'
@@ -0,0 +1,144 @@
1
+ @announce
2
+ Feature: Automatically add, commit, and push multiple repos
3
+
4
+ This task will run:
5
+
6
+ repo add -A, repo commit, and repo push on all dirty repos
7
+
8
+ Examples
9
+
10
+ Interactive
11
+
12
+ repo action:update
13
+
14
+ Non-interactive
15
+
16
+ repo action:update --force
17
+
18
+ Filter repos
19
+
20
+ repo action:update --repos=repo1,repo2
21
+
22
+ Background: Test repositories and a valid config file
23
+ Given a repo in folder "test_path_1" with the following:
24
+ | filename | status | content |
25
+ | .gitignore | C | |
26
+ And a repo in folder "test_path_2" with the following:
27
+ | filename | status | content |
28
+ | .gitignore | C | |
29
+ And a file named "repo.conf" with:
30
+ """
31
+ ---
32
+ folders:
33
+ assets : repo/asset/configuration/files
34
+ tasks : ../../tasks
35
+ commands:
36
+ - status
37
+ - log
38
+ - add
39
+ - commit
40
+ - push
41
+ """
42
+ And the folder "repo/asset/configuration/files" with the following asset configurations:
43
+ | name | path |
44
+ | test1 | test_path_1 |
45
+ | test2 | test_path_2 |
46
+
47
+
48
+ Scenario: No uncommitted changes
49
+ When I run `repo action:update`
50
+ Then its output should contain:
51
+ """
52
+ no changed repos
53
+ """
54
+
55
+ Scenario: Uncommitted changes filtered out with the '--repos' param
56
+ Given a repo in folder "test_path_1" with the following:
57
+ | filename | status | content |
58
+ | .gitignore | M | tmp/* |
59
+ And a repo in folder "test_path_2" with the following:
60
+ | filename | status | content |
61
+ | .gitignore | M | tmp/* |
62
+ | test | ? | test |
63
+ And a repo in folder "my_clean_repo" with the following:
64
+ | filename | status | content |
65
+ | .gitignore | C | tmp/* |
66
+ When I run `repo action:update --force --repos=my_clean_repo`
67
+ Then its output should contain:
68
+ """
69
+ no changed repos
70
+ """
71
+
72
+ Scenario: Uncommitted changes in multiple repos, non-interactive, custom commit message
73
+ Given a repo in folder "test_path_1" with the following:
74
+ | filename | status | content |
75
+ | .gitignore | M | tmp/* |
76
+ And a repo in folder "test_path_2" with the following:
77
+ | filename | status | content |
78
+ | .gitignore | M | tmp/* |
79
+ | test | ? | test |
80
+ And the repo in folder "test_path_1" has a remote named "origin" in folder "test_path_1.remote.git"
81
+ And the repo in folder "test_path_2" has a remote named "origin" in folder "test_path_2.remote.git"
82
+ When I run `repo action:update --force --message="my custom commit message"`
83
+ Then its output should contain:
84
+ """
85
+ updating test1,test2
86
+ """
87
+ And its output should contain:
88
+ """
89
+ update finished
90
+ """
91
+ And its output should not contain:
92
+ """
93
+ failed
94
+ """
95
+ When I run `repo status --no-verbose`
96
+ Then the exit status should be 0
97
+ When I run `repo --no-verbose git log -1 --pretty=format:'%s' --repos test1`
98
+ Then its output should contain:
99
+ """
100
+ my custom commit message
101
+ """
102
+ Then its output should not contain:
103
+ """
104
+ automatic commit
105
+ """
106
+ When I run `repo push --no-verbose --repos test1`
107
+ Then its output should contain:
108
+ """
109
+ up-to-date
110
+ """
111
+
112
+ @slow_process
113
+ Scenario: Uncommitted changes in a single repo, interactive prompt to continue
114
+ And a repo in folder "test_path_2" with the following:
115
+ | filename | status | content |
116
+ | .gitignore | M | tmp/* |
117
+ | test | ? | test |
118
+ And the repo in folder "test_path_2" has a remote named "origin" in folder "test_path_2.remote.git"
119
+ When I run `repo action:update` interactively
120
+ And I type "y"
121
+ Then its output should contain:
122
+ """
123
+ updating test2
124
+ """
125
+ And its output should contain:
126
+ """
127
+ update finished
128
+ """
129
+ And its output should not contain:
130
+ """
131
+ failed
132
+ """
133
+ When I run `repo status --no-verbose`
134
+ Then the exit status should be 0
135
+ When I run `repo --no-verbose git log -1 --pretty=format:'%s' --repos test2`
136
+ Then its output should contain:
137
+ """
138
+ automatic commit
139
+ """
140
+ When I run `repo push --no-verbose --repos test2`
141
+ Then its output should contain:
142
+ """
143
+ up-to-date
144
+ """
@@ -0,0 +1,64 @@
1
+ ---
2
+ # default CLI options
3
+ options:
4
+ color : AUTO
5
+ verbose : false
6
+ short : false
7
+ unmodified : HIDE
8
+ match : ALL
9
+ list : ALL
10
+
11
+ folders:
12
+
13
+ # main repo configuration files
14
+ assets : assets
15
+
16
+ #
17
+ # repo user tasks, file extentions can be '.rb' or '.thor'
18
+ #
19
+ # @examples:
20
+ #
21
+ # linux:
22
+ #
23
+ # ~/.repoman/tasks
24
+ #
25
+ # win32
26
+ #
27
+ # c:/dat/condenser/tasks
28
+ #
29
+ tasks : tasks
30
+
31
+ # git commands must be whitelisted
32
+ commands:
33
+ - diff
34
+ - grep
35
+ - log
36
+ - ls-files
37
+ - show
38
+ - status
39
+ - push
40
+ - add
41
+ - commit
42
+
43
+ logging:
44
+ loggers:
45
+ - name : root
46
+ appenders:
47
+ - logfile
48
+ - stdout
49
+ appenders:
50
+ - type : Stdout
51
+ name : stdout
52
+ level : info
53
+ layout:
54
+ type : Pattern
55
+ pattern : '%l %c : %m\n'
56
+ color_scheme: default
57
+ - type : File
58
+ name : logfile
59
+ level : info
60
+ truncate : true
61
+ filename : 'repo.log'
62
+ layout:
63
+ type : Pattern
64
+ pattern : '[%d] %l %c : %m\n'