forked from googleapis/release-please
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
133 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import {DefaultUpdater} from '../default'; | ||
|
||
/** | ||
* Updates a README.md file | ||
*/ | ||
export class PythonReadme extends DefaultUpdater { | ||
/** | ||
* Given initial file contents, return updated contents. | ||
* @param {string} content The initial content | ||
* @returns {string} The updated content | ||
*/ | ||
updateContent(content: string): string { | ||
if (this.version.preRelease) { | ||
// it's a pre-release, so add the pre-release flag if it's missing | ||
return content.replace( | ||
/^# install from PyPI\n^pip install (\S+)$/gm, | ||
'# install from PyPI\npip install --pre $1' | ||
); | ||
} else { | ||
// it's not a pre-release, so remove the pre-release flag if it's present | ||
return content.replace( | ||
/^# install from PyPI\n^pip install --pre (\S+)$/gm, | ||
'# install from PyPI\npip install $1' | ||
); | ||
} | ||
} | ||
} |
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,6 @@ | ||
## Installation | ||
|
||
```sh | ||
# install from PyPI | ||
pip install test-repo | ||
``` |
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,6 @@ | ||
## Installation | ||
|
||
```sh | ||
# install from PyPI | ||
pip install --pre test-repo | ||
``` |
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,50 @@ | ||
import {readFileSync} from 'fs'; | ||
import {resolve} from 'path'; | ||
import {describe, it} from 'mocha'; | ||
import {expect} from 'chai'; | ||
import {Version} from '../../src/version'; | ||
import {PythonReadme} from '../../src/updaters/python/python-readme'; | ||
|
||
const fixturesPath = './test/updaters/fixtures'; | ||
|
||
describe('PythonReadme', () => { | ||
const withPreFlag = readFileSync( | ||
resolve(fixturesPath, 'README-python-pre.md'), | ||
'utf8' | ||
); | ||
|
||
const withoutPreFlag = readFileSync( | ||
resolve(fixturesPath, 'README-python-no-pre.md'), | ||
'utf8' | ||
); | ||
|
||
it('makes no changes if there is a --pre on the install instructions in a README for a prerelease version', async () => { | ||
const readmeUpdater = new PythonReadme({ | ||
version: Version.parse('0.6.0-alpha.1'), | ||
}); | ||
expect(readmeUpdater.updateContent(withPreFlag)).to.equal(withPreFlag); | ||
}); | ||
|
||
it('makes no changes if there is no --pre on the install instructions in a README for a non-prerelease version', async () => { | ||
const readmeUpdater = new PythonReadme({ | ||
version: Version.parse('0.6.0'), | ||
}); | ||
expect(readmeUpdater.updateContent(withoutPreFlag)).to.equal( | ||
withoutPreFlag | ||
); | ||
}); | ||
|
||
it('adds --pre if there is no --pre on the install instructions in a README for a prerelease version', async () => { | ||
const readmeUpdater = new PythonReadme({ | ||
version: Version.parse('0.6.0-alpha.1'), | ||
}); | ||
expect(readmeUpdater.updateContent(withoutPreFlag)).to.equal(withPreFlag); | ||
}); | ||
|
||
it('removes --pre if there is a --pre on the install instructions in a README for a non-prerelease version', async () => { | ||
const readmeUpdater = new PythonReadme({ | ||
version: Version.parse('0.6.0'), | ||
}); | ||
expect(readmeUpdater.updateContent(withPreFlag)).to.equal(withoutPreFlag); | ||
}); | ||
}); |