Skip to content

Commit 24eb17b

Browse files
committed
Automated update by Adabot (40d73ad)
Updating https://github.com/adafruit/Adafruit_CircuitPython_ADS1x15 to 0.1.0 from e731810: > fix .travis.yml > add .travis.yml and .gitignore; I2C.read_into -> readinto Updating https://github.com/adafruit/Adafruit_CircuitPython_BME280 to 2.0 from 1.0.0: > Update travis config to use 2.x branch for MPY generation. > changed read_into to readinto > Merge pull request adafruit/Adafruit_CircuitPython_BME280#1 from chickadee-tech/doc_fix Updating https://github.com/adafruit/Adafruit_CircuitPython_BME680 to 2.0.1 from f1e5aa2: > Ensure gas property updates reading state. > rename fix > Update travis config with 2.x branch MPY generation. > changed read_into to readinto > Merge pull request adafruit/Adafruit_CircuitPython_BME680#1 from chickadee-tech/doc_fix Updating https://github.com/adafruit/Adafruit_CircuitPython_BMP280 to 2.0 from 1.0.0: > Update travis to use 2.x branch for MPY generation. > changed read_into to readinto > Merge pull request adafruit/Adafruit_CircuitPython_BMP280#2 from chickadee-tech/doc_fix Updating https://github.com/adafruit/Adafruit_CircuitPython_BNO055 to 2.0 from 0.1.3: > Switch to 2.x branch for MPY generation. > changed read_into to readinto Updating https://github.com/adafruit/Adafruit_CircuitPython_CCS811 to 0.0.2 from 0.0.1: > changed read_into to readinto Updating https://github.com/adafruit/Adafruit_CircuitPython_DS3231 to 2.0.1 from 1.0.0: > changed read_into to readinto > Add demo example based on PCF8523 guide. > Switch to build from circuitpython 2.x branch mpy-cross Updating https://github.com/adafruit/Adafruit_CircuitPython_LIS3DH to 0.1.3 from 0.1.2: > busdevice method changed from read_into() to readinto() > Optimize the way data in unpacked (adafruit/Adafruit_CircuitPython_LIS3DH#9) > added ImportError to except > changed to use struct module instead of ustruct (adafruit/Adafruit_CircuitPython_LIS3DH#6) > Update to upcoming NeoPixel API Updating https://github.com/adafruit/Adafruit_CircuitPython_MAX31855 to 2.0 from 0.1.1: > Update .travis.yml > changed conditional import for struct and ustruct (adafruit/Adafruit_CircuitPython_MAX31855#2) Updating https://github.com/adafruit/Adafruit_CircuitPython_MCP9808 to 2.0 from 0.1.1: > Update .travis.yml > changed read_into to readinto > Clarify code indents (adafruit/Adafruit_CircuitPython_MCP9808#2) > Minor tidying Updating https://github.com/adafruit/Adafruit_CircuitPython_MPR121 to 0.1.2 from 0.1.1: > changed read_into to readinto Updating https://github.com/adafruit/Adafruit_CircuitPython_PCF8523 to 0.1.1 from 0.1.0: > changed read_into to readinto Updating https://github.com/adafruit/Adafruit_CircuitPython_SI7021 to 2.0 from 0.1.4: > Switch travis config to build from 2.0 circuitpython branch. > changed read_into to readinto Updating https://github.com/adafruit/Adafruit_CircuitPython_TSL2561 to 2.0 from 51b7cd9: > Update travis config to use 2.x branch for MPY generation. > Merge pull request adafruit/Adafruit_CircuitPython_TSL2561#6 from caternuson/master > fix deploy filename > Correct the docs badge > Merge pull request adafruit/Adafruit_CircuitPython_TSL2561#3 from caternuson/master > Merge pull request adafruit/Adafruit_CircuitPython_TSL2561#2 from caternuson/iss001 Updating https://github.com/adafruit/Adafruit_CircuitPython_VC0706 to 2.0 from 286bd31: < Add example with internal filesystem write. Updating https://github.com/adafruit/Adafruit_CircuitPython_BusDevice to 2.0.1 from 0.3.1: > remove deprecated method read_into > Added readinto() method to be more consistant with busdevice.spi. (adafruit/Adafruit_CircuitPython_BusDevice#10) Updating https://github.com/adafruit/Adafruit_CircuitPython_Register to 1.0.3 from 1.0.2: > changed read_into to readinto to follow changes in Adafruit_CircuitPython_BusDevice (adafruit/Adafruit_CircuitPython_Register#6)
1 parent 40d73ad commit 24eb17b

File tree

3 files changed

+141
-0
lines changed

3 files changed

+141
-0
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Subproject commit deab33cfed871fef4783a4b3f4d0a6db4c73b62c
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Subproject commit cf7842bea5e5a1a01fb3480eef16af48554ffc26

