diff options
author | baba <baba@bpsinc.jp> | 2013-05-11 11:53:07 +0400 |
---|---|---|
committer | baba <baba@bpsinc.jp> | 2013-05-11 11:53:07 +0400 |
commit | 320f0ac856b9a1f6862e8189dccfcb9bb0589628 (patch) | |
tree | 1e5ba33a141845c7670222c9ae148d5598490c5b /lib/tasks/migrate | |
parent | 6e1ee1fea6400c3621005f1b79e1b8dab43cd000 (diff) |
Migrate notes.line_code format.
Since version 4.1, notes.line_code means:
{SHA1 hash of file path}_{old line}_{new line}
but the older version means:
{file index of the commit}_{old line}_{new line}
This rake task migrate the above differences.
Diffstat (limited to 'lib/tasks/migrate')
-rw-r--r-- | lib/tasks/migrate/migrate_note_linecode.rake | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/lib/tasks/migrate/migrate_note_linecode.rake b/lib/tasks/migrate/migrate_note_linecode.rake new file mode 100644 index 00000000000..71be1f12d1b --- /dev/null +++ b/lib/tasks/migrate/migrate_note_linecode.rake @@ -0,0 +1,13 @@ +desc "GITLAB | Migrate Note LineCode" +task migrate_note_linecode: :environment do + Note.inline.each do |note| + index = note.diff_file_index + if index =~ /^\d{1,10}$/ # is number. not hash. + hash = Digest::SHA1.hexdigest(note.noteable.diffs[index.to_i].new_path) + new_line_code = note.line_code.sub(index, hash) + note.update_column :line_code, new_line_code + print '.' + end + end +end + |