Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
newren committed Nov 22, 2024
1 parent 0d4a6f3 commit 98fa5b7
Showing 1 changed file with 36 additions and 1 deletion.
37 changes: 36 additions & 1 deletion git-filter-repo
Original file line number Diff line number Diff line change
Expand Up @@ -1566,6 +1566,25 @@ _IDS = _IDs()
_SKIPPED_COMMITS = set()
BLOB_HASH_TO_NEW_ID = {}
BLOB_NEW_ID_TO_HASH = {}
sdr_next_steps = _("""
NEXT STEPS FOR YOUR SENSITIVE DATA REMOVAL:
* If you are doing your rewrite in multiple steps, ignore these next steps
until you have completed all your invocations of git-filter-repo.
* See the "Sensitive Data Removal" subsection of the "DISCUSSION" section
of the manual for more details about any of the next steps.
* Inspect this repository and verify that the sensitive data is indeed
completely removed from all commits.
* Force push the rewritten history to the server:
%s
* Contact the server admins for additional steps they need to take; the
First Changed Commit(s)%s may come in handy here.
* Have other colleagues with a clone discard their clone and reclone;
or follow the detailed steps in the manual to repeatedly rebase and
purge the sensitive data from their copy. Again, the First Changed
Commit(s)%s may come in handy.
* See the "Prevent repeats and avoid future sensitive data spill section
of the manual.
"""[1:])

class SubprocessWrapper(object):
@staticmethod
Expand Down Expand Up @@ -2962,6 +2981,7 @@ class LFSObjectTracker:
self.file_info = file_info
self.check_sources = check_sources
self.check_targets = check_targets
self.objects_orphaned = False

def _get_lfs_values(self, contents):
values = {}
Expand Down Expand Up @@ -4735,6 +4755,7 @@ class RepoFilter(object):
for obj in sorted(differences):
f.write(obj+b"\n")
if differences:
self._lfs_object_tracker.objects_orphaned = True
print(msg)

def _record_metadata(self, metadata_dir, orig_refs):
Expand All @@ -4746,7 +4767,7 @@ class RepoFilter(object):
changed_commits = sum(k!=v for (k,v) in commit_renames.items())
print(f"You rewrote {changed_commits} (of {len(commit_renames)}) commits.")
print("") # Add a blank line before important rewrite information
print(f"NOTE: First changed commit(s) is/are:\n "
print(f"NOTE: First Changed Commit(s) is/are:\n "
+ decode(b"\n ".join(x for x in first_changes)))

with open(os.path.join(metadata_dir, b'sensitive_data_removal'), 'bw') as f:
Expand Down Expand Up @@ -4917,6 +4938,20 @@ class RepoFilter(object):
print(_("Completely finished after {:.2f} seconds.")
.format(time.time()-start))

# Give post-rewrite instructions for cleaning up other copies for SDR
if self._args.sensitive_data_removal:
lfs_note = ""
if self._lfs_object_tracker.objects_orphaned = True
lfs_note = _(" and LFS objects orphaned by this rewrite")
push_command = "git push --force --mirror origin"
if self._args.no_fetch:
if self._args.partial:
push_command = "git push --force origin " + " ".join(changed_refs)
else:
push_command = "git push --all --tags origin"
print("")
print(sdr_next_steps % (push_command, lfs_note, lfs_note))

def main():
setup_gettext()
args = FilteringOptions.parse_args(sys.argv[1:])
Expand Down

0 comments on commit 98fa5b7

Please sign in to comment.