gitdataai/libs/git/ref_utils.rs
ZhenYi 14f6e1e500 feat(core): initialize project with access control and AI integration
- Add gitignore and prettier configuration files for project scaffolding
- Implement room access control service with project member verification
- Create user access key management with CRUD operations and activity logging
- Add accordion UI component for frontend expandable sections
- Implement room AI configuration with list, upsert, and delete operations
- Add AI event types for agent join/leave/status change tracking
- Create streaming AI processing services for mode and react patterns
- Build room AI service with model detection and idempotency handling
- Integrate chat service orchestration for AI message processing
- Add typing indicators and stream cancellation for AI interactions
- Implement mention parsing and context extraction for AI agents
2026-05-03 06:04:31 +08:00

37 lines
1012 B
Rust

//! Shared utility functions for reference name validation.
use crate::GitError;
/// # Rules
/// - Must not be empty
/// - Must not start with '.' or '@' (@ is shorthand for HEAD)
/// - Must not end with '/'
/// - Must not contain '..'
/// - Must not contain spaces, '~', '^', ':', '?', '*', '[', or '\'
///
/// # Returns
/// - `Ok(())` if name is valid
/// - `Err(GitError::InvalidRefName)` if name is invalid
pub fn validate_ref_name(name: &str) -> Result<(), GitError> {
if name.is_empty()
|| name.starts_with('.')
|| name.starts_with('@')
|| name.ends_with('/')
|| name.contains("..")
|| name.contains(' ')
|| name.contains('~')
|| name.contains('^')
|| name.contains(':')
|| name.contains('?')
|| name.contains('*')
|| name.contains('[')
|| name.contains('\\')
{
return Err(GitError::InvalidRefName(format!(
"invalid ref name: {}",
name
)));
}
Ok(())
}