git-gpt 0.0.1 → 0.0.3

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: c0685c10e66a36290fd0eae99a4cd6d89ba6dd8ab630f8a562617be4af31cdd4
4
- data.tar.gz: 35d25ec93cd1eee111a8a60b8ba1dc81f2accd58704185819850c29b0b3920bb
3
+ metadata.gz: 361917c413bdd904805df016c8b3574bc5fe27d5ac69b50e0bbbc6bd2eadfe37
4
+ data.tar.gz: e993f778f75d42f858dfd614fb758f920d08dbd75ab65e8db852ea6450dd1014
5
5
  SHA512:
6
- metadata.gz: 128b5a721cd62d858a7e85e80367a4790d114fa6b955739e5ec489cd377ca198e142fdaae2b11f440ce4da94384ed7fa5d1e4ada8c6f3ff5483497ec2b61ad9f
7
- data.tar.gz: c57883e32bbcf67804d84d268cc9d3cb5d0828774d62ee3163836fd559d75efa24d90c6bc5d9d26453fe1642f22997a04284f67bd495e16f71314f4f46483b82
6
+ metadata.gz: d09b73de08fa50e61feb3280b2e4178882b1da97bdcdeda0ac7b04b9257d28478b8468c9683b7e73e1af10e8c564e831b8f8d83a7a2e5f0984f505e797c8df98
7
+ data.tar.gz: 62a5a8e076e111351ff5261d5b31b93e3028894c97a7f35898fa764d7876af75f7833b9bb8bf586332beb84068d7663318c7d3cc022034b977e88eb74b4e1999
data/README.md CHANGED
@@ -1,43 +1,77 @@
1
1
  # Git::Gpt
2
2
 
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/git/gpt`. To experiment with that code, run `bin/console` for an interactive prompt.
4
-
5
- TODO: Delete this and the text above, and describe your gem
3
+ git-gpt is a ruby gem that adds an additional git subcommand, git gpt. It assists you in creating commit messages for your git changes. It uses the powerful capabilities of ChatGPT to generate commit messages based on the current git status and git diff. Additionally, you can specify a list of files to narrow down the context for the commit message.
6
4
 
7
5
  ## Installation
8
6
 
9
- Add this line to your application's Gemfile:
7
+ First, you need to install the gem. You can do this globally or in your specific Ruby environment.
10
8
 
11
- ```ruby
12
- gem 'git-gpt'
9
+ ```sh
10
+ gem install git-gpt
13
11
  ```
14
12
 
15
- And then execute:
13
+ Once installed, it will be accessible as a git subcommand.
16
14
 
17
- $ bundle install
15
+ ## Usage
18
16
 
19
- Or install it yourself as:
17
+ You can invoke the `git gpt` command in your terminal anywhere in your git repository:
20
18
 
21
- $ gem install git-gpt
22
19
 
23
- ## Usage
20
+ ```sh
21
+ git gpt
22
+ ```
23
+
24
+ This will return a commit message generated by ChatGPT based on the changes detected by `git status` and `git diff`.
24
25
 
25
- TODO: Write usage instructions here
26
+ If you wish to narrow down the context to a specific list of files, you can do so by passing them as arguments:
26
27
 
27
- ## Development
28
+ ```sh
29
+ git gpt file1 file2 file3
30
+ ```
28
31
 
29
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
32
+ In the above example, `file1`, `file2`, and `file3` are placeholders for the file names you want to focus on. This will generate a commit message based on the changes in those files only.
30
33
 
31
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
34
+ ### USAGE NOTE
32
35
 
33
- ## Contributing
36
+ `git gpt` does not actually commit your code, it simply prints a commit message that you can choose to use or not. If you run it multiple times, you will likely get different results.
34
37
 
35
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/git-gpt. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/git-gpt/blob/main/CODE_OF_CONDUCT.md).
38
+ By default it asks ChatGPT to create short messages. If you like longer or multiline messages, you can adjust your prompt (see Advanced Configuration below).
36
39
 
