-
I have a task to move some existing repos to GitHub and we are wanting to add somethings like .github/CODEOWNERS and workflow kind of data to the repo from the initial commit as we migrate them. We are setting up some workflow and github actions, but want to have so we could trigger bug fixes on the history of commits so were trying to add the .github folder (that is already setup for our new repo for new work products) to our initial commit and have it propagate to all branches and all tags so if we need to do work on fixing an older release (via tag number) the new release/feature/fix branch will already have the actions and code owner setup as well as the tip of the main branch as if the repo was created in GitHub with all the actions, codeowners, and workflow there from the start. It feels like git-filter-repo has that power, but I cannot seem to make it work. We have tried $ git checkout -b withgitignore $firstcommithash
$ git add .gitignore
$ git commit --amend
$ for branch in branch1 branch2 branch3 ... ; do
git checkout $branch
git rebase withgitignore
done but it requires us to do it with each branch and pretty much requires user interaction which we can't do. $ RELATIVE_TO_PROJECT_ROOT_PATHNAME="../template_repo/.github" # also tried with an end slash and with /CODEOWNERS
$ FILENAME=".github"
# also tried the above two lines with an end slash (.github/) and with .github/CODEOWNERS and it just says it can't find whatever "FILENAME" is set to
$ git filter-repo --force --commit-callback "if not commit.parents: commit.file_changes.append(FileChange(b'M', $RELATIVE_TO_PROJECT_ROOT_PATHNAME, b'$(git hash-object -w $FILENAME)', b'100644'))"
fatal: could not open '.github' for reading: No such file or directory
Traceback (most recent call last):
File "C:\Users\xzlg3r\bin\git-filter-repo", line 4005, in <module>
main()
File "C:\Users\xzlg3r\bin\git-filter-repo", line 4002, in main
filter.run()
File "C:\Users\xzlg3r\bin\git-filter-repo", line 3937, in run
self._parser.run(self._input, self._output)
File "C:\Users\xzlg3r\bin\git-filter-repo", line 1409, in run
self._parse_commit()
File "C:\Users\xzlg3r\bin\git-filter-repo", line 1260, in _parse_commit
self._commit_callback(commit, aux_info)
File "C:\Users\xzlg3r\bin\git-filter-repo", line 3485, in _tweak_commit
self._insert_into_stream(commit)
File "C:\Users\xzlg3r\bin\git-filter-repo", line 3912, in _insert_into_stream
self._parser.insert(obj)
File "C:\Users\xzlg3r\bin\git-filter-repo", line 1387, in insert
obj.dump(self._output)
File "C:\Users\xzlg3r\bin\git-filter-repo", line 721, in dump
change.dump(file_)
File "C:\Users\xzlg3r\bin\git-filter-repo", line 618, in dump
quoted_filename = PathQuoting.enquote(self.filename)
File "C:\Users\xzlg3r\bin\git-filter-repo", line 191, in enquote
if unquoted_string.startswith(b'"') or b'\n' in unquoted_string:
TypeError: startswith first arg must be str or a tuple of str, not bytes
fatal: stream ends early
fast-import: dumping crash report to .git/fast_import_crash_28148 Any help would be welcome, I am a bit over my head. I am pretty good at bash, C/C++, Java, C#, but just learning Python so reading the code I am making some kind of headway, but getting lost. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
A few issues here:
Hope that helps. |
Beta Was this translation helpful? Give feedback.
A few issues here:
tree
, you need to file represent a tree object, not an actual directory.