Browse Source

Update updategit script.

5.3.8
Chris Smith 4 years ago
parent
commit
04625b7396
1 changed files with 17 additions and 4 deletions
  1. 17
    4
      .updater/updategit.py

+ 17
- 4
.updater/updategit.py View File

@@ -2,13 +2,15 @@
2 2
 
3 3
 import fileinput
4 4
 import re
5
+import subprocess
6
+import sys
5 7
 from os import close, remove, path
6 8
 from shutil import move
7
-from subprocess import call
8 9
 from tempfile import mkstemp
9 10
 
10 11
 assert path.isdir('.git'), "No git dir found"
11 12
 
13
+
12 14
 def replace(file_path, pattern, subst):
13 15
     # From http://stackoverflow.com/a/39110
14 16
     fh, abs_path = mkstemp()
@@ -20,16 +22,27 @@ def replace(file_path, pattern, subst):
20 22
     remove(file_path)
21 23
     move(abs_path, file_path)
22 24
 
25
+
26
+def call(args):
27
+    print('>>> %s' % ' '.join(args))
28
+    return subprocess.call(args)
29
+
23 30
 call(['git', 'fetch'])
24 31
 
32
+updated = False
25 33
 for line in fileinput.input():
26 34
     branch, version, changelog, url = line.strip().split(' ')
27 35
     branch = 'master' if branch == 'latest' else branch
28 36
     call(['git', 'branch', branch, 'master']) # Will fail if the branch exists
29 37
     call(['git', 'checkout', branch])
30
-    call(['git', 'rebase', 'origin/%s' % branch]) # May fail as well
38
+    call(['git', 'reset', '--hard', 'origin/%s' % branch]) # May fail as well
31 39
     replace('Dockerfile', r'^ARG url=.*', 'ARG url=%s' % url)
32
-    call(['git', 'commit', '-am', 'Auto update to version %s.\n\nChangelog: %s' % (version, changelog)])
33
-    call(['git', 'push', 'origin', branch])
40
+    c = call(['git', 'commit', '-am', 'Auto update to version %s.\n\nChangelog: %s' % (version, changelog)])
41
+    if c == 0:
42
+      call(['git', 'push', 'origin', branch])
43
+      updated = True
34 44
 
35 45
 call(['git', 'checkout', 'master'])
46
+
47
+sys.exit(0 if updated else 1)
48
+

Loading…
Cancel
Save