Skip to content

Commit

Permalink
Add --follow option to Git log command (jupyterlab#864)
Browse files Browse the repository at this point in the history
  • Loading branch information
navn-r committed Jul 27, 2021
1 parent bd822b7 commit 0808588
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
5 changes: 4 additions & 1 deletion jupyterlab_git/git.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
"""
Expand All @@ -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,
Expand Down
7 changes: 5 additions & 2 deletions jupyterlab_git/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
"""

Expand All @@ -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)
Expand Down
3 changes: 2 additions & 1 deletion src/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -711,7 +711,8 @@ export class GitExtension implements IGitExtension {
URLExt.join(path, 'log'),
'POST',
{
history_count: count
history_count: count,
follow_path: this.selectedHistoryFile || '.'
}
);
}
Expand Down

0 comments on commit 0808588

Please sign in to comment.