37
- ## License
40
+ ## Basic Configuration
41
+
42
+ Best practice is to set the `OPENAI_API_KEY` environment veriable. Optionally, you can set `OPENAI_ORGANIZATION_ID`.
43
+
44
+ ## Advanced Configuration
38
45
 
39
- The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
46
+ By default `git gpt` uses `gpt-3.5-turbo` with a temperature of `0.7`. You can find the default prompt [here](https://github.com/assaydepot/git-gpt/blob/main/lib/git/gpt.rb#L12-L26). If you'd like to change the default settings, you can add a `.git-gpt-config.yml` file in your git repository. `git-gpt` will look for that file in the current directory, any parent directory (all the way to `/`) and your `HOME` directory. It will look in that order and use the first one it finds. The structure of the YAML file is as follows, all keys are optional.
40
47
 
41
- ## Code of Conduct
48
+ ```yaml
49
+ model: gpt-4
50
+ temperature: 0.8
51
+ openai_api_key: sk-acb1234567890xyz
52
+ openai_organization_id: org-abc1234567890xyz
53
+ prompt: >
54
+ You are a software engineer working on a project. You write diligent and detailed commit messages. You are working on a new feature and you are ready to commit your changes.
55
+
56
+ The current git status is:
57
+ \```
58
+ $GIT_STATUS
59
+ \```
60
+
61
+ The current git diff is:
62
+ \```
63
+ $GIT_DIFF
64
+ \```
65
+
66
+ Please write a commit message for this change. Format the commit message using markdown. You may use bullet points. Please comment specifically on any files with significant changes.
67
+ ```
68
+
69
+ See a real example [here](https://github.com/assaydepot/git-gpt/blob/main/.git-gpt-config.yml).
70
+
71
+ ## Contributing
72
+
73
+ Bug reports and pull requests are welcome on GitHub at https://github.com/your-github-username/git-gpt. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.
74
+
75
+ ## License
42
76
 
43
- Everyone interacting in the Git::Gpt project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/git-gpt/blob/main/CODE_OF_CONDUCT.md).
77
+ The gem is available as open source under the terms of the MIT License.
data/git-gpt.gemspec CHANGED
@@ -8,8 +8,8 @@ Gem::Specification.new do |spec|
8
8
  spec.authors = ["Chris Petersen"]
9
9
  spec.email = ["chris@petersen.io"]
10
10
 
11
- spec.summary = "Use GPT-4 to generate commit messages"
12
- spec.description = "Use GPT-4 to generate commit messages"
11
+ spec.summary = "Use ChatGPT to write your commit messages"
12
+ spec.description = "Use ChatGPT to write your commit messages"
13
13
  spec.homepage = "https://github.com/assaydepot/git-gpt"
14
14
  spec.license = "MIT"
15
15
  spec.required_ruby_version = ">= 2.6.0"
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Git
4
4
  module Gpt
5
- VERSION = "0.0.1"
5
+ VERSION = "0.0.3"
6
6
  end
7
7
  end
data/lib/git/gpt.rb CHANGED
@@ -2,6 +2,7 @@
2
2
 
3
3
  require_relative "gpt/version"
4
4
  require 'yaml'
5
+ require 'json'
5
6
  require 'openai'
6
7
 
7
8
  module Git
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: git-gpt
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Petersen
@@ -24,7 +24,7 @@ dependencies:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '4.0'
27
- description: Use GPT-4 to generate commit messages
27
+ description: Use ChatGPT to write your commit messages
28
28
  email:
29
29
  - chris@petersen.io
30
30
  executables:
@@ -71,5 +71,5 @@ requirements: []
71
71
  rubygems_version: 3.3.7
72
72
  signing_key:
73
73
  specification_version: 4
74
- summary: Use GPT-4 to generate commit messages
74
+ summary: Use ChatGPT to write your commit messages
75
75
  test_files: []