MCPcopy Create free account
hub / github.com/apache/solr / yaml_filename

Method yaml_filename

dev-tools/scripts/addDepsToChanges.py:89–124  ·  view source on GitHub ↗

Generate a filesystem-safe filename for this entry. Format: PR#####-slug.yaml Truncates slug on whitespace boundaries, allowing up to 255 chars total.

(self)

Source from the content-addressed store, hash-verified

87 }
88
89 def yaml_filename(self) -> str:
90 """
91 Generate a filesystem-safe filename for this entry.
92 Format: PR#####-slug.yaml
93 Truncates slug on whitespace boundaries, allowing up to 255 chars total.
94 """
95 # Clean message for slug
96 slug = self.message.lower()
97 # Replace whitespace with single space
98 slug = re.sub(r'\s+', ' ', slug)
99 # Remove non-alphanumeric except dashes
100 slug = re.sub(r'[^a-z0-9-._ ]', '', slug)
101
102 # Calculate available space for slug
103 # Format: "PR" + pr_num + "-" + slug + ".yaml"
104 # Typical PR#1234 = 8 chars + "-" = 9 chars, ".yaml" = 5 chars, total overhead = 14 chars
105 # Most filesystems limit filenames to 255 chars
106 max_filename_length = 255
107 overhead = len(f"PR{self.pr_num}-.yaml")
108 max_slug_length = max_filename_length - overhead
109
110 # Truncate to max length on word boundaries if necessary
111 if len(slug) > max_slug_length:
112 # Find the last space within the limit
113 truncated = slug[:max_slug_length]
114 last_dash = truncated.rfind(' ')
115 if last_dash > max_slug_length // 2: # Keep at least half the available space
116 slug = truncated[:last_dash]
117 else:
118 # If no good word boundary, use hard limit and clean up trailing spaces
119 slug = truncated.rstrip(' ')
120 else:
121 # Remove trailing spaces
122 slug = slug.rstrip(' ')
123
124 return f"PR{self.pr_num}-{slug}.yaml"
125
126
127def get_prev_release_tag(ver):

Callers 1

write_changelog_yamlFunction · 0.80

Calls 1

subMethod · 0.45

Tested by

no test coverage detected