Make hash IDs opt-in via id_mode config (bd-5404)
- Add id_mode config (sequential|hash), defaults to sequential - Update CreateIssue/CreateIssues to check id_mode and generate appropriate IDs - Implement lazy counter initialization from existing issues - Update migrate --to-hash-ids to set id_mode=hash after migration - Fix hash ID tests to set id_mode=hash - Fix renumber test to use explicit IDs - All 183 test packages pass This makes hash IDs backward-compatible opt-in rather than forced default.
This commit is contained in:
@@ -17,10 +17,13 @@ func TestHashIDGeneration(t *testing.T) {
|
||||
|
||||
ctx := context.Background()
|
||||
|
||||
// Set up database with prefix
|
||||
// Set up database with prefix and hash mode
|
||||
if err := store.SetConfig(ctx, "issue_prefix", "bd"); err != nil {
|
||||
t.Fatalf("Failed to set prefix: %v", err)
|
||||
}
|
||||
if err := store.SetConfig(ctx, "id_mode", "hash"); err != nil {
|
||||
t.Fatalf("Failed to set id_mode: %v", err)
|
||||
}
|
||||
|
||||
// Create an issue - should get a hash ID
|
||||
issue := &types.Issue{
|
||||
@@ -139,10 +142,13 @@ func TestHashIDBatchCreation(t *testing.T) {
|
||||
|
||||
ctx := context.Background()
|
||||
|
||||
// Set up database with prefix
|
||||
// Set up database with prefix and hash mode
|
||||
if err := store.SetConfig(ctx, "issue_prefix", "bd"); err != nil {
|
||||
t.Fatalf("Failed to set prefix: %v", err)
|
||||
}
|
||||
if err := store.SetConfig(ctx, "id_mode", "hash"); err != nil {
|
||||
t.Fatalf("Failed to set id_mode: %v", err)
|
||||
}
|
||||
|
||||
// Create multiple issues with similar content
|
||||
issues := []*types.Issue{
|
||||
|
||||
Reference in New Issue
Block a user