Skip to content
This repository was archived by the owner on Dec 15, 2022. It is now read-only.

Commit 2fed01a

Browse files
author
Nathan Sobo
committed
Revert "Merge pull request #95 from atom/as-ns/fix-relativize"
This reverts commit e46f3ee, reversing changes made to 1c9311b.
1 parent 3208c12 commit 2fed01a

File tree

5 files changed

+14
-16
lines changed

5 files changed

+14
-16
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ notifications:
55
on_success: never
66
on_failure: change
77

8-
node_js: 10
8+
node_js: node
99

1010
git:
1111
depth: 10
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +0,0 @@
1-
**.test

spec/fixtures/ignored-workspace/ignored.test

Whitespace-only changes.

spec/git-spec.js

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,6 @@ describe('git', () => {
132132
repo = git.open(ignoreRepoDir)
133133
expect(repo.isIgnored('a.txt')).toBe(true)
134134
expect(repo.isIgnored('subdir/subdir')).toBe(true)
135-
expect(repo.isIgnored(repo.relativize(path.join(ignoreRepoDir, 'ignored.test')))).toBe(true)
136135
})
137136
})
138137

@@ -855,8 +854,8 @@ describe('git', () => {
855854
repo = git.open(__dirname)
856855
const workingDirectory = repo.getWorkingDirectory()
857856

858-
expect(repo.relativize(path.join(workingDirectory, 'a.txt'))).toBe('./a.txt')
859-
expect(repo.relativize(path.join(workingDirectory, 'a/b/c.txt'))).toBe('./a/b/c.txt')
857+
expect(repo.relativize(path.join(workingDirectory, 'a.txt'))).toBe('a.txt')
858+
expect(repo.relativize(path.join(workingDirectory, 'a/b/c.txt'))).toBe('a/b/c.txt')
860859
expect(repo.relativize('a.txt')).toBe('a.txt')
861860
expect(repo.relativize('/not/in/working/dir')).toBe('/not/in/working/dir')
862861
expect(repo.relativize(null)).toBe(null)
@@ -877,9 +876,9 @@ describe('git', () => {
877876
fs.symlinkSync(repoDirectory, linkDirectory)
878877

879878
repo = git.open(linkDirectory)
880-
expect(repo.relativize(path.join(repoDirectory, 'test1'))).toBe('./test1')
881-
expect(repo.relativize(path.join(linkDirectory, 'test2'))).toBe('./test2')
882-
expect(repo.relativize(path.join(linkDirectory, 'test2/test3'))).toBe('./test2/test3')
879+
expect(repo.relativize(path.join(repoDirectory, 'test1'))).toBe('test1')
880+
expect(repo.relativize(path.join(linkDirectory, 'test2'))).toBe('test2')
881+
expect(repo.relativize(path.join(linkDirectory, 'test2/test3'))).toBe('test2/test3')
883882
expect(repo.relativize('test2/test3')).toBe('test2/test3')
884883
})
885884
})
@@ -891,17 +890,17 @@ describe('git', () => {
891890
repo.caseInsensitiveFs = true
892891
const workingDirectory = repo.getWorkingDirectory()
893892

894-
expect(repo.relativize(path.join(workingDirectory.toUpperCase(), 'a.txt'))).toBe('./a.txt')
895-
expect(repo.relativize(path.join(workingDirectory.toUpperCase(), 'a/b/c.txt'))).toBe('./a/b/c.txt')
893+
expect(repo.relativize(path.join(workingDirectory.toUpperCase(), 'a.txt'))).toBe('a.txt')
894+
expect(repo.relativize(path.join(workingDirectory.toUpperCase(), 'a/b/c.txt'))).toBe('a/b/c.txt')
896895

897896
const linkDirectory = path.join(fs.realpathSync(temp.mkdirSync('lower-case-symlink')), 'link')
898897
wrench.copyDirSyncRecursive(path.join(__dirname, 'fixtures/master.git'), path.join(repoDirectory, '.git'))
899898
fs.symlinkSync(repoDirectory, linkDirectory)
900899

901900
repo = git.open(linkDirectory)
902901
repo.caseInsensitiveFs = true
903-
expect(repo.relativize(path.join(linkDirectory.toUpperCase(), 'test2'))).toBe('./test2')
904-
expect(repo.relativize(path.join(linkDirectory.toUpperCase(), 'test2/test3'))).toBe('./test2/test3')
902+
expect(repo.relativize(path.join(linkDirectory.toUpperCase(), 'test2'))).toBe('test2')
903+
expect(repo.relativize(path.join(linkDirectory.toUpperCase(), 'test2/test3'))).toBe('test2/test3')
905904
})
906905
})
907906

src/git.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ Repository.prototype.relativize = function (path) {
169169
if (workingDirectory) {
170170
workingDirectory = workingDirectory.toLowerCase()
171171
if (lowerCasePath.startsWith(`${workingDirectory}/`)) {
172-
return './' + path.substring(workingDirectory.length + 1)
172+
return path.substring(workingDirectory.length + 1)
173173
} else if (lowerCasePath === workingDirectory) {
174174
return ''
175175
}
@@ -178,7 +178,7 @@ Repository.prototype.relativize = function (path) {
178178
if (this.openedWorkingDirectory) {
179179
workingDirectory = this.openedWorkingDirectory.toLowerCase()
180180
if (lowerCasePath.startsWith(`${workingDirectory}/`)) {
181-
return './' + path.substring(workingDirectory.length + 1)
181+
return path.substring(workingDirectory.length + 1)
182182
} else if (lowerCasePath === workingDirectory) {
183183
return ''
184184
}
@@ -187,15 +187,15 @@ Repository.prototype.relativize = function (path) {
187187
workingDirectory = this.getWorkingDirectory()
188188
if (workingDirectory) {
189189
if (path.startsWith(`${workingDirectory}/`)) {
190-
return './' + path.substring(workingDirectory.length + 1)
190+
return path.substring(workingDirectory.length + 1)
191191
} else if (path === workingDirectory) {
192192
return ''
193193
}
194194
}
195195

196196
if (this.openedWorkingDirectory) {
197197
if (path.startsWith(`${this.openedWorkingDirectory}/`)) {
198-
return './' + path.substring(this.openedWorkingDirectory.length + 1)
198+
return path.substring(this.openedWorkingDirectory.length + 1)
199199
} else if (path === this.openedWorkingDirectory) {
200200
return ''
201201
}

0 commit comments

Comments
 (0)