diff --git a/jupyterlab_git/git.py b/jupyterlab_git/git.py index 8a002b549..98494103a 100644 --- a/jupyterlab_git/git.py +++ b/jupyterlab_git/git.py @@ -432,7 +432,7 @@ async def status(self, path): return data - async def log(self, path, history_count=10): + async def log(self, path, history_count=10, follow_path="."): """ Execute git log command & return the result. """ @@ -441,6 +441,9 @@ async def log(self, path, history_count=10): "log", "--pretty=format:%H%n%an%n%ar%n%s", ("-%d" % history_count), + "--follow", + "--", + follow_path, ] code, my_output, my_error = await execute( cmd, diff --git a/jupyterlab_git/handlers.py b/jupyterlab_git/handlers.py index 076f89da1..d4fa6a3cc 100644 --- a/jupyterlab_git/handlers.py +++ b/jupyterlab_git/handlers.py @@ -196,7 +196,7 @@ async def post(self, path: str = ""): class GitLogHandler(GitHandler): """ - Handler for 'git log --pretty=format:%H-%an-%ar-%s'. + Handler for 'git log --pretty=format:%H-%an-%ar-%s --follow --'. Fetches Commit SHA, Author Name, Commit Date & Commit Message. """ @@ -208,7 +208,10 @@ async def post(self, path: str = ""): """ body = self.get_json_body() history_count = body.get("history_count", 25) - result = await self.git.log(self.url2localpath(path), history_count) + follow_path = body.get("follow_path", ".") + result = await self.git.log( + self.url2localpath(path), history_count, follow_path + ) if result["code"] != 0: self.set_status(500) diff --git a/src/model.ts b/src/model.ts index d1a3f74d4..329e03f2c 100644 --- a/src/model.ts +++ b/src/model.ts @@ -711,7 +711,8 @@ export class GitExtension implements IGitExtension { URLExt.join(path, 'log'), 'POST', { - history_count: count + history_count: count, + follow_path: this.selectedHistoryFile || '.' } ); }