Skip to content

Commit 6061365

Browse files
committed
Also test by-hash
1 parent b5dce6e commit 6061365

File tree

2 files changed

+60
-3
lines changed

2 files changed

+60
-3
lines changed

unison-share-api/src/Unison/Server/Local/Endpoints/Definitions.hs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ import Unison.Codebase.Branch qualified as Branch
3232
import Unison.Codebase.Branch.Names qualified as Branch
3333
import Unison.Codebase.Path qualified as Path
3434
import Unison.Codebase.ProjectPath
35-
import Unison.Debug qualified as Debug
3635
import Unison.HashQualified qualified as HQ
3736
import Unison.Name (Name)
3837
import Unison.NamesWithHistory (SearchType (..))
@@ -159,15 +158,13 @@ getDefinitionDependentsEndpoint _rt codebase projectAndBranch hqn mayWidth = do
159158
let nameSearch = makeNameSearch hqLength namesWithoutLibdeps
160159
QueryResult {hits} <- lift $ Backend.hqNameQuery codebase nameSearch ExactName [hqn]
161160

162-
Debug.debugM Debug.Temp "hits" hits
163161
let defs =
164162
hits & foldMap \case
165163
Tp TypeResult {reference} -> Defns {terms = Set.empty, types = (Set.singleton reference)}
166164
Tm TermResult {referent} -> Defns {terms = (Set.singleton referent), types = Set.empty}
167165

168166
dependents <- lift $ Codebase.dependentsWithinBranchScope rootBranch0WithoutLibdeps defs
169167
pure (dependents, namesWithoutLibdeps)
170-
Debug.debugM Debug.Temp "dependents" dependents
171168

172169
let pped = PPED.makePPED (PPE.hqNamer 10 namesWithoutLibdeps) PPE.dontSuffixify
173170
definitionSearchResults <-

unison-src/transcripts/idempotent/api-dependents.md

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,8 @@ RESPONSE:
167167
168168
```
169169

170+
Has no dependents:
171+
170172
``` api
171173
GET /api/projects/scratch/branches/main/getDefinitionDependents?name=mySum
172174
RESPONSE:
@@ -175,3 +177,61 @@ RESPONSE:
175177
}
176178
177179
```
180+
181+
Can also get dependents by a hash-only:
182+
183+
``` api
184+
GET /api/projects/scratch/branches/main/getDefinitionDependents?name=@0qbc2dfom7
185+
RESPONSE:
186+
{
187+
"results": [
188+
{
189+
"branchRef": "main",
190+
"definition": {
191+
"displayName": "myVal",
192+
"hash": "#88n7vpiqu9qhuj8v444iq3h7v93qvi7kei7dmmjojg3kc52v1aisg435t9bfedqakhk5fv8hu15daf379c7ovrfci9q627s6e3r7h1g",
193+
"summary": {
194+
"contents": [
195+
{
196+
"annotation": {
197+
"contents": "#0qbc2dfom7m4pputtdojo849g2mp5kkr00kvsvjktb07tcmo1jql53bg73bqiib35vja4a7059rcet0raf7jsh4d8vg5582ibinpqj8",
198+
"tag": "TypeReference"
199+
},
200+
"segment": "MyType"
201+
}
202+
],
203+
"tag": "UserObject"
204+
},
205+
"tag": "Plain"
206+
},
207+
"fqn": "myVal",
208+
"kind": "term",
209+
"projectRef": "scratch"
210+
},
211+
{
212+
"branchRef": "main",
213+
"definition": {
214+
"displayName": "myCase",
215+
"hash": "#le6cur61p625qb7qfsaq836ln4l20u3ecngthot7io4p762ijb5t5hiv0c59eab9b8lktjp8l0j70r53ci43s89hjjik6hfsvkbjv28",
216+
"summary": {
217+
"contents": [
218+
{
219+
"annotation": {
220+
"contents": "##Nat",
221+
"tag": "TypeReference"
222+
},
223+
"segment": "builtin.Nat"
224+
}
225+
],
226+
"tag": "UserObject"
227+
},
228+
"tag": "Plain"
229+
},
230+
"fqn": "myCase",
231+
"kind": "term",
232+
"projectRef": "scratch"
233+
}
234+
]
235+
}
236+
237+
```

0 commit comments

Comments
 (0)