Skip to content
Snippets Groups Projects
Commit 6d46d2bc authored by yvesn's avatar yvesn
Browse files

SSDM-6987: obis - storing git attributes in .git/info/attributes instead of .gitattributes

parent e2466c7f
No related branches found
No related tags found
No related merge requests found
......@@ -144,7 +144,7 @@ class ChecksumGeneratorGitAnnex(object):
raise ValueError("Git annex backend not supported: " + self.backend)
def _get_annex_backend(self):
with open('.gitattributes') as gitattributes:
with open('.git/info/attributes') as gitattributes:
for line in gitattributes.readlines():
if 'annex.backend' in line:
backend = line.split('=')[1].strip()
......
......@@ -283,6 +283,9 @@ class GitDataMgmt(AbstractDataMgmt):
if result.failure():
return result
with cd(path):
result = self.git_wrapper.initial_commit()
if result.failure():
return result
# Update the resolvers location
self.settings_resolver.set_resolver_location_roots('data_set', '.')
self.settings_resolver.copy_global_to_local()
......
import shutil
import os
from pathlib import Path
from .utils import run_shell
from .command_result import CommandResult, CommandException
from .checksum import ChecksumGeneratorCrc32, ChecksumGeneratorGitAnnex
......@@ -63,18 +64,25 @@ class GitWrapper(object):
return result
attributes_src = os.path.join(os.path.dirname(__file__), "git-annex-attributes")
attributes_dst = os.path.join(path, ".gitattributes")
attributes_dst = os.path.join(path, ".git/info/attributes")
shutil.copyfile(attributes_src, attributes_dst)
self._apply_git_annex_backend(attributes_dst, git_annex_backend)
cmd = [self.git_path, "-C", path, "add", ".gitattributes"]
result = run_shell(cmd)
if result.failure():
return result
cmd = [self.git_path, "-C", path, "commit", "-m", "Initial commit."]
result = run_shell(cmd)
return result
def initial_commit(self):
# initial commit is needed. we can restore to it when something fails
folder = '.obis'
file = '.gitignore'
path = folder + '/' + file
if not os.path.exists(folder):
os.makedirs(folder)
Path(path).touch()
result = self.git_add(path)
if result.failure():
return result
return self.git_commit("Initial commit.")
def _apply_git_annex_backend(self, filename, git_annex_backend):
if git_annex_backend is not None:
lines = []
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment