gitlab_cli 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,18 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ lib/bundler/man
11
+ pkg
12
+ rdoc
13
+ spec/reports
14
+ test/tmp
15
+ test/version_tmp
16
+ tmp
17
+ *.swp
18
+ config.yml
@@ -0,0 +1,41 @@
1
+ 2013-05-12 Drew Blessing
2
+ * Issue 19: Utilize Thor actions
3
+ * Issue 25: Change from ~/.gitlab.yml to ~/.gitlab_cli.yml
4
+
5
+ 2013-05-09 Drew Blessing
6
+ * Pull Request 23: Add an user friendly message for 'config missing'. PR submitted by genewoo.
7
+ * Issue 24: Throw error when passing a invlid project id. Issue submitted by genewoo.
8
+
9
+ 2013-05-08 Drew Blessing
10
+ * Issue 13: Refactor to support a gitlab cli gem
11
+ * Issue 17: Create a config file in $HOME folder instead of using config.yml
12
+ * Issue 18: Refactor util class
13
+ * Issue 20: Add dependencies to gemspec
14
+ * Issue 21: Test across multiple OS's
15
+
16
+ 2013-04-24 Drew Blessing
17
+ * Issue 16: display_results_in_pager still defaults `true` in config class
18
+ * Version 1.1.1: Tag version 1.1.1
19
+
20
+ 2013-04-23 Drew Blessing
21
+ * Pull Request 14: Fix bug with project description. PR submitted by Jiwoong.
22
+ * Issue 9: Add `project info` command to README
23
+ * Issue 10: Test against 5.1
24
+ * Issue 11: `projects` command only shows 20 projects, no options to paginate. Issue submitted by weisjohn.
25
+ * Issue 15: Don't need to `inspect` snippet content.
26
+ * Version 1.1.0: Tag version 1.1.0 (No default behavior was altered. New features implemented)
27
+
28
+ 2013-04-22 Drew Blessing
29
+ * Issue 10: Test against Gitlab 5.1
30
+ * Version 1.0.0: Tag version 1.0.0
31
+
32
+ 2013-04-21 Drew Blessing
33
+ * Issue 3: Add option to save a snippet file locally
34
+ * Issue 4: Fix subcommand usage print out
35
+ * Issue 5: Improve examples in README
36
+ * Issue 6: Move project setup to top of README
37
+ * Issue 7: Improve error handling for times when Gitlab is not accessible
38
+ * Issue 8: Fix regression introduced in commit 4b5397dfce9af738156e8343dbca4bba56fc84d1
39
+
40
+ 2013-04-19 Drew Blessing
41
+ * Initial release
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in gitlab_cli.gemspec
4
+ gemspec
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Drew Blessing
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,91 @@
1
+ # _GitLab CLI Tool_
2
+
3
+ _Many people prefer to work from the CLI when possible. This tool aims to bring some of the GitLab functionality into the CLI to avoid repeated trips to the web UI. At this time the tool only allows interaction with snippets._
4
+
5
+ ## Version 2.0.0
6
+
7
+ This version contains breaking changes!!
8
+
9
+ * Now packaged as a gem!
10
+ * Configuration file loaded from user's home directory - ~/.gitlab.yml
11
+ * Easier to use within your Ruby scripts/applications (see "Use as a library")
12
+
13
+ ## GitLab Versions
14
+
15
+ This tool has only been tested with the following versions of GitLab. Some or all of the features may or may not work with other versions but they are not _officially_ supported.
16
+
17
+ * 5.1.0
18
+ * 5.0.x
19
+
20
+ ## Installation and Setup
21
+
22
+ _How do I get started?_
23
+
24
+ Install from rubygems (Recommended)
25
+
26
+ 1. _`gem install gitlab_cli`_
27
+
28
+ Install from the repo (requires rake and bundler).
29
+
30
+ 1. _Clone the repo._
31
+ 2. _`rake build`_
32
+ 3. _`rake install` (Requires root privileges)._
33
+
34
+ You now have access to the `gitlab` command.
35
+
36
+ _Required Gems_
37
+
38
+ If you install from rubygems then you will not need to install these required gems yourself. The gem package manager will attempt to install the proper versions for you.
39
+
40
+ 1. thor >= 0.17.0 and < 0.19
41
+ 2. json >= 1.7.7 and < 1.8
42
+ 3. rest-client >= 1.6.7 and < 1.7
43
+
44
+ Note for Linux users: You may need to install the `ruby-devel` package via YUM if you receive an error on install. The error you would see is:
45
+
46
+ ```
47
+ Building native extensions. This could take a while...
48
+ ERROR: Failed to build gem native extension.
49
+
50
+ /usr/bin/ruby extconf.rb
51
+ mkmf.rb can't find header files for ruby at /usr/lib/ruby/ruby.h
52
+
53
+
54
+ Gem files will remain installed in /usr/lib/ruby/gems/1.8/gems/json-1.7.7 for inspection.
55
+ Results logged to /usr/lib/ruby/gems/1.8/gems/json-1.7.7/ext/json/ext/generator/gem_make.out
56
+ ```
57
+
58
+ _How can I find the private token for my user?_
59
+
60
+ Login to your GitLab web UI, go to 'My Profile', and select the 'Account' tab. Copy the private token from the box and paste into your config.
61
+
62
+ _How can I add the repo bin path to my environment PATH variable?_
63
+
64
+ Place it in your ~/.bash_profile file. You should end up with something like this:
65
+ `export PATH=$PATH:/path/to/gitlab-cli/repo/bin/`
66
+
67
+ ## How to use (Commands)
68
+
69
+ View a list of all the commands you can use to interact with Gitlab CLI, complete with examples.
70
+
71
+ [Commands](doc/Commands.md)
72
+
73
+ ## Use as a library
74
+
75
+ Now that Gitlab CLI is distributed as a gem it is increasingly easy to use in your Ruby scripts or applications. Click the link below to see documentation on how to get started using Gitlab CLI as a library.
76
+
77
+ [Use as a library](doc/Library.md)
78
+
79
+ ## Issues
80
+
81
+ If you encounter issues with this project, please find help via one of these avenues.
82
+
83
+ 1. _IRC: #gitlab on Freenode - nick dblessing_
84
+ 2. _GitHub Issues: Open a new issue here on GitHub_
85
+
86
+ ## Contributing changes
87
+
88
+ I welcome all contributions. If you would like to include a new feature or bug fix, simply open a pull request and explain the problem or feature you contributed. I will review the contribution at that point. If you want to discuss fixes or improvements before submitting a pull request, please find me on IRC #gitlab on Freenode or open a GitHub issue.
89
+
90
+ ## License
91
+ See LICENSE file.
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+ require 'gitlab_cli/cli'
3
+
4
+ GitlabCli::CLI.start
@@ -0,0 +1,11 @@
1
+ ---
2
+ :gitlab_url: https://gitlab.example.com
3
+
4
+ # Found in My Profile -> Account -> Private token
5
+ :private_token: super_secret_key_from_gitlab
6
+
7
+ # Whether or not to display potentially lengthy
8
+ # results in the system pager (i.e. 'less').
9
+ # Default: false (to maintain original behavior)
10
+ # Recommended setting: true
11
+ :display_results_in_pager: false
@@ -0,0 +1,39 @@
1
+ ## Util Classes and Methods
2
+
3
+ The 'util' classes are what you should use to interact with Gitlab CLI as a library.
4
+
5
+ ### _Projects_
6
+
7
+ GitlabCLI::Util::Projects
8
+
9
+ \#get_all - Returns an array of Project objects.
10
+
11
+ ### _Project_
12
+
13
+ GitlabCLI::Util::Project
14
+
15
+ \#get(project) - When given a project ID/full path with namespace, returns a Project object.
16
+
17
+ \#get_project_path_with_namespace(project_id) - When given a project ID, returns the full path with namespace.
18
+
19
+ ### _Snippets_
20
+
21
+ GitlabCLI::Utils::Snippets
22
+
23
+ \#get_all(project) - When given a project ID/full path with namespace, returns an array of Snippet objects.
24
+
25
+ ### _Snippet_
26
+
27
+ GitlabCLI::Util::Snippet
28
+
29
+ \#get(project, snippet) - When given a project ID/full path with namespace and a snippet ID, returns a Snippet object.
30
+
31
+ \#create(project, title, file_name, code) - When given a project ID/full path with namespace, title, file name string, and code body, creates a snippet and returns a Snippet object.
32
+
33
+ \#view(project, snippet) - When given a project ID/full path with namespace and a snippet ID, returns raw snippet content.
34
+
35
+ \#update(project, snippet, content) - When given a project ID/full path with namespace, snippet ID, and code body, updates a snippet\'s content and returns a Snippet object.
36
+
37
+ \#delete(project, snippet) - When given a project ID/full path with namespace and a snippet ID, deletes a snippet.
38
+
39
+ \#download(project, snippet, file_path) - When given a project ID/full path with namespace, snippet ID, and a local file path, saves a snippet\'s content to the specified file.
@@ -0,0 +1,142 @@
1
+ ## Commands
2
+ Note: All command results are subject to user authorization. For example, if the command says it will return all projects it will return all projects...that the user is able to see.
3
+
4
+ Note2: Anywhere you see [PROJECT] you can either specify the full namespace/project name for the project or you can provide the project ID. Both can be obtained by running the first command below.
5
+
6
+ ### _List all projects_
7
+
8
+ Usage: `gitlab projects [OPTIONS]`
9
+
10
+ Options: `--nopager`, `--pager` to turn paging off or on one time (See note below example output)
11
+
12
+ Example output:
13
+ ```
14
+ 3: globalproject1
15
+ 4: namespace1/project2
16
+ 6: namespace1/project3
17
+ 11: namespace2/project1
18
+ 13: user1/project1
19
+ ```
20
+
21
+ Note: As of v1.1.0, this command can output in the system pager or `less` to improve readability when many results are shown. Set configuration `display_results_in_pager` command to `true` to enable this functionality.
22
+ Use --nopager or --pager to temporarily turn paging off or on respectively. These options effectively overrides the true/false setting for `display_results_in_pager` configuration setting.
23
+
24
+ ### _View detailed information about a project_
25
+
26
+ Usage: `gitlab project info [PROJECT]`
27
+
28
+ Example output:
29
+ ```
30
+ Project ID: 3
31
+ Name: My Project
32
+ Path w/ Namespace: namespace1/myproject
33
+ Project URL: https://gitlab.example.com/namespace1/myproject
34
+ Description: This is my awesome repo!
35
+ Default Branch: master
36
+ Owner: Drew Blessing <drew.blessing@example.com>
37
+ Public?: false
38
+ Issues enabled?: false
39
+ Merge Requests enabled?: true
40
+ Wall enabled?: false
41
+ Wiki enabled?: false
42
+ Created at: Mon Apr 01 18:42:38 UTC 2013
43
+
44
+ ```
45
+
46
+ ### _List all snippets for a project_
47
+
48
+ Usage: `gitlab snippets [PROJECT] [OPTIONS]`
49
+
50
+ Using project ID: `gitlab snippets 13`
51
+
52
+ Using project full namespace/project format: `gitlab snippets user1/project1`
53
+
54
+ Options: `--nopager`, `--pager` to turn paging off or on one time (See note below example output)
55
+
56
+ Example output:
57
+ ```
58
+ 2: Title - Filename
59
+ 16: README - README.md
60
+ ```
61
+
62
+ Note: As of v1.1.0, this command can output in the system pager or `less` to improve readability when many results are shown. Set configuration `display_results_in_pager` command to `true` to enable this functionality.
63
+ Use --nopager or --pager to temporarily turn paging off or on respectively. These options effectively overrides the true/false setting for `display_results_in_pager` configuration setting.
64
+
65
+ ### _View a snippet (Uses default pager or "less")_
66
+
67
+ Usage: `gitlab snippet view [PROJECT] [SNIPPET_ID]`
68
+
69
+ Using project ID: `gitlab snippet view 13 16`
70
+
71
+ Using project full namespace/project format: `gitlab snippet view user1/project1 16`
72
+
73
+ ### _Edit a snippet (Users default editor or "vi")_
74
+
75
+ Usage: `gitlab snippet edit [PROJECT] [SNIPPET_ID]`
76
+
77
+ Using project ID: `gitlab snippet edit 13 16`
78
+
79
+ Using project full namespace/project format: `gitlab snippet edit user1/project1 16`
80
+
81
+ Example output:
82
+ ```
83
+ Snippet updated.
84
+ URL: https://gitlab.example.com/user1/project1/snippets/16
85
+ ```
86
+
87
+ ### _View detailed information about a snippet_
88
+
89
+ Usage :`gitlab snippet info [PROJECT] [SNIPPET_ID]`
90
+
91
+ Using project ID: `gitlab snippet info 13 16`
92
+
93
+ Using project full namespace/project format: `gitlab snippet info user1/project1 16`
94
+
95
+ Example output:
96
+ ```
97
+ Snippet ID: 16
98
+ Title: README
99
+ File Name: README.md
100
+ Author: John Doe <john.doe@example.com>
101
+ Created at: Fri Apr 19 01:11:08 UTC 2013
102
+ Updated at: Fri Apr 19 01:11:08 UTC 2013
103
+ Expires at: Never
104
+ ```
105
+
106
+ ### _Add a snippet_
107
+
108
+ Usage 1: `gitlab snippet add [PROJECT] [FILE] -t [TITLE] -n [FILE_NAME]`
109
+
110
+ Usage 2: `cat [FILE] | gitlab snippet add [PROJECT] -t [TITLE] -n [FILE_NAME]`
111
+
112
+ Using project ID: `gitlab snippet add 13 16 /path/to/file -t "Awesome title" -n file.txt`
113
+
114
+ Using project full namespace/project format: `gitlab snippet add user1/project1 16 /path/to/file -t "Awesome title" -n file.txt``
115
+
116
+ Example output:
117
+ ```
118
+ Snippet created.
119
+ ID: 20
120
+ URL: https://gitlab.example.com/user1/project1/snippets/20
121
+ ```
122
+
123
+ ### _Delete a snippet (Asks for confirmation)_
124
+ Use -y flag to bypass confirmation. Use at your own risk.
125
+
126
+ Usage: `gitlab snippet delete [PROJECT] [SNIPPET_ID]`
127
+
128
+ Using project ID: `gitlab snippet delete 13 16`
129
+
130
+ Using project full namespace/project format: `gitlab snippet delete user1/project1 16`
131
+
132
+ ### _Save a snippet to your local filesystem_
133
+ Note: The "save" subcommand is an alias of "download." Both have the same effect.
134
+
135
+ Usage 1: `gitlab snippet download [PROJECT] [SNIPPET_ID] [FILE]`
136
+
137
+ Usage 2: `gitlab snippet save [PROJECT] [SNIPPET_ID] [FILE]`
138
+
139
+ Using project ID: `gitlab snippet save 13 16 /path/for/new/file`
140
+
141
+ Using project full namespace/project format: `gitlab snippet download user1/project1 16 /path/for/new/file`
142
+
@@ -0,0 +1,35 @@
1
+ ## Use as a library
2
+
3
+ First, require 'gitlab_cli'.
4
+
5
+ `require 'gitlab_cli'`
6
+
7
+ Next, call the appropriate class and method within Gitlab CLI. You will probably want to stick with calling the Util classes. They will return objects with all the pertinent information. Below are a few examples of how you may use Gitlab CLI. For a complete list of classes, methods and objects, please check out the links below.
8
+
9
+ * [Util Classes and Methods](Classes.md)
10
+ * [Objects](Objects.md)
11
+
12
+ ### _Get all projects in Gitlab_
13
+ Returns an array of Project objects
14
+
15
+ `projects = GitlabCli::Util::Projects.get_all`
16
+
17
+ Then you can loop through and access any of the Project attributes.
18
+
19
+ ```
20
+ projects.each do |project|
21
+ puts project.name
22
+ end
23
+ ```
24
+
25
+ ### _Get a specific snippet_
26
+ Assumes you know the project id/full namespace and snippet id
27
+
28
+ `snippet = GitlabCli::Util::Snippet.get(3, 19)`
29
+
30
+ `snippet = GitlabCli::Util::Snippet.get("namespace/project_name", 19)`
31
+
32
+ Then you can access any of the Snippet attributes.
33
+
34
+ `puts snippet.title`
35
+
@@ -0,0 +1,53 @@
1
+ ## Objects
2
+
3
+ ### _Project_
4
+
5
+ GitlabCLI::Project
6
+
7
+ Attributes:
8
+
9
+ * id - The numerical ID of the project
10
+ * name - The name of the project
11
+ * description - A long description of the project
12
+ * default_branch - The default branch to display in the interface
13
+ * public - Is the project public? True/False
14
+ * path - The short path for the project
15
+ * path_with_namespace - The full path with namespace for the project
16
+ * issues_enabled - Can issues be created? True/False
17
+ * merge_requests_enabled - Accept merge requests for the project? True/False
18
+ * wall_enabled - Is the wall enabled? True/False
19
+ * wiki_enabled - Is the wiki enabled? True/False
20
+ * created_at - The date/time the project was created
21
+ * project_url - The URL to the project
22
+ * owner - The owner of the project (returns a User object)
23
+
24
+ ### _Snippet_
25
+
26
+ GitlabCLI::Snippet
27
+
28
+ * id - The numerical ID of the snippet
29
+ * title - The title of the snippet
30
+ * file_name - The file name for the snippet
31
+ * expires_at - The date/time the snippet is set to expire
32
+ * updated_at - The date/time the snippet was last updated
33
+ * created_at - The date/time the snippet was first created
34
+ * project_id - The ID of the project it is in
35
+ * view_url - The URL to the snippet
36
+ * author - The author of the snippet (returns a User object)
37
+
38
+ ### _User_
39
+
40
+ GitlabCLI::User
41
+
42
+ * id - The numerical ID of the user
43
+ * username - The short username of the user
44
+ * email - The email address of the user
45
+ * name - The user\'s full name
46
+ * blocked - Is the user prevented from logging in? True/False
47
+ * created_at - The date/time the user was first created
48
+ * bio - The user\'s bio
49
+ * skype - The user\'s Skype account
50
+ * linkedin - The user\'s LinkedIn account
51
+ * twitter - The user\'s Twitter account
52
+ * extern_uid - The external UID for the user, if the provider is not GitLab
53
+ * provider - The user\'s provider, GitLab/LDAP/OmniAuth