Skip to content

Commit

Permalink
.gitconfig is now autogenerated
Browse files Browse the repository at this point in the history
  • Loading branch information
stas00 committed Dec 18, 2018
1 parent 378163f commit ae39961
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 42 deletions.
42 changes: 0 additions & 42 deletions .gitconfig

This file was deleted.

4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -130,3 +130,7 @@ examples/.last_checked

# symlinks to fastai
nbs/dl1/fastai

# .gitconfig is now autogenerated
.gitconfig

47 changes: 47 additions & 0 deletions tools/trust-origin-git-config
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,57 @@ def validate_script():
print(f"Can't execute {filepath}")
if result.stderr: print(f"Error: {result.stderr.decode('utf-8')}")

def write_config():
is_windows = hasattr(sys, 'getwindowsversion')
cmd = "tools/fastai-nbstripout" if not is_windows else r"python tools\\\\fastai-nbstripout"
with open(".gitconfig", 'w') as f:
f.write(f"""# You need to enable this configuration once after checking out the repo
# for the first time (assuming you checked it out into the course-v3/ dir):
#
# cd fastai
# git config --local include.path ../.gitconfig
#
# If you need to disable this instrumentation do:
#
# git config --local --unset include.path
#
# You can always check .git/config to see whether a ../.gitconfig
# [include] entry is there or not.
#
# If tools/fastai-nbstripout is modified to produce a different output,
# manually rerun all the notebooks under git:
#
# {cmd} -d nbs/*/*ipynb
#
# # disable the strip out filter to get git to see changes
# git config --local --unset include.path
# git commit -a
# git push
# # restore the filter
# git config --local include.path ../.gitconfig
#
# code notebooks strip out
[filter "fastai-nbstripout-code"]
clean = {cmd}
smudge = cat
required = true
[diff "ipynb-code"]
textconv = {cmd} -t
# docs notebooks strip out
[filter "fastai-nbstripout-docs"]
clean = {cmd} -d
smudge = cat
required = true
[diff "ipynb-docs"]
textconv = {cmd} -dt
""")

def trust_enable():
#validate_script()

write_config()
cmd = "git config --local include.path ../.gitconfig"
print(f"Executing: {cmd}")
result = subprocess.run(cmd.split(), shell=False, check=False, stderr=subprocess.PIPE)
Expand Down

0 comments on commit ae39961

Please sign in to comment.