Add missing run-* and send-* to all command sections#504
Add missing run-* and send-* to all command sections#504creativeprojects merged 4 commits intomasterfrom
Conversation
WalkthroughThe changes refactor configuration structures for command sections, centralising monitoring and shell command hooks into a unified Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant ConfigLoader
participant Profile
participant GenericSectionWithSchedule
participant GenericSection
participant SendMonitoringSections
User->>ConfigLoader: Load profile config
ConfigLoader->>Profile: Parse sections (Check, Prune, Forget, etc.)
Profile->>GenericSectionWithSchedule: Access command section
GenericSectionWithSchedule->>GenericSection: Access hooks (run/send)
GenericSection->>SendMonitoringSections: Access monitoring hooks
Note right of SendMonitoringSections: Monitoring HTTP requests grouped (before/after/finally)
Assessment against linked issues
Note ⚡️ AI Code Reviews for VS Code, Cursor, WindsurfCodeRabbit now has a plugin for VS Code, Cursor and Windsurf. This brings AI code reviews directly in the code editor. Each commit is reviewed immediately, finding bugs before the PR is raised. Seamless context handoff to your AI code agent ensures that you can easily incorporate review feedback. Note ⚡️ Faster reviews with cachingCodeRabbit now supports caching for code and dependencies, helping speed up reviews. This means quicker feedback, reduced wait times, and a smoother review experience overall. Cached data is encrypted and stored securely. This feature will be automatically enabled for all accounts on May 16th. To opt out, configure 📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
⏰ Context from checks skipped due to timeout of 90000ms (5)
✨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (2)
config/send.go (2)
11-17: Minor efficiency / clarity nit: avoid copying slices in nested loops
range s.getAllSendMonitoringSections()returns a copy of each slice header. While modifying elements via indexing is safe, the double dereference is a little opaque. Using a pointer to the slice (or moving the inner loop into a helper) would improve readability:for _, sections := range s.getAllSendMonitoringSections() { for i := range sections { sections[i].BodyTemplate = fixPath( sections[i].BodyTemplate, expandEnv, expandUserHome, absolutePrefix(rootPath)) } }Functionally identical, but clearer and avoids the extra
valuevariable.
42-44: HTTP-header regex is overly strict
^\w([\w-]+)\w$rejects many valid HTTP header names (e.g. single-letter names, names starting with “X-”, or containing_).
Consider liberalising to the RFC 9110 token grammar or, at minimum, allowing a single character and the initial “X-” pattern:- Name string `mapstructure:"name" regex:"^\\w([\\w-]+)\\w$" ...` + Name string `mapstructure:"name" regex:"^[!#$%&'*+\\-.^_`|~0-9A-Za-z]+$" ...`This provides better standards compliance and avoids false negatives.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
Cache: Disabled due to data retention organization setting
Knowledge Base: Disabled due to data retention organization setting
📒 Files selected for processing (11)
Makefile(1 hunks)config/profile.go(6 hunks)config/profile_test.go(2 hunks)config/send.go(1 hunks)contrib/templates/reference.gomd(1 hunks)docs/version.toml(1 hunks)go.mod(1 hunks)main.go(1 hunks)monitor/hook/sender_test.go(2 hunks)sonar-project.properties(1 hunks)wrapper_test.go(1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
config/profile_test.go (1)
restic/commands.go (1)
CommandNames(515-517)
⏰ Context from checks skipped due to timeout of 90000ms (5)
- GitHub Check: Build and test (1.24, windows-latest)
- GitHub Check: Build and test (1.24, macos-latest)
- GitHub Check: Build and test (1.24, ubuntu-latest)
- GitHub Check: build
- GitHub Check: Analyze (go)
🔇 Additional comments (12)
go.mod (1)
3-3: Approve Go version bump
Bumping from Go 1.24.2 to 1.24.3 aligns with the project’s version strategy and matches related version updates in other files.Makefile (1)
96-96: Approve Hugo tag format update
Adding the leading “v” in--tag v0.145.0ensures theegettarget fetches the correctly tagged Hugo release and maintains consistency with other tools.contrib/templates/reference.gomd (1)
7-8: Approve new alias in front matter
Introducing the/configuration/referencealias supports seamless redirects in documentation and aligns with the updated configuration reference path.docs/version.toml (1)
2-2: Approve docs version bump
Updating the version to “v0.31.0” keeps the documentation in sync with the new release.sonar-project.properties (1)
4-4: Approve Sonar project version bump
Bumpingsonar.projectVersionto 0.31.0 aligns the SonarQube configuration with the codebase’s release version for accurate analysis.main.go (1)
29-29: Version updated appropriately for new feature releaseThe version bump from 0.30.0-dev to 0.31.0-dev properly reflects the feature enhancement of adding run-* and send-* hooks to all command sections.
monitor/hook/sender_test.go (2)
255-266: Test updated to reflect refactored configuration structureThe test configuration has been properly updated to use the new nested hierarchy where
GenericSectionWithSchedulecontains aGenericSectionwith embeddedSendMonitoringSections. This reflects the centralisation of monitoring sections in the codebase.
291-305: Test updated to match refactored configuration hierarchySimilar to the previous test, this test case has been updated to use the new configuration structure which provides a more unified approach to handling monitoring sections across different command types.
wrapper_test.go (1)
1027-1031: Test updated to use refactored configuration typesThe test has been properly updated to use
GenericSectionWithSchedule{}instead of the previousSectionWithScheduleAndMonitoring{}type, aligning with the new unified structure for command sections. This supports the goal of providing consistent run-* and send-* hooks across all commands.config/profile_test.go (3)
1396-1398: Test updated to mark 'init' command as monitoredThe "init" command is now correctly marked as monitored, and a test case for a non-monitored "other" command has been added. This ensures proper testing of the monitoring section functionality across different command types.
1609-1631: Excellent new test ensuring all commands support run-before hooksThis new test comprehensively verifies that all commands supported by restic can have run-before shell commands configured. It systematically tests each command returned by
restic.CommandNames(), ensuring complete coverage of the feature.
1633-1655: Comprehensive test for send-before hooks on all commandsThis new test verifies that all restic commands properly support send-before monitoring sections. The test is thorough, checking each command individually and ensuring that the monitoring sections are correctly parsed and accessible.
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #504 +/- ##
==========================================
+ Coverage 79.24% 79.32% +0.08%
==========================================
Files 133 134 +1
Lines 13219 13221 +2
==========================================
+ Hits 10475 10487 +12
+ Misses 2326 2316 -10
Partials 418 418
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|



Some restic commands where missing the ability to run commands (before and after) or send monitoring data (before and after)
Now the
run-*andsend-*can be used on all restic commandsFixes #492
Fixes #496