Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Frage zu git in einem Shellscrpit
View unanswered posts
View posts from last 24 hours
View posts from last 7 days

 
Reply to topic    Gentoo Forums Forum Index Deutsches Forum (German) Diskussionsforum
View previous topic :: View next topic  
Author Message
3PO
Veteran
Veteran


Joined: 26 Nov 2006
Posts: 1110
Location: Schwabenländle

PostPosted: Sat Feb 11, 2012 9:23 am    Post subject: Frage zu git in einem Shellscrpit Reply with quote

Hallo Zusammen,

ich will in einem Script folgende Bedingung einbauen:

- Mache "git pull"
- Wenn es etwas Neues gibt, dann mache "make clean all"

Ich habe das jetzt so gelöst:

Code:
[ ! "$(git pull |grep  'Already up-to-date.')" ]  && make clean all


Funktionieren tut das Ganze ja soweit, aber da gibt es doch sicherlich elegantere Lösungen?
Back to top
View user's profile Send private message
firefly
Watchman
Watchman


Joined: 31 Oct 2002
Posts: 5161

PostPosted: Sat Feb 11, 2012 10:43 am    Post subject: Reply with quote

eventuell liefert git verschiedene return werte je nachdem ob was getan wurde oder nicht.

das ganze kannst du wie folgt ausprobieren:

Code:
<git-command> ; echo $?

$? enthält den return wert des letzten kommandos.
_________________
Ein Ring, sie zu knechten, sie alle zu finden,
Ins Dunkel zu treiben und ewig zu binden
Im Lande Mordor, wo die Schatten drohn.
Back to top
View user's profile Send private message
3PO
Veteran
Veteran


Joined: 26 Nov 2006
Posts: 1110
Location: Schwabenländle

PostPosted: Sat Feb 11, 2012 1:28 pm    Post subject: Reply with quote

Nun, genau um das "<git-command>" geht es ja. Leider ist "git help" diesbezüglich nicht sehr aufschlussreich. :(
Back to top
View user's profile Send private message
mv
Watchman
Watchman


Joined: 20 Apr 2005
Posts: 6747

PostPosted: Sat Feb 11, 2012 2:12 pm    Post subject: Reply with quote

M.W. ist
Code:
git status --porcelain
das einzige Git-Kommando, das in garantierter Weise eine parse-bare Ausgabe für Scripts generiert. Ob da die Information dabei steht, die Du willst, weiß ich aber nicht.
Back to top
View user's profile Send private message
3PO
Veteran
Veteran


Joined: 26 Nov 2006
Posts: 1110
Location: Schwabenländle

PostPosted: Sat Feb 11, 2012 2:31 pm    Post subject: Reply with quote

Leider zeigt das nicht an, ob beim "git pull" etwas geändert wurde. :(
Back to top
View user's profile Send private message
ScytheMan
l33t
l33t


Joined: 30 Nov 2005
Posts: 605

PostPosted: Sat Feb 11, 2012 3:31 pm    Post subject: Reply with quote

du könntest einen client side git hook basteln.

im client repository muss das unter .git/hooks/

leider weiß ich nicht welches hook-file du dafür verwenden musst, aber "man githooks" dürfte weiterhelfen.

post-merge dürfte wohl passen.


Last edited by ScytheMan on Sat Feb 11, 2012 4:43 pm; edited 1 time in total
Back to top
View user's profile Send private message
manuels
Advocate
Advocate


Joined: 22 Nov 2003
Posts: 2146
Location: Europe

PostPosted: Sat Feb 11, 2012 4:28 pm    Post subject: Reply with quote

Du könntest das hier mal probieren: http://git.661346.n2.nabble.com/checking-action-of-git-pull-td1624645.html
_________________
Build your own live cd with catalyst 2.0!
Back to top
View user's profile Send private message
3PO
Veteran
Veteran


Joined: 26 Nov 2006
Posts: 1110
Location: Schwabenländle

PostPosted: Sat Feb 11, 2012 5:55 pm    Post subject: Reply with quote

THX @ manuels,

ich werde es mal so probieren. ;)

Code:
cd $GIT_DIR
original_head=$(git rev-parse HEAD) || exit
git pull || exit
updated_head=$(git rev-parse HEAD) || exit
[ $original_head != $updated_head ] && make clean all
Back to top
View user's profile Send private message
cryptosteve
Veteran
Veteran


Joined: 04 Jan 2004
Posts: 1169
Location: GER

PostPosted: Mon Feb 13, 2012 3:14 pm    Post subject: Reply with quote

Ich fand die Ausgangslösung - gemessen an den sonstigen Möglichkeiten - gar nicht so übel. :)
_________________
- born to create drama -
gpg: 0x9B6C7E15
CS Virtual Travel Bug: VF6G5D
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Deutsches Forum (German) Diskussionsforum All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum