GitXplorerGitXplorer
g

Milepost

public
37 stars
1 forks
0 issues

Commits

List of commits on branch main.
Unverified
4a3ad903510f1fd166169adfd59d45ce715f8e1e

Fix license badge

ggiginet committed 2 years ago
Unverified
52b90e72f5d547a59161735dfcbbfb94e7dc5d86

Add badges

ggiginet committed 2 years ago
Unverified
c509ae5f07be6a23e4dbe01ccb43853464fea00c

Use Xcode 14.0

ggiginet committed 2 years ago
Unverified
dccc4c57d283f2443adcd25b269c4b80b1a8ee65

Refactor

ggiginet committed 2 years ago
Unverified
3748c310d1cfaa9cc00d5ee23a31ed38d431428b

Fix typo

ggiginet committed 2 years ago
Unverified
e76bf050936abe44a567f73f19c84ce192fcff19

Rename to Comitter

ggiginet committed 2 years ago

README

The README file for this repository.

Milepost

Build Status Language SwiftPM compatible Platform License

A Simple SwiftPM plugin to show Git commit on your apps

Summary

Milepost is a simple library to fetch Git commit info.

You can show Git revisions for debug builds or production builds for end-users' inquiry.

This library provides SwiftPM Build Tools Plugin. It helps developers to integrate it easily.

Installation

1. Integrate Milepost in your project with SwiftPM

  • File > Add Packages...
  • Enter https://github.com/giginet/Milepost.git
  • Choose Milepost product

2. Link Milepost in your application target

  • Application Target > General > Frameworks, Libraries, and Embedded Content > +
  • Choose Milepost

3. Add build phases to fetch git info

  • Application Target > Build Phases > Run Build Tool Plug-ins > +
  • Choose PrepareMilepost

Usage

You can fetch a latest revision with RevisionLoader.load().

import Milepost

let revision = RevisionLoader.load()!
revision.hash
revision.branch
revision.shortHash
revision.lastCommit.author.description
revision.lastCommit.committer.description
revision.lastCommit.subject
revision.lastCommit.authorDate
revision.lastCommit.commitDate

You can easily build a setting page like followings:

import SwiftUI
import Milepost

struct RevisionView: View {
    var body: some View {
        List {
            Section {
                if let revision = RevisionLoader.load() {
                    LabeledContent("Hash") {
                        Text(revision.hash)
                            .font(.caption)
                    }
                    LabeledContent("Short Hash") {
                        Text(revision.shortHash)
                    }
                    LabeledContent("Branch") {
                        Text(revision.branch ?? "-")
                    }
                    LabeledContent("Last Author") {
                        VStack(alignment: .trailing) {
                            Text(revision.lastCommit.author.name)
                            Text(revision.lastCommit.author.email)
                                .font(.caption)
                        }
                    }
                    LabeledContent("Commit Message") {
                        Text(revision.lastCommit.subject ?? "-")
                    }
                }
            } header: {
                Text("Revision")
            }
        }
    }
}

Requirements

Users Version
Developers Xcode 14.0 or above and macOS 11.0 or above
App Users any iOS, iPadOS, macOS, watchOS, tvOS

This plugin uses SwiftPM Build Tools Plugin. So you have to use Xcode 14.0 or above.

This feature is only required on a build process. Thus, this library runs on any platform versions.