从subversion存储库中删除敏感信息

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了从subversion存储库中删除敏感信息相关的知识,希望对你有一定的参考价值。

I recently had to remove some files from a svn repo.
should work pretty much out of the box, just fill in blatantly exampleish text and read the comments
  1. #!/usr/bin/perl
  2. use strict;
  3. my $svn_repo='local/path/to/repo';
  4. my $f='full_repo_dump';
  5. my $pattern='foldername/otherfoldername/offendingFileOrDirectory';
  6. `svnadmin dump $svnrepo > $f`;
  7.  
  8. open I,'<'.$f;
  9. open O,'>'.$f.'_cleaned';
  10.  
  11. my $c=0;
  12. my $i=1;
  13. while($_=<I>){
  14. while(/^Node-path: $pattern/){#this is what we want to remove
  15. $_=<I>;
  16. while(!/^Node-path/){
  17. $_=<I>;
  18. exit unless($_); #we are out of file to read, quittin time(this is likely bad form)
  19. }
  20. }
  21. ###just a workaround for large repo dumps and status bar type stuff
  22. if($c eq 0){
  23. $c=100001;
  24. print ++$i," " ;
  25. }
  26. if($i%1000 eq 0){# also if your repo dump>2gb or so it will crash. this is not very precise, but it worked in my case
  27. close O; #anyway, you get the point, close and open as append only to flush whatever file buffers perl's using
  28. open O,'>>'.$f.'_cleaned';
  29. }
  30. $c--;
  31. ###
  32. print O $_;
  33. }
  34.  
  35. `svnadmin create freshly_cleaned_repo`;
  36. `svnadmin load freshly_cleaned_repo < $f`;
  37. #you should also `svnadmin dump $svnrepo -r0 > hey_whats_my_uuid`, look inside it for your uuid and
  38. # then `svnadmin setuuid freshly_cleaned_repo this-is-your-really-long-uuid-here`
  39. # pulling and setting the uuid could be automated

以上是关于从subversion存储库中删除敏感信息的主要内容,如果未能解决你的问题,请参考以下文章

您如何处理公共 git 存储库中的敏感数据?

subversion如何在存储库中存储文件?

如何转换 git 存储库中的大量提交 [重复]

从 git 推送到 subversion 存储库

如何删除文件夹的Subversion控件?

Subversion存储库中“分支”,“标记”和“主干”的含义是什么?