Skip to content

Commit f2a87b9

Browse files
authored
Add docs for import latest commit (#8346)
1 parent 0d35ad2 commit f2a87b9

File tree

2 files changed

+66
-4
lines changed

2 files changed

+66
-4
lines changed

docs/docs/guides/repository.mdx

Lines changed: 62 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -232,10 +232,15 @@ After creation, your new repository should appear under **Integrations > Git Rep
232232

233233
### Update a read-only repository with remote changes
234234

235-
Unlike fully integrated repositories which sync automatically, read-only repositories must be manually updated by changing the `ref` value when you want to pull in new changes.
235+
Unlike fully integrated repositories which sync automatically, read-only repositories require manual action to pull in new changes. There are two ways to do this:
236+
237+
- **Change the `ref` property**: Point the repository to a different branch, tag, or commit hash
238+
- **Import latest commit**: Fetch the latest commit from the remote for the current ref and re-import resources
236239

237240
For more details on how each repository type tracks changes, refer to the [Repository Topic](../topics/repository.mdx#read-only-vs-core).
238241

242+
#### Change the ref
243+
239244
<Tabs>
240245
<TabItem value="Via the Web Interface" default>
241246

@@ -285,6 +290,60 @@ After updating the ref, the repository will begin synchronizing. You can monitor
285290

286291
:::
287292

293+
#### Import latest commit
294+
295+
If the remote repository has new commits on the same ref that your read-only repository is already tracking, you can pull the latest commit without changing the ref. This fetches from the remote, resolves the latest commit for the tracked ref, and re-imports all resources.
296+
297+
<Tabs>
298+
<TabItem value="Via the Web Interface" default>
299+
300+
1. Log in to the Infrahub UI
301+
2. Go to **Integrations > Git Repositories**
302+
3. Click on the `CoreReadOnlyRepository` record you want to update
303+
4. Click the **More** menu
304+
5. Select **Import latest commit**
305+
306+
The repository will fetch the latest changes from the remote, update to the most recent commit on the tracked ref, and re-import resources.
307+
308+
</TabItem>
309+
<TabItem value="Via the GraphQL Interface">
310+
311+
1. Open the **GraphQL Interface**
312+
313+
:::note GraphQL Sandbox
314+
315+
Access the sandbox by clicking your user icon in the bottom left corner and selecting **GraphQL Sandbox**.
316+
317+
:::
318+
319+
2. Execute the import mutation with the repository ID:
320+
321+
```graphql
322+
mutation {
323+
InfrahubReadOnlyRepositoryImportLastCommit(
324+
data: {
325+
id: "REPOSITORY_ID"
326+
}
327+
) {
328+
ok
329+
task {
330+
id
331+
}
332+
}
333+
}
334+
```
335+
336+
The mutation returns a task ID that you can use to monitor the progress of the import operation.
337+
338+
</TabItem>
339+
</Tabs>
340+
341+
:::success Check synchronization status
342+
343+
After triggering the import, the repository will fetch from the remote and re-import resources. You can monitor the process by checking the repository's sync status and the commit field, which will update to reflect the latest commit from the tracked ref.
344+
345+
:::
346+
288347
### Troubleshoot repository connections
289348

290349
If you encounter issues with your repository connections, you can use the following steps to diagnose and resolve them:
@@ -305,7 +364,8 @@ If you encounter issues with your repository connections, you can use the follow
305364
3. Use repository actions for advanced troubleshooting:
306365
- From the repository detail view, click the **More** menu
307366
- Select **Check connectivity** to verify authentication and connection
308-
- Select **Reimport last commit** to force reimport without changing the reference
367+
- Select **Reimport current commit** to force reimport without changing the reference
368+
- For read-only repositories, select **Import latest commit** to fetch and import the latest commit from the remote for the tracked ref
309369

310370
:::success Validation
311371
A healthy repository connection should show `Online` for operational status and `In sync` for sync status once all operations complete.

docs/docs/topics/repository.mdx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,8 @@ This separation ensures that Git operations don't block API requests and enables
9191
**For Read-only Repositories:**
9292

9393
- No automatic synchronization occurs
94-
- Updates require manual modification of the `ref` property
94+
- Updates can be triggered by modifying the `ref` property to point to a different branch, tag, or commit
95+
- Alternatively, use the **Import latest commit** action to fetch the latest commit for the current ref from the remote without changing the ref
9596
- Each update fetches the specified commit and imports resources according to configuration
9697

9798
### Merging branches
@@ -150,7 +151,8 @@ Indicates the state of data synchronization:
150151
Beyond basic synchronization, repositories support administrative actions for troubleshooting and maintenance:
151152

152153
- **Check connectivity**: Validates network access and authentication without modifying data
153-
- **Reimport last commit**: Forces re-processing of the current commit without fetching new changes, useful for recovering from import errors
154+
- **Reimport current commit**: Forces re-processing of the current commit without fetching new changes, useful for recovering from import errors
155+
- **Import latest commit** (read-only repositories only): Fetches the latest commit from the remote for the tracked ref and imports its resources. This is useful when the remote repository has new changes and you want to pull them without manually updating the `ref` property. Unlike changing the `ref`, this operation keeps the same ref but updates to whatever commit that ref currently points to on the remote
154156

155157
## Design trade-offs and constraints
156158

0 commit comments

Comments
 (0)