git_stamp 3.2.0 copy "git_stamp: ^3.2.0" to clipboard
git_stamp: ^3.2.0 copied to clipboard

Provides advanced project information. From simple information such as build-branch to a screen with Flutter code with commits and change history.

Git Stamp 🏷 #

Provides advanced project information. From simple information such as build-branch to a screen with Flutter code with commits and change history.

Latest Tag GitHub stars Commits GitHub Workflow Status

Pub Package Likes package publisher

Table of contents #

🏞️ Preview #

GitStamp Icon

GitStamp Page

Light Dark

The main motivation was Minecraft with information like this:

Version: v1.20.81
Build: 24130126
Branch: r/20_u8
SHA: a9081c5429038dcf3f26269f7351d89f

Git Stamp code:

import 'git_stamp/git_stamp.dart';

Text('Version: ${GitStamp.appVersion}'),
Text('Build: ${GitStamp.appBuild}'),
Text('Branch: ${GitStamp.buildBranch}'),
Text('SHA: ${GitStamp.latestCommit.hash}'),

🕯️ Mechanism #

graph TD
    CODE((SOURCE CODE))-->SYNC(flutter pub get)
    SYNC-->BUILD(flutter build ...)

    subgraph "App"
        CODE
        PUB
        PUB((PACKAGES))-->CODE
    end

    subgraph "Git Stamp"
        GIT_CLI(GIT CLI)-->GENERATOR
        DART_CLI(DART CLI)-->GENERATOR
        FLUTTER_CLI(FLUTTER CLI)-->GENERATOR
    end

    subgraph "Git Stamp CLI"
        GENERATE
        ADD
    end

    GENERATOR((GENERATOR))-->ADD(~$ dart pub add git_stamp)
    ADD-->|Add package|PUB

    GENERATOR-->GENERATE(~$ dart run git_stamp)
    GENERATE-->|Create ./git_stamp directory with .dart files|CODE

🛠️ Installation #

Package url_launcher if you use.

dependencies:
  url_launcher: ^6.2.3
dev_dependencies:
  git_stamp:
    git:
      url: https://github.com/arononak/git_stamp
      ref: main

Warning

Add badge to your README.md 😄️

Git Stamp

[![Git Stamp](https://img.shields.io/badge/i%20love%20Git%20Stamp-ffff99?style=flat)](https://github.com/arononak/git_stamp)

Important

Add git_stamp to .gitignore.

echo -e "\n/lib/git_stamp/" >> .gitignore.

If you add a /git_stamp folder for the repository and use the FULL version, the size of the repository will grow EXPONENTIALLY.

📦 Integration #

Example GitHub Actions file:

.github/workflows/build_and_deploy.yml

name: build_and_deploy

on:
  push:
    branches: [main]
  pull_request_target:
    branches: [main]

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - uses: subosito/flutter-action@v2
        with:
          flutter-version: '3.22.2'
          channel: 'stable'
      - run: flutter --version
      - uses: actions/setup-java@v1
        with:
          java-version: "12.x"
      - run: flutter pub get
      - run: dart run git_stamp
      - run: flutter build web --release --web-renderer canvaskit
      - uses: actions/upload-artifact@master
        with:
          name: build
          path: build/web
  deploy:
    name: "Deploy"
    runs-on: ubuntu-latest
    needs: build
    steps:
      - uses: actions/checkout@v3
      - uses: actions/download-artifact@master
        with:
          name: build
          path: build/web
      - uses: FirebaseExtended/action-hosting-deploy@v0
        with:
          repoToken: "${{ secrets.GITHUB_TOKEN }}"
          firebaseServiceAccount: "${{ secrets.FIREBASE_SERVICE_ACCOUNT }}"
          projectId: xxx
          channelId: live

Important

If you use Github Action, you only get a single commit because GitHub Actions by default only retrieves the latest version (single commit) and does not include the full history of the repository. This is normal behavior to optimize the build process and improve performance, especially for large repositories. Try configuring github actions or generating Git Stamp files before git push.

🏗️ Generating #

CLI Command Build type Use url_launcher Generate Flutter UI Files
dart run git_stamp LITE DISABLED YES
dart run git_stamp --build-type full --gen-url-launcher enabled FULL ENABLED YES
dart run git_stamp --gen-only build-branch,build-date-time CUSTOM DISABLED NO

Caution

Generating requires the use of the git command-line interface (CLI).

gen-only parameters
commit-list
diff-list
repo-creation-date
build-branch
build-date-time
build-system-info
repo-path
observed-files-list
app-version

💻 Usage #

ListTile

if (kDebugMode) ...[
  ListTile(
    title: const Text('Git Stamp'),
    subtitle: Text(GitStamp.latestCommit.hash),
    leading: const Icon(Icons.commit),
    onTap: () => showGitStampPage(context: context),
  ),
],

IconButton

if (isProd == false) ...[
  IconButton(
    onPressed: () => showGitStampPage(context: context),
    icon: const Icon(Icons.book),
  ),
],

Central GitStamp node for advanced usage:

class GitStamp {
   static List<GitStampCommit> commitList
   static GitStampCommit latestCommit

   static const Map<String, String> diffList

   static const String buildBranch
   static const String buildDateTime
   static const String buildSystemInfo
   static const String repoCreationDate
   static const String repoPath
   static const String observedFilesList

   static const String appVersion
   static const String appBuild

   static const bool isLiteVersion
}

📝 License #

Note

Copyright © 2024 Aron Onak. All rights reserved.
Licensed under the MIT license.
If you have any feedback, please contact me at arononak@gmail.com

43
likes
160
pub points
42%
popularity

Publisher

verified publisheraroncode.com

Provides advanced project information. From simple information such as build-branch to a screen with Flutter code with commits and change history.

Homepage
Repository (GitHub)
View/report issues

Topics

#git #git-history #git-integration #tool #codegen

Documentation

Documentation
API reference

License

MIT (license)

Dependencies

args, flutter, intl, pub_semver, pubspec_parse

More

Packages that depend on git_stamp