adabot/circuitpython_bundle.py

Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
# The MIT License (MIT)
2+
#
3+
# Copyright (c) 2017 Scott Shawcroft for Adafruit Industries
4+
#
5+
# Permission is hereby granted, free of charge, to any person obtaining a copy
6+
# of this software and associated documentation files (the "Software"), to deal
7+
# in the Software without restriction, including without limitation the rights
8+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
# copies of the Software, and to permit persons to whom the Software is
10+
# furnished to do so, subject to the following conditions:
11+
#
12+
# The above copyright notice and this permission notice shall be included in
13+
# all copies or substantial portions of the Software.
14+
#
15+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21+
# THE SOFTWARE.
22+
23+
from adabot import requests
24+
import os
25+
import subprocess
26+
import shlex
27+
from io import StringIO
28+
29+
import sh
30+
from sh.contrib import git
31+
32+
bundles = ["Adafruit_CircuitPython_Bundle", "CircuitPython_Community_Bundle"]
33+
34+
def fetch_bundle(bundle, directory):
35+
if not os.path.isdir(bundle_path):
36+
os.makedirs(directory, exist_ok=True)
37+
git.clone("-o", "adafruit", "https://github.com/adafruit/" + bundle + ".git", bundle_path)
38+
working_directory = os.getcwd()
39+
os.chdir(bundle_path)
40+
git.pull()
41+
git.submodule("init")
42+
git.submodule("update")
43+
os.chdir(working_directory)
44+
45+
46+
class Submodule:
47+
def __init__(self, directory):
48+
self.directory = directory
49+
50+
def __enter__(self):
51+
self.original_directory = os.path.abspath(os.getcwd())
52+
os.chdir(self.directory)
53+
54+
def __exit__(self, exc_type, exc_value, traceback):
55+
os.chdir(self.original_directory)
56+
57+
58+
def commit_to_tag(repo_path, commit):
59+
with Submodule(repo_path):
60+
try:
61+
output = StringIO()
62+
git.describe("--tags", "--exact-match", commit, _out=output)
63+
commit = output.getvalue().strip()
64+
except sh.ErrorReturnCode_128:
65+
pass
66+
return commit
67+
68+
def repo_version():
69+
version = StringIO()
70+
try:
71+
git.describe("--tags", "--exact-match", _out=version)
72+
except sh.ErrorReturnCode_128:
73+
git.log(pretty="format:%h", n=1, _out=version)
74+
75+
return version.getvalue().strip()
76+
77+
78+
def repo_remote_url(repo_path):
79+
with Submodule(repo_path):
80+
output = StringIO()
81+
git.remote("get-url", "origin", _out=output)
82+
return output.getvalue().strip()
83+
84+
def update_bundle(bundle_path):
85+
working_directory = os.path.abspath(os.getcwd())
86+
os.chdir(bundle_path)
87+
git.submodule("foreach", "git", "fetch")
88+
# sh fails to find the subcommand so we use subprocess.
89+
subprocess.run(shlex.split("git submodule foreach 'git checkout -q `git rev-list --tags --max-count=1`'"), stdout=subprocess.DEVNULL)
90+
91+
# Don't update circuitpython, its going away soon.
92+
git.submodule("update", "circuitpython")
93+
94+
status = StringIO()
95+
result = git.status("--short", _out=status)
96+
updates = []
97+
for status_line in status.getvalue().strip().split("\n"):
98+
action, directory = status_line.split()
99+
if action != "M" or not directory.startswith("libraries"):
100+
RuntimeError("Unsupported updates")
101+
102+
# Compute the tag difference.
103+
diff = StringIO()
104+
result = git.diff("--submodule=log", directory, _out=diff)
105+
diff_lines = diff.getvalue().split("\n")
106+
commit_range = diff_lines[0].split()[2]
107+
commit_range = commit_range.strip(":").split(".")
108+
old_commit = commit_to_tag(directory, commit_range[0])
109+
new_commit = commit_to_tag(directory, commit_range[-1])
110+
url = repo_remote_url(directory)
111+
summary = "\n".join(diff_lines[1:-1])
112+
updates.append((url[:-4], old_commit, new_commit, summary))
113+
os.chdir(working_directory)
114+
return updates
115+
116+
def commit_updates(update_info):
117+
message = ["Automated update by Adabot (adafruit/adabot@{})"
118+
.format(repo_version())]
119+
for url, old_commit, new_commit, summary in update_info:
120+
url_parts = url.split("/")
121+
user, repo = url_parts[-2:]
122+
summary = summary.replace("#", "{}/{}#".format(user, repo))
123+
message.append("Updating {} to {} from {}:\n{}".format(url,
124+
new_commit,
125+
old_commit,
126+
summary))
127+
message = "\n\n".join(message)
128+
git.add(".")
129+
git.commit(message=message)
130+
pass
131+
132+
if __name__ == "__main__":
133+
directory = ".bundles"
134+
for bundle in bundles[:1]:
135+
bundle_path = os.path.abspath(os.path.join(directory, bundle))
136+
#fetch_bundle(bundle, bundle_path)
137+
update_info = update_bundle(bundle_path)
138+
if update_info:
139+
commit_updates(update_info)

0 commit comments

Comments
 (0)