You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: CONTRIBUTING.md
+24-6Lines changed: 24 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -75,13 +75,31 @@ rake slack:api:update
75
75
76
76
Sometimes it's necessary to patch auto-generated Slack Web API methods. For example, we want to help clients with calling `to_json` on the `attachments` parameter sent to `chat_postMessage`. See [#20](https://github.com/slack-ruby/slack-ruby-client/issues/20).
77
77
78
-
Make a change to a generated file, for example `lib/slack/web/api/endpoints/chat.rb` and generate a patch.
78
+
The broad steps are:
79
+
1. Run `rake slack:api:update` to check that existing patches are still valid.
80
+
- If you run into a `failed to apply patch` error, the auto-generated methods likely drifted from the last patch. Follow the steps [below](#resolving-patch-errors).
81
+
- This may add new methods if the API has updated, please split them up into multiple PRs if so.
82
+
2. Make a change to a generated file, for example `lib/slack/web/api/endpoints/chat.rb`.
83
+
3. Generate a patch:
84
+
```
85
+
git diff --no-color HEAD lib/slack/web/api/endpoints/chat.rb > lib/slack/web/api/patches/chat.1.patch
86
+
```
87
+
4. Run `rake slack:api:update` to ensure that the patch is cleanly applied. Implement a test for the added or modified functionality and commit the patch file.
88
+
89
+
##### Resolving Patch Errors
90
+
91
+
The auto-generated method files may drift overtime e.g. new arguments may be added or descriptions changed. Since previous patches were based on the older auto-generated files, git may be unable to apply them to the new files. Resolving them requires some good ol' splicing:
92
+
1. Comment out the patching code in `lib/tasks/web.rake`:
93
+
```ruby
94
+
# Dir.glob("lib/slack/web/api/patches/#{group}*.patch").sort.each do |patch|
95
+
# puts "- patching #{patch}"
96
+
# system("git apply #{patch}") || raise('failed to apply patch')
97
+
# end
98
+
```
99
+
2. Run `rake slack:api:update` to create the raw auto-generated files. Commit the files that you are updating, so we can run `git diff` later.
100
+
3. Go through the old patches for the files (e.g. in `lib/slack/web/api/patches/chat.1.patch`), copying code into the new files.
101
+
4. Continue with Step 2 [above](#patching-slack-web-api).
79
102
80
-
```
81
-
git diff --no-color HEAD lib/slack/web/api/endpoints/chat.rb > lib/slack/web/api/patches/chat.1.patch
82
-
```
83
-
84
-
Run `rake slack:api:update` to ensure that the patch is cleanly applied. Implement a test for the added or modified functionality and commit the patch file.
Copy file name to clipboardExpand all lines: bin/commands/chat.rb
+5-5Lines changed: 5 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -137,13 +137,13 @@
137
137
g.long_desc%( Updates a message. )
138
138
g.command'update'do |c|
139
139
c.flag'channel',desc: 'Channel containing the message to be updated.'
140
-
c.flag'text',desc: "New text for the message, using the default formatting rules. It's not required when presenting attachments."
141
140
c.flag'ts',desc: 'Timestamp of the message to be updated.'
142
141
c.flag'as_user',desc: 'Pass true to update the message as the authed user. Bot users in this context are considered authed users.'
143
-
c.flag'attachments',desc: 'A JSON-based array of structured attachments, presented as a URL-encoded string. This field is required when not presenting text.'
144
-
c.flag'blocks',desc: 'A JSON-based array of structured blocks, presented as a URL-encoded string.'
145
-
c.flag'link_names',desc: 'Find and link channel names and usernames. Defaults to none. See below.'
146
-
c.flag'parse',desc: 'Change how messages are treated. Defaults to client, unlike chat.postMessage. See below.'
142
+
c.flag'attachments',desc: "A JSON-based array of structured attachments, presented as a URL-encoded string. This field is required when not presenting text. If you don't include this field, the message's previous attachments will be retained. To remove previous attachments, include an empty array for this field."
143
+
c.flag'blocks',desc: "A JSON-based array of structured blocks, presented as a URL-encoded string. If you don't include this field, the message's previous blocks will be retained. To remove previous blocks, include an empty array for this field."
144
+
c.flag'link_names',desc: 'Find and link channel names and usernames. Defaults to none. If you do not specify a value for this field, the original value set for the message will be overwritten with the default, none.'
145
+
c.flag'parse',desc: 'Change how messages are treated. Defaults to client, unlike chat.postMessage. Accepts either none or full. If you do not specify a value for this field, the original value set for the message will be overwritten with the default, client.'
146
+
c.flag'text',desc: "New text for the message, using the default formatting rules. It's not required when presenting blocks or attachments."
# New text for the message, using the default formatting rules. It's not required when presenting attachments.
264
262
# @option options [timestamp] :ts
265
263
# Timestamp of the message to be updated.
266
264
# @option options [Object] :as_user
267
265
# Pass true to update the message as the authed user. Bot users in this context are considered authed users.
268
266
# @option options [Object] :attachments
269
-
# A JSON-based array of structured attachments, presented as a URL-encoded string. This field is required when not presenting text.
267
+
# A JSON-based array of structured attachments, presented as a URL-encoded string. This field is required when not presenting text. If you don't include this field, the message's previous attachments will be retained. To remove previous attachments, include an empty array for this field.
270
268
# @option options [Object] :blocks
271
-
# A JSON-based array of structured blocks, presented as a URL-encoded string.
269
+
# A JSON-based array of structured blocks, presented as a URL-encoded string. If you don't include this field, the message's previous blocks will be retained. To remove previous blocks, include an empty array for this field.
272
270
# @option options [Object] :link_names
273
-
# Find and link channel names and usernames. Defaults to none. See below.
271
+
# Find and link channel names and usernames. Defaults to none. If you do not specify a value for this field, the original value set for the message will be overwritten with the default, none.
274
272
# @option options [Object] :parse
275
-
# Change how messages are treated. Defaults to client, unlike chat.postMessage. See below.
273
+
# Change how messages are treated. Defaults to client, unlike chat.postMessage. Accepts either none or full. If you do not specify a value for this field, the original value set for the message will be overwritten with the default, client.
274
+
# @option options [Object] :text
275
+
# New text for the message, using the default formatting rules. It's not required when presenting blocks or attachments.
0 commit comments