Skip to content

Commit 725cbff

Browse files
author
spencercjh
committed
Init
1 parent d615b4b commit 725cbff

5 files changed

Lines changed: 151 additions & 0 deletions

File tree

.github/dependabot.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# To get started with Dependabot version updates, you'll need to specify which
2+
# package ecosystems to update and where the package manifests are located.
3+
# Please see the documentation for all configuration options:
4+
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
5+
6+
version: 2
7+
updates:
8+
- package-ecosystem: "github-actions"
9+
directory: "/"
10+
schedule:
11+
interval: "weekly"

.gitignore

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
### VisualStudioCode template
2+
.vscode/*
3+
!.vscode/settings.json
4+
!.vscode/tasks.json
5+
!.vscode/launch.json
6+
!.vscode/extensions.json
7+
!.vscode/*.code-snippets
8+
9+
# Local History for Visual Studio Code
10+
.history/
11+
12+
# Built Visual Studio Code Extensions
13+
*.vsix
14+
15+
### JetBrains template
16+
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider
17+
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
18+
19+
# User-specific stuff
20+
.idea/**/workspace.xml
21+
.idea/**/tasks.xml
22+
.idea/**/usage.statistics.xml
23+
.idea/**/dictionaries
24+
.idea/**/shelf
25+
26+
# AWS User-specific
27+
.idea/**/aws.xml
28+
29+
# Generated files
30+
.idea/**/contentModel.xml
31+
32+
# Sensitive or high-churn files
33+
.idea/**/dataSources/
34+
.idea/**/dataSources.ids
35+
.idea/**/dataSources.local.xml
36+
.idea/**/sqlDataSources.xml
37+
.idea/**/dynamic.xml
38+
.idea/**/uiDesigner.xml
39+
.idea/**/dbnavigator.xml
40+
41+
# Gradle
42+
.idea/**/gradle.xml
43+
.idea/**/libraries
44+
45+
# Gradle and Maven with auto-import
46+
# When using Gradle or Maven with auto-import, you should exclude module files,
47+
# since they will be recreated, and may cause churn. Uncomment if using
48+
# auto-import.
49+
# .idea/artifacts
50+
# .idea/compiler.xml
51+
# .idea/jarRepositories.xml
52+
# .idea/modules.xml
53+
# .idea/*.iml
54+
# .idea/modules
55+
# *.iml
56+
# *.ipr
57+
58+
# CMake
59+
cmake-build-*/
60+
61+
# Mongo Explorer plugin
62+
.idea/**/mongoSettings.xml
63+
64+
# File-based project format
65+
*.iws
66+
67+
# IntelliJ
68+
out/
69+
70+
# mpeltonen/sbt-idea plugin
71+
.idea_modules/
72+
73+
# JIRA plugin
74+
atlassian-ide-plugin.xml
75+
76+
# Cursive Clojure plugin
77+
.idea/replstate.xml
78+
79+
# SonarLint plugin
80+
.idea/sonarlint/
81+
82+
# Crashlytics plugin (for Android Studio and IntelliJ)
83+
com_crashlytics_export_strings.xml
84+
crashlytics.properties
85+
crashlytics-build.properties
86+
fabric.properties
87+
88+
# Editor-based Rest Client
89+
.idea/httpRequests
90+
91+
# Android studio 3.1+ serialized cache file
92+
.idea/caches/build_file_checksums.ser
93+

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
# git-branch-behind-main
2+
23
Check whether the current branch is behind main

action.yaml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
name: "git-branch-behind-main"
2+
description: "Check whether the current branch is behind main"
3+
branding:
4+
icon: git-branch
5+
color: orange
6+
runs:
7+
using: "composite"
8+
steps:
9+
- name: Checkout
10+
uses: actions/checkout@v3
11+
- name: Check
12+
shell: bash
13+
run: |
14+
./check.sh

check.sh

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#!/bin/bash
2+
# refer to https://www.jianshu.com/p/dd1b924fe48e, thanks for the author
3+
set -eu
4+
5+
git-log-flat-colored() {
6+
git --no-pager log --format="%C(yellow)%h%Creset %C(cyan)%cd%Creset %s %Cgreen%an%Creset" --date=short "$@"
7+
}
8+
9+
CURRENT_FEATURE=$(git symbolic-ref --short -q HEAD)
10+
CURRENT_PATH=$(git rev-parse --show-toplevel)
11+
REFERENCE_BRANCH="origin/main"
12+
13+
echo -e "\033[0;34m >>-----当前核查仓库路径${CURRENT_PATH}-----<< \033[0m"
14+
15+
# Check if the "origin/main" branch exists, and if so, update the remote record and compare for any backward commits
16+
if git rev-parse --verify ${REFERENCE_BRANCH} >/dev/null 2>&1; then
17+
18+
git fetch origin
19+
20+
NB_COMMITS_BEHIND=$(git rev-list --left-right --count ${REFERENCE_BRANCH}...@ | cut -f1)
21+
22+
if [ "${NB_COMMITS_BEHIND}" -gt "0" ]; then
23+
echo -e "\033[0;31m >>-----${CURRENT_FEATURE}-----<< 当前分支有 ${NB_COMMITS_BEHIND} 个提交落后于 \"${REFERENCE_BRANCH}\", 请合并最新的 master 分支代码\n \033[0m"
24+
git-log-flat-colored ${REFERENCE_BRANCH} | head -"${NB_COMMITS_BEHIND}"
25+
exit 2
26+
else
27+
echo -e "\033[0;32m >>-----${CURRENT_FEATURE}-----<<当前分支包含 ${REFERENCE_BRANCH} 分支上的所有提交记录 \033[0m"
28+
fi
29+
else
30+
echo -e "\033[0;31m >>-----不能比较,检测${REFERENCE_BRANCH}不存在-----<< \033[0m"
31+
exit 2
32+
fi

0 commit comments

Comments
 (0)