Skip to content

Commit fa66ac6

Browse files
authored
Merge pull request #13 from hfagerlund/feature/automate-installation
Add installation script
2 parents 6e9d2ca + d18e82a commit fa66ac6

File tree

5 files changed

+90
-47
lines changed

5 files changed

+90
-47
lines changed

Makefile

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# author: Heini Fagerlund
2+
# license: MIT
3+
#
4+
# Copyright (c) 2018 Heini Fagerlund
5+
#
6+
# Permission is hereby granted, free of charge, to any person obtaining a copy
7+
# of this software and associated documentation files (the "Software"), to deal
8+
# in the Software without restriction, including without limitation the rights
9+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
# copies of the Software, and to permit persons to whom the Software is
11+
# furnished to do so, subject to the following conditions:
12+
#
13+
# The above copyright notice and this permission notice shall be included in
14+
# all copies or substantial portions of the Software.
15+
#
16+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22+
# THE SOFTWARE.
23+
24+
SHELL = /bin/sh
25+
26+
MAIN_FILE = git-add-msg
27+
AUX_FILES = git-add-msg-config_sample.cfg
28+
AUX_FILES += git-add-msg-trac-service
29+
30+
.PHONY: all check-var
31+
32+
all:
33+
@echo "usage: make [install DEST_DIR=<path-to-git-extensions-directory>]"
34+
35+
check-var:
36+
ifndef DEST_DIR
37+
$(error Error: DEST_DIR is not set. For usage, run 'make')
38+
endif
39+
40+
install: check-var
41+
$(info > Installing git-add-msg to directory: '$(DEST_DIR)':)
42+
@install -d -m 0755 $(DEST_DIR)
43+
@install -m 0755 $(MAIN_FILE) $(DEST_DIR)
44+
@install -m 0644 $(AUX_FILES) $(DEST_DIR)
45+
@ls -1 $(DEST_DIR)
46+
@echo "> Installation completed."

README.md

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,12 @@ A git extension (command line tool) that automatically logs commits to Trac and/
33

44
Replaces the following commands:
55
```
6-
$ git add .
6+
$ git add -A
77
```
88
and:
99
```
1010
$ git commit -am "<insert-your-commit-message-here>"
1111
```
12-
and (optionally):
13-
```
14-
$ git status
15-
```
1612
Also creates a **changelog.log** file (in your project's root directory), and (optionally) adds a comment in the Trac ticket for each commit.
1713

1814
## tl;dr
@@ -33,30 +29,36 @@ $ git add-msg
3329
(All copyrights for the above remain with their respective owners.)
3430
- - -
3531
## Installation
36-
### Download:
37-
Download the **git-add-msg** project in [.zip](https://github.com/hfagerlund/git-add-msg/archive/master.zip) format, or clone the repository:
3832
```
3933
$ git clone https://github.com/hfagerlund/git-add-msg.git
34+
$ cd git-add-msg
35+
$ make install DEST_DIR=/path/to/your-git-extensions-directory
4036
```
41-
42-
43-
Place the (extracted) **git-add-msg**, **trac-service**, and **config_sample.cfg** files in ``<your-git-extensions-directory>``, and add it to your (executable) path:
37+
* add the path to `<your-git-extensions-directory>` to your **executable path**:
4438
```bash
45-
export PATH="$PATH:/path/to/<your-git-extensions-directory>" #Note: no trailing slash
39+
export PATH="$PATH:/path/to/your-git-extensions-directory" #Note: no trailing slash
4640
```
4741

42+
### To uninstall:
43+
Manually remove the following files from `<your-git-extensions-directory>`:
44+
```
45+
git-add-msg-config.cfg
46+
git-add-msg-config_sample.cfg
47+
git-add-msg
48+
git-add-msg-trac-service
49+
```
4850
- - -
4951
## Configuration
5052
#### All users:
51-
(OPTIONAL) Copy and save ``config_sample.cfg`` as ``config.cfg``. This step can be skipped (refer to note below).
53+
(OPTIONAL) Rename ``git-add-msg-config_sample.cfg`` to ``git-add-msg-config.cfg`` in `<your-git-extensions-directory>`. This step can be skipped (refer to note below).
5254

53-
**Note**: if a ``config.cfg`` file is **not** present, it will result in a warning message being displayed when the tool is run (this can be safely ignored).
55+
**Note**: if a ``git-add-msg-config.cfg`` file is **not** present, it will result in a warning message being displayed when the tool is run (this can be safely ignored if not using Trac).
5456

5557
- - -
5658
#### Trac users only:
57-
(1.) Update ``config.cfg`` (copied from ``config_sample.cfg``) with your Trac settings by replacing the following values:
59+
(1.) Update ``git-add-msg-config.cfg`` (copied from ``git-add-msg-config_sample.cfg`` in `<your-git-extensions-directory>`) with your Trac settings by replacing the following values:
5860
```
59-
repo="no_repo_specified" # replace <no_repo_specified> with the name of your Trac repository
61+
repo="no_repo_specified" # replace <no_repo_specified> with the **name** of your Trac repository (found in Trac under 'Administration' > 'Manage Repositories' > 'Name')
6062
username="no_username_specified" # (as above, but with your Trac login username)
6163
password="no_password_specified"
6264
host="no_host_specified"
@@ -92,11 +94,6 @@ git committing...
9294
[master e10379d] #221: updated content
9395
1 files changed, 1 insertions(+), 0 deletions(-)
9496
Trac ticket successfully updated.
95-
Do you wish to view the git status?
96-
Yes (y)
97-
No (n)
98-
## selected 'n'
99-
Exiting.
10097
```
10198

10299
#### Trac users:
@@ -121,6 +118,7 @@ Copyright (c) 2015 Heini Fagerlund. Licensed under the [MIT license](http://open
121118

122119
- - -
123120
## Changelog
121+
* 0.3.1 - January 29, 2018. New feature: automated installation.
124122
* 0.2.1 - January 29, 2018. Fixed display of changeset number in auto-generated Trac link.
125123
* 0.2.0 - January 13, 2016. Deprecated (optional) git status check.
126124
* 0.1.4 - December 30, 2015. Fixed display of ticket update message.

git-add-msg

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,18 @@
22
# A git extension (command line tool) that automatically logs commits to Trac and/or a changelog.
33
#
44
## ie. is a substitute for the following commands:
5-
## $ git add .
5+
## $ git add -A
66
## $ git commit -am "<place your commit msg here>"
7-
## (optionally) $ git status
87
#
9-
# Also creates file 'changelog.txt' (ie. logs git SHA-1 hashes/changesets).
8+
# Also creates file 'changelog.log' (ie. logs git SHA-1 hashes/changesets).
109
#
1110
# Usage:
1211
# * make executable using: $ chmod 0750 git-add-msg
1312
# * (all users) run using: $ git add-msg
1413
# * (Trac users) run using -r option to automatically add comments, with links to changesets in specified repository, in Trac tickets.
1514
#
1615
# author: Heini Fagerlund
17-
# version: 0.2.1
16+
# version: 0.3.1
1817
# license: MIT
1918
#
2019
# Copyright (c) 2015 Heini Fagerlund
@@ -50,7 +49,7 @@ _key()
5049
usage() {
5150
printf "\t%s\n" "$bar"
5251

53-
printf "\t %s\n" "USAGE: ./trac-service [-r <string>]
52+
printf "\t %s\n" "USAGE: ./git-add-msg-trac-service [-r <string>]
5453
options:
5554
-r Trac repository name"
5655
printf "\t%s\n" "$bar"
@@ -66,14 +65,14 @@ while getopts ":r:" option; do
6665
esac
6766
done
6867

69-
if [ -f $currentDir/config.cfg ];
68+
if [ -f $currentDir/git-add-msg-config.cfg ];
7069
then
71-
sed -i "s/^\(repo=\).*$/\1\"$rarg\"/" $currentDir/config.cfg
70+
sed -i "s/^\(repo=\).*$/\1\"$rarg\"/" $currentDir/git-add-msg-config.cfg
7271
repo=${rarg:-no_repo_specified}
7372
else
7473
printf "\t%s\n" "$bar"
7574
printf "ALL USERS:\nTo avoid seeing this message again,
76-
copy and save config_sample.cfg as config.cfg.\n\nTrac USERS ONLY:\nUpdate config.cfg with your Trac settings.\n"
75+
copy and save git-add-msg-config_sample.cfg as git-add-msg-config.cfg.\n\nTrac USERS ONLY:\nUpdate git-add-msg-config.cfg with your Trac settings.\n"
7776
printf "\t%s\n" "$bar"
7877
exit
7978
fi
@@ -88,7 +87,7 @@ do
8887

8988
if [ ! -z "$mymultimsg" -a "$mymultimsg" != " " ]; then
9089
printf "git committing...\n"
91-
git add .
90+
git add -A
9291
git commit -am "#$ticketnum: $mymultimsg" | xclip
9392
changeset=$( xclip -o )
9493

@@ -141,7 +140,7 @@ MYXML
141140
</xsl:template>
142141
</xsl:stylesheet>
143142
EOF
144-
. trac-service
143+
. git-add-msg-trac-service
145144

146145
else
147146
rm -r ./bin/
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
# configuration file - integrates add-msg git extension with Trac
2-
#
2+
#
33
# Replace the values for all variables with your Trac settings,
4-
# and save this file as 'config.cfg'.
4+
# and save this file as 'git-add-msg-config.cfg'.
55
#
6-
# Run the following command to help secure this file:
7-
# $ chmod 0600 config.cfg
6+
# Run the following command to help secure this file:
7+
# $ chmod 0600 git-add-msg-config.cfg
88

99
#Trac configuration:
1010
repo="no_repo_specified" # name of repository
1111
username="no_username_specified" # login username
1212
password="no_password_specified" # login password
1313
host="no_host_specified" # Trac host (name or IP address)
14-
port="no_port_specified" # Trac port number
14+
port="no_port_specified" # Trac port number
1515
instance="no_instance_specified" # Trac instance name

trac-service renamed to git-add-msg-trac-service

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,26 +3,26 @@
33
# Use with git-add-msg to log git commits to Trac using its XML-RPC API
44
#
55
# author: Heini Fagerlund
6-
# version: 0.2.1
6+
# version: 0.3.1
77
# license: MIT
8-
#
8+
#
99
# The MIT License (MIT)
1010
# [OSI Approved License]
11-
#
11+
#
1212
# The MIT License (MIT)
13-
#
13+
#
1414
# Copyright (c) 2015 Heini Fagerlund
15-
#
15+
#
1616
# Permission is hereby granted, free of charge, to any person obtaining a copy
1717
# of this software and associated documentation files (the "Software"), to deal
1818
# in the Software without restriction, including without limitation the rights
1919
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
2020
# copies of the Software, and to permit persons to whom the Software is
2121
# furnished to do so, subject to the following conditions:
22-
#
22+
#
2323
# The above copyright notice and this permission notice shall be included in
2424
# all copies or substantial portions of the Software.
25-
#
25+
#
2626
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
2727
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
2828
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
@@ -33,17 +33,17 @@
3333

3434

3535
#Trac configuration
36-
. $currentDir/config.cfg
36+
. $currentDir/git-add-msg-config.cfg
3737

3838
#populate result.xml with commit msg as comment
3939
xsltproc --output bin/result.xml bin/transform.xsl bin/body_template.xml
40-
40+
4141
if curl -H 'Content-Type: application/xml' --data @bin/result.xml "http://$username:$password@$host:$port/$instance/login/xmlrpc" &> /dev/null
4242
then printf "Trac ticket successfully updated.\n"
4343
else
44-
printf "\t%s\n" "$bar"
45-
printf "WARNING: Trac ticket could not be updated.\nAre the Trac settings in config.cfg up-to-date?
44+
printf "\t%s\n" "$bar"
45+
printf "WARNING: Trac ticket could not be updated.\nAre the Trac settings in git-add-msg-config.cfg up-to-date?
4646
If so, please check whether Trac is running, and try again.\n\nIf you are not using Trac, please disregard this message.\n\n"
47-
printf "\t%s\n" "$bar"
47+
printf "\t%s\n" "$bar"
4848
fi
4949
rm -r ./bin/

0 commit comments

Comments
 (0)