-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: compatibility with submodules (#48)
Previously githubinator couldn't find git data for files inside a submodule. Now it generates URLs, for the correct repositories. There's a new test for `dir` function, but the actual blame URL generation was tested manually on https://github.com/discourse/all-the-plugins and its submodules.
- Loading branch information
Showing
4 changed files
with
69 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { dir } from "../../git" | ||
import * as assert from "assert" | ||
import * as path from "path" | ||
import * as fs from "fs" | ||
|
||
suite("git", async () => { | ||
test("dir", () => { | ||
const repoPath = path.normalize(path.join(__dirname, "../../..")) | ||
const gitPath = path.join(repoPath, ".git") | ||
|
||
assert.deepStrictEqual(dir(__dirname), { | ||
git: gitPath, | ||
repository: repoPath, | ||
}) | ||
assert.deepStrictEqual(dir(repoPath), { | ||
git: gitPath, | ||
repository: repoPath, | ||
}) | ||
|
||
const contents = "gitdir: ../../../../.git/modules/test_submodule" | ||
const submodulePath = path.join(__dirname, "test_submodule") | ||
fs.mkdirSync(submodulePath, { recursive: true }) | ||
fs.writeFileSync(path.join(submodulePath, ".git"), contents) | ||
|
||
assert.deepStrictEqual(dir(submodulePath), { | ||
git: path.join(repoPath, ".git/modules/test_submodule"), | ||
repository: submodulePath, | ||
}) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters