-
-
Save kazuhisya/1062909 to your computer and use it in GitHub Desktop.
making convenient git commit
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
#!/bin/sh | |
PREFIX="from now" | |
MESSAGE="[${PREFIX}] `LANG=en date`" | |
if [ $# -eq 0 ] | |
then | |
git add -u | |
printf "${MESSAGE}\n\n%s" "`git diff --cached`" | git commit -F - | |
elif [ $1 != "--rebase" ] | |
then | |
git add $@ | |
printf "${MESSAGE}\n\n%s" "`git diff --cached`" | git commit -F - | |
else | |
FIRST_NOW_COMMIT=`git log --pretty=oneline --grep="${PREFIX}" | tail -n 1 | cut -d " " -f 1` | |
INITIAL_COMMIT=`git log --pretty=oneline | tail -n 1 | cut -d " " -f 1` | |
if [ ${FIRST_NOW_COMMIT} != ${INITIAL_COMMIT} ] | |
then | |
git rebase -i ${FIRST_NOW_COMMIT}^ | |
else | |
WORKING_BRANCH=`git branch -l | grep "*" | cut -d " " -f 2` | |
git checkout ${FIRST_NOW_COMMIT} | |
git commit --amend | |
git rebase --onto HEAD ${FIRST_NOW_COMMIT} ${WORKING_BRANCH} | |
fi | |
fi |
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
;;; git-now.el - Call "git now" command | |
(provide 'git-now) | |
(defun now () | |
(interactive) | |
(call-process "git" nil "*git now*" nil "now") | |
(pop-to-buffer "*git now*" t nil) | |
(other-window -1) | |
(message "git now!")) |
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
Summary: making convenient git commit | |
Name: git-now | |
Version: 0.0 | |
Release: 1%{?dist} | |
License: Apache License, Version 2.0 | |
Group: Development/Languages | |
Provides: git-now | |
Requires: git | |
BuildRequires: git | |
Source0: git-now | |
BuildArch: noarch | |
BuildRoot: %{_tmppath}/%{name}-%{version}-root | |
Packager: Kazuhisa Hara <[email protected]> | |
%description | |
git now: making convenient git commit | |
%prep | |
%build | |
%install | |
mkdir -p $RPM_BUILD_ROOT/usr/libexec/git-core | |
cp -Rp %{_sourcedir}/git-now $RPM_BUILD_ROOT/usr/libexec/git-core | |
chmod +x $RPM_BUILD_ROOT/usr/libexec/git-core/git-now | |
%clean | |
rm -Rf $RPM_BUILD_ROOT | |
%post | |
%files | |
%defattr(-,root,root) | |
/usr/libexec/git-core/git-now | |
%changelog | |
* Mon Jul 04 2011 Kazuhisa Hara <[email protected]> | |
- Initial version |
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
#!/bin/sh | |
PREFIX="from now" | |
if [ ! "`git log --pretty=oneline $3 | head -n 1 | grep "${PREFIX}"`" ] | |
then | |
exit 0 | |
else | |
echo "error: There are tmp log messages in the received objects." 1>&2 | |
echo "error: Change these messages by 'git now --rebase'." 1>&2 | |
exit 1 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment