1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
//! # Revision Tag Management for CernVM-FS
//!
//! This module provides functionality for handling repository revision tags in CernVM-FS.
//! Revision tags are metadata entries that identify specific snapshots of the repository
//! content at different points in time. They allow for temporal navigation through
//! repository history.
//!
//! ## Revision Tags
//!
//! In CernVM-FS, revision tags provide the following capabilities:
//! - Named references to specific repository states (e.g., "production", "testing")
//! - Revision number tracking for sequential versioning
//! - Timestamp information for temporal navigation
//! - Channel assignment for content categorization
//! - Description text for human-readable context
//!
//! ## Tag Queries
//!
//! This module provides SQL queries for retrieving tags by different criteria:
//! - By name: Find a specific named tag
//! - By revision: Find a tag with a specific revision number
//! - By date: Find the tag active at a specific point in time
//! - All tags: List all repository tags in chronological order
//!
//! ## Usage
//!
//! Revision tags are typically accessed through the History module:
//!
//! ```no_run
//! use cvmfs::history::History;
//!
//! let history = History::new("/path/to/history.db").unwrap();
//!
//! // Get tag by name
//! if let Ok(Some(tag)) = history.get_tag_by_name("production") {
//! println!("Production tag is at revision {}", tag.revision);
//! }
//! ```
use Row;
use crateCvmfsResult;
/// SQL query to retrieve all tags ordered by timestamp (newest first)
///
/// This query returns all tags in the history database, ordered by their
/// timestamp in descending order (newest first). It's useful for presenting
/// a chronological history of repository changes.
pub const SQL_QUERY_ALL: &str = "\
SELECT name, hash, revision, timestamp, channel, description \
FROM tags \
ORDER BY timestamp DESC";
/// SQL query to retrieve a tag by its name
///
/// This query looks up a single tag by its name identifier. Tag names are
/// unique within a repository, so this query returns at most one result.
/// It's commonly used to find specific named tags like "production" or "latest".
pub const SQL_QUERY_NAME: &str = "\
SELECT name, hash, revision, timestamp, channel, description \
FROM tags \
WHERE name = ? \
LIMIT 1";
/// SQL query to retrieve a tag by its revision number
///
/// This query looks up a tag by its numeric revision identifier. Each revision
/// represents a published state of the repository, with higher numbers indicating
/// newer revisions. This query returns at most one result.
pub const SQL_QUERY_REVISION: &str = "\
SELECT name, hash, revision, timestamp, channel, description \
FROM tags \
WHERE revision = ? \
LIMIT 1";
/// SQL query to retrieve the earliest tag after a given timestamp
///
/// This query finds the first tag that was created after the specified timestamp.
/// It orders results by timestamp in ascending order and returns only the first match.
/// This is useful for finding which tag was active at a specific point in time.
pub const SQL_QUERY_DATE: &str = "\
SELECT name, hash, revision, timestamp, channel, description \
FROM tags \
WHERE timestamp > ? \
ORDER BY timestamp ASC \
LIMIT 1";
/// Represents a named tag for a specific repository revision
///
/// A RevisionTag provides metadata about a specific snapshot of the repository.
/// It includes information such as the name of the tag, the content hash it
/// points to, its revision number, when it was created, and descriptive text.
/// Tags are used to mark important states of the repository and to provide
/// navigation points in the repository history.