Skip to content

Commit 941c457

Browse files
author
Vladimir Kotal
authored
fix incoming check and test for newer git verions (#3187)
fixes #3176
1 parent 40669ec commit 941c457

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

opengrok-tools/src/main/python/opengrok_tools/scm/git.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,15 @@ def __init__(self, logger, path, project, command, env, hooks, timeout):
3939
if not self.command:
4040
raise RepositoryException("Cannot get git command")
4141

42+
# The incoming() check relies on empty output so configure
43+
# the repository first to avoid getting extra output.
44+
git_command = [self.command, "config", "--local", "pull.ff", "only"]
45+
cmd = self.getCommand(git_command, work_dir=self.path,
46+
env_vars=self.env, logger=self.logger)
47+
cmd.execute()
48+
if cmd.getretcode() != 0 or cmd.getstate() != Command.FINISHED:
49+
cmd.log_error("failed to configure git pull.ff")
50+
4251
def reposync(self):
4352
git_command = [self.command, "pull", "--ff-only"]
4453
cmd = self.getCommand(git_command, work_dir=self.path,
@@ -58,7 +67,6 @@ def incoming(self):
5867
env_vars=self.env, logger=self.logger)
5968
cmd.execute()
6069
self.logger.info("output of {}:".format(git_command))
61-
self.logger.info(cmd.geterroutputstr())
6270
if cmd.getretcode() != 0 or cmd.getstate() != Command.FINISHED:
6371
cmd.log_error("failed to perform pull")
6472
raise RepositoryException('failed to check for incoming in '

opengrok-tools/src/test/python/test_mirror.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,13 @@ def mock_get(*args, **kwargs):
160160

161161
# Clone a Git repository so that it can pull.
162162
repo = Repo.init(repo_path)
163+
new_file_path = os.path.join(repo_path, 'foo')
164+
with open(new_file_path, 'w'):
165+
pass
166+
assert os.path.isfile(new_file_path)
167+
index = repo.index
168+
index.add([new_file_path])
169+
index.commit("add file")
163170
repo.clone(cloned_repo_path)
164171

165172
with monkeypatch.context() as m:

0 commit comments

Comments
 (0)