-
Notifications
You must be signed in to change notification settings - Fork 2
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
Brian Amesbury
committed
Aug 31, 2018
1 parent
1a4440f
commit 4a9910c
Showing
18 changed files
with
1,108 additions
and
66 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
--- | ||
|
||
name: Bug report | ||
|
||
about: \[Create a report to help us improve\] | ||
|
||
--- | ||
|
||
**Describe the bug** | ||
A clear and concise description of what the bug is. | ||
|
||
**To Reproduce** | ||
Steps to reproduce the behavior: | ||
1. Provide a [Short, Self Contained, Correct (Compilable), Example](http://sscce.org/) | ||
|
||
**Expected behavior** | ||
A clear and concise description of what you expected to happen. | ||
|
||
**Screenshots** | ||
If applicable, add screenshots to help explain your problem. | ||
|
||
**Environment (please complete the following information):** | ||
- OS: [e.g. linux] | ||
- Plugin Version: [0.0.6] | ||
- Git Version [e.g. 2.16] | ||
|
||
**Additional context** | ||
Add any other context about the problem here. |
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,19 @@ | ||
--- | ||
|
||
name: Feature request | ||
|
||
about: \[Suggest an idea for this project\] | ||
|
||
--- | ||
|
||
**Is your feature request related to a problem? Please describe.** | ||
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] | ||
|
||
**Describe the solution you'd like** | ||
A clear and concise description of what you want to happen. | ||
|
||
**Describe alternatives you've considered** | ||
A clear and concise description of any alternative solutions or features you've considered. | ||
|
||
**Additional context** | ||
Add any other context or screenshots about the feature request here. |
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,31 @@ | ||
# How to contribute | ||
|
||
#### **Did you find a bug?** | ||
|
||
* **Ensure the bug was not already reported** by searching on GitHub under [Issues](https://github.com/moonlitdoor/mld-git-version/issues). | ||
|
||
* If you're unable to find an open issue addressing the problem, [open a new one](https://github.com/moonlitdoor/mld-git-version/issues/new). | ||
|
||
* Use the this [Bug Report](./.github/ISSUE_TEMPLATE/bug_report.md) template to facilitate the fixing of the bug. | ||
|
||
#### **Did you write a patch that fixes a bug?** | ||
|
||
* Open a new GitHub pull request with the patch. | ||
|
||
* Ensure the PR description clearly describes the problem and solution. Include the relevant issue number if applicable. | ||
|
||
#### **Did you fix whitespace, format code, or make a purely cosmetic patch?** | ||
|
||
* Changes that are cosmetic in nature and do not add anything substantial to the stability, functionality, or testability will generally not be accepted. | ||
|
||
#### **Do you intend to add a new feature or change an existing one?** | ||
|
||
* Open an issue [here](https://github.com/moonlitdoor/mld-git-version/issues/new). | ||
|
||
* Use the this [Feature Request](./.github/ISSUE_TEMPLATE/feature_request.md) template to facilitate the request. | ||
|
||
--- | ||
|
||
Thanks for your help! | ||
|
||
Moonlit Door Software |
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,21 @@ | ||
MIT License | ||
|
||
Copyright (c) [2018] [Moonlit Door Software] | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
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 |
---|---|---|
@@ -1,6 +1,116 @@ | ||
mld-git-version | ||
=============== | ||
# mld-git-version | ||
|
||
A Gradle plugin that sets various properties available for use as the version based on the git repository. | ||
|
||
[![Build Status](https://travis-ci.com/moonlitdoor/mld-git-version.svg?branch=master)](https://travis-ci.com/moonlitdoor/mld-git-version) | ||
|
||
[![Travis (.com) branch](https://img.shields.io/travis/com/moonlitdoor/mld-git-version/master.svg?style=for-the-badge)](https://travis-ci.com/moonlitdoor/mld-git-version) | ||
[![Version](https://img.shields.io/github/release/moonlitdoor/mld-git-version.svg?style=for-the-badge)](https://github.com/moonlitdoor/mld-git-version/releases) | ||
[![GitHub](https://img.shields.io/github/license/mashape/apistatus.svg?style=for-the-badge)](https://opensource.org/licenses/MIT) | ||
|
||
|
||
[Published to Gradle Plugins](https://plugins.gradle.org/plugin/com.moonlitdoor.git-version) | ||
|
||
## Description | ||
|
||
After applying the plugin, it will expose 5 properties based on the git repository: | ||
* `gitVersion` The current version based on the most recent tag on the current git branch. Examples: | ||
* `HEAD` is tagged as `v1.0.0` and the `git status` is clean, the value would be `v1.0.0`. | ||
* `HEAD` is tagged as `v1.0.0` and the `git status` is not clean, the value would be `v1.0.0-1-SNAPSHOT`. | ||
* `HEAD^` is tagged as `v1.0.0`, the `git status` is clean, and commit hash of `HEAD` is `1a4440f73d7c91b53dacc072e1eab03516477c94` the value would be `v1.0.0-1-g1a4440f7`. | ||
* `HEAD^` is tagged as `v1.0.0`, the `git status` is not clean, and commit hash of `HEAD` is `1a4440f73d7c91b53dacc072e1eab03516477c94` the value would be `v1.0.0-2-SNAPSHOT`. | ||
* `gitCommitCount` The number of commits on the current git branch. | ||
* `gitTagCount` The number of tags on the current git branch. | ||
* `gitCommitAndTagCount` The number of commits and tags on the current git branch. | ||
* `gitBranchName` The current git branch. | ||
|
||
## Usage | ||
|
||
#### [Groovy](./build.groovy.gradle) | ||
|
||
```groovy | ||
plugins { | ||
id "com.moonlitdoor.git-version" version "0.0.7" | ||
} | ||
task demo { | ||
doLast { | ||
println "gitVersion='$gitVersion'" | ||
println "gitCommitCount='$gitCommitCount'" | ||
println "gitTagCount='$gitTagCount'" | ||
println "gitCommitAndTagCount='$gitCommitAndTagCount'" | ||
println "gitBranchName='$gitBranchName'" | ||
} | ||
} | ||
``` | ||
|
||
``` | ||
$ gradlew -b build.groovy.gradle demo | ||
> Task :demo | ||
gitVersion='0.0.5-5-SNAPSHOT' | ||
gitCommitCount='17' | ||
gitTagCount='5' | ||
gitCommitAndTagCount='22' | ||
gitBranchName='master-1-SNAPSHOT' | ||
BUILD SUCCESSFUL in 0s | ||
1 actionable task: 1 executed | ||
``` | ||
|
||
#### [Kotlin](./build.kotlin.gradle.kts) | ||
|
||
```kotlin | ||
plugins { | ||
id("com.moonlitdoor.git-version") version "0.0.7" | ||
} | ||
|
||
tasks.register("demo") { | ||
doLast { | ||
println("gitVersion='$gitVersion'") | ||
println("gitCommitCount='$gitCommitCount'") | ||
println("gitTagCount='$gitTagCount'") | ||
println("gitCommitAndTagCount='$gitCommitAndTagCount'") | ||
println("gitBranchName='$gitBranchName'") | ||
} | ||
} | ||
``` | ||
|
||
``` | ||
$ gradlew -b build.kotlin.gradle.kts demo | ||
> Task :demo | ||
gitVersion='0.0.5-5-SNAPSHOT' | ||
gitCommitCount='17' | ||
gitTagCount='5' | ||
gitCommitAndTagCount='22' | ||
gitBranchName='master-1-SNAPSHOT' | ||
BUILD SUCCESSFUL in 0s | ||
1 actionable task: 1 executed | ||
``` | ||
|
||
#### [Master Builds](https://jitpack.io/private#moonlitdoor/mld-git-version/master-SNAPSHOT) | ||
|
||
```groovy | ||
allprojects { | ||
repositories { | ||
maven { url 'https://jitpack.io' } | ||
} | ||
} | ||
``` | ||
|
||
```groovy | ||
dependencies { | ||
implementation 'com.github.moonlitdoor:mld-git-version:master-SNAPSHOT' | ||
} | ||
``` | ||
|
||
## Issue Tracking | ||
Want to file a bug? Want to suggest an idea? Add an [issue](https://github.com/moonlitdoor/mld-git-version/issues). | ||
|
||
## License | ||
All Moonlit Door Software is licensed under the [MIT License](./LICENSE). | ||
|
||
## Contributing | ||
Please see [CONTRIBUTING.md](./CONTRIBUTING.md) for details of how to build and contribute to the project. |
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,13 @@ | ||
plugins { | ||
id "com.moonlitdoor.git-version" version "0.0.7" | ||
} | ||
|
||
task demo { | ||
doLast { | ||
println "gitVersion='$gitVersion'" | ||
println "gitCommitCount='$gitCommitCount'" | ||
println "gitTagCount='$gitTagCount'" | ||
println "gitCommitAndTagCount='$gitCommitAndTagCount'" | ||
println "gitBranchName='$gitBranchName'" | ||
} | ||
} |
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,13 @@ | ||
plugins { | ||
id("com.moonlitdoor.git-version") version "0.0.7" | ||
} | ||
|
||
tasks.register("demo") { | ||
doLast { | ||
println("gitVersion='$gitVersion'") | ||
println("gitCommitCount='$gitCommitCount'") | ||
println("gitTagCount='$gitTagCount'") | ||
println("gitCommitAndTagCount='$gitCommitAndTagCount'") | ||
println("gitBranchName='$gitBranchName'") | ||
} | ||
} |
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,21 @@ | ||
buildscript { | ||
repositories { | ||
mavenLocal() | ||
} | ||
|
||
dependencies { | ||
classpath "com.moonlitdoor.git-version:git-version:0.0.7-1-SNAPSHOT" | ||
} | ||
} | ||
|
||
apply plugin: "com.moonlitdoor.git-version" | ||
|
||
task demo { | ||
doLast { | ||
println "gitVersion='$gitVersion'" | ||
println "gitCommitCount='$gitCommitCount'" | ||
println "gitTagCount='$gitTagCount'" | ||
println "gitCommitAndTagCount='$gitCommitAndTagCount'" | ||
println "gitBranchName='$gitBranchName'" | ||
} | ||
} |
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
17 changes: 17 additions & 0 deletions
17
git-version/src/main/kotlin/com/moonlitdoor/git/version/GitFacade.kt
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,17 @@ | ||
package com.moonlitdoor.git.version | ||
|
||
import java.io.File | ||
import java.util.concurrent.TimeUnit | ||
|
||
open class GitFacade { | ||
|
||
open fun runCommand(projectDir: File, vararg command: String): String { | ||
val process = ProcessBuilder(*command) | ||
.directory(projectDir) | ||
.redirectOutput(ProcessBuilder.Redirect.PIPE) | ||
.redirectError(ProcessBuilder.Redirect.PIPE) | ||
.start() | ||
process.waitFor(60, TimeUnit.SECONDS) | ||
return process.inputStream.bufferedReader().readText().trim() | ||
} | ||
} |
Oops, something went wrong.