Skip to content

Commit ced1413

Browse files
committed
[#] Fix grammar, typos
1 parent 87e43c8 commit ced1413

3 files changed

+22
-22
lines changed

docs/how_to_create_a_single_commit_with_multiple_files_using_github_api.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ blob1 = remote_repo.create_git_blob(file_to_update_01_content, "utf-8")
8585

8686
We are using a [Python package](https://github.com/PyGithub/PyGithub) which is a wrapper for the GitHub REST API.
8787

88-
The only way to get the data is by using its SHA and we do not have the filename store anywhere yet. The way git stores the filename is by using another object in the database: the `tree`. The simplest `tree` object only contains a reference to one `blob` object. The `tree` is like a directory with the list of files where the contents of the files are the `blob` objects. We need to create a dir (`tree`) also for only one file because Git will add the file metadata there. The same object is used for one an multiple files. The `tree` can also contains another `tree`.
88+
The only way to get the data is by using its SHA and we do not have the filename store anywhere yet. The way git stores the filename is by using another object in the database: the `tree`. The simplest `tree` object only contains a reference to one `blob` object. The `tree` is like a directory with the list of files where the contents of the files are the `blob` objects. We need to create a dir (`tree`) also for only one file because Git will add the file metadata there. The same object is used for one an multiple files. The `tree` can also contain another `tree`.
8989

9090
In order to create the `tree`, we need to take the state of the staging area. You first have to set up an index by staging some files with these commands:
9191

docs/how_to_create_a_subkey_for_signing.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ If you want to sign commits and you do not know how to do it, you will probably
77
- [Git Documentation - Git Tools - Signing Your Work](https://git-scm.com/book/en/v2/Git-Tools-Signing-Your-Work)
88
- [GitHub Documentation - Signing commits](https://docs.github.com/en/authentication/managing-commit-signature-verification/signing-commits)
99

10-
In those documents, they promote the use of the master or primary key. Or at least if what they use. They probably do not want to overwhelm the reader with a lot of GPG technical stuff.
10+
In those documents, they promote the use of the master or primary key. Or at least, it's what they use. They probably do not want to overwhelm the reader with a lot of GPG technical stuff.
1111

1212
If you list one of your GPG keys you will see something like:
1313

@@ -31,7 +31,7 @@ The meaning for the letters inside brackets are the [GPG key capabilities](https
3131
| E | Encrypt |
3232
| A | Authentication |
3333

34-
If you want to create a signing key you can follow Debian's post. In my case for the key I'm using in all the examples, this was the output:
34+
If you want to create a signing key, you can follow [Debian's post](https://wiki.debian.org/Subkeys). In my case for the key I'm using in all the examples, this was the output:
3535

3636
```text
3737
gpg --edit-key 88966A5B8C01BD04F3DA440427304EDD6079B81C
@@ -112,9 +112,9 @@ Then, you can replace your git config:
112112
signingkey = B29BA7899D6062BE
113113
```
114114

115-
You need to upload agan the public key to GitHub in order to import also the subkey, otherwise you new commits using the the subkey will be shown as unverified.
115+
You need to upload again the public key to GitHub to import also the subkey, otherwise you new commits using the subkey will be shown as unverified.
116116

117-
TODO: then you should remove all the capabilities from the primary key expcet for "Certify" ([C]).
117+
TODO: you should remove all the capabilities from the primary key except for "Certify" ([C]).
118118

119119
## Links
120120

docs/how_to_sign_commits_using_the_gitpython_package.md

+17-17
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
> [GitPython](https://github.com/gitpython-developers/GitPython) is a python library used to interact with git repositories, high-level like git-porcelain, or low-level like git-plumbing.
44
5-
GitPython does not allow you to sign commits with its `git-porcelain` method. The way you can committ with GitPython is:
5+
GitPython does not allow you to sign commits with its `git-porcelain` method. The way you can commit with GitPython is:
66

77
```python
88
repo = Repo(repo_dir)
@@ -32,19 +32,19 @@ index.write()
3232
repo.git.commit(arg, ...)
3333
```
3434

35-
I do not not exactly why you need to `write` your changes but it something the git commit wrapper does:
35+
I do not know exactly why you need to `write` your changes but it is something the git commit wrapper does:
3636

3737
<https://github.com/gitpython-developers/GitPython/blob/88732b694068704cb151e0c4256a8e8d1adaff38/git/index/base.py#L938-L957>
3838

39-
And it's something [Sebastian Thiel](https://github.com/gitpython-developers/GitPython/issues/580#issuecomment-282474086) said it was needed.
39+
And it's something [Sebastian Thiel](https://github.com/gitpython-developers/GitPython/issues/580#issuecomment-282474086) said it is needed.
4040

41-
So if you want to sign the commit you only have to specify the signing key. The GitPython package relies on Git configuration and Git relies on GPG configuration. What is happending under the hood is:
41+
So if you want to sign the commit, you only have to specify the signing key. The GitPython package relies on Git configuration, and Git relies on GPG configuration. What is happening under the hood is:
4242

4343
1. GitPython is going to call the git commit command using a [git binary wrapper](https://github.com/gitpython-developers/GitPython/blob/254305c935893d7578b112acfa814a07d398ae28/git/cmd.py#L171).
4444
2. Git is going to call GPG command to sign the commit.
4545
3. GPG is going to prompt you with the passphrase of the key.
4646

47-
As long as the GPG and Git configuration are OK, GitPython will sign the commit correctly. The [example 03](../03_sign_commit_using_the_gitpython_package) in this repo creates a new signed commit, but before signing, it also sets up the GPG and Git configuration needed. I'm not going to explain how you can create a GPG key and sign commits manually becuase you can follow other tutorials like:
47+
As long as the GPG and Git configuration are OK, GitPython will sign the commit correctly. The [example 03](../03_sign_commit_using_the_gitpython_package) in this repo creates a newly signed commit, but before signing, it also sets up the GPG and Git configuration needed. In case you want to know how you can sign commits manually, you can follow other tutorials like:
4848

4949
- [Git Documentation - Git Tools - Signing Your Work](https://git-scm.com/book/en/v2/Git-Tools-Signing-Your-Work)
5050
- [GitHub Documentation - Signing commits](https://docs.github.com/en/authentication/managing-commit-signature-verification/signing-commits)
@@ -55,7 +55,7 @@ I'm going to explain only how to do it automatically using Python. There are som
5555
2. Preset the passphrase
5656
3. Set Git global user
5757

58-
After those steps you can call the GitPython commit method with the signing key ID you want to use.
58+
After those steps, you can call the GitPython commit method with the signing key ID you want to use.
5959

6060
## Import a GPG key using Python
6161

@@ -101,23 +101,23 @@ import_result = gpg.import_keys(gpg_private_key, passphrase=passphrase)
101101
fingerprint = import_result.fingerprints[0]
102102
```
103103

104-
The code it's very simple. For this example I'm passing both the private key and passphrase as environment variables. I'm using docker for the example and docker `.env` file for passing env vars. But since docker does not allow to use multi-line string values for variables, I had to store the privete key as a one-line string and then convert it back to the standard multi-line version. That means the `gpg_private_key` variable contains something like:
104+
The code is very simple. For this example, I'm passing both the private key and passphrase as environment variables. I'm using docker for the example and docker `.env` file for passing env vars. But since docker does not allow to use multi-line string values for variables, I had to store the private key as a one-line string and then convert it back to the standard multi-line version. That means the `gpg_private_key` variable contains something like:
105105

106106
```text
107107
GPG_PRIVATE_KEY=-----BEGIN PGP PRIVATE KEY BLOCK-----\n\nl****************************\n-----END PGP PRIVATE KEY BLOCK-----\n
108108
```
109109

110110
If you run the example using docker.
111111

112-
You also have to provide the `passphrase` which will be use to encript the private key. The method returns the finrgerprint of the imported keys and the number of keys imported. In the example `import_result.fingerprints` contains this array:
112+
You also have to provide the `passphrase` which will be used to encrypt the private key. The method returns the fingerprint of the imported keys and the number of keys imported. The variable `import_result.fingerprints` contains this array:
113113

114114
```text
115115
['88966A5B8C01BD04F3DA440427304EDD6079B81C', '88966A5B8C01BD04F3DA440427304EDD6079B81C']
116116
```
117117

118-
I do not know why the primary key ID is duplicated. Maybe it's a bug an it should return the fingerprint of the subkey (`97D36F5B8F5BECDA8A1923FC00D11C7C438584F9`). Anyway, for this exmaple I'm going to use the primary key which is not a good practice, althouth Git and GitHub tutorials also use it. Please read the links below to know why it is not considered a good practice.
118+
I do not know why the primary key ID is duplicated. Maybe it's a bug, and it should return the fingerprint of the subkey (`97D36F5B8F5BECDA8A1923FC00D11C7C438584F9`). Anyway, for this example, I'm going to use the primary key, which is not a good practice, although Git and GitHub tutorials also use it. Please read the links below to know why it is not considered a good practice.
119119

120-
At this point, we have the key imported in our keyring but GPG it's going to ask us for the passphrase every time we sign something. The next section explain why you can avoid that.
120+
At this point, we have the key imported in our keyring but GPG it's going to ask us for the passphrase every time we sign something. The next section explains why you can avoid that.
121121

122122
## How to preset the GPG key passphrase
123123

@@ -145,13 +145,13 @@ fpr:::::::::B1D4A2483D1D2A02416BE0775B6BDD35BEDFBF6F:
145145
grp:::::::::97D36F5B8F5BECDA8A1923FC00D11C7C438584F9:
146146
```
147147

148-
Keygrips are stores on `grp:` records in a fix field position.
148+
Keygrips are stored on `grp:` records in a fixed field position.
149149

150-
Finally the GPG cofiguration is completed. We only need to tell Git who is the user who is committing.
150+
Finally, the GPG configuration is completed. We only need to tell Git who is the user committing.
151151

152152
## How to config Git's global user
153153

154-
If we do not set git user's configuration we get an error like this:
154+
If we do not set the git user's configuration we get an error like this:
155155

156156
```text
157157
stderr: 'Committer identity unknown
@@ -176,11 +176,11 @@ repo.config_writer().set_value("user", "name", "A committer").release()
176176
repo.config_writer().set_value("user", "email", "committer@example.com").release()
177177
```
178178

179-
We need to use the same author name and email that we have on the GPG key. Althougth the `gnupg` has some methods to get that information, I did it parsing again the output of the same command I used to get the keygrip of the key.
179+
We need to use the same author name and email that we have on the GPG key. Although the `gnupg` has some methods to get that information, I did it by parsing the output of the same gpg command again.
180180

181181
## Future improvements
182182

183-
Te action shows some warnings:
183+
The action shows some warnings:
184184

185185
```text
186186
gpg: WARNING: unsafe permissions on homedir '/root/.gnupg'
@@ -200,9 +200,9 @@ By the way, the GitHub Action I'm using in the workflows to import GPG keys also
200200

201201
## Acknowledges
202202

203-
Thanks to all the contributors all the [Import GPG GitHub Action](https://github.com/marketplace/actions/import-gpg). It would have taken me much more time to find the solution whithout following their Typescript solution.
203+
Thanks to all the contributors of the [Import GPG GitHub Action](https://github.com/marketplace/actions/import-gpg). It would have taken me much more time to find the solution whithout following their Typescript solution.
204204

205-
And also to [Sebastian Thiel](https://github.com/Byron) who is one of the maintainer of the [GitPython](https://github.com/gitpython-developers/GitPython) package and who [pointed me and other people to the right solution](https://github.com/gitpython-developers/GitPython/issues/580#issuecomment-282473867).
205+
And also to [Sebastian Thiel](https://github.com/Byron) who is one of the maintainers of the [GitPython](https://github.com/gitpython-developers/GitPython) package and who [pointed me and others to the right solution](https://github.com/gitpython-developers/GitPython/issues/580#issuecomment-282473867).
206206

207207
## Other mini Python examples
208208

0 commit comments

Comments
 (